TR1 brought the language to a pretty good place with smart pointers, and at first C++11 looked awesome with its type inference features and range-based for loops.
But, also in C++11 were tons of weird gotchas with new and old features. The one that comes to mind is the uniform initialization. It was supposed to fix the issues with calling regular constructors, so you could just use the new syntax and not worry.
But, they also added initializer lists, and those have issues with uniform initialization, so now you not only need to know all the pre-existing issues with the old syntax, you need to know the new syntax and its issues.
This all comes back to C++ refusing to break backwards compatibility, which is great and all, but at this point they've made a language that is only good for job security.
Then again, two weeks ago I started learning Rust and I'm absolutely blown away. I'm completely absorbed by it. I'm now thinking of migrating some of the Python projects to Rust so that I can have a single executable which I can then copy around without having to care about virtual environments. I mean, I loved C and C++ for its precision, and love Python for it's liveliness (I use `reload` a lot so all the projects are living things which support hot reloading), but Rust seems to hit the sweet spot between C++ and Python. Between performance and little dependencies due to the lack of an interpreter, and a somewhat easy to use threading and async / await with Tokio, with all the safety guarantees Rust offers. I'm currently in heaven for this and I hope it lasts.
Use a Python package manager, and/or run your Python processes in containers.
That way you can upgrade your OS without having to upgrade all Python programs at the same time.
Are there some recommended keywords or things to avoid which I could use to orient myself? Like "use deadsnakes" or "avoid deadsnakes"?
There's some ways to keep multiple isolated Python environments around on the same OS (and Poetry can help with that, too). But I would suggest that you just stick every Python program in its own dedicated docker container, if you can get away with the overhead. (There are some ways to make rather slim containers.)
Of course, it doesn't have to be docker. Any other containerisation or VMs also work.
In general, I found it a good idea to keep the host operation system as small as possible, and stick everything into containers that you can upgrade separately.
what I really need are RAII, smart pointer, the STL library and algorithms basically, plus simple OOP use cases, those combined are not very complicated to me.
That's just about what anyone needs, I fear most people are simply too deep in their cargo cults these days to reason about a complex lang appropriately.
Best part of latest improvements is that most common mortals don't have to deal with SFINAE, enable_if or tag dispatching.
From my outside perspective it seems absolutely chaotic and simply unmaintainable.
C++ has not quite joined Perl, PHP, and Java as languages I will not work with anymore, but it's the next logical candidate.
Java by itself is an extremely simple language.
I really prefer environments where you could start with main() and figure out the behavior from there, and things like Spring make that impossible.
Really, if java only had lambdas and lisp-y macros from the beginning, we wouldn't have these problems.
This is one property of Go that I really like. Because of lack of constructors/destructors/magic functions and all that jazz, the only functions executed in a Go program are functions explicitly called through main().
And yes, lambdas and macros would probably have been a good replacement for that those two were originally meant to achieve.
But then I realized that such build steps re-introduce the same problems as runtime reflection does: You cannot understand the code statically.
So, yeah, maybe reflection and annotations are simply an overused hammer that makes everything look like nails... It feels like every library goes out of its way to use annotations for everything, completely defeating type-safety and static analysis. When it should actually be like, "is there really no way we can solve this without annotations and reflection".
But yeah, "fully automated build step" generally looks like "let's parse enough of the language so that we can implement our own custom reflection system" which leads to every project having an incompatible one and in practice much more pain (and macros) for the developers than if it was a standard one, e.g. Qt, Unreal Engine and so many others have their custom homegrown reflection scheme and there are a thousand libs on GitHub trying to reimplement it: https://github.com/topics/reflection?l=c%2B%2B
It's exactly like type systems being Turing complete : if yours isn't, someone somewhere will be making a language that compiles down to yours with one because of how useful of a property it can be in some cases
I've seen worse magic crap happening with Ruby and Python with their auto-magic method invocations.
I want to agree, but at least locally (as in geographically), these technologies seem to be heralded as fantastic. Maybe there's some kind of Spring Bubble around here, but on the main Maven site, Lombok shows up as the #16 most popular package (with primarily logging and language packages above it), and Spring isn't too far behind.
> Ruby and Python with their auto-magic method invocations
It's probably worth separating those two... as far as the functionality goes, Ruby and Python both have the capability of similar magic, but in my experience with popular frameworks, Ruby takes it to a whole other level while in Python it's generally discouraged.
I realize it's all anecdata here, but in my experience working with various companies and platforms, the Ruby magic generally just lives behind the scenes and Just Works. The Java magic would often turn into runtime exceptions, and the people who tried to do Ruby-like magic in Python would have similar difficulties. All of that revolved, primarily, around the ecosystems around the languages.
Now I use Go for most purposes, and C or CUDA when appropriate.
Good riddance.
It still has issues that are commonly associated with hosting provider configuration/control over the runtime, apparently.
(sources are anecdotal; two friends who've had the mental fortitude to stick with the language for so long)
For really tiny stuff Rust won't go there. If you program an 8051 clone, Rust isn't interested in your problem, ideas like "generic programming" and "pattern matching" don't make a whole lot of sense when only 128 bytes of RAM is accessible. But is C really the right tool for that environment either ?
Once you've got 64kB of RAM, that's definitely potential Rust territory.
"For me, the reason I was enthusiastic about Go was just about the same time we were starting on Go, I read (or tried to read) the C++0x proposed standard. And that was the convincer for me." - Ken Thompson
17:45 mark here: https://www.youtube.com/watch?v=sln-gJaURzk
The fact that their "2009" standard shipped only in 2011, after ripping out features everybody agreed were good yet never seemed finished, is why they moved to their current "train" model where there's a new C++ every three years, like it or not. The train will leave, if your feature wasn't ready well there's another train in three years.
Quite the opposite. In Go/Java I find myself frequently thinking how to adapt my problem so it can be expressed in a very limited set of language features. I want to build a house but I only get a hammer and some nails. Works nice if I want a wooden house but not so much if I want to use bricks and concrete. In Rust I get a giant toolbox with almost everything and I just pick the right tool for the job. So although I had to learn more tools initially, later I can focus more on the job, not the language, because the language adapts to the problem. And the final result is typically also better in terms of quality, performance, etc.
Would you care to elaborate what exactly is not as nice as you had expected? I'm really into Go and to me it really does seem as good as expected. Just curious about what made it suck for your usecase.
Go's designers get to use tuple for their favourite use case: returning from a function.
You as a user of the language don't get to use tuples for anything else.
(And using tuples to indicate failure is really, really silly. You'd want algebraic datatypes for that. Ie a beefed up enum, not an ad-hoc struct.)
Go's designers get to use generic functions and datastructures for their favourite use cases. Eg the infamous `make` is sort-of generic, and Go's arrays, maps and channels etc are generic.
I wouldn't call multiple return values a "tuple". I understand where you coming from, since Python multiple return values are implemented with tuples, but still that point sounds like saying that passing multiple parameters to C functions is "a tuple".
That being said, Go's "simplicity" in design is not only about interface simplicity - it's a lot about implementation simplicity. I imagine that adding tuples would cause a whole lot of complexity that they'd have to deal with. Since Go doesn't have a concept of immutable data types (except consts), tuples would effectively be just variable-typed constant-size slices, which are already implementable as arrays of empty interfaces, but have a runtime overhead...
I hope you see where I'm getting. Creating a language is complex and has a lot of tradeoffs. Then again, I see where you're coming from. I suppose it's a question of whether or not the tradeoffs (the "hypocritical design") is worth the good parts (simplicity of language, which leads to fast compile times, fast runtime, etc.). For me, personally, it is.
Thanks for the input.
You intended this as a reductio ad absurdum, but you are entirely right. That's how it's handled in eg Haskell.
> I imagine that adding tuples would cause a whole lot of complexity that they'd have to deal with. Since Go doesn't have a concept of immutable data types (except consts), tuples would effectively be just variable-typed constant-size slices, which are already implementable as arrays of empty interfaces, but have a runtime overhead...
I'm not sure that would be a good way to implement tuples. In fact, I suspect it's probably close to the worst way to implement them?
I'd image you'd want to take the machinery you have for structs, and adjust it so that it can deal with anonymous structs with anonymous fields identified by position. (But still preserve all the static typing, instead of throwing your hands up and going with 'variable-typed'.) The runtime overhead would be more or less exactly the same as for structs.
In general, I see tuples as a syntactic sugar over structs and expect them to be compiled like that (or better) in a statically typed language; instead of representing them as some kind of weird slice.
Theoretically, you could probably even implement tuples-via-structs as a preprocessor.
> I imagine that adding tuples would cause a whole lot of complexity that they'd have to deal with.
Yes, so instead of abstaining from tuples, because of these complications, they added a special case for their favourite use case.
Have a look at OCaml for a relatively simple language with less design hypocrisy, and fast compile times and fast runtimes. (Compared eg to the much more complex Haskell.)
I believe this is incorrect. Strings are immutable, for example. You could also say the same about pointers and maybe a few other data types.
Now that I've had more time to think about it, I think the problem of Python-like tuples in Go is that they require Pythonesque everything-is-a-reference paradigm in order to function the same way, otherwise they just act as heterogenous arrays in Go (which exist as arrays of empty interfaces, with a slight runtime cost). Go is mainly value-oriented language like C, with the exception of built-in container types and strings (and maybe a few others that slipped my mind).
I suppose that adding fixed-type pass-by-value tuples would essencially be reimplementing struct. Go doesn't like duplicating functionality.
Whether to pass by reference or value and other design decisions should probably be taken (as much as practicable) from the design decisions for structs in your language.
Could you elaborate? I'm considering switching to Go for the same exact reasons you listed.
C is pretty archaic in its feature set, so it's not surprising it doesn't have many language features that don't work well together since it doesn't really have any language features in the first place. That's not necessarily a good thing, either, but that's a different discussion.
> With C++ it feels like to me like that benefit is often lost entirely, and whats left is just incorrect code that for some reason passes by the compiler without error.
That's an odd statement to make here. Yes this is an unfortunate combination that results in memory leaks, but how is C's "everything is a memory leak" any better? 100% broken is better than 10% broken?
That said, I do wish C++ hadn't added coroutines in the first place. It feels like a weird addition to the language. Then again, I also wish Rust hadn't added them, either. They are nightmarishly complex in a non-GC'd language, and the benefits are far from clear. The "colored function" problem remains a hotly debated topic, and low-level, performance-focused languages (like C++ & Rust) feel like the very wrong place to hammer on those topics.
I'd rephrase "100% broken" as "always does what it says it will", and "10% broken" as "almost always does what it says it will." I'd prefer the former 99% of the time.
now there's a spicy take, i've been programming in C since 2005 and i don't think i've ever heard about this "everything is a memory leak" principle.
Because if you use features that may leak memory, you can still trust yourself as a programmer. If you cant even trust the language / compiler, I would consider that worse.
> Then again, I also wish Rust hadn't added them, either
I agree.
That's a bit hyperbolic, unless you apply the same phrase to any language (including C++) without a full tracing garbage collector or equivalent. X leaking a resource is not the same as X returning a resource that the caller is explicitly responsible for freeing. Further, C in practice is not as bad as you portray. Maintainers of large open-source projects, of which I used to be one, often define their own memory-management facilities and rules which are just as good as C++'s in preventing leaks for most code. I think they shouldn't need to nowadays, and that C would be a poor choice for a new project at any level, but that's easily shown without resorting to hyperbole.
Handling JavaScript exceptions as opposed to promise rejections in async code is a continual source of pain. They don’t work together. If you do try/catch on async code but forget to call await, catch will never be hit and your program might crash. There appears to be no linter available to detect this. Unless I’ve completely missed something, the interaction between these two features is a terrible design.
And even then it's not a bug per-se, at best a misfeature (it can be useful as a performance hack although the performance improvements of global and builtins lookups of 3.11 might finally put that to rest).
Because that goes against the most fundamental idea of programming languages that you can build larger abstractions by combining basic building blocks.
All other things aside, C++ seems to be the language "to big to fail" and so it just keeps getting more and more features added to keep it competitive.
It would be just about OK for the compiler to refuse to compile X and Y together.
If you "switched off" X, then in C++ (where code is in headers which are just concatenated with your code), this would effectively split the language, as you also couldn't use libraries which use X in their headers.
I am trying very hard to imagine any other higher level language where two distinct language features, each used correctly in their own way, can not be safely combined. The only thing that comes to mind are python's default parameters and passing an empty list as one.
C offers total freedom in exchange for providing ways to shooting yourself in the foot. All of its "dangerous" features can be used correctly for some benefit. With C++ it feels like to me like that benefit is often lost entirely, and whats left is just incorrect code that for some reason passes by the compiler without error.