Archive for the ‘Uncategorized’ Category

C++Now 2017 – Report

Saturday, May 20th, 2017

C++Now 2017 just wrapped up in Aspen, CO. A great week of presentations and discussions once more. C++Now is a very different conference from the normal mainstream. For a start, it’s small – only 150 people. And the sort of content you find at C++Now is more niche material: challenging the status quo and trying to move the medium forward and push the boundaries of what’s possible in C++.

The keynotes

This year’s keynotes focused on what C++ can learn from other languages – Rust, Haskell, and D.

Rust: Hack Without Fear! – Niko Matsakis

The Rust keynote was really good, showcasing Rust’s ownership model that allows it to achieve memory safety and freedom from data races. Pretty cool stuff, and something that C++ is just beginning to take baby steps towards.

Competitive Advantage with D – Ali Çehreli

The D keynote was very underwhelming – I didn’t come away with a good sense of where D is better than C++ and why its features are desirable.

Haskell Taketh Away: Limiting Side Effects for Parallel Programming – Ryan Newton

The Haskell keynote was probably my favourite of the trio, and the presenter did a really good job of not going down the Haskell rabbit holes so common in such talks. He didn’t try to explain monads or anything like that. He didn’t explain how return is different. He did explain real usage of Haskell and the memory model and choices for achieving side effects, and he was obviously an experienced speaker. I know some Haskell, and I was surprised to see that he put up some code on slides that was pretty advanced for a C++ crowd of mostly Haskell novices. But I think he did a great job of keeping the talk concrete, and some of the compiler technology and directions he talked about toward the end of the talk were pretty amazing.

Selected talks

C++11’s Quiet Little Gem: <system_error> – Charley Bay

This was the first talk of the week after the opening keynote. Charley is a high-energy and entertaining speaker and this talk really opened my eyes to the goodness that is <system_error> and how to use it. Around 350 fast-moving slides! I’ll definitely be using and recommending <system_error> in future.

The Mathematical Underpinnings of Promises in C++ – David Sankel

This was the kind of talk you only find at C++Now and it was great. David engages the audience really well on esoteric topics and showed how a rigorous mathematical treatment of a subject can help ensure that an API is appropriately powerful, but also that a good API shouldn’t just be a simple reflection of the mathematical operations.

He followed up this talk with its complement, a practical talk about using the API (Promises in C++: The Universal Glue for Asynchronous Programs). I’m sold: std::future is crippled, and a library like his promise library is the right way to deal with asynchronous control flow.

The ‘Detection Idiom’: A Better Way to SFINAE – Marshall Clow

This was a repeat of Marshall’s recent ACCU talk, with the opportunity for the C++Now audience to ask plenty of questions. The detection idiom (developed by Walter Brown in various talks and papers over the last few years) is a pretty simple way to do one common kind of metaprogramming operation: detecting whether a given type supports something. I feel like this is exactly the kind of thing which is going to help mainstream C++ take advantage of metaprogramming recipes: fairly uncomplicated techniques that just make code better.

The Holy Grail: A Hash Array Mapped Trie For C++ – Phil Nash

Phil presented a followup to his Meeting C++ and ACCU talk “Functional C++ for Fun and Profit“. He showed a very cool persistent HAMT implementation. There was plenty of hard data and code to digest in this talk and like all the best talks, I walked away wanting to play with things I’d just seen. He also noted that “trie” is properly pronounced “tree” (although many people say “try” which is good for disambiguation) and that he’d be sticking to “tree” not only for that reason, but because he didn’t want to be known for both “try” and Catch!

Other thoughts

The annual week in Aspen for C++Now is the highlight of my professional year. The program this year was very strong and I’m sad that I had to miss talks and make hard decisions about what to see in any given slot. But the talks are only half of this conference: at least as important is the socialising and discussion that goes on. C++Now is deliberately scheduled with long sessions and long breaks between sessions so that attendees can chat, argue, and collaborate. At other conferences I learn a handful of new things over the course of a week. At C++Now I learn dozens of new techniques, tricks and titbits at the rate of several per hour. Just a few examples of things that happen at C++Now:

  • Library in a Week: Jeff Garland corrals whoever wants to get involved, and over the week people implement really cool things. It’s like a hackathon within a conference.
  • Having a problem with your benchmarking? Take your laptop to the hotel bar where Chandler Carruth will take a look at your code and tell you exactly how the optimizer sees it, and what you can do to make it twice as fast.
  • The student volunteer program is simply amazing and inspiring. Just look at the current crop and alumni and you see young men and women who are incredibly smart and doing amazing things with C++. Figuring out new tricks and ways to stretch the language that will become codified idiom, making the library you use in a couple of years faster, cleaner, and nicer to use.

Finally, my own talk (with Jason Turner) – entitled “constexpr ALL the things!” – was very well received. I’m heading home tomorrow, but the experiences from Aspen will go back with me, leading to improvements in my own code and that of my work colleagues, making lots of things better. And the friendships I’ve made and refreshed during this week will continue that flow of information and improvement through the year.

Do-notation can be misleading

Wednesday, August 13th, 2014

Consider the following function:

oddness :: Maybe Int
oddness = do
  let a = Just 1 :: Maybe Int
  b <- a
  return b

Perfectly fine, albeit contrived, redundant, etc. Bear with me. Now consider what happens if we change the value of a:

oddness :: Maybe Int
oddness = do
  let a = Nothing :: Maybe Int
  b <- a
  return b

This looks odd, because it looks like we’re extracting the value from a into b, and then passing it to return – it looks like there’s some Int we extract from Nothing, and calling return converts it back to Nothing.

But of course, we know that this do-notation desugars to something like:

oddness :: Maybe Int
oddness =
  let a = Nothing :: Maybe Int
  in a >>= \b -> return b

And recall the definition of (>>=) for Maybe:

instance  Monad Maybe  where
    (Just x) >>= k      = k x
    Nothing  >>= _      = Nothing

So what’s happening here is that what’s on the right of (>>=) remains unevaluated, and Nothing is the result. Mystery solved.

How 6-year-olds think about evolution…

Saturday, December 8th, 2012

Had an interesting conversation with Henry tonight. Can’t quite remember how we started – he was asking something to do with the Ice Age, or the Stone Age. Then he asked, “How did the first person get here?” Now, he’s seen plenty of nature shows; he’s heard of evolution; so I decided to ask him some questions to make him think, viz:

“How did the first cat/dog/cow/etc get here?” (Hmmm… not sure.)
“Is a zebra a horse?” (Yes. A white horse with black stripes.)
“Is a donkey a horse?” (No.)
“But donkeys are quite like horses, aren’t they? Slightly different.” (Hmmm… maybe they are related. Like cousins?)
“Do you still think a zebra is a horse?” (Hmmm… maybe they are cousins too.)
“What’s an example of a small dog?” (A chihuahua.)
“What’s an example of a large dog?” (A golden retriever.)
“How do you know they are both dogs? They are very different.” (They just are dogs.)
“But they look really different, don’t they? More different than a zebra and a horse.” (Hmmm.)
“Is a lion related to a horse?” (No. Hmmm… well, they both run fast. And they both have fur. Maybe they are distant cousins.) [Interesting that he chose “running fast” to be a familial trait.]
“Is a person related to a horse?” (No. Yes? Yes. Oh! People evolved from apes, I saw it in a nature show.)
“Do you know what extinct means?” (Yes. It means something that isn’t alive any more. There aren’t any left.)
“What is an example of an extinct animal?” (A dinosaur. But dinosaurs aren’t really extinct because they evolved into birds!)

At this point the conversation degenerated into a game of dinosaurs evolving into birds and flying around the couch with a blanket streaming behind…

The 4th Amendment and Email

Tuesday, November 20th, 2012

Tonight there was an interesting broadcast of To The Point examining email privacy rights and the 4th amendment, with reference to the recent warrantless FBI investigation resulting in the resignation of David Petraeus as the director of the CIA. The program also featured Declan McCullagh, author of this piece on c|net.

The judicial system has long held that the government requires a warrant to open your mail. And in the 60s, it caught up to telephone technology when it ruled that wiretap warrants actually require a higher burden of proof than a regular “physical search” warrant, because they constitute an ongoing, secret eavesdropping. But the law has not yet caught up with email technology – the government can still peruse emails without a warrant.

This is obviously detrimental to privacy, and something all liberty-minded folks are against. And, it was claimed in the show, large technology companies (Google, Facebook et al) are in the camp that the government shouldn’t be allowed to mine email accounts without due process. But ISTM that it’s not that simple for the 3rd party companies. Because the very same legal interpretation that means that the government doesn’t require a warrant, protects them.

If emails are public records (as they are currently, so the argument for defence of warrantless email access goes), then 3rd parties have no particular responsibility to keep them private. (According to the discussion on To The Point, emails are protected at the instant they are travelling across the wire, but when stored they count as public.)

On the other hand, if emails are private, then the government can’t access them willy-nilly, but presumably that imposes extra responsibilities on the 3rd parties. Which may not be something that Google, Facebook et al want. Can they in good conscience make the argument that the government shouldn’t be allowed access, but they should be able to mine data for advertising or selling on? I think not.

Late night stealth

Thursday, July 26th, 2012

I would like to share with you some things I’ve learned about creeping around stealthily late at night, after the family have gone to bed, in case you find yourself in a similar situation. I’m pretty good at it now. So, obviously to avoid waking anyone up, you want to avoid making any noise, and also avoid any lights. Here’s my list of things to be aware of:

  • Night vision is given by a biochemical change inside the eye: in 5-10 minutes you’ll get pretty good night vision, and in half an hour more or less the maximum. But any exposure to light will very quickly reverse the change. So, if you need to turn on a light (eg the bathroom), just keep one eye tight shut to preserve its night vision.
  • Your peripheral vision is more light-sensitive than your central vision. This is because humans are optimised for daylight: the fovea has a high concentration of cones (sensitive in good lighting conditions) and a lower concentration of rods (sensitive to low light levels). You can see this in a dark room with a very dim light source – if you look directly at the light, it will disappear because the cones around your fovea can’t detect it. But you will see it clearly if you don’t look directly at it.
  • If you’re anything like me, your joints, especially knees and ankles, may crack when walking up and down stairs (and maybe at other times). I’ve found the best defence against this is to give my feet a quick roll around before embarking upon the stairs.
  • Know your house. This takes time to master, but if you are a habitual late-nighter, you’ll learn all the things that make noise. It is very important not to walk into anything, before you have your proper night vision! Kids’ rooms are among the most dangerous places in the dark. Even if you don’t step on a lego brick, you may still knock something that plays a tune or makes a loud noise.
  • Practically all staircases have creaky areas. To minimize creak, walk on the edge of the riser or towards the wall. The middle of the step is likely to creak the most.
  • Doors are most likely to creak at the ajar position, even if they are moved slowly. If you have a somewhat creaky door, moving it quickly is sometimes a good option to avoid the creak.
  • Soft noises of the white noise type are unlikely to wake people. Don’t be obsessed with being absolutely silent. The soft brushing of socks on carpet, or the quiet swish of a curtain closing are noises that shouldn’t wake anyone.
  • If you have to get into bed with a sleeping person, do your best to spread your weight and not to press the mattress down unevenly.
  • If you have to get undressed, do so in another room. Clothes can make quite a bit of noise, jeans and belts especially. Flannel pyjamas are almost silent.
  • Socks are better than bare feet. Bare feet are OK on carpet, but less so on hard floors.
  • Know a bit about phases of sleep. This will enable you to judge whether the sleepers are more or less likely to awaken. Note: phases of sleep progress differently in very young children.

The Second Amendment

Tuesday, July 24th, 2012

Why do people support the second amendment?

I’m going to try to avoid straw man arguments here. And the first straw man argument to avoid, I think, is: “because it protects us from tyranny: if the government becomes corrupt, we can rise up and overthrow it.” Perhaps I’m being naive, but do people really believe they could overthrow the US government through violent means? Perhaps they do; belief without evidence (or belief in the face of evidence to the contrary) is far from rare and even perceived as a virtue and called “faith”. The defence against tyranny argument is also appealing; it’s a fantasy people would like to believe, fuelled by the movie industry and no doubt the NRA. But can people really be fooled by it? I move on.

A second, slightly more nuanced argument which I’ve heard from some, hinges (I think) on the purpose of the Bill of Rights: to frame the (moral) context for the law, viz. “it’s important to preserve the right to rebel against a corrupt government.” This is a logical absurdity. If one is rising up against a corrupt government, one is undoubtedly breaking many laws. Overthrowing a corrupt government is (almost by definition) a choice of the moral over the legal. It doesn’t matter whether your right to overthrow a corrupt government is recognized by that government!

A third reason to support the second amendment, which I’m not going to bother arguing against, but I can’t help thinking is real for some (unfortunately) is the argument from authority. These amendments were written by the founders of the US. And the fact that it’s amendment #2 and not #22 lends it extra gravitas, I’m sure. But again, I’ll move on.

A fourth argument (and I’m afraid another straw man) is the old chestnut “if guns are outlawed, only outlaws will have guns.” This argument has always mystified me because, well, so what? This is already the case in many countries, all of which have substantially lower gun death rates than the US.

In the end, I think the only really understandable position to take is simply that of a gut feeling that this is enshrining an ancient, basic individual right, that extends from the right to life and protection of one’s person. According to Wikipedia, this is the position taken by the SCOTUS. and it is consistent with the purpose of the Bill of Rights, being not to define or grant rights, but to recognize and protect those rights which are accepted as being ancient, “natural” and fundamental to the human condition. This is why the language of the amendments is not, “people may do X” but rather, “the right of the people to do X shall not be infringed/violated.”

I don’t agree that people have a right to arms: one might as well say that people have a right to drive. To me, this would be at least as defensible here in LA: nevertheless we recognize that driving is a privilege and not a right. But even though I don’t agree with this last argument, it is at least understandable that people feel this way. I just hope that people are able to critically examine their beliefs about the second amendment and be honest about why they support it.

A musical interlude

Sunday, February 5th, 2012

I had piano lessons at around age 5, and again around age 10. I never practised enough or liked my teacher much. As a teenager at university, I went back to the piano to play tunes that I wanted to, and taught myself enough to get by on those. After university, nothing for a long time. But I wanted for a while to go back to piano, and so I’ve been studying since summer at the Redondo/Hermosa/Manhattan School of Dance and Music. I still don’t get enough time to practise, but I am learning a lot more music theory and really enjoying composing.

So here is the latest piece I composed: a minuet for violin and cello.

Merry Xmas

Sunday, December 25th, 2011

This year it was a fairly quiet affair, seeing as we’d already visited family in late summer and at Thanksgiving.

The kids did well as usual. Mini-Elbeno got a Kindle Fire from the grandparents (and has been bound not to buy anything on it without the express permission and help of Mrs Elbeno or myself). Micro-Elbeno is apparently going to grow up to be a typographer because he loves letters so much. He got various alphabetic gifts.

I got Mrs Elbeno a wooden watch made from maple and sandalwood. As for me, I got a few items from my always well-stocked Amazon wishlist:

It’s October

Wednesday, October 5th, 2011

And that means the 17th Annual Interactive Fiction Competition is underway. This year there are many entries playable on the web! What will they think of next, eh?

Also, Blizzcon approaches (a little more than 2 weeks away), another Humble Bundle is out (and as good as usual), and today it rained quite a lot here. Hope everyone’s enjoying the Diablo III beta; we’re still working hard.

More exciting news: a new bookshop opened nearby: Mysterious Galaxy. They specialize in SF, Horror, Fantasy and Mystery. I popped in there with mini-Elbeno on Saturday and picked up a copy of The Invention of Hugo Cabret for him to enjoy.

Diablo III Beta goes public

Tuesday, September 20th, 2011

After a few weeks of being friends and family only (and sorry to my games industry friends, but you weren’t allowed in either) it’s now open season for the Diablo III Beta test.