5 ms·
If Bjarne had been able to keep C++ his own creation instead of letting the "standards" people come in and take the thing over, C++ might have avoided becoming
by bokglobule 13y ago
If Bjarne had been able to keep C++ his own creation instead of letting the "standards" people come in and take the thing over, C++ might have avoided becoming the over-designed language its become. Anyone recall the differences between [const const {star}], [const {star} const], etc ?
Language design has come a long way since the early 80's. His concerns back then were a programming language that would retain the performance of 'C' on most hardware and be straightforward to generate from 'C' code due to re-use of the 'C' syntax (the early C++ systems relied on converters that translated C++ to 'C'). Over time compilers were created to generate machine code straight from C++. When 4k was a lot of RAM, it made sense to focus on this; it still does if you're developing embedded software with very limited hardware. (FWIW, I've written software in C++ since 1990).
I'd argue hard that today, in most cases, and in particular in web applications, the issue is developer productivity. Today we're focusing more on expressing solutions in code that are much closer to the way that we think. Whether it's Ruby, F#, Scala, or Javascript, the tools we're using allow for more powerful solutions in far less code and complexity than C++.
Let the flames begin..
- comex 13y agofor the record, const const * is redundant. I think const is only so confusing because you can write it two different ways (char const * vs. const char *); if only the former was allowed, it would seem a lot more logical.
- n00b101 13y agoint* - pointer to int. int const * - pointer to const int. int * const - const pointer to int. int const * const - const pointer to const int. Is that so hard? Those people posting here who think that THIS is the hardest problem in computing should perhaps find a new line of work.
- comex 13y agoExactly: if 'int const * ' were common, it would be relatively clear that const goes after the type of the thing that is const - but the overwhelming use of the alternate form, 'const int *', makes it more confusing what to do.
- n00b101 13y agoconst int * - pointer to const int I see this is as (const int)* foo; which is the same as (int const)* foo; And people prefer const int foo; over int const foo; So it all makes sense in terms of the grammar. Admittedly, it can be difficult to remember, but pointers and const correctness are complicated and combining them is going to be complicated to write out no matter what grammar you use. Even if the grammar was restricted, it's difficult to remember this type of thing and if you encountered such code in the wild and had any doubts about its semantics then you would look it up on Google before modifying it (right?)
- lbarrow 13y agoAgreed. I recently started working in C++ after spending a lot of time with more traditional web application languages like Ruby, Python and Clojure. It was shocking to see how grotesque and overbuilt the language was compared to the tools I was used to. I don't think I was just having sticker shock due to the relative lack of power and expressiveness of C++. I expected to spend time managing memory, recasting objects, etc -- that didn't surprise me. Instead, I was surprised by how badly different parts of the language play with each other, and how many more parts C++ has. ANSI C has about 30 keywords. C++98 had about 30 more. C++11 adds even more. All of these language constructs have complicated relationships with each other, often filled with gotchas and traps. Compare this with the ~30 keywords in Python (and even less in Clojure). If I'm bound by CPU performance nowadays (which doesn't happen often), I'd use Go or a JVM language. If I absolutely had to, I'd consider C. But never C++.
- btilly 13y agoI am currently doing a small performance intensive project in C++, and my take is that C++ has been a good fit for this. But you have to consciously decide at the start what set of features that you will use. And no more. Because C++ has multiple usable subsets. Find one. Stay within one. Avoid confusion. (Particularly if, like me, you're not a C++ programmer and don't wish to become one. Then you can have a clearly defined boundary of what needs to be learned for the project.)
- nicholassmith 13y agoI recommend anyone using C++ to do this exact thing. It's the sanest way to use it without driving yourself mad when something no longer works because X causes issues with Y.
- kunai 13y agoAny Rubyist or Python developer will be caught off-guard with C++. Dynamically typed languages are intrinsically easier, and languages like Python and Ruby do garbage collection for you, resulting in a lot less work for the developer. C++ does none of that. It's a slightly higher-level modification of C with object-oriented features, and C is still a lower-level language closer to, say, ALGOL or Simula rather than higher-level like Java or Smalltalk. Adding OOP still retains the hardware control and all of the bad stuff that comes with it (segfaults, buffer overflows, etc.), but adds complexity. C++ is complex. Twisted. Mangled. But it's powerful, and you can do things in it that you could never dream of doing in C, Java/Jython/Mono, Python, Ruby, or Go. It's like a Mitsubishi Lancer Evolution. It's a pain in the ass to deal with on a daily basis, but its potential is simply unmatched by any other vehicle in its price range. There are others that are more comfortable. But none reach the capability and sharpness of the Evo. C++ is the Evo.
- pubby 13y agoThe problem isn't really the number of people on the committee, but rather the inability to remove and revise features without breaking backwards compatibility. > Today we're focusing more on expressing solutions in code that are much closer to the way that we think. Whether it's Ruby, F#, Scala, or Javascript, the tools we're using allow for more powerful solutions in far less code and complexity than C++. If you compare the amount of code to the ease of abstraction then I'd say C++ scales much better than languages like JavaScript. It's just that C++ gets multiplied by a huge constant: http://i.imgur.com/WxU2oLy.png http://i.imgur.com/WxU2oLy.png
- beagle3 13y ago> If Bjarne had been able to keep C++ his own creation ... C++ might have avoided becoming the over-designed language its become. My impression is that this is wrong - the language owes essentially everything that it is (including the over-design) to Bjarne. I wrote my first C++ program in 1992 (or perhaps even earlier? I can't find copies of anything I wrote in C++ earlier than 1992), and I've been following the evolution and standardization. Bjarne is definitely the person that started the "Oh, it's useful! Let's add it to the language incoherently introducing redundancy, duplication, and corners, and we'll sort it out later" mess that is C++. I campaigned (unsuccessfully) in 1993 with my employer at the time to switch from C to C++ because I saw the benefits. Back then, C++ was already a mess in the making, but it was still small and elegant, and if you stayed within the subset supported by Turbo C++, g++ and Cfront, life was good. Since 2005 or so, I've been campaigning against C++ and for C (or Python if performance is not critical). That was after I was brought in to fix a C++ monstrosity of a project (and not the first project like that), and realized that the problem actually IS with the language and culture.
- a3n 13y ago"[const const {star}], [const {star} const]" This is the reason why I hope I never program in C++ again: you can't learn it (or re-learn it) by inspection. Yeah, I suppose your example has something to do with the spiral rule (it's been many years), which comes from C (and C has its excuses). But if you come at that cold, it's impossible to reason it out. No language is entirely learnable by inspection, it's a scale, and C++ is way on the wrong end.
- n00b101 13y agoWaaa, programming is hard, waaa, I don't want to worry about const correctness of pointers, waaa I don't want to know what pointer is at all, waaaaaa let me keep making my HTML programs in Visual Clojure BASIC.
- a3n 13y agoThe particular example of the language could have been done with distinct words, not a single overloaded word that depends on order of placement. More decorator-like, for example.
- n00b101 13y agoint * - pointer to int. int const * - pointer to const int. int * const - const pointer to int. int const * const - const pointer to const int. I'm not sure what type of grammar could have been used to make this easier. Nobody said that indirection is easy, but indirection IS essential.
- a3n 13y agoEverything on the right of the dash in your example, or something like it. If you have to use other words to describe what something is, why not use the other words in the first place?
- wtallis 13y agoAll he did was reverse the order of the types. Right-to-left parsing really isn't that complicated, and mimicking English grammar is not as good an idea as you think it is.
- 10098 13y agoDude, "const const" is not even valid C++. Come on.
- gsg 13y agoHe's thinking of C, which allows all kinds of dumb crap in declarations. const typedef; is my favourite.
- dorolow 13y agoSome developers need tools that offer better performance than the languages you enumerated. Not that I have anything against those languages or more abstract languages in general. Quite the contrary, if it was up to me we'd all be writing lisp. Outside of serving as a prototyping tool, a role that Python and Matlab admittedly fill pretty well, I don't believe using Javascript or Ruby or any other (interpreted/high level/more abstract) language would bring much to the problem domain I do most of my work in, realtime computer vision. It may be a shock to some on HN, but there are other applications for computing than web development. I doubt Scala is going to be penetrating triple-A game development any time soon, although I do think it's neat that Javascript has become popular for game UI work. I really like that C#/Unity is going strong and I'm really itching to do something cool with WebGL, asm.js, and/or emscripten. But despite all the progress these languages have made, some problems still haven't been overcome and it's disingenuous to imply that they have. I doubt many would make the argument that C++ is suitable for web development, and I would expect most people to realize that native code still has its place, at least for now. The day I can use Python, Ruby, F#, Haskell, Erlang, or something cool, I will officially be the happiest person on the planet. It hasn't happened yet. Maybe Rust (oh yes) or Go will set everyone free. With all that being said, C++11 is a very welcome addition to the language. While adding more bulk to the language, it ends up reducing the complexity of your code. Auto and decltype have been fantastic for eliminating redundant typing info and boilerplate by making code more generic. Smart pointers, unique_ptr particularly, have been great. For Lambda functions combined with STL algorithms like for_each have eliminated a substantial amount of code on their own. Move semantics have had the effect of reducing the amount of line noise by reducing the frequency of seeing things typed const& and the double whammy of bringing performance gains for little or no effort in many cases. I don't think anyone can deny that C++ is a bit heavier than any language ought to be, but it's what we have and I'll welcome any attempt to make my life easier. Software and programming languages are not zero sum. The use and existence of C++ doesn't preclude the existence or use of another language. Don't try to convince yourself and others that all problems are nails just because you really like hammers. edit: for the record, I mostly do Python and Clojure outside of work when I'm not doing something graphics oriented
- n00b101 13y ago> I would expect most people to realize that native code still has its place, at least for now. Native code has always had a place and will always have a place. New applications will be written in C++, 20 years from now, when all the inefficient, fadish languages (and the inconsequential websites that they power) have long been forgotten.