Archive for the ‘Languages/C++’ Category.

Ruby Read

According to Tim O’Reilly’s always interesting quarterly analysis of the book industry, Ruby is doing extraordinarily well, with a 689% quarterly increase in sales and is now approaching Perl in terms of book sales.

Caveats include the (some would say profound) difference between book sales and use. Most Perl programmers already have accumulated books on the topic. Similarly, C# showed a spike in book sales, but that is almost certainly largely a reflection on the release of VS2005 and not an indicator of a sudden shift towards that language.

Having said that, an important component of programming language popularity is “buzz” and the perception created by a sudden increase in books/seminars/articles. With sites like Digg creating “flash-interest,” and increasing the volatility of the marketplace for attention, “buzz” may play an even bigger role in whatever The Next Big Language is than it did in the success of C++ and Java (two languages whose success was undoubtedly boosted by the amount of associated teaching / discussion).

Variable Length Arrays (Not) In Visual C++

The C99 language standard added support for variable length arrays (VLAs):

 void foo(int len){  float myArray[len];  ... } 

In porting some C# code to C++, I had a method signature like that, so I tried to use a VLA. Sadly, VC++ 2005 produces “error C2057: expected constant expression,” “error C2466: cannot allocate an array of constant size 0,” and “error C2133: ‘myArray’ : unknown size”. I’ve confirmed that this is a compliance thing: the code works with

gcc -std=iso9899:1999

. Pity.>

Non-Professionals Using C++

John Montgomery’s revelation that the most commonly used languages of non-professional programmers are HTML, JavaScript, and C++ is worth reflecting on.

First, let’s just state the obvious: HTML without JavaScript isn’t a programming language, and few people are using Rhino or what-have-you to explore JavaScript as a standalone language, so the first “two slots” in the list mean “I put together Web pages.”

The commentors on his blog entry seem to primarily attribute the popularity of C++ to its use in academics. I suspect that, at least as important, is its primacy in game development. The window for being an academic-but-not-professional programmer is only a few years, while the window for harboring a fantasy of being a game programmer extends from age 12 to age I-dunno’.

Modding a game probably provides one of the bigger “bangs for the buck” for a non-pro developer and I think that it remains true that modding generally is done with a C/C++-derived syntax.

Teachability Important to Programming Language Success

Eric Gunnerson, discussing “Why so many languages?” makes the key point that “Compactness and simplicity have big benefits as well in programming languages.”

Once upon a time, I made a good living teaching Java. Sometimes I taught it to C and C++ developers, sometimes I taught it to COBOL developers. One way or the other, in a week you could really deliver value: if people understood imperative structured code, you could really move them towards an understanding of object-oriented programming in just a week. Same for C# 1.0.

Even so, you had to talk about “well, not everything’s an object,” and deal with function-call semantics and equivalence and so forth. Personally, I think that the inclusion of native types was a critically beneficial language-design decision for Java, but it does complicate teaching. In .NET, it’s even harder to teach, because you can’t say that value types are limited exceptions.

About a year ago, I had a friendly debate with my colleague Allen Holub about the changes in the then-new C# 2.0 and Java 5 languages. One disagreement we have is that Allen doesn’t like generics, I do. I tend to like explicit typing, my feeling is that 99% percent of the time you have a type intent that you can memorialize with a few finger strokes and gain Intellisense and better comprehension. But Allen cleverly didn’t argue the finger-typing issue, he said that what he disagrees with is that generics are not OO, thereby making the language harder to learn.

He’s right. Once upon a time, C was relatively easy to learn; learning how pointers work was the big issue. Now, I can’t imagine someone “picking up” C++ and not being absurdly non-productive. Never mind the STL, how many freaking ways are there just to represent a string? John Montgomery recently posted the surprising factoid that the most commonly used languages by non-professional programmers are HTML, JavaScript, and C++, more than VB or Java or Perl. One wonders what perception these people gain of the task of professional programming.

This is why, when thinking about trends in language syntax, I think there’s a possibility, although not necessarily a likelihood, of a collapse towards simplicity and the widespread embrace of a LISP-like or Smalltalk-like language.

Windows Media Player SDK 10 in C# or VB.NET

The WMPlayer10SDK does not contain the expected primary interop assembly (PIA) so that Windows Media Player can be programmed from .NET languages such as Visual Basic and C#. The WMP 9 SDK puts a PIA in the /redist directory. However, the WMP10 SDK can be programmed in a managed language: you can just copy the files AxInterop.WMPLib.dll and Interop.WMPLib.dll from the /samples directory. Or, you can still download the WMP9SDK and use the old PIA.

Okay, hopefully this post now contains enough keywords to be found via search engines…