3 ms·
> Whatever ultimately displaces them someday... it will have to be an order of magnitude better, and it would still take years. I actually think there's no roo
by pcwalton 11y ago
> Whatever ultimately displaces them someday... it will have to be an order of magnitude better, and it would still take years.
I actually think there's no room for any language to displace C++ in that way, ever.
The biggest reason that people give for bouncing off Rust is that the novel aspects of the language--lifetimes and borrowing--are too unfamiliar and/or hard to learn. Any language that is to be an "order of magnitude better" than C++ will necessarily have aspects that are unfamiliar and hard to learn. Long-time C++ users will bounce off that language for the same reasons they're bouncing off Rust.
No non-C++ language will ever appeal to C++ users who don't want to learn new concepts. C++ is very good at being C++, and for that reason it's immortal. Rather, new languages will continue to chip away at the uses of C++, making its use more and more marginal. This is a process that has been going on since the '90s--remember that in the '90s practically all software was written in C++, whereas in 2016 most new programmers aren't even learning it anymore. C++ has been declining not because it's being replaced but because its domains have become smaller and smaller. Rust is just a continuation of that trend: now there's a better option for security-critical software that can't be written in a GC language for performance and/or flexibility reasons (to name Rust's strongest domain), which has reduced the domain of C++ just as Java did 15 years ago for the server space and the rise of the iPhone App Store did in 2008 for the consumer app space. The continuation of this trend is what will gradually make C++ more and more niche going into the future.
- gue5t 11y agoThis seems like the opposite of what I would expect. I'd think any good C or C++ programmer would reason about lifetimes in their programs on a regular basis. When I first came across Rust I was so happy to see a language codify the conventions around ownership and mutation that had previously been relegated to comments, naming patterns, and a rough consensus around what "const" meant. I would expect the people bouncing off of borrowck to be those coming from GC'd languages where where and how long a value lives aren't things most programmers think about. Programmers coming to Rust from this environment have to learn about the fundamental concepts of lifetimes and in-memory representation/storage at the same time as they learn the limitations and reasoning model of borrowck. Without having seen the mistakes they're being prevented from making, I can imagine trying to fix borrow errors would feel more like a game of appease-the-adversarial-checker than a safety harness catching you when you slip up. The only reason I see to keep writing C++ is the impedance gap between Rust and C++ making it less than pleasant to convert a large C++ codebase to Rust gradually. On top of name-mangling/linking concerns, Rust encourages composition and static method dispatch whereas it's rare to find a large C++ project not using inheritance and vtables extensively. You'd probably just end up going through the C ABI for all interop which is hard to argue would increase code quality compared to simply sticking to pure C++.
- pcwalton 11y agoI'd hope so, but in practice I see a lot of C++ people bouncing off Rust's memory management for two reasons: (1) The most common one: They think that they can write C++ safely with no memory management issues, and that people who don't are just bad programmers. This has been empirically refuted over and over again and I think there's no successful way to defend this idea, but it's a very appealing position on the face of it, so it's something I hear a lot. (2) The less commonly expressed, but much more legitimate one: Memory management problems just aren't the biggest issues they deal with. I hear this from game developers from time to time (e.g. Jonathan Blow, though he's not by any means the only one). This is, in my mind, a totally legitimate position. Viewed in this light, C++'s memory management primitives are simple ways to eliminate the most obvious errors, which helps prevent some (not all) crashes and vulnerabilities from reaching production. Rust is entirely a move in the wrong direction for these projects, because it adds nontrivial cognitive overhead. Interestingly, people rarely ever describe reason (2) in those words, probably because the idea that you would opt in to less safety makes people queasy. But that doesn't make sense to me; it's legitimate to want less safety if your app doesn't require it. (I do think, of course, that reason (2) is not legitimate if less safety makes your app vulnerable to e.g. remote code execution by network attackers and RCE would result in the leak of sensitive data or other game-over scenarios.) I've actually been a proponent of solving (2) by adding easier ways to write unsafe code in Rust. But (2) is not a commonly-expressed position, so there's been little community interest in solving it (which I'm fine with).
- zanny 11y agoMy only gripe with Rust is that they should have taken a page out of Python's book in making a langugage syntax both stringent and beautiful. Not only is PEP-8 the greatest thing when dealing with a community project ever, but the syntax is designed around human readability in such a great way. I think syntax like fn foo(bar: int) -> string {}; is a step backwards. More glyphs, more arcane nomenclature, and I just get a ting of change for the sake of change or "I want to be a functional hipster". What is wrong with rettype name<templates>(argtype argname): ? Why am I still writing all these damn semicolons and curly braces? I'm already intending the code and newlining every statement. Why are there so many damn macros when C++ is realizing having language features rather than preprocessor macros is a huge usability gain? I still think Rust is the best language out there today, but the failures in my view drive me insane that its not perfect. Its so close! I guess I kind of just want a native compiled statically typed Python, though.
- pcwalton 11y ago> My only gripe with Rust is that they should have taken a page out of Python's book in making a langugage syntax both stringent and beautiful. I prefer Rust's syntax to whitespace-sensitive languages. > I think syntax like fn foo(bar: int) -> string {}; is a step backwards. More glyphs, more arcane nomenclature, and I just get a ting of change for the sake of change or "I want to be a functional hipster". No, Rust's type syntax is the way it is to avoid the lexer hack, which causes real problems in C++ (typename qualification, in particular). > What is wrong with rettype name<templates>(argtype argname): ? The lexer hack. > Why are there so many damn macros when C++ is realizing having language features rather than preprocessor macros is a huge usability gain? Rust macros are not preprocessor macros, not even close. Macros are language features.
- jeffdavis 11y agohttps://en.m.wikipedia.org/wiki/The_lexer_hack https://en.m.wikipedia.org/wiki/The_lexer_hack
- zanny 11y agoWhat is the lexical hack in relation to the syntax I proposed? I'm not arguing it, I'm just curious why Rust is using the prefix var pointer syntax when you are almost never supposed to use those in language. I guess my point is more you could start from a clean unambiguous syntax (when is "rettype name<templates>(argtype argname):" ambiguous?) and rather than just verbatim copy C's glyphic syntax append vocabulary to the language to describe ill-used features. One thing I have always considered a reasonable design choice going forward would be to start* with somethking akin to ptr(foo) rather than foo to denote dereferencing. In general I would like to see languages in this field start* with vocabulary and transition to glyphic grammar only on the most frequently used language features. That would mean you could start with a language that does things like this: int foo(5) short bar(3) long res(foo.plus(bar)) bar.equals(foo) And then you could have just int, short, long etc classes that have operator overloads for =, +, etc and systemically avoid glyphic overload ambiguity because you are forced to handle that ambiguity in the operator descriptions. With modern compilers (particularly LLVM) this could probably work very well, because the optimizers are so good even if you start defining your primitives in object notation and handing off really ugly bytecode that is treating everything as a non-dynamic object the backend llvm equivalent asembly generator will almost certainly be able to strip all the overhead out and return you back to optimized platform specific math operators onregister-sized words. I'm not a language designer (obviously). I'm just a developer frustrated with how every language but Python is so much harder for my uncle to read (who is not a programmer) and thus makes me spend more brain energy deciphering it than if it were less verbose and more plaintext. And after writing a few of the Rust tutorials on the weekend a few months ago and giving a crack at writing a webrtc library for it I was really frustrated with how much extraneous glyphic grammar I had to learn and deal with in the language, since it seems so much worse than C++ from my perspective.