News for hackers. Stuff that matters.
Re:Duetto: a C++ compiler for the Web going beyond Emscripte... by betterunix on Thursday October 31, 2013 @11:19AM (#6647282)
"I bet with the currently developing standard (C++11, C++14) more people will start loving C++ again"

I doubt it. C++11 takes C++ even further from where it needs to be. Every high-level feature is bogged down by low-level annoyances. Do you capture variables by value or by reference? Do you need a weak pointer to break this cycle, or can you use a weak pointer somewhere else (or maybe just not both with smart pointers at all?)? Your destructor has an error to report -- now what?

The reason nobody likes C++ is that it is overly complicated for low-level programming and too low-level and annoying for high-level programming. At best the only thing people can say about C++ is that it is "good enough" and popular.

Re:Duetto: a C++ compiler for the Web going beyond Emscripte... by vinkelhake on Thursday October 31, 2013 @11:53AM (#6647525)
Pray tell us, where does C++ need to be?

All C++ programmers who I have talked to welcome most things in C++11. It simplifies their C++-code in many ways. As an example: specifying how to capture variables was something they were already dealing with when writing functors manually, now they have a shorthand syntax for it.

As for the reason why non-C++ programmers don't like C++, perhaps you are in a better position to say.

Re:Duetto: a C++ compiler for the Web going beyond Emscripte... by betterunix on Thursday October 31, 2013 @12:12PM (#6647656)
"Pray tell us, where does C++ need to be?"

In my honest opinion, C++ needs to separate low level concerns from high level constructs. How variables are captured in lexical closures is a very low-level concern, but lexical closures are a high-level construct -- by mixing in such low-level details, the overall utility of closures in C++ is reduced. This is made even worse by the fact that the programmer must manually maintain the lexical environment of the closure -- and the new "smart pointers" are only marginally helpful, not nearly as robust as a modern garbage collector (which can, oddly enough, improve performance).

C++ could be a really great language if these things were better separated. I write my code in Lisp, and when I have low-level needs I usually have to write some C code and use an FFI. It gets the job done but it is awful to debug and there is a performance hit. C++ is in a much better position: you can write low-level code, or you can write high-level code, or both, and no language barriers need to be crossed (reducing costs in various places).

"As for the reason why non-C++ programmers don't like C++, perhaps you are in a better position to say."

Well, aside from what I mentioned above, I can give you one more: extending the language. You have a few narrow ways to do it, and then you are just stuck. Operator overloading is great, but what if you want to add a new operator? What if you want to change how your type checker works, so that you can have a dependent type system? There are a few hacks that people can do with templates, but on the whole adding a new feature basically means rewriting your compiler (see e.g. what it took to get support for lexical closures), and C++ compilers are pretty hard to write in the first place. This is something of a Lisper gripe, though there are a few languages beyond Lisp that allow programmers to add new syntax or semantics.

Re:Duetto: a C++ compiler for the Web going beyond Emscripte... by vinkelhake on Thursday October 31, 2013 @12:38PM (#6647833)
Ownership is something that is central in C++. Programmers who come from languages where they can rely on a garbage collector probably find it odd that they would have to specify how variables are captured. For a C++ programmer, it is natural to think about who owns something and in which scope it lives.

To generalize a bit: a lot of the things that might seem odd to non C++-programmers are perfectly natural to C++-programmers.

It's not often that I hear that C++ is too narrow. Being able to add new operators and changing the way the type checker works both seem like niche things and something that is more fit for a research language.

Re:Duetto: a C++ compiler for the Web going beyond Emscripte... by angersock on Thursday October 31, 2013 @12:28PM (#6647756)
I love C++ to death--it gives me a level of control I need to get at very small fiddly bits when I need to, and also to abstract away great swathes of things when I want to.

That said, I very much agree with your point--the middle ground between those two modes is cluttered and there lies madness.

The problem with the new features of C++11/14/42 is that they are never going to remove the existing jank of the language; these folks don't seem to understand--or want to understand--that there is never going to be a magical fucking tabula rasa onto which they'll scrawl their code, unless they want to rewrite all the things from scratch (which may actually be a good idea).

That being the case, they're going to get run circles around by people who either stick to existing jank and libraries or use a language with a better set of batteries and more flexibility (Ruby, Python, etc.).

The power and speed of C++ is not worth the difficulty, usually, of finding people who can use it properly.

Re:Duetto: a C++ compiler for the Web going beyond Emscripte... by vidarh on Friday November 01, 2013 @09:48PM (#6657754)
> As for the reason why non-C++ programmers don't like C++, perhaps you are in a better position to say.

As an ex-C++ programmer who did in fact do a large-scale web application deployment in C++ back in '99, and who used to do template meta-programming for fun:

It's too verbose.

C++11 does go some way to alleviate that, and might slow the number of people leaving C++, but it's unlikely to bring many people back, as the performance difference matters less and less, and the performance of language implementations for the languages people have jumped ship for (Ruby in my case) keeps getting better, narrowing the gap (and we already decided we could tolerate the much larger performance gaps of the past when we left in the first place).

Re:Duetto: a C++ compiler for the Web going beyond Emscripte... by protomyth on Thursday October 31, 2013 @12:11PM (#6647649)
Is there a book that teaches best practice C++11 without teaching any of the old cruft?
Re:Duetto: a C++ compiler for the Web going beyond Emscripte... by dman on Thursday October 31, 2013 @01:21PM (#6648143)
Re:Duetto: a C++ compiler for the Web going beyond Emscripte... by angersock on Thursday October 31, 2013 @12:21PM (#6647708)
Re:Duetto: a C++ compiler for the Web going beyond Emscripte... by protomyth on Thursday October 31, 2013 @12:31PM (#6647774)
What an amazingly unhelpful, snarky, useless comment. If you don't like the question or I guess the topic, just skip it.
Re:Duetto: a C++ compiler for the Web going beyond Emscripte... by angersock on Thursday October 31, 2013 @01:09PM (#6648035)
You're more likely to find up-to-date and useful resources on the 'net then in a dead-tree form.

Moreover, you aren't likely to be able to write any meaningful code without cruft, because you'll have to use existing libraries, where that cruft lives.

Giving you a reference to writing C properly--something most folks still don't do--is actually somewhat helpful as opposed to pure snark.

Does C++ have a fixed ABI yet? Is there a fixed name-mangling scheme across compilers? How do I bind other languages to the lambdas?

Re:Duetto: a C++ compiler for the Web going beyond Emscripte... by protomyth on Thursday October 31, 2013 @01:34PM (#6648248)
No, its just pure snark. C and C++ are long different. I love K&R[1] C, but is really doesn't show properly written C unless some update occurs that addresses the newer standards and all the fun memory issues.

> Does C++ have a fixed ABI yet? Is there a fixed name-mangling scheme across compilers? How do I bind other languages to the lambdas?

Pretty useless for the purpose of my question. I was asking a simple question, your just in it to spread snark.

1) The original edition was one of my favorite books and what I used to learn C back in the day.

Re:Duetto: a C++ compiler for the Web going beyond Emscripte... by Aldo_MX on Thursday October 31, 2013 @12:29PM (#6647764)
> Is there a book that teaches best practice C++11 without teaching any of the old cruft? http://www.stroustrup.com/4th.html
Re:Duetto: a C++ compiler for the Web going beyond Emscripte... by protomyth on Thursday October 31, 2013 @04:42PM (#6649701)
This might sound like an odd question, but what font are the code examples in?

I had an older version of the book that had all the code examples in a proportional italics font and it was some of the toughest reading I have done.

Re:Duetto: a C++ compiler for the Web going beyond Emscripte... by Someone on Thursday October 31, 2013 @04:58PM (#6649824)
The preview at http://www.amazon.com/The-Programming-Language-hardcover-Edi... shows a proportional dark blue font, with comments in italics, at least in the paperback edition (is color printing that cheap nowadays?)

The blue looks problematic on screen. I don't remember having problems with the font in the print edition.

Re:Duetto: a C++ compiler for the Web going beyond Emscripte... by dman on Thursday October 31, 2013 @11:41AM (#6647433)
I like C++ because it addresses problems relevant for building performant applications in the real world. Details matter for performance - the memory hierarchy, cost of small allocations, allocating and accessing aligned data, copying to enable concurrency are all real things.
Re:Duetto: a C++ compiler for the Web going beyond Emscripte... by betterunix on Thursday October 31, 2013 @12:22PM (#6647719)
Details may matter for performance (though in my experience people tend to gravitate towards such things while ignoring asymptotic improvements that can be far more dramatic), but C++ is annoying even if that is something you are trying to do. C++ has a tendency to insert "surprises" into compiled code -- lots of implicit function calls, copies, etc.

I saw this sort of thing first-hand when I TA'd a data structures course taught in C++, when a student came to me asking for help with some very bizarre behavior: a member function was being called for an object that had never been allocated. The problem was that the student had forgotten to write a return statement (why is that even allowed? compilers can obvious detect this, since using -Wall picked it up), and a virtual destructor call had been inserted, but the vtbl for some other object was sitting there and so some other member function for an unrelated class was called.

So while you are sitting there trying to figure out if your class members are aligned optimally, your C++ compiler is inserting function calls and not letting you know about it. If it were just a few implicit calls or copies, it would not be a big deal, but C++ is a huge, complicated language with lots of such things.

Basically, almost everything you mentioned is a low-level concern for which high-level constructs are just a distraction. The point of high-level programming is to direct programmer effort away from such things (hence the implicit function calls and copies, etc.). If you want to program at a low level, fine -- but my point was that in C++, low-level and high-level programming are too tightly coupled.

Finally, it is worth pointing out that this:

"copying to enable concurrency are all real things."

Is not something C++ has any kind of advantage in. I do it in Lisp all the time. You see it in functional programming languages all the time.

Re:Duetto: a C++ compiler for the Web going beyond Emscripte... by dman on Thursday October 31, 2013 @12:52PM (#6647927)
The C++ philosophy is to only pay for costs of things that you actually use. Making every check in -Wall an error by default would make every one pay the costs of those extra checks at compile time.