Tuesday, May 3, 2005

Coming to terms with hatred

I have C++. I hate it more and more with each and every passing day. Each day that I spend writing C++ code I find more things about it that I hate. Each day that I spend writing code in just about anything except C++ I find more things that other languages do better. It's something that I've spent a while trying to understand: I know at least the basics of why I don't like it. What I don't know is why other people like it.

Some people like cold, terse, compact, mathematical code. These people should use C. Some people need high performance. These people should use C. Some people like object-oriented programming. These people should use C# or Java or VB.

After about a year of being around professional C++ developers, I still completely fail to understand what they like about the language. It doesn't let me easily do any of the things I want to do in programming. I want my code to look like thoughts, to look like some kind of shorthand for English sentences. I want my code to include things that explain what the program does, not how the computer stores the bits. Objects are the things that separate C++ from C, and yet they still seem like a hastily-designed (though admittedly technically sound) afterthought.

I saw *const*int (or something to that effect... a pointer to a const pointer or whatever) a few days ago. I think that's what pushed me over the edge; the point where I absolutely cannot grow to accept C++. (I don't know; maybe it's possible in C too.) The syntax is so bad that it doesn't even matter if it's a useful construct or not.

I'm still disappointed with the syntax of C# and VB and Java too. They're still full of baggage from years gone by. People seem content with letting the language stay the same, and only adding new nouns and verbs to it, but I don't see why. I want new syntactical constructs. It's not that there's nothing much left to add to languages... I invented three bits of syntax just this afternoon on my whiteboard. There are tons of weird, experimental languages, and I've never been really satisfied with any of them; while they often have some interesting ideas, they always seem to come at the expense of functionality. I want a language that is redesigned from the ground up to be readable and expressive and predictable and still performant, free of unnecessary legacy syntax, and yet still allow me to do all of the things I used to do.

I think that the .NET and Java environments are the perfect incubation chambers for an experimental language: so much of the things that you want a new language to do so it has all of the functionality of an old language are still there: memory management, program flow, and a massive class library to draw on. I've wanted to write my own language for five or ten years now, and my desire to do so has increased dramatically since starting to use C++ more often. It's just so broken and awful.


Anonymous said...

Perhaps you could provide examples other than "I don't like the syntax."?

Travis said...

I'm not really inclined to go into too much more detail. It wouldn't really accomplish anything. But, a brief list of things I don't like that come to mind right now:



The syntax for for loops (it's too generic; why make a specialized while loop only to make it more generic in a different way?)

delete []x

int *x, *y (as opposed to int* x, y)

Case sensitivity

switch case fall-through

And all of the kludges that header files bring, like:

#define FILENAME_H
(or #pragma once)

Defining default parameters, static, virtual, etc. in the header file but not the implementation

Starting the name of each class member function with ClassName:: because you defined ClassName in a header file

...and et cetera.

Travis said...

My main problems with C# and Java are mostly carryover hatred from C++... things like case sensitivity, the for statement, and so forth. I also dislike the fact that Java primitives are too primitive (though perhaps it's been addressed in 1.5; I haven't played with 1.5 much). For example, I can't access fields on int, like MAX_VALUE. They're on Integer, which is not the same thing. Bah.

For VB, I hate the things from BASIC that should have gone away but haven't, like On Error GoTo, Dim, and ReDim; unnecessarily long keywords like "NotInheritable" instead of "Sealed," the lack of a real tertiary inline if, and having to use "AndAlso" to short-circuit logical expressions. At least VB in .NET 2.0 has nice compiler warnings for some things-that-should-not-be like accidentally forgetting to declare a variable type, and lets you make those errors if you so choose.

Travis said...

I probably should have made all this another post. I mean, hey, free content.