Stroustrup on next-gen C++: I didn't want to let go of my baby
theregister.co.uk
theregister.co.uk
I can see this first hand with Objective-C, where Apple evolves the language as they see fit. The joining of such different paradigms as Smalltalk-style OO and C was fragile in the first place and can barely sustain the new functionality.
Another example is C#. No matter how nice the language becomes, it will always be the MS language for me, and I don't trust MS when it comes to APIs and languages - they shuffle things around for no reason, cancel projects, etc. And then you're screwed.
Go is imported by Google, not exported by them.
It's also got good funding, a large number of well known core team members (who won't let it die) and a good license which protects the users in the future.
Some other notable organisations develop everything internally and then release it to the public i.e. they export it. For example C#.
More a "solve Google's specific problems" language, general Google purpose
As an example, C++ and Java programs at Google were taking more than half an hour to compile. This is why Go's semantics were chosen with speed-of-compilation in mind:
* Strictly acyclic module hierarchies (greatly simplifies compile-time name resolution)
* No generics (specialization has a compile-time cost)
* Unused imports are a fatal compilation error (to avoid having to parse unnecessary files)
All three of these decisions are somewhat contentious; Pike admits as much in many of his talks. But they were chosen because of the challenges of writing software at Google's scale. It is in this roundabout way that Go "belongs" to Google, in the sense that it addresses problems that Google has and prioritizes the best solutions to those problems, whether or not those solutions are at odds with the needs of non-Google users.
Huh? Cocoa (and the rest of Obj-C libraries Apple does) are just fine, hardly "barely sustained" by the language.
And it wasn't even Apple, the core framework logic is mostly the same as in NeXT era Objective-C (minus some welcomed syntactic sugar additions).
Smalltalk-style OO and C are very well married in Objective-C, and the language has been, historically, a joy to work with. Jusk ask Tim Berners Lee and Carmack.
Even today it gives strengths that other platforms lack, namely the ability to have very dynamic high level abstractions and easily drop to C whenever you want, which for desktop and especially mobile use is very nice: better memory management and no GC pauses, while still having a full blown OO GUI framework.
I do C++ dev work for a living, I enjoy it. The language can be a nightmare, but as long as you're sensible and frugal with what you're using it's no worse than anything else. The trick is to really, really think about whether a specific feature is worth taking into a more complex direction with some of the edgier C++ functionality, or sticking with more core, basic, understandable code which might trade off performance.
I should probably say I've not done any 'proper' C++ development for a while, mostly we build with Qt and that abstracts a lot of the headaches away into a nice toolkit.
That is part what makes C++ worse: the fact that being a C++ experts primarily means knowing what not to do.
http://www.semantics.org/cpp_gotchas/index.html
C++ also encourages programmers to do "bad things," where other languages discourage such code. In Scheme, arguments to functions are evaluated in an undefined order, and so such arguments should never have global side effects; but Scheme discourages global side effects in general. In C++, arguments to functions are also evaluated in an undefined order...but global side effects are encouraged and widely used in C++, and it is easy to inadvertently create a situation where this becomes a problem (e.g. one argument might resize a vector, when the other is an iterator to that vector -- both common, both encouraged, but a pretty bad combination). C++ makes the most dangerous ways to do things the easiest and least verbose: pointers to access arrays, fixed-width integers, floating point numbers, etc.; other languages make such dangerous things more verbose and force programmers to be explicit when they try to utilize such constructs.
Along those lines, the Microsoft compiler team had a good blog post with links to relevant portions of the standard that I found helpful. [0] All of those "No" not implemented yet is a definite problem. I can also recommend the MSDN series "Welcome Back to C++ (Modern C++)" [1]. And also Microsoft supplies the source code for an app called "hilo" that utilizes c++11, asynchronous techniques and MVVM patterns, but obviously in the context of the microsoft platform! [2]
[0]: http://blogs.msdn.com/b/vcblog/archive/2011/09/12/10209291.a...
[1]: http://msdn.microsoft.com/en-us/library/hh279654(v=vs.110).a...
C++ has such a bad legacy, it's going to be really hard to shake off the bad old days.
Perhaps in time when the newer generations actually have been using C++11 for a while, but not for at least 5-10 years if you ask me.
i've asked for this kind of thing before,but never had a really good suggestion. seems like it could be a huge seller...
[when i last asked here what, 6 months ago, i think the only vaguely useful answer i got was to read the draft standard]
Can anyone recommend a quick-start guide to modern(ish) C++ for the experienced C developer?
The C++ FAQ is really helpful but doesn't seem to be updated to C++11 http://www.parashift.com/c++-faq/
Fortunately you can refer to Stroustrup's FAQ about C++11 http://www.stroustrup.com/C++11FAQ.html
For reference (like libc manpage, basic usage, which header to include): http://en.cppreference.com/
When some people say "Modern C++" they mean template meta-programming (traits, partial template specialisation, etc) as exemplified by Alexandrescu's book "Modern C++ design": http://www.amazon.com/Modern-Design-Generic-Programming-Patt... (note that I am not necessarily advocating such techniques, but understanding them will certainly help when you run across them in the wild).
No-one thinks auto_ptr was a great thing. It was a tool, which could be used with care, but for years most books have said "don't use auto_ptr".
Throw specifications are... throw specifications. Some people like them, over time it has turned out they don't scale too well. Java has gone through a very similar process. I don't get why you were so angry about them.
I don't know why you think anyone thought export was the bee's knees, it's never been available in any of the major compilers since introduction.
In particular, I think everyone agrees export and auto_ptr were bad ideas. That's what literally everyone I hear talk about them says. I don't get why you think these mistakes aren't admitted?
To say something more on-topic: as someone who has been programming in C++ for 15 years, I agree with your comments regarding how C++'a community typically admits the things it sucks at, and is rather pragmatic about the whole thing. (You kind of have to be with a kitchen-sink language like C++ ;P.)
While I agree they are frequently a pain, I'm unaware of any language which has really managed to do exceptions much better. I am happy to hear of examples however.
Since you asked for examples, I'll point to the Common Lisp "conditions" system, which includes restarts:
http://www.gigamonkeys.com/book/beyond-exception-handling-co...
(I'll be honest here and point out that "handler-case," while simpler and more convenient, can still have a double exception fault; this is resolved similar to how Java resolves such things, which is to "forget" one of the exceptions. "handler-bind" is slightly less convenient but is much more robust, and does not have this problem.)
I think given your obvious bias in both method and approach you should probably just plan on learning a new language every 2-3 years or so when what your ideas of the "best" way to do things changes and languges supporting the latest fad are developed. Probably, just avoid commenting on C++ altogether as it is a waste of your energy because it will quite frankly never do what you want given the aims and goals of the steering committee.
One thing that makes this hard in C++ of course is people tend to get annoyed if libraries don't work with clang, g++ and a recent visual studio. Even then you have the problem of older g++ and old visual studio, and then esoteric compilers. In Haskell on the other hand people tend to always be running a recent version of ghc.
eg:
int stoi(const std::string& str, size_t *pos = 0, int base = 10); std::string to_string(int value);
Or some Qt with its non-standard metacompiler.
But yes, that can be considered bad legacy stuff.
And I must say: It's a whole different programming language and a new level of productivity.
struct Foo{...} std::vector<Foo> vec; for( int i = 0; i < 10; ++i) { vec.push_back( Foo() ); }
Results: 35 move / 25 copy / 10 move + 15 copy / 25 move.
It all depends on your compiler and STL implementation. Not knowing scares the hell out of me.
vec.reserve(10);
and report back how many allocations occur.
* Compilers are introducing move as we move in C++11. If you compile your code in C++03 (or a compiler with partial C++11 support, no move).
* The standard doesn't place a strict definition on how vectors are increased in size as you push_back. Of course, if you want to control the amount of space in a vector manually, rather than let your compiler decide, you can reserve in advance.
Is your problem just with moving to C++11, or do you get different numbers (other than different numbers of moves) in a compiler with proper C++11 support (basically, the most recent version of everything).
http://en.cppreference.com/w/cpp/container/vector/emplace_ba...
Also what compiler did you feel comfortable picking a year ago to base a production development effort on?
Ha! So even Soustrup agrees C++ is inevitably subsetted by its users.
> “I try to focus on things that lead to correct programs fairly easily. I emphasise the use of constructors to establish invariance, to acquire resources, destructors for cleaning up, copy operations, and the new [C++ 11] move semantics that allow you to move an object out of one scope and into another one very cheaply," he added.
Keeping the rest of the quote here - now I'm looking for a more abstract and more inclusive notion about what constructors and destructors do.