Live data from Hacker News

Zed Shaw on C++

librelist.com

201–210 of 210 posts

Re: Zed Shaw on C++

#201
The portable subset of C++ were around long before mozilla, webkit or chromium. Anyone can read mozilla's or google's guidelines about which subset of c++ is safe to use.

One of the best examples is Informix RDBMS which was acquired by IBM in 2000. And the second best is... JVM. ^_^

Re: Zed Shaw on C++

#202
post #183

Earlier quoted context omitted.

No compiler error ever ruined a NASA mission.

Funny, but imo misses the point. The beauty of dynamic typing is that it makes the writing of the code easier, which makes development shorter, which gives you more time to thoroughly test your code. After years leading a QA team, I'm convinced that more time testing is always superior to more time writing code, even if the code you're writing is there to stop bugs!

The beauty of static typing is that it consists of a proof that entire classes of errors cannot occur when your program runs. Like Dijkstra said, tests can only prove the presence of bugs, never their absence. Static typing proves their absence and is thus extremely useful in writing highly reliable software.

Re: Zed Shaw on C++

#203
post #122

Earlier quoted context omitted.

Can you give an example of stop-the-world garbage collection?

If you meant actually existing stop the world GC, the server GC in Microsoft's CLR stops all threads on a processor to do GC.

[deleted]

Re: Zed Shaw on C++

#204

Earlier quoted context omitted.

Wow, an MMA analogy on this site? Who are Seth Petruzelli, Roy Nelson, and Matt Mitrione then?

Donald Knuth is Hélio Gracie Edsger Dijkstra is Masahiko Kimura John McCarthy is Yip Man Paul Graham is Bruce Lee Steve Jobs is Fedor Emelianenko Linus Torvalds is Mauricio Rua Bill Gates is Brock Lesnar Steve Ballmer is Eric Esch David Heinemeier Hansson is Anderson Silva Guido van Rossum is B.J. Penn Sergey Brin is Antônio Rogério Nogueira Lawrence Page is Antônio Rodrigo Nogueira

That's awesome! I laughed a lot at Steve "Butterbean" Ballmer and the Google brothers! I thought John McCarthy was going to be John McCarthy.

Yukihiro Matsumoto -> Kazushi Sakuraba

Dennis Ritchie, Ken Thompson, Rob Pike -> Royce, Rickson, Renzo Gracie

Joel Spolsky -> Tank Abbot

Bjarne Stroustrup -> Matt Hughes

RM Stallman -> Ken Shamrock

Steve Wozniak -> Mark Coleman

Rasmus Lerdorf -> Jon Fitch

Don Stewart -> Art Jimmerson

Re: Zed Shaw on C++

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

If your currently in an apoplectic fit as to why people don't love C++, const correctness, boost, and the standard library, then read no further.

For those with a slightly broader perspective and an inquisitive mind, perhaps you should take a look at at the Reason C++ framwork, specially if you have never seen C++ in its most pure uncomplicated OO form.

http://reasoning.info

Reason is a C++ framework that ive been writing for about 8 years, which aleviates many of the sources of pain highlighted in this discussion. Writing code with Reason is much more like using a dynamic language, with a full library like Java or .Net.

It supports raii, but doesnt use exception handling and doesnt bother with const nonsense or over the top inheritance restrictions. In fact pretty much everything in Reason is public and designed to be derived, modified or enhanced.

It has generic programming features, but doesnt force you to write everything as templates (a classic mistake that the standard library makes). For example, you can have an iterator of int's without caring what the underlying container type is, so your code and algorithms can actually be generic, not just infectious templates.

Unlike a lot of C++ frameworks and libraries, its not specifically focused on networking, or a few esoteric template classes or collection libraries.

Reason is a fully featured systems programming framework with a complete interface to all the usual posix api's and everything else you would expect from a modern language. It has strings, regexes, streams, parsers, sockets, threads, filesystem, encryption, encoding, xml, xpath, collections, time and date, sql (mysql, postgress, sqlite), http (client/server), smart pointers, formatting, logging, and much more.

But the features are perhaps not as important as how it is written. It is simple, and very object oriented, everything is designed to work togeather cleanly and obey the principle of least surprise. Just like Python and Ruby, Reason allows you to do a lot in a very small amount of code.

So if your wondering how you can have the simplicity of C, with just the good parts of C++, heres your answer.

http://reasoning.info

Re: Zed Shaw on C++

#206
post #148

Earlier quoted context omitted.

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.)

Your objects contain/use various resources, such as memory, file descriptors, mutexes, etc. The way to reclaim any of these is to destroy the object, which lets you reclaim all of them. So memory management is very much tied to other resource management, since they both involve the same thing (deciding when to destroy objects you no longer need). Unfortunately not all resources can be collected equally lazily, so mem…

> The way to reclaim any of these is to destroy the object, which lets you reclaim all of them.

I asked why one should mix management of resources, and you answer that one should mix management of resources. But I still don't know why?

Re: Zed Shaw on C++

#207
post #145
post #132

Earlier quoted context omitted.

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.

Not necessarily allocating very large chunks in bulk but umm... Allocating nodes for a million nodes of a graph and subsequently processing them. Java JVM fragments memory heavily. En

Re: Zed Shaw on C++

#208
post #206

Earlier quoted context omitted.

Your objects contain/use various resources, such as memory, file descriptors, mutexes, etc. The way to reclaim any of these is to destroy the object, which lets you reclaim all of them. So memory management is very much tied to other resource management, since they both involve the same thing (deciding when to destroy objects you no longer need). Unfortunately not all resources can be collected equally lazily, so mem…

> The way to reclaim any of these is to destroy the object, which lets you reclaim all of them. I asked why one should mix management of resources, and you answer that one should mix management of resources. But I still don't know why?

It's more that how the hell do you unmix them (any why would you bother, anyway)?

Re: Zed Shaw on C++

#209
post #206

Earlier quoted context omitted.

> The way to reclaim any of these is to destroy the object, which lets you reclaim all of them. I asked why one should mix management of resources, and you answer that one should mix management of resources. But I still don't know why?

It's more that how the hell do you unmix them (any why would you bother, anyway)?

How to unmix: Just e.g. close your files explicitly, but let the memory of the data structures that represent your files be garbage collected normally.

For patterns of usage similar to RAII, Common Lisp uses unwind-protect. I already mentioned Disciplined Disciple Compiler that extends Haskell to give static guarantees for following certain rules for resource management.

Why would you bother: RAII only covers some cases for resource management, and most garbage collectors can take an arbitrary long time to collect an object that's no longer reachable. Which is fine for memory, because memory is fungible, but the attached resources, say mutexen, are not necessarily fungible.

Re: Zed Shaw on C++

#210
post #61

Earlier quoted context omitted.

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.

Done: http://www.amazon.com/exec/obidos/ASIN/0321635361
Post reply on HN