5 ms·
If you can think like a C programmer, you will be able to write really fast programs in D. D, C++ (and also C# and Java) are very similar languages. If you lea
by randomNumber7 6y ago
If you can think like a C programmer, you will be able to write really fast programs in D.
D, C++ (and also C# and Java) are very similar languages. If you learn any of those, learning the others will be easy.
C++ is just the most complicated because of the accidental complexity of the language.
- otabdeveloper4 6y agoNo, not at all. C++ is much closer to something like OCaml than to C or Java. The "complexity" is not accidental, and it only seems complex because people are not used to languages with static typing systems. C++ is not complex if you mastered something like the Haskell type system. (C and Java aren't really statically typed; they rely on run-time typing for polymorphism.)
- oblio 6y agoC++ is not complex? The C++ complexity is not accidental? C++ is like Haskell or OCaml? Dude, C++ can still compile C code, right? And how are C++ templates anything like Haskell or OCaml? Aren't they just some fancy text-based code generator thing, at the end of the day? I'm really curious about this as everything I've seen so far contradicts your perspective. Or are you talking just about modern C++ (post C++ 11)? That doesn't work as C++ of all kinds is out there in the wild and you'll run into it, at least from external dependencies.
- otabdeveloper4 6y ago> C++ is not complex? The C++ complexity is not accidental? C++ is like Haskell or OCaml? C++ doesn't compete with Java or Go, C++ competes in the "polymorphism via static typing" niche along with Haskell, Ocaml, etc. If you look at what Haskell at al. need to do to get static polymorphism right then C++ doesn't look at all that complex or strange. > Dude, C++ can still compile C code, right? No, wrong. > And how are C++ templates anything like Haskell or OCaml? C++ templates are a purely functional Lisp-like DSL. > Aren't they just some fancy text-based code generator thing, at the end of the day? So is Haskell. > I'm really curious about this as everything I've seen so far contradicts your perspective. You just don't know C++. People think they do because they learned a bit of C back in college, but they don't. > Or are you talking just about modern C++ (post C++ 11)? C++11 was a decade ago; hardly "modern". > That doesn't work as C++ of all kinds is out there in the wild and you'll run into it, at least from external dependencies. There's lots of legacy crap out there in the wild, including legacy COBOL and legacy Haskell. I fail to see your point; "modern" C++ isn't some wild departure from the original idea of C++. Ever since STL it has been in a pretty specific and well-defined trajectory.
- Person5478 6y agoI don't necessarily disagree with you, but I think you're overselling it a bit. I've often found myself arguing that C++ has a simpler type system than the likes of C# and Java due to the latter's pragmatic bifurcation of their types. The C++ type system is certainly a lot more consistent. I know that MyType is passed by value, &MyType is passed by reference, and &&MyType can be reseated. Boom, you're done. It works the same whether it's an integer, a struct, a union, or a class. Whereas int and Int are not the same thing in Java, autoboxing is a thing, and updating the value in a function may or may not update what the caller see's. Same thing in C# only they were a bit smarter about it (they had hindsight). Instead generalizing it to value types vs reference types, but now you have a whole slew of rules to keep in mind, especially around nullability and default values. Just the other day I had to remind myself that in C# KeyValuePair is a value type and therefore cannot be null so the linq method 'FirstOrDefault' will return a tuple with all of it's elements default initialized. You don't have any of these types of questions in C++. I've argued for years that the type system in C++ is simpler. Most think I'm a kook, and I understand why, but having worked with C# from the .net 1.0 days and C++ from the mid 90's, I firmly believe it. OTOH, there __IS__ a lot of accidental complexity in C++. This generally comes from three places. 1. source compatibility with C. Sometimes this interacts in weird ways with C++, and sometimes it's just C. This is absolutely worth it. Until zig no one had interop with C as good as C++. 2. C++'s mantra of not paying for what you don't use (exceptions being the ... exception), and an extreme focus on performance. This can cause ergonomics or some of the downsides of approaches to be extreme. 3. simple lack of hindsight. auto_ptr and its interactions with containers such as vector are a perfect example of this. There are a lot of gotcha's and surpising behavior and things you just need to know (such as when you need a virtual destructor). C++ is absolutely a complex language. Do I think it's significantly more complex than rust? No I don't actually, but it can't be denied that C++ is complex (Rust is complex). People way oversell it, as if it's next to impossible to write good, stable code in C++ without being an absolute guru. Nothing could be further from the truth, and imo good C++ code __LOOKS GOOD__. There flat isn't a language out there that can shift from high level code to low level code and I would argue the abstraction abilities of C++ is also stronger than Java or C#. I absolutely love C++, but it's definitely complex. But that complex IS typically there for a reason.
- travv0 6y ago> (C and Java aren't really statically typed; they rely on run-time typing for polymorphism.) Um, what? Having type information available at runtime is orthogonal to whether or not a language is statically typed.
- otabdeveloper4 6y ago"Aren't really" means "cannot commit to 100 percent static typing all the way".
- ku-man 6y agoThe complexity of C++ isn't accidental, it is self-inflicted.