Dennis Ritchie

dmr (Dennis Ritchie)

What a sad week.

Rob Pike reports that Dennis Ritchie also has passed away. Ritchie was one of the pioneers of computer science, and a well-deserved Turing winner for his many contributions, notably the creation of C — by far the most influential programming language in history, and still going strong today.

Aside: Speaking of “still going strong,” this is a landmark week for the ISO Standard C Programming Language as well. Just a couple of days ago, the new C standard passed what turned out to be its final ballot,[*] and so we now have the new ISO C11 standard. C11 includes a number of new features that parallel those in C++11, notably a memory model and a threads/mutexes/atomics concurrency library that is tightly aligned with C++11. The new C standard should be published by ISO in the coming weeks.

[*] ISO rules are that if you pass the penultimate ballot with unanimous international support, you get to skip the formality of the final ballot and proceed directly to publication.

Bjarne Stroustrup made an eloquent point about the importance of Ritchie’s contributions to our field: “They said it couldn’t be done, and he did it.”

Here’s what Bjarne meant:

Before C, there was far more hardware diversity than we see in the industry today. Computers proudly sported not just deliciously different and offbeat instruction sets, but varied wildly in almost everything, right down to even things as fundamental as character bit widths (8 bits per byte doesn’t suit you? how about 9? or 7? or how about sometimes 6 and sometimes 12?) and memory addressing (don’t like 16-bit pointers? how about 18-bit pointers, and oh by the way those aren’t pointers to bytes, they’re pointers to words?).

There was no such thing as a general-purpose program that was both portable across a variety of hardware and also efficient enough to compete with custom code written for just that hardware. Fortran did okay for array-oriented number-crunching code, but nobody could do it for general-purpose code such as what you’d use to build just about anything down to, oh, say, an operating system.

So this young upstart whippersnapper comes along and decides to try to specify a language that will let people write programs that are: (a) high-level, with structures and functions; (b) portable to just about any kind of hardware; and (c) efficient on that hardware so that they’re competitive with handcrafted nonportable custom assembler code on that hardware. A high-level, portable, efficient systems programming language.

How silly. Everyone knew it couldn’t be done.

C is a poster child for why it’s essential to keep those people who know a thing can’t be done from bothering the people who are doing it. (And keep them out of the way while the same inventors, being anything but lazy and always in search of new problems to conquer, go on to use the world’s first portable and efficient programming language to build the world’s first portable operating system, not knowing that was impossible too.)

Thanks, Dennis.

ISO C++11 Published

ISO

ISO has now published the new C++11 standard and issued a press release: English here, French here.

Thanks again to everyone who made this happen, most especially Bjarne Stroustrup, who not only invented the language three decades ago, but as Evolution Working Group subgroup chair continues to be an active guiding force in its continued evolution. C++11 wouldn’t be the same without the wisdom of his experience and his able direction.

Preemptive note for those who are concerned that ISO charges money for the final official text of the standard: There are, or will soon be, several good options ranging from cheap to free. First, all of the C++11 working drafts and papers are freely available at the WG21 committee page, including near-final drafts of the standard, except only for the final text where ISO asserts copyright. Second, as national bodies ratify and publish the standard themselves, you will be able to purchase the final text of the standard from them instead of ISO if you prefer (the only difference will be the cover page); for example, ANSI published the previous C++ standard in PDF form for $18, which is much less than most C++ books.

ISO’s bulletin text follows:

ISO PRESS RELEASE / COMMUNIQUE DE PRESSE DE L’ISO (VERSION FRANCAISE CI-APRES)

C++ language gets high marks on performance with new ISO/IEC standard

C++, one of the most popular programming languages used in everything from Web browsers to 3D video games, has been fully updated and published as, ISO/IEC 14882:2011, Information technology – Programming languages – C++.

C++11’s improvements incorporate many of the best features of managed languages. Its new features extend C++’s traditional strengths of flexibility and efficiency.

MORE: http://www.iso.org/iso/pressrelease.htm?refid=Ref1472

Follow ISO on Twitter http://www.twitter.com/isostandards

Join us on Facebook: http://www.facebook.com/isostandards

Le langage C++ remarqué pour sa performance grâce à une nouvelle norme ISO/CEI

C++, un des langages de programmation les plus populaires utilisé dans tout, du moteur de recherche Internet aux jeux vidéo en 3D, a fait l’objet d’une mise à jour complète, publiée dans le document ISO/CEI 14882:2011, Technologies de l’information – Langages de programmation – C++.

Les améliorations apportées à C++11 intègrent un bon nombre des points forts des langages managés. De nouvelles fonctionnalités viennent rehausser la souplesse et l’efficacité de C++.

PLUS D’INFO: http://www.iso.org/iso/fr/pressrelease.htm?refid=Ref1472

Suivre l’ISO sur Twitter http://www.twitter.com/isostandards

Joignez-nous sur Facebook: http://www.facebook.com/isostandards

Why no container-based algorithms?

A few minutes ago, a colleague on another team asked:

I really enjoyed your talk on Modern C++ from the Build conference, and have a quick question: Could there be a simpler syntax – something like:

foreach(collection, lambda_function) // or some other syntactic name for “foreach”

which would expand to

for_each(begin(collection), end(collection), lambda_function)

Same for find_if, etc.

This was considered and is desirable. In today’s C++ it’s easy to do for some algorithms, but not others. The main problem is overloading, which needs better template support (i.e., C++0x concepts which were proposed but didn’t make it) and/or adding enable_if.

Briefly, the basic problem is that you already have predicate overloads for some algorithms:

template<typename Iter>
void sort( Iter, Iter ); // 1

template<typename Iter, typename Pred>
void sort( Iter, Iter, Pred ); // 2

So far, so good. But what we want to add is:

template<typename Container>
void sort( Container& ); // 3

template<typename Container, typename Pred>
void sort( Container&, Pred ); // 4

And 4 is difficult to distinguish cleanly from 1 today. Both are match-anything function templates taking two parameters, and 1 would be preferred by the language when the argument types are identical, but in common cases you encounter unfortunate effects. For example, Howard Hinnant points out that if you try to call sort with (say) an iterator and a const_iterator, if we had only 1 you’d get a reasonably clear error message, but now because 4 is able to match different parameter types the compiler will instead try to invoke 4, which isn’t at all close to the original intent, and you’ll get a deeply strange template error message somewhere in the bowels of 4’s implementation because it wasn’t expecting anything like an iterator for either parameter.

Of course, not all algorithms have this issue where there are already overloads with different numbers of parameters. I’m hopeful that the standard library will get range-based overloads of all standard algorithms that are enable_if’d to avoid the problem or can use concepts if those make it into a future standard.

Here’s what the enable_if workaround might look like (I haven’t actually tried this though):

template<typename Iter>
typename enable_if< !CallableWithBeginAndEnd< Iter >::value, void >::type
sort( Iter, Iter ); // 1

template<typename Iter, typename Pred>
void sort( Iter, Iter, Pred ); // 2

template<typename Container>
void sort( Container& ); // 3

template<typename Container, typename Pred>
typename enable_if< CallableWithBeginAndEnd<Container>::value, void >::type
sort( Container&, Pred ); // 4

WordPress.com expertise

I’m generally satisfied with the look and feel of this blog, but would like to tweak it in a few small ways to get a cleaner look, nicer formatting for code examples, and such.

If you or someone you know is familiar with WordPress.com blog customization, and is interested in a small project along these lines, please send me mail. Thanks.

Steve Jobs

Today our industry is much less than it was yesterday. We have lost one of the great innovators. Even more importantly, Steve Jobs’ family has lost a husband and brother and father, and our thoughts are with them.

What can be said that hasn’t been said? Steve has been arguably the single most influential driver and shaper of personal computing in every one of its five decades, from the 1970s to the 2010s. It’s obviously true for the 1970s (Apple, Apple ][) and 1980s (Mac). As for the 1990s, it should be enough that the Mac shaped essentially all of that decade’s desktop and notebook platforms, and icing on the cake that technologies pioneered at NeXT and Pixar so heavily influenced personal gaming and other personal computing. In the 2000s, suffice it to say that Steve put the personal  i  into modern computing and again transformed this industry, and other industries. Looking forward, absent some other world-changing event, it’s clear that the rest of the 2010s will see personal computing develop along the trail he and his teams have blazed already in this decade.

Here is a measure of a man’s impact: Imagine how different — how diminished — the world would be today if Steve had passed away ten years ago.

Makes our hearts fade a little, doesn’t it?

Now imagine how different — how much more — the world would be if Steve had lived another ten years.

Or another twenty. Or another fifty, as though what we have seen were but the first half of his life — and if the second half were not as a slowly aging, diminishing man, but with his health and strength and faculties as strong as ever for that much more time, a true fifty more years.

We are all cut down too soon.

Thanks, Steve.

My two //build/ talks online

//build/

My two talks from last week’s //build/ conference are online.

My personal favorite is Writing Modern C++ Code: How C++ Has Evolved Over the Years. The thesis is simple: Modern ISO Standard C++ code is clean, safe, and fast. C++ has got a bad rap over the years, partly earned, but that’s history. This talk is a “welcome to modern C++” for programmers who may never have seen C++ before, or are familiar only with older and more difficult C++.

If you’re already a modern C++ developer you may be thinking, “but I do most of those things already, why is there a whole talk on this at a Microsoft conference?” Because as interest and use of Standard C++ is heating up again, it’s important to ensure that people have a good experience as they return to C++, or turn to it for the first time. Thus we sometimes have called this the “happy path” talk — designed to show the simple happy path through modern C++ that avoids needless pitfalls.

My other talk was Using the Windows Runtime From C++. This is Windows 8-specific and talks about the “foreign object model” language extensions used by Visual C++ 11 to talk to the new native ABI-safe WinRT types. These extensions should be used sparingly, only on the thin module boundaries around otherwise nice and portable Standard C++ code, and it was necessary to add them only because Standard C++ types aren’t ABI-safe and accessible safely from other languages. (If ISO C++ were to get a module system at some point that includes being able to talk about ABI-safe types on module boundaries, that would be happiness indeed!) There is also a template library called Windows Runtime C++ Template Library (WRL) that is another way to access basically the same functionality using template syntax; pick whichever you like best.

Thanks to all who attended!

My C++ and Beyond Intro: C++ Renaissance

Why C++

Channel 9 has just posted a recording of my intro talk at C++ and Beyond 2011 last month in Banff. Here’s the link: C++ and Beyond 2011: Why C++.

It’s a keynote-y talk, not a technical talk, but we felt it was important to address an important trend involving the language. The goal is to share a perspective and rationale for why of late there’s such a resurgence of interest in C++ — both across the industry, and within Microsoft.

Whether or not you agree with the perspective and rationale, I hope you enjoy it!

C9 interview with Scott Meyers, Andrei Alexandrescu, and me

Scott Andrei Herb at C&B 2011
Scott Andrei & Herb at C&B 2011

After the end of the C++ and Beyond event earlier this month, Charles Torre interviewed all three of us for Channel 9.

I thought it came out really well, and stayed firmly focused on C++ — including even during the parts we talked about D and other languages, where the focus was on how their best parts could be applied to C++.

Charles also taped more of the seminar, including the panels and my opening ‘keynote-y’ talk about the what’s and why’s of the C++ Renaissance. Some of those will also appear on C9 over time; I’ll blog about them as they go up.

Some highlights of this particular interview:

[00:00] Event debriefing

[01:38] Scott on C++ developers

[03:18] Modern C++

[04:17] Why D, Andrei? And what from D could and should be brought into C++?

[17:25] What problems does D solve that C++ can’t?

[22:03] C++ and D interoperability (COM is old, but COM is good)!

[24:22] C++11 and Beyond

[26:01] Herb, ISO C++ Committee’s next phase – what are you going to do? [note: see also more details in my trip report for the standards meeting held the following week]

[28:22] Scott, Andrei and Herb share perspectives on the ISO standards process, philosophies of language design, what C++ gets wrong, what it gets right

[49:48] Perspectives on this year’s event and if/when C++ and Beyond will happen again

Trip Report: August 2011 C++ Standards Meeting

The summer 2011 ISO C++ meeting was held on August 15-19 in Bloomington, Indiana, USA on the wonderful Indiana University campus. The minutes will be available at the 2011 papers page in a couple of weeks.

As previously announced, C++11 was unanimously approved just days before the standards meeting, so this was the first post-C++11 meeting. As planned, at this meeting we focused on processing some bug reports (defect reports, aka DRs) and have some initial discussion of the ‘what’s next’ variety. As expected, no decisions were made about whether we should consider new language extensions soon — that discussion will likely happen at our next meeting in February.

The big news out of last week’s meeting was on the standard library side: There was a clear decision that the library working group is ready to consider new library extensions, starting with the file system library proposal that was already accepted for post-C++11. The following announcement and instructions were read into the minutes:

The C++ committee Library Working Group welcomes proposals for library extensions which will be considered starting in the February 2012 meeting. We have not yet set out an overall timeline for future library extensions, but are ready to consider new proposals at this point.

To increase the chances of your proposal being accepted by the committee, we strongly recommend that a committee member willing to champion your proposal (this could be you yourself, or a delegate) attend upcoming meetings to help shepherd your proposal through the process.

It’s possible that this will take the form of a second library extensions technical report along the lines of the very successful Library Extensions Technical Report 1 (aka TR1). Whatever the form, it’s clear that the first order of business besides maintenance of the C++11 standard will be a new round of extensions to the C++ standard library.

Personally, I think that’s exactly what needed to happen at this meeting, and I’m very happy to see it take place. ASIO or thread pools, anyone? Maybe parallel algorithms, and concurrent containers? Stay tuned.

Looking forward

It’s our tradition to schedule one meeting a year outside the continental United States, and preferably outside North America, because this helps international participation by making it easier for people from all parts of the world to attend. Next year, as we’ve done before, this “un-American” meeting will be the Kona meeting, which is closer for folks in eastern Asia and Australia who may wish to attend.

Here are the planned dates and locations for upcoming ISO C++ standards committee meetings: