Tuesday, October 18, 2005

What's wrong with C++?

I whole heartedly agree with this article!!

What's wrong with C++?
by Bartosz Milewski

src: http://www.relisoft.com/tools/CppCritic.html
--------------------------------------------------
Some time ago NWCPP (Northwest C++ Users Group in Seattle) organized a public panel on the future of C++, with Scott Meyers, Herb Sutter, and Andrei Alexandrescu. I started thinking about C++ and realized that I wasn't that sure any more if C++ was the answer to all my problems. I wanted to ask the panelists some tough questions. But I was there for a big surprise--before I had the opportunity to say anything, they started the criticism of C++ in the earnest--especially Scott.

One of the big issues was the extreme difficulty of parsing C++. Java and C#, both much younger languages, have a multitude of programming tools because it's so easy to parse them. C++ has virtually nothing! The best tool one can get is Microsoft Visual Studio, which is really pathetic in that department (I haven't tried Eclipse). Apparently, VS uses a different (incomplete) parser for its browser than it does for its compiler, and that's probably why it can't deal with namespaces or nested classes. When you search for a definition of a function, you get a long list of possible matches that don't take into account any of the qualifications of the original query. Finding all callers of a method is so unreliable that it's better not to use it. And these are the most basic requirements for an IDE. By the way, the Help engine seems to be using yet another parser.

I talked to John Lykos at one of the conferences, and he told me that he would pay big bucks for a tool that would be able to tell what header files must be included in a given file. That was many years ago and to my knowledge there still isn't such a tool. On the other hand, there are languages in which the programmer doesn't even have to specify include files, so clearly this is not an unsurmountable problem and it's only C++ that makes it virtually impossible.

Complex programming problems require complex languages. An expressive language helps you deal better with the complexity of a problem. I believe there is some proportionality between the complexity of the problem and the complexity of the language. But if a language is disproportionately complex, it starts adding complexity to the problem you're trying to solve instead of reducing it. There are endless examples of unnecessary complexity in C++.

Accidentally, the parsing difficulties of C++ might be the biggest roadblock in its evolution. In principle, changing the syntax of the language shouldn't be difficult, as long as you can provide good translation tools. You can look at syntax as a matter of display, rather than its inherent part. Just like you have pretty printers that format your code, you could have a pretty viewer that shows C++ declarations using Pascal-like syntax. You could then switch between programming using the rationalized syntax and the traditional syntax.

As long as C++ gurus live in the clouds of the Olympus, they won't see the need for this kind of evolution. That's why C++ becomes more and more elitist. In the future, people who do NYT crossword puzzles and the ones who program in C++ will be in the same category.

Very smart people keep writing books with titles that read like "Esoteric Nooks and Crannies of C++", or "More Bizarre Pitfalls of C++". Or puzzles that start with "What's wrong with this code fragment that to all normal people looks perfectly OK?". You don't see such publications in the Java or C# community. C++ is becoming a freak language that's parading its disfigurements in front of mildly disgusted but curiously fascinated audience.
"So you have to put a space between angle brackets? How bizarre!"
"Are you telling me that you can't pass an instance of a locally defined class to an STL algorithm? How curious!"
"Talk to me dirty! Tell me more about name resolution!"
"Pardon my French, Is this specialization or overloading?"
--------------------------
Also see: http://www.alledegodenavnevaroptaget.dk/interview.html

17 comments:

Anonymous said...

##Psychic Reading##

Anonymous said...

"One of the big issues was the extreme difficulty of parsing C++."

It is ___provably___ impossible to write a correct C++ parser which will complete compilation with either success of failure because the C++ template system is Turing complete. This means that code generation is based on a turing complete program. Code generation in C++ isn't based on a program description, but an actual turing complete program.

As such, it is subject to the halting problem. Therefore, it is unknowable whether a compilation will complete, and unknowable if you are looking at a valid C++ program.

-flan, who doesn't care to have a blogger account.

Anonymous said...

oops, the C++ spec allows implementations to terminate compiles if they recurse too deeply. Nevermind.

delightfully-different said...

Exciting blog. The site out did itself and will be
back! I love surfing the internet for blogs that are
exactly like this blog.
Search for my blog, please!

outa-time said...

Enchanting blog. Your site was off the chain and I
will return! I peep the web for blogs just like this
one.
I was in love with your 1800contacts coupon codes blog site.

Instant Cash Loan Till Payday Com said...

Wondrous blog. Your site was very pleasing and I
will go back again! I like surfing the net for blogs
as good as yours.
Please take a journey to my 1800contacts com coupon blog.

dat-girl said...

Enchanting blog. Your site was off the chain and I
will return! I peep the web for blogs just like this
one.
I'm looking at the possibility of checking your 1800contacts coupon codes blog.

stunned said...

Creative blog. I just kept looking at it over and
over! Im always looking for blogs like this!
In my spare time I will look for your 1800contacts coupon codes blog.

florida mortgage lenderf7 said...

Great blog. I'm always finding blog like yours. It
got my attention and I will go to the site again!
Go by and hit my 1800contacts com coupon blog, you'll be glad you did.

maryland mortgagee said...

Powerful blog. The site was incredible and will be
back again! Web surfing helps to find good blogs like
this one.
In an efford of finding the right info, check for my 1800contacts com coupon blog site.

final fantasy 10 musicd said...

Terrific blog. I search the internet everytime I
get a moment to find blogs. Its better than cold iced
tea and I have to visit it one more time!
If your look to uncover information, please visit my coupon codes 1800contacts blog

quick cash advance loan1c1 said...

Unbelievable blog. I can hardly wait to vist this
site again.I'm consistently looking up blogs like
this.
I want you to look for my 1800contacts coupon code blog.

amaretto-mudslide said...

Terrific blog. I search the internet everytime I
get a moment to find blogs. Its better than cold iced
tea and I have to visit it one more time!
Where you been? You have got to look at my coupon codes 1800contacts blog!

job opportunitya said...

Sensational blog. I took pleasure in the site and I
will go back! Surfing online for blogs like this one
is worth my time.
Go by and hit my free plastic surgery blog, you'll be glad you did.

job opportunitya said...

Hype blog. And I admire your site and plan on
returning to it! When I web surf it always helps me to
find great blogs.
Check out my plastic surgery gone bad blog, please!

Anonymous said...

yr

Matt Kukowski said...

I COMPLETELY AGREE! There are programmers out there that think they are genius because they can write code that is so CONVOLUTED and pointless, just because they think they are smart to do so. I Think C++ is ok when it comes to BASIC class use, but as soon as one convoluted the code with more and more crap... it makes programming a CHORE instead of being fun, and having the kick in the discovery your program DOES SOMETHING USEFUL. Not just saying, Oh I can code THIS and you can't follow it without spending hours trying to DECODE the CODE.