Earlier quoted context omitted.
It looks nothing like C++ decades ago, it is effectively a completely different language. I found C++ unusable before C++11, and even C++11 feels archaic these days. Idiomatic C++20 and later is almost a decent language.
"Modern C++ Design" was the first book that highlighted template metaprogramming and showed you ways to use it as a Turing complete programming language in itself. Even a decade+ after it was printed my friend said it was recommended reading for employees within Google so I gave him mine - but I'm not sure about these days. Talking about how much you can do with C++ templates made me think of that.
I stopped everything and started writing C again
461–470 of 475 posts
Re: I stopped everything and started writing C again
#462Earlier quoted context omitted.
Yes, but the C++ library becomes inherently broken because there is no error reporting.
I'm pretty sure Google, LLVM, Firefox etc use the stdlib without exceptions so it's probably possible. You can retrieve the error with errno right?
Re: I stopped everything and started writing C again
#463About a year ago, I had gotten fed up with what felt like overlyb strict context requirements basically giving me to abandon years of work and thought I'd try my hand at C++ again. I wanted to do this on Linux, because I my main laptop is a Linux machine after my children confiscated my Windows laptop to play Minecraft with the only decent GPU in the house. And I just couldn't get past the tooling. I could not get th…
I find make, cmake, and the other stuff annoying also. For personal stuff I just use a build.sh file. For debugging I use gf2, which is a gdb frontend. Hopefully raddebugger gets ported to linux soon. One nice tool I like on linux for prototyping is the tiny c compiler, because it compiles 7x faster than gcc or clang. It is also much faster than the visual studio compiler. I remember trying to get the tiny c compiler…
I just don't understand why people want to live like that in C++ land. It almost feels like masochism. Especially considering VC++ basically "just works" in comparison. Why do Linux users hate DevEx so much?
Re: I stopped everything and started writing C again
#464Earlier quoted context omitted.
I think Rust is harder to learn , but once you grok it, I don't think it's harder to use , or at least to use correctly. It's hard to write correct C because the standard tooling doesn't give you much help beyond `-Wall`. Rust's normal error messages are delightfully helpful. For example, I just wrote some bad code and got: --> src/main.rs:45:34 | 45 | actions.append(&mut func(opt.selected)); | ---- ^^^^^^^^^^^^ expe…
Agree, Rust is quite hard to learn, but now that I know it I have a hard time writing anything else. It really gives you the best of a lot of worlds. Granted I can still crank out a python program faster, that kinda works but god forbid you need to scale it or use any sort of concurrency at all.
Re: I stopped everything and started writing C again
#465Earlier quoted context omitted.
There's no amount of simplification that'll free you from the need to manually check and handle/propagate errors or deallocate resources in C. You might be able to reduce the amount of code you need to write, but it's still several lines of C versus one line of something else - and if you make a mistake or even forget something in those several lines, things will often compile and run fine, but you'll have memory lea…
I don't have these issues in C, you're projecting. Not that I write bug free software by any means; no one does, though some like to pretend.
Re: I stopped everything and started writing C again
#466Earlier quoted context omitted.
Package managers are for running other people's code, I would not expect the same of static analysis tools, especially since they are of use while auditing other people's code before building/running it.
Cargo's threat model here is identical to that of rust analyser. If you trust your dependency tree sufficiently to run `cargo build`, then you trust it sufficiently to run rust analyser.
https://doc.rust-lang.org/cargo/reference/build-scripts.html
Re: I stopped everything and started writing C again
#467Earlier quoted context omitted.
The point is that any formal borrow checking will reject perfectly valid patterns because they are impossible to statically prove, and this comes up especially often with data structures like graphs. So you end up struggling against the compiler - either you just go unsafe (in which case you have to be even more careful than in C and Zig because Rust makes more optimization assumptions based on ownership which you're…
You are describing the deficiencies of Rust implementation of a borrow checker and disregarding general benefits of it. Obviously there could be some way to mark self-referencing objects. C/Zig do not even allow to specify who is responsible for freeing the allocation, and every time you use a library you need to either search the docs or (more often) reverse-engineer the code. Probably this is why writing or checkin…
C and Zig have exactly the same facility to let you specify who's responsible for allocation - owning vs non-owning types for resources; it's just that you have to write them by hand, and for types that are owning, destructor calls must be done explicitly (but still, the pattern of "if I got an instance of OwnedFoo, I need to call destroy() on it" is much more straightforward then chasing the docs for each function).
Re: I stopped everything and started writing C again
#468Earlier quoted context omitted.
Only the parts that need to heap-allocate. Which includes most containers, but not e.g. algorithms.
It's everything that throws, which covers a lot more than STL, including .
Re: I stopped everything and started writing C again
#469Earlier quoted context omitted.
Heap was invented for a reason, and some tasks are naturally easier to model with it. The problem is that once it's there, people start using it as the proverbial hammer, and everything looks like a nail even if it isn't. Note though that ""allocate all of memory into a buffer at startup" is a lot more viable if you scope it not to the start of the app, but to the entrypoint of some code that needs to make a complica…
That works for something where the events being handled are like "serve a web page" or "compile a C function". It doesn't work for a spreadsheet or word processor or a web browser.
And that aside, there are still many apps that are more like "serve a web page". Most console apps are like that. Many daemons are, too.
Re: I stopped everything and started writing C again
#470Earlier quoted context omitted.
Agree, Rust is quite hard to learn, but now that I know it I have a hard time writing anything else. It really gives you the best of a lot of worlds. Granted I can still crank out a python program faster, that kinda works but god forbid you need to scale it or use any sort of concurrency at all.
Go?