Live data from Hacker News

Zed Shaw on C++

librelist.com

141–150 of 210 posts

Re: Zed Shaw on C++

#141
I'm going to keep saying this until I turn blue in the face. Perhaps if I stamp my feet it might get more attention (wink)

Please stop confusing the language with the APIs or the available libraries and features of the language.

This sounds simple, but it's profound: simply because you can do something, that doesn't mean that you have to do it that way.

To use Zed's example, let's say I'm hacking around a lot of strings. What's wrong with rolling a string class, adding a member or two? You only have to carry around a bunch of nonsense if you want to. If you don't want to use templates and strings and such, don't use them.

This is another in a long line of articles that go something like this: We did X in this certain way, and boy did it suck. Therefore all of X is the devil's work and will destroy civilization.

You can put about anything you want in for X. It's like a (oddly enough) template engine for writing blog entries.

You should go through stages in your career, with just about any X. Stage one is that you are ignorant. Stage two is that you've tried it. Stage 3 is expertise. Stage 4 is hate, and Stage 5 is grudging acknowledgement that parts of X are okay for certain situations. You realize that yes, X is done poorly maybe 99% of the time, but lots of smart people worked on it and there are some little gems in there that are useful from time to time.

Looks like Zed is stuck on Stage 4

Throw away the templates, throw away all the library stuff you don't like -- is there a reason to make a class and wrap some things? If so, you can do that in C++. You can't in C. It's a very simple question, and it has nothing to do with any of the things Shaw is going on about.

Re: Zed Shaw on C++

#142
post #15
post #4

There appear to be a lot of good rants against C++. To name a few: * Linus Torvalds : http://lwn.net/Articles/249460/ * C++ Frequently Questioned Answers : http://yosefk.com/c++fqa/ Are there any good passionate pro C++ versus C arguments?

"There appear to be a lot of good rants against C++....Are there any good passionate pro C++ versus C arguments?" By definition, the people who write the "entertaining" rants against C++ have an axe to grind. The people who like C++ just silently use it , and feel no need to write advocacy blog posts for the language. Even if they were to blog about it, it would be about as compelling as someone advocating for their…

Well, lack of advocacy could indicate lack of awareness of other programming languages.

Don't the boost guys say that now C++ is the most powerful programming language?

Re: Zed Shaw on C++

#143
post #33

I agree totally with Zed Shaw on this, but some quick observations: * C++ circa 2000 (before mainline g++ could handle Alexandrescuisms) is significantly different from C++ circa 2010, albeit in ways that probably upset Shaw even more (the more central role boost has taken, the more "expressive" templates have gotten, don't call me on any of this stuff). * C++ std::string is an abomination, but you can always just do…

> const-correctness may be another misfeature (I know I make fun of it), but the point isn't hard to see: if you take the time to const-correct your code, the compiler will spit out errors that would have otherwise been runtime faults.

I think it is so interesting the mentality of static typing people. I would much prefer handling the few resulting run time faults than having to stuff with my code with const.

Anyway, there is no guarantee in C++ that something that compiles with all consts in the world will not throw a segfault at run time in the least expected moment...

Re: Zed Shaw on C++

#144

Earlier quoted context omitted.

It's not that any one thing is bad. It's that lots of things are bad.

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.

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.

Simply false: take a look at Oberon sometime.

Re: Zed Shaw on C++

#145
post #132

Earlier quoted context omitted.

> C++ just doesn't attract self-publicists the way Ruby seems to. That's a cheap shot ... Linus Tolvards is definitely not the Ruby-type. And his arguments are sound ... for system programming, C is a much better language because it's simpler, lacks magic, making the pieces of code easier to understand without the bigger context, and it's more portable. And for application-level programming, why would you chose a lan…

Try allocating a very large chunk of memory using a high-level language with garbage collector. It's not always about collection.

Why would you allocate a large chunk of memory, when you are using a garbage collected language?

There may be reasons to want to mix manual and automatic memory management. If you want to do that, there are language that support it. Like D.

Re: Zed Shaw on C++

#146
post #57

Earlier quoted context omitted.

The problem with std::string is that when I type a quoted string in my code, it isn't natively a std::string, it's natively a char* and gets converted to strings. C++'s biggest mistake was not standardizing early on an official object-oriented string datatype. It should have been in the first version of C++, it should have been treated like a primitive type (even if it isn't), and they should have said "thou shalt us…

The great thing about const is that if you don't like it you can pretty much ignore it. The only time it might be necessary to deal with it is if you are using a library that returns const objects. If you do like const (which I do) then you can put it in pretty much everywhere, except if you are dealing with a library that isn't "const correct", but then a bit of type casting will save the day. That's a big advantage…

That's not really true. If you need to work with libraries that use const everywhere you have only two options:

* Use const everywhere

* Use casts everywhere

The same thing happens if you use const and your libraries don't...

Re: Zed Shaw on C++

#147

I'm going to keep saying this until I turn blue in the face. Perhaps if I stamp my feet it might get more attention (wink) Please stop confusing the language with the APIs or the available libraries and features of the language. This sounds simple, but it's profound: simply because you can do something, that doesn't mean that you have to do it that way. To use Zed's example, let's say I'm hacking around a lot of stri…

"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 ceremonial standard library, and that's not a coincidence.

Re: Zed Shaw on C++

#148

Earlier quoted context omitted.

> C++ just doesn't attract self-publicists the way Ruby seems to. That's a cheap shot ... Linus Tolvards is definitely not the Ruby-type. And his arguments are sound ... for system programming, C is a much better language because it's simpler, lacks magic, making the pieces of code easier to understand without the bigger context, and it's more portable. And for application-level programming, why would you chose a lan…

> And for application-level programming, why would you chose a language without a garbage-collector? Because your code uses some finite resources other than memory, and you don't want the ability to forget to release said resources when you're done with them and they go out of scope.

Why should memory management related to managing other resources. Anyway, you might be interested in The Haskell Disciplined Disciple Compiler (http://www.haskell.org/haskellwiki/DDC) which lets you statically encode resource management rules. (And of course spots garbage collection for memory.)

Re: Zed Shaw on C++

#149
post #33

I agree totally with Zed Shaw on this, but some quick observations: * C++ circa 2000 (before mainline g++ could handle Alexandrescuisms) is significantly different from C++ circa 2010, albeit in ways that probably upset Shaw even more (the more central role boost has taken, the more "expressive" templates have gotten, don't call me on any of this stuff). * C++ std::string is an abomination, but you can always just do…

> const-correctness may be another misfeature (I know I make fun of it), but the point isn't hard to see: if you take the time to const-correct your code, the compiler will spit out errors that would have otherwise been runtime faults. I think it is so interesting the mentality of static typing people. I would much prefer handling the few resulting run time faults than having to stuff with my code with const. Anyway,…

No compiler error ever ruined a NASA mission.

Re: Zed Shaw on C++

#150
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…

I guess, if you set your mind to it, you could probably make Forth do a nice mixture of low and high-level stuff, too.

But why do people insist on being able to do low and high level stuff in the same language? What's wrong with, say, using Python for high level stuff, and calling into C for low level tasks? C+Python is probably more convenient than C++.

Post reply on HN