Each to what it is good at

nicholas on 2008-10-26T21:20:37

A couple of things amused me in the blog that Ovid linked to. Ninh writes

Come to think of it, I find it kind of insulting that PHP thinks you need ugly training wheels like this in the first place. Last time I checked, the world wasn’t filled with scrawny developers that would come crying to their mommies after getting their first facepalm of “AmbiguousInvocationError”.

Um, but isn't he tilting at windmills? I thought that the whole philosophy of PHP was "easy things as easy as possible". Which, if Larry's water bed theory of language design holds, means that something has to give elsewhere.

Meanwhile, as part showing that :: works just fine in C++ as namespace and package separator, Ninh gives example code and notes

Yes, you’ve read this correctly. Unlike PHP, C++ will simply say that you’re a silly person to write “less-than-intelligent” stuff like this in the first place and thinks it is the responsibility of YOU, the programmer, to solve this problem.

Except, here's how his C++ compiler tells you, the programmer, that you have conflicting Foo::bars:

$ c++ -o test test.cpp
/var/tmp//ccCahjBl.s:47:FATAL:Symbol __ZN3Foo3barEv already defined.

Here's what my compiler made of it:

g++ clash.cc -o clash
/var/folders/TZ/TZzOop8WEdSNgET6iqWhPE+++TI/-Tmp-//ccMPeaMa.s:49:FATAL:Symbol __ZN3Foo3barEv already defined.

Yes, such a clear, concise error message, isn't it? Includes the file name and the line number of the conflict, so I can go straight to it in my editor. A best practice that every other language should be following.


User Hostile

chromatic on 2008-10-26T23:07:32

C++ is perhaps not the best example of scrutable error messages from compilers. (The single design decision in C++ with which I can wholeheartedly agree is "You don't pay for what you don't use. I'm not sure C++ always lives up to that in terms of the conceptual tax, however.)

intel c++ seems smarter

tonyc on 2008-10-27T05:40:26

Of course, not all compilers are stupid enough to leave the error reporting until assembly time:

tony@mars:~/play$ icpc test.cpp
test.cpp(11): error: "Foo" has already been declared in the current scope
  namespace Foo {
            ^

compilation aborted for test.cpp (code 2)

Debugging symbols

drhyde on 2008-10-27T14:30:04

Is it less inscrutable if you build with -g? Which, of course, the sensible C/C++ programmer will be doing anyway during development.

Wait, what am I saying? A sensible C hacker? Hah!