Live data from Hacker News

Zed Shaw on C++

librelist.com

171–180 of 210 posts

Re: Zed Shaw on C++

#171

Earlier quoted context omitted.

Lots and lots of things are bad in C++. But that's because it's an elaborate language with lots of things in it. You only have to use one bad thing at a time ;-). Basically, any language with lots of modularity and lots of low level access is going to be big and have lots of features that are problematic in some situations.

Say you need both modularity and low level access in a given program. Can they be so entangled that you absolutely have to put both in the same language ? No matter how I put it, I fail to see how C++ can be better than C + (Python or Lua or Haskell, with FFI). Is the concept of using 2 languages at the same time so scary?

Is the concept of using 2 languages at the same time so scary?

In all honesty, yes.

But consider this also. The advantage of C++, such as it is, is that the big, harry objects you are creating can call each with just about any calling conventions you chose and you can parameterize them at run time and compile time in whatever crazy way you'd like (pointers, templates, static objects, classes and ponies! (Ponies will only be standardized in C++_2015)). This is why Python, Lua and all each call c/c++ for extensions. But while there are many interesting scripting languages out there, there's no guarantee that any of these languages' calling convention, memory usage and constraints will be what your large objects need. Specifically, to effectively use a particular higher-level language you'd have to know from the beginning that said language's conventions would satisfy your needs from beginning to end.

Add to this the fact that C++ may not be a "good" programming language but that it's not that bad if used with discipline and understanding. The badness of c++ comes from the many, many ways you can shoot yourself in the foot - it still doesn't force to do anything. But how many subtle bugs can creep in if you're sloppy in passing raw pointers to some other language? And using any higher level language will involve forcing yourself to do a number of things that could prove problematic.

Re: Zed Shaw on C++

#172
post #164

Earlier quoted context omitted.

My short rant: C++ is as bad as they say it is. It is horrible, it is the worst language in the world ... except for all the other (a la Winston Churchill and democracy). The horrifical complexifications of C++ are just terrible, yet every one of them has a reason behind it. And also, the horrifical complexities are a bit more optional than the horrifical complexities of, say, Java. There isn't another language that…

What you say about Java's verbosity is sort of flawed in the same way that attacks on C++ about its template metaprogramming madness are flawed. Don't confuse a language with what people write in it. There is a point though. C++ encourages obscure "too clever" constructs, and Java encourages excessive verbosity. But in both cases you can decide not to go there.

As far as I know, there's a lot more to Java that isn't optional: everything must be inside a class definition, everything must use the garbage collector.

In C++, you don't have to declare a single class or create a single template.

Re: Zed Shaw on C++

#173
post #155

Earlier quoted context omitted.

"What's wrong with rolling a string class, adding a member or two?" The fact that it's 2010? A language and its standard library are theoretically different things, but in any practical sense, the choice to use a language carries with it the choice to use its standard library. Additionally, the way the standard library is usually reflects constraints placed on it by its language. Java, for example, has a verbose and…

The C++ standard library and std::string implicitly have specific constraints and use cases, but they were imposed by the design process, not by the language. C++ has many string types because each string type has its strengths and weaknesses. For instance, QString is a fully-featured and Unicode-aware string written in C++ that I use most of the time. std::string is good for most things. What are your specific issue…

A proper s[n]printf()-like functionality would be more than nice. No ostringstream crap, no boost's format() hacks, just plain sprintf().

Re: Zed Shaw on C++

#174
post #124

Earlier quoted context omitted.

My short rant: C++ is as bad as they say it is. It is horrible, it is the worst language in the world ... except for all the other (a la Winston Churchill and democracy). The horrifical complexifications of C++ are just terrible, yet every one of them has a reason behind it. And also, the horrifical complexities are a bit more optional than the horrifical complexities of, say, Java. There isn't another language that…

There is no other language for crafting large-scale, high performance tools is demonstrably false. There are high-volume low latency world-class financial systems written totally in Java. The seriously complex and high-performance ITA system is written in Lisp. And if you read Coders at Work, some of the criticisms of C++ suggest that the reason behind many of the C++ features is that Bjarne didn't want to say NO . A…

The seriously complex and high-performance ITA system is written in Lisp

Have you worked on it? Do you know this? Is it all written in Lisp, or are the parts that need high-performance and predictability written in C or C++?

There's a lot of language FUD out there. I say this as someone who owns OnLisp, and has spent a lot of time learning Lisp.

Re: Zed Shaw on C++

#175

I agree with most of what he says but not with his memory management argument. In C++ you could do something like this: f() { LinkedList list; populate(list); use(list); //forget } Freeing the list elements is done in one place only, in the destructor of LinkedList. In C, you have to call some kind of free function in every single place a LinkedList is used. The burden of managing memory is on the user of a library,…

Thank you for bringing that up. It's called RAII and it's one of my favorite features of C++. The fun thing about it is that it can also be used to manage other resources such as files, sockets, locks or what not.

Re: Zed Shaw on C++

#176
The problem with a lot of these posts on HN is that the audience seems to be rather biased towards low-performance app areas like web, and business apps.

Oh noes! I have to handle 10 requests a second!

Take a look at the SWENG-gamedev mailing list for some of the performance issues that people face in games and game tools.

/pissing-contest

Note: obviously this is not an argument against C instead of C++. It's more to forestall the meta-discussion.

Re: Zed Shaw on C++

#177

Earlier quoted context omitted.

That's usually considered a drawback of C++; it's a huge, complicated language and everybody tends to use a different subset for their own work.

The same can be said of English. And in both cases, there are sundry tasks of limited scope where the language is probably not the most natural choice (e.g. operas). However, when one is simultaneously dealing with multiple, disparate domains/constraints simultaneously (e.g. real-time computer vision), such a language might be the least unattractive option thanks to its inclusiveness.

Except program don't express natural language, and in fact the required context awareness of natural language is exactly what kills many languages and frameworks. I shouldn't have to know all of these things to edit some stranger's code, it should be obvious how it works.

Re: Zed Shaw on C++

#178
post #61

Earlier quoted context omitted.

Start here: http://en.wikipedia.org/wiki/Andrei_Alexandrescu

Wow, had no idea he was at Facebook now. Loki is neat, even if it does represent everything that is evil about C++.

He's also writing (I think it's almost done?) "The D Programming Language", which is pretty highly anticipated.

Re: Zed Shaw on C++

#179
post #73

Earlier quoted context omitted.

There's this thing called a joke . . . I believe that's waht Zed is making here.

You Sir, win a dollar! I think to make the joke really clear I'd have to add a few more consts and some pointers in there.

You should head over to Reddit and see how bad that one statement managed to keep up your perma-trolling. It's pretty intense.

Re: Zed Shaw on C++

#180
post #3

I really do love a good C++ rant.

Thank you for this post. For the life of me I cannot explain why, but it delighted me immensely, and I am inexplicably incapable of reading it in my head without an exaggerated British accent.

Strangely enough, despite being thoroughly american, I am given to british spellings and mannerisms in my writing and speech. I think it has something to do with being really into british humor and fiction for most of my life. (british comedies, Terry Pratchett, Dr. Who...)

I constantly get teased by friends about my british spelling s of common words.

Post reply on HN