7 ms·
As someone who has been writing C++ at Google, this exactly. Despite all the tooling, guidelines and "internal magic", C++ is still an abomination. And no it ha
by ayberk 4y ago
As someone who has been writing C++ at Google, this exactly. Despite all the tooling, guidelines and "internal magic", C++ is still an abomination. And no it has nothing to do with memory management, I actually do like C.
I love how Eric Raymond describes it as "anti-compact", because, well, it really is. C++ as a whole should be deprecated -- and no new projects should use C++ (unless for some very odd and specific reason).
- DeathArrow 4y ago>C++ as a whole should be deprecated -- and no new projects should use C++ (unless for some very odd and specific reason). And what can be used instead of C++? C? If C was better, then C++ wouldn't have been invented. Rust? It's much more painful to use than C++. Zig? It's immature and has very low usage. Nim? Has very low user base. Julia? It isn't solving the same problems.
- rychco 4y agoMark Russinovich (of Sysinternals fame), thinks Rust should be the non-GC language of choice moving forward. https://twitter.com/markrussinovich/status/1571995117233504257 https://twitter.com/markrussinovich/status/15719951172335042...
- jeffreyrogers 4y agoIf people think C++ is hard to learn and attracts opinionated people boy are they in for a surprise when they start using Rust.
- zozbot234 4y agoRust is way easier to learn than C++.
- primeblue 4y ago
- pjmlp 4y agoUntil one needs to deal with async/await, write GUI code, the upcoming GAT, or macros.
- zozbot234 4y agoExcept that the C++ substitutes for those features (where applicable; C++ has nothing like GAT, and has to make do with complex template meta-programming) are a lot harder too.
- pjmlp 4y agoC++ has had GAT like capabilities on templates since forever. Complex template meta-programming only if one is stuck in pre-C++17 compilers.
- josephg 4y agoLearning rust is like cycling over 2 big hills. It’s exhausting and painful if you’re in any way out of shape. Learning C++ is like cycling from SF to LA. It starts easy enough and every day you’re making a lot of satisfying progress. But you have so far to go because of all the features and quirks of the language. It’s probably easier to get started learning C++. But it’s also much faster to finish learning rust and be able to read almost all rust code. (Pin still scares me though)
- shaklee3 4y agorust doesn't have many of the features of c++, so it seems easier until you realize it's not.
- Cyph0n 4y agoI like the analogy! I’m still not comfortable with Pin, UnsafeCell, raw FFI (lifetime and ownership handling across the boundary is tricky), and complex macros. But I also think that you don’t need to understand these at all to be an effective Rust dev.
- tele_ski 4y agoI like you're analogy, but I do think there are features of c++ that are big hills as well. To me it would be SF to LA with some big ups and downs on that long ride. I'm also curious what's difficult about pin in rust? It basically just disables moving of the object for the lifetime of the pin.
- josephg 4y ago> I'm also curious what's difficult about pin in rust? I understand the concept. It’s the syntax which trips me up. You don’t mark structs as Pin. You mark them as !Unpin. And then, when is it safe to pin_project fields? Every time I read the documentation I understand it for about an hour. 2 weeks later I need to re-read the docs again to convince myself I’m not subtly messing anything up. I’ve also gotten myself in hot water writing custom Futures, trying to wade through the barrage of compiler errors at the intersection of lifetimes, Pin and async. It’s a lot harder than it needs to be. The compiler holes around GAT, async closures and async trait methods doesn’t help.
- pjmlp 4y agoMicrosoft has apparently ported DWrite to Rust (the C++/WinRT team is now having all the fun in Rust/WinRT, while ignoring the lack of tooling in C++/WinRT after they killed C++/CX), Azure IoT unit is adopting Rust on Azure Sphere alongside C while not supporting C++, and at Ignite Mark Russinovich did mention they are planning to port some sysinternals tools into Rust as kind of POC.
- deleted 4y ago[deleted]
- germandiago 4y agoI do not think so, though.
- FpUser 4y agoI do respect Mark and his Sysinternals products. However I could not care less what he thinks is the language I should be using. I choose what works for me and as long as it brings me healthy dosh I am not in need of one's "approval.
- littlestymaar 4y ago> Rust? It's much more painful to use than C++. Unless you're doing something really highly specific to C++ (like Cuda for instance or deep integration with big C++ codebase), saying that rust is painful compared to C++ is laughable.
- intelVISA 4y agoGonna have to unwrap() this take
- yoyohello13 4y agoI'll just ignore this take and let it become a problem later.
- queuebert 4y ago.expect("fireworks")
- adgjlsfhk1 4y agoJulia is solving many of the same problems as C++. GPU compute, HPC, high performance algebra kernels are all well within Julia's purview. It's not (at least yet) good for things like writing OS kernels but there is a large amount of overlap with C++.
- programmer_dude 4y agoIsn't Julia a dynamically typed language?
- eigenspace 4y agoYes. So what?
- programmer_dude 4y agoThen it is not a replacement for C++. It's going to be slow.
- adgjlsfhk1 4y agoit's not. it uses type inference to infer types and llvm to compile down to native code. differentialequations.jl is often faster than the fastest C and Fortran solvers, and Octavian.jl often beats MKL at matrix multiplication.
- programmer_dude 4y agoType inference changes things. It's awesome that it can beat handwritten C and Fortran code.
- eigenspace 4y agoStatic types are not required for things like type inference and optimizing compilers. It's just that many dynamic languages are not written with performance in mind, and have semantics that make optimization impossible. Julia was designed from the ground up to have C level performance, and well written Julia code does that easily in throughput focused scenarios. Julia's intermediate representation which it compiles dynamic code down to is statically typed, and any dynamism just manifests itself as the compiler waiting until the types are resolved at runtime before running again and generating new specialized code. If your code is written so that the types are all inferrable, there's no pauses.
- smackeyacky 4y agoI don't think that's true. I started C++ using the 'cfront' system, the major push wasn't because C was somehow lacking, it was because it was fashionable to do object orient programming which is hard in C. Various horrible patterns were invented using function pointers so C programmers could feel like they were doing object oriented programming and all of them sucked. When cfront turned up, the first versions basically automated that suckage. C++ did get better, but it was still horrible compared to CLOS or Smalltalk. This was largely due to weirdness in how the constructor/destructor ordering worked, the giant bogosity that is multiple inheritance and a few massive other undefined behaviours that every compiler did differently, but I think at this point it's fair to point out the language is bad and things like C# are so much better it's not even funny any more.
- DeathArrow 4y agoYes, OOP kind of sucks. But you can use C++ without OOP if you so wish. C# is much better but still it isn't a systems programming language due to garbage collection. So while you can solve some classes of problems easier and better, it can't replace all of C++ use cases.
- pjmlp 4y agoThat depends on the point of view. Writing compilers, linkers, running bare metal on embedded hardware are all systems programming tasks.
- jjav 4y ago> And what can be used instead of C++? For most use cases Java is a better option. Very fast, without any of the pain. If you truly must not have a VM (rare), there's still C. Perhaps rust.
- greyhair 4y agoI think this is probably the most salient point. C/Rust then Java. I don't know why people hate on Java so much. And I think C lives fine along side Rust.
- timbit42 4y agoJava forces OOP and it's verbosity is worse than COBOL.
- jjav 4y ago> Java forces OOP and it's verbosity is worse than COBOL. Java doesn't force OOP in any meaningful way. I mean it does, in that you need to wrap all code in a class, but that's a non-issue (one line of code at the top and a closing bracket). You can write Java code where all functions are static and do nothing is object-oriented, when that's the best match for your needs. On verbosity, you can latch on to the ConstructorAccessorMapFieldGetterFactorySingleton nonsense if you want but that's on you. Nothing in the Java language forces that on anyone. Having been writing Java code since 1996 I've never written such code.
- astrange 4y agoJava is based on Objective-C without any of the nice flexibility, doesn't have value types, has C-like numeric types except they're less flexible yet not any safer, and its culture thinks you organize code by putting it into 6+ layers of namespaces inside other namespaces. My rule is that languages are good if they have value types, which explains why PHP is good.
- Gibbon1 4y agoC# also has value types and structs. Also a bonus over the top fanboyism is absent.
- dtx1 4y ago> Rust? It's much more painful to use than C++ Write a sufficiently complex memory safe program in C++. I dare you. It's been proven again and again that humans can't do it. And calling Rust more painful than C++ is just absurd.
- kazinator 4y ago> Write a sufficiently complex memory safe program in C++. That is totally easy. What's not so easy, necessarily, is complex numerically safe program in C++ (that performs well).
- pencilguin 4y agoI write them routinely. Many, many people write them routinely. It is easy, in modern C++. You appear to have fallen for the Rust hype machine. We do know many people at Google can't.
- xedrac 4y ago> Rust? It's much more painful to use than C++. As someone who has used C++ professionally for two decades, I disagree. Rust's pain is superficial and all up front. C++ pain is death by a thousand paper cuts, especially if you have people on your team that aren't intimately familiar with its pitfalls and its more modern constructs. I don't plan to write a new C++ project ever again, unless there's some very compelling reason to do so. Rust is an absolute breath of fresh air.
- jeffreyrogers 4y ago> C++ as a whole should be deprecated -- and no new projects should use C++ (unless for some very odd and specific reason). It's quite a bit easier than Rust and no other popular language has its most important features (cross platform, interfaces with syscalls and other libraries easily, manual memory management possible, likely to be supported for a long time).
- dthul 4y agoHaving used both C++ and Rust extensively, I would say that it is easier to get something to compile in C++ than in Rust, but I find Rust overall much easier. C++ is really very complex, and even after more than a decade of using it there are so many things I don't know. With Rust I feel like I have a pretty solid grasp of most of the language.
- cmollis 4y agoI agree.. I've been writing in Rust for about 2 months and I find it to be a much easier surface than C++.. getting over the borrow checker isn't as bad as some make it out to be.. in fact, if it compiles it largely works.. you might be cloning one too many strings as a newbie, but you get the hang of it quickly.. when I wrote a lot of C++, I used a really small feature set.. but that was like 20 years ago.. now (apparently) it's a lot better.. with Rust, you need to think about memory, stack, and heap, but it's not ridiculous. The type system is really great. Granted, I'm not writing a database, but so far, I see a lot of really good libraries that integrate really easily, and it's just fun to use. The functional features and futures feel a lot like scala... and it's fast.
- cmollis 4y agooh and the last time I wrote in C++, I was using gmake.. all those compiler and linker switches.. header and linker search paths.. ugh.. I felt like I was launching a rocket to the moon just getting some of that to build. don't miss that.. chasing down memory corruption in threads with gdb.. also painful. I get that C++ is much better now, but I haven't really used it in a long time so can't comment.
- germandiago 4y ago> C++ as a whole should be deprecated -- and no new projects should use C++ (unless for some very odd and specific reason) Too bold statement. There are still lots of reasons to keep using C++. LOTS.
- gort19 4y agoI can see why for legacy projects, but for new projects, what are they?
- timbit42 4y agoThere are lots of reasons to keep using C++ on existing projects in C++ but there are not many reasons to choose C++ for a new project.
- pencilguin 4y agoThis is exactly equivalent to saying that all existing C++ coders should be demoted or fired. It is, among worse things, damned rude.
- Teever 4y agoThe only thing worse would be if you were a C++ programmer in the coal industry...
- germandiago 4y agohow does that look?
- patrick451 4y agoThat's only true if you're writing code with zero dependencies, which is rarely the case.
- germandiago 4y agoNot only that: toolchains, IDEs, static analyzers, mature frameworks for Protobuf, Capnproto, C compatibility, Python wrapping of APIs including little friction: deriving classes and exception conversion in pybind11 for example... There are lots. It is just that some ppl think real world is just like when they sit down to code a zero-dep, no time-pressure thing.
- pencilguin 4y agoThis is exactly equivalent to saying all existing C++ programmers should be demoted to doing only maintenance work, or fired. As such, it is in violation of site terms and conditions, and damned rude.
- ajvs 4y agoIf you take criticism of any activity you partake in as being "damned rude" and a violation of site T&C, then there'd never be any discussion at all. You are not your job, and prepare yourself for listening to honest criticism of the things you base your identity around or you will find it very difficult to learn and grow.
- pencilguin 4y agoIt was not the criticism that was damned rude. Criticize anything you like, or don't. What was rude and, frankly, hateful, was the call to demote or lay off all C++ programmers.
- ayberk 4y agoApologies if it came as rude or hateful, that wasn't my intention. Funny thing is I'm a C++ programmer myself right now as I mentioned :) Even if we decide to "deprecate" C++ today, Google alone would have large enough C++ codebase left to maintain for the next two generation of programmers. So no, I don't think it means we should demote or fire all C++ programmers -- but at the same time I'd like to note that as a programmer no one should be married to a single language -- languages come and go.