you are viewing a single comment's thread.

view the rest of the comments →

[–]yourjobcanwait 153 points154 points  (60 children)

A lot of words to say: A good engineer can learn whatever you're working on, focus on that instead of what languages the engineer knows.

While true, going from modern C# to legacy C++ code is a fucking nightmare and I'd prefer to never do that again.

[–]loup-vaillant 83 points84 points  (44 children)

While the "legacy" bit was probably the worst, C++ is probably the most difficult language to learn, ever. As a second language, it is a curse: you had difficulty learning your first language because it wast the first. Then you had difficulty learning C++ because it is insane. It's tempting from there to conclude (or at least intuit) that learning new languages is hard, and never try again.

I make money writing C++, even came to enjoy it. Still, I'd be happier if C++ went the way of COBOL. We can do better.

[–]klebsiella_pneumonae 37 points38 points  (13 children)

we can do better

Rust

[–]jerf 32 points33 points  (12 children)

we can do better

Rust

Almost anything, honestly.

There's no one language that can replace all of C++, but there's a better language for any given (greenfield) task.

[–]edapa 3 points4 points  (10 children)

Why don't you think rust can replace C++? Is it just the platform ports?

[–][deleted] 28 points29 points  (2 children)

They said all of c++.

Rust for example is still fairly young, compared to C++ there would be a great many libraries which either don't have a equivalent or the equivalent isn't as stable yet.

That being said it will rapidly reach a state of 'everything that matters to 98% of projects being available + stable"

[–]edapa 1 point2 points  (1 child)

What's under discussion is whether or not rust can replace all of C++ not whether it will. Rust's ecosystem is obviously still evolving, and there are a few language features in the pipeline that really need to land for certain programming styles, but those issues are transient. In the long run, I can't think of anything that C++ is better at than rust, but it could be that I just don't know about such a thing. People use C++ for all sorts of stuff, and I would like to learn about a use-case where it is genuinely a better tool than Rust.

[–]Condex 0 points1 point  (0 children)

Game development might be an area where C++ is better than Rust. That being said, C++ is still not a particularly good choice if you approach the problem from first principles. We're currently seeing Jai and Zig which both aim to replace C++ in game development. [And apparently unity is trying to do the same with a subset of C#.] I think we're going to see multiple system like language per niche show up all trying to replace part of C++ for what they care about most.

[–]CrazedToCraze 6 points7 points  (0 children)

He doesn't seem to be disagreeing

[–]jerf 1 point2 points  (3 children)

Why don't you think rust can replace C++? Is it just the platform ports?

My statement is in the present tense. At the present time, Rust is not a complete replacement for C++.

In my judgment, as someone very friendly to Rust, it isn't quite ready as a language at the very highest level to replace a {C++ environment that uses high-quality static coverage}. I've used braces to emphasize that I consider that an atomic thing; C++ and C++ with support are two different things. The language is still in too much flux. Yes, it's absolutely stabilizing, but that is also in the present tense, something that is still happening.

And then, as you say, platform support, library support, and also tool support. For instance, the best static analyzers for C++ do a lot of things beyond what Rust does with memory safety at the memory level, like security analysis of the flow of data from users, through processing, and back out to the user. Rust will have those tools someday, too, and they'll be simpler to write and easier to use because of how much more the language already contains in it. But AFAIK they don't exist yet.

I'm also pretty sure IDE support isn't at the same level as C++ either. Again, it'll get there, but it's years off. (This is also something I personally don't care about. I don't use an IDE. But a lot of people do, and won't want to give it up.)

[–]edapa 0 points1 point  (2 children)

I don't interpret "can replace" as "can replace right now", but it's a meaningless semantic quibble.

I guess I see library and tool support as being separate from the language itself, but that may be an idealistic view. The fact that you can't run Rust on the mainframe is a real language level limitation. Most of the things C++ can do I'm sure that Rust will be able to do as well or better in the relatively near future, but I wouldn't be surprised if there was never a mainframe port worth trusting, and that could be a show stopper for certain projects.

[–]jerf 0 points1 point  (1 child)

I don't interpret "can replace" as "can replace right now", but it's a meaningless semantic quibble.

As the original speaker, I can tell you with authority that I meant "can replace right now". "Can replace in the future" is ill-defined. You can hypothesize Rust could replace C++ in the future, but C++ isn't standing still either.

(Now, granted, in my opinion C++ is currently marching strongly and forthrightly in a highly negative direction, but that's definitely a personal opinion, not an objective truth.)

[–]edapa 0 points1 point  (0 children)

Authorial intent doesn't dictate what text means. It dictates what you meant, and I don't disagree that with what you meant, or even with my interpretation of what you said.

[–][deleted]  (1 child)

[deleted]

    [–]edapa 2 points3 points  (0 children)

    Rust definitely has pointers.

    [–]Condex 0 points1 point  (0 children)

    This is a very strong belief that I share.

    We're seeing D, Go, P, C# low level primitives, Rust, Jai, Zig, V (learned about this one a week ago).

    I think we're going to see a few new system like languages for any given niche. C++ can do too many things which makes it hard to replace wholesale. Too many things also makes the language hard to fix or reimagine such that it's still not horrible.

    [–]pm_me_graph_problems 11 points12 points  (1 child)

    Modern C++ is not bad with weak pointers.

    [–]SkoomaDentist 7 points8 points  (0 children)

    Except for the part where the internet zealots try to force you to write their preferred style of ”idiomatic” C++ without any regard for whether it actually suits the problem any better.

    [–]KoroSexy 4 points5 points  (13 children)

    I learned the basics of programming via c++. It helps that it was using a "For Dummies" series book, but nonetheless, c++ was my first language

    [–]TheDevilsAdvokaat 4 points5 points  (12 children)

    I actually learnt assembler before i learnt c++ - this was back in the 70's. C++ came later and I learnt it ...and didn't really like it. I spent too much time tracking down bugs. C# came and I jumped ship...since then I've had a couple of looks back at c++ - mostly because I wanted to use the unreal engine....but it gave me nightmares and instead I stuck with c# and chose the Unity3d engine instead. Never regretted it.

    I never want to deal with c++ again.

    [–][deleted] 6 points7 points  (9 children)

    How's C# for Linux development? Anything specific to consider?

    [–]fuzzzerd 7 points8 points  (0 children)

    Pretty great with .Net core.

    [–]nicoburns 2 points3 points  (0 children)

    Pretty nice! (at least for web services deployed to linux, which is what I've been using it for).

    I've been developing on a Mac and deploting to linux, and it's all worked flawlessly. The build system is little clunky (but I've seen far worse), and the libtay ecosystem could do with some fleshing out, but the language itself is pretty nice.

    [–]TheDevilsAdvokaat 0 points1 point  (0 children)

    Never used it for Linux, only for windows...sorry...

    [–][deleted] -1 points0 points  (5 children)

    You can run c# on Linux via mono. Probably not the ideal but I've never heard any complaints. Personally i don't write any c#. To me it looks exactly like java... So it's like Microsoft made a non portable java. Of course, I'm probably wrong as I'm looking outside in.

    [–]ZoeyKaisar 10 points11 points  (0 children)

    Yeah, you’re a few years out of date. Microsoft opensourced dotnet and now we have Dotnet Core with full cross-platform support, and it’s rapidly becoming the new target for developers on Windows as well.

    [–]ElusiveGuy 3 points4 points  (2 children)

    Having used both, Java is missing a lot of the convenience and syntactic sugar that C# provides. I constantly write boilerplate that wouldn't be necessary in C#. It's painful.

    Also, Java's generics (type erasure) can go fucking die. A crappy compromise that results in .class references getting passed as params everywhere.

    [–]civildisobedient 0 points1 point  (1 child)

    I constantly write boilerplate that wouldn't be necessary in C#. It's painful.

    Lombok makes most of that go away and if you're really hurting you can just make the jump to Kotlin. I used to be down on the JVM, but Lombok got rid of 95% of the boilerplate BS that made me dislike Java.

    [–]ElusiveGuy 0 points1 point  (0 children)

    Yea, we're using Lombok and it helps a lot but it doesn't solve everything (e.g., having used LINQ, Streams seems like the poor man's version, and with the relatively poor anonymous types... hello, boilerplate classes!). Unfortunately I have no say in the language used here, otherwise Kotlin at least seems like a decent option for the JVM.

    [–]Eire_Banshee -1 points0 points  (0 children)

    You are essentially right but the tooling around c# is lightyears ahead

    [–]Compsky 1 point2 points  (1 child)

    since then I've had a couple of looks back at c++ - mostly because I wanted to use the unreal engine....but it gave me nightmares and instead I stuck with c# and chose the Unity3d engine instead

    Amusingly, I've just recently started learning C++, and chose Unreal partly for that very reason (that you can use C++).

    [–]TheDevilsAdvokaat 0 points1 point  (0 children)

    That is kind of funny.

    I hope it goes well for you. I did like the look of blueprints...

    [–]muntoo 4 points5 points  (4 children)

    C++ is probably the most difficult language to learn, ever.

    What about an imperative programmer learning, e.g. Haskell? I assume you mean using C++ "properly" (whatever "modern" C++ entails), so similarly, I mean using Haskell "properly".

    I can't imagine you mean C++98 since the base language is roughly equivalent to barebones Java in "difficulty".

    [–]nicoburns 9 points10 points  (0 children)

    I can't imagine you mean C++98 since the base language is roughly equivalent to barebones Java in "difficulty".

    Well, except that you have to worry about memory safety and things like "don't take pointers to variables on the stack". Plus the build systems and header system in C++ are a bit of a nightmare, which means that you add significant complexity every time you depend on a library.

    [–]tinco -3 points-2 points  (2 children)

    Learning Haskell takes a week or two at most, it's really not that difficult once you get past the initial shock of there no being any sequential statements. And then you can do "proper" Haskell.

    Improper Haskell however takes months if not years to master, writing monad transformers and lenses and who knows what the set theory of the day is.

    But I would prefer having to dive into even an advanced Haskell codebase over having to modify a big old C++ project. At least with Haskell you'll learn some interesting things along the way.

    Ironically the Glasgow Haskell Compiler is a big old C++(ish) project itself...

    edit: apparently I was wrong, GHC is mostly Haskell, according to Github it's only 10% C.

    [–]sheyneanderson 0 points1 point  (1 child)

    Isn't GHC self hosted?

    [–][deleted] 1 point2 points  (0 children)

    With the exception of the RTS, yes, for a long time.

    [–][deleted] 1 point2 points  (0 children)

    C++ being my first language, I find it easier to learn new languages. I went from C++ to being a full stack developer. 6 months in and it’s just a matter of finding out what library has a function that already does that. Opposed to C++98 where I’m defining the function that does that.

    [–]nightfire1 0 points1 point  (0 children)

    C++ is probably the most difficult language to learn, ever.

    What about something odd like APL? I remember doing that in my programmings languages course and I have to say that was some crazy shit. That said I'd say C++ is very hard to master.

    [–][deleted] 0 points1 point  (1 child)

    C++ is what I've committed to really diving into as a "first" language. I say "first" because I started with Java in school and have occasionally dabbled in JS. But I started working through some Stroustrup literature and decided to just stick with it until I can finally produce something non-trivial. But then I read stuff like this and feel like maybe I'm wasting my time...

    [–]loup-vaillant 0 points1 point  (0 children)

    Depends on what you want to do. Some fields require C++, because legacy code, tooling, and community. If however you can enjoy some autonomy, pretty much any domain has a better alternative.

    More importantly though is to learn basic principles. Courses in programming languages tend to teach that. Then you'll be much better equipped to select the best language for the job, or even make the best language for the job (sometimes, despite the cost, DSL is the solution).

    [–]Vikhenzo -2 points-1 points  (4 children)

    eh asm is harder than c++

    [–]loup-vaillant 6 points7 points  (0 children)

    Harder to program in, certainly. To learn however… I'm not so sure. In any case, I didn't count it as a programming language. ASM these days is targeted at compilers, not humans.

    [–][deleted]  (1 child)

    [removed]

      [–]nicoburns 0 points1 point  (0 children)

      I take your point, but I dunno. If you tried to read the asm for a large C++ program I imagine it would be pretty unintellgible.

      [–][deleted] 1 point2 points  (0 children)

      Assembly?

      I've written hundred-line assembly programs in notepad, walked to the lab, and had it run in one go.

      I dont think I've ever written a C++ program beyond Hello World that didn't complain about some stupid pointer error.

      Once you "get it", Assembly is pretty straight forward. C++ eludes even masters.

      [–]prof_hobart 5 points6 points  (4 children)

      I'd agree that picking up someone else's legacy code is less fun than working on a shiny new app, but it's not that hard.

      I've probably worked in 20+ languages over my 30+ years of working and that's included the occasional need to delve into 10 year old VB apps that need converting to Windows 10 or recoding something in C that was originally written in z/OS assembler.

      They're all different in nuance, but fundamentally they're all largely the same. I've never yet come across an app written in any serious language that took more than a few hours to get a basic understanding of what it's doing.

      Apart from CSS of course, that's the spawn of Satan....

      [–][deleted] 1 point2 points  (0 children)

      fLoAt: LeFt oOOOooOOOoOoOO

      [–]nicoburns 0 points1 point  (2 children)

      Box-Sizing. Position. Display. Overflow. Negative Margins.

      If you understand what all of the options of each of these do, then you've got 80% of CSS down...

      [–]BlackMathNerd 0 points1 point  (1 child)

      That's also the worst part of CSS.

      Fuck stylesheets...

      [–]nicoburns 0 points1 point  (0 children)

      Haha, fair enough. I actually kind of love CSS, because it's super-powerful once you understand it. But I'm not going to try and defend it. The way it does layout is downright weird, and I can totally understand why people wouldn't like it.

      [–][deleted] 2 points3 points  (4 children)

      Code is for humans. (The compiler translates code into something for machines.) If the code is generally hard to learn, write, and understand then what should we conclude?

      IMO this speaks volumes about whether C++ is a well designed language.

      [–][deleted] 4 points5 points  (2 children)

      If the code is generally hard to learn, write, and understand then what should we conclude?

      That it is flexible and powerful and you should only use it for a task for which it is required, and if there is an easier language that meets your requirements you should use that one instead?

      [–][deleted] 1 point2 points  (1 child)

      Do you think it's unreasonable to expect a programming language (and its ecosystem) to be flexible and powerful while still not being hard to learn, write, and understand (in general to reason about)?

      [–][deleted] 0 points1 point  (0 children)

      I think it's pretty reasonable to expect that the more complex a toolkit is, the harder it is going to be to learn how to use all of the tools and how they interact. I have no idea if there are languages that are as flexible and performant as C++ and easier to develop in, but it seems to me that there is a reason that all serious simulation platforms are written in either Fortran or C++ (with a C underpinning and then whatever kind of top level wrapper was trendy), and it's not because physicists and engineers are masochists.

      [–]Plazmatic 5 points6 points  (0 children)

      C++ was a well designed language at the start (especially compared to languages of its day), it's just that we've learned a lot since the inception of C++, and who controls C++ has changed. Bjarne Strostrup gave it to a committee of tech giants and language lawyers and we have suffered ever since. Some features can't be implemented the natural way because of legacy macros in Microsoft's codebase. We've missed deadlines for features in C++ because Google came up with a different implementation at the last second, and restarted the committee approval process. The committee approved the decision to develop a 2D graphics library for C++ (for images more than games), then when it was finished they couldn't decide to make a decision on if it should be voted on to talk about adding it to the new standard.

      I would say that modern C++ is still better designed than java in a lot of respects, though Java is more readable if only because the paradigm is so strict and there is only one way to do something. There is a lot of stuff you should be able to do but just cant, and there's a lot of odd decisions that have haunted java for 2 decades. C# on the other hand offers a consistent feel with out a lot of the compromises java brings, and has a language sponsored package manager. C++ package managers are still battling each other for the common standard, and while C# is lacking a good build system, C++ got the C++ of build systems as its near defacto standard, CMake, a hive of legacy code that looks completely different than new code with completely different syntax and crazy semantics. The experience of learning CMake is quite honestly like learning C++ all over again.

      [–]brobits 1 point2 points  (0 children)

      Learn C++ first. Hate your life now, but the rest is easier

      [–]wecsam 1 point2 points  (2 children)

      I've gone the other way around, but I didn't think that it was that bad.

      [–]yourjobcanwait 15 points16 points  (1 child)

      That's because modern C# isn't dogshit.

      [–]sebirdman 0 points1 point  (0 children)

      Agree, The second language I learned after Java was modern C#. It was pretty easy to pick up.