3 ms·
When I did C++ I always ended up using a very small subset of it. No exceptions, no inheritance besides a few interfaces. But in general I agree with his point.
by Ididntdothis 7y ago
When I did C++ I always ended up using a very small subset of it. No exceptions, no inheritance besides a few interfaces. But in general I agree with his point. There are a few things C could improve though.
One would be a way to automatically clean up resources. Maybe something like “defer” in Go.
I wonder if templates would fit into C. STL is super useful.
A real string type would be good too.
- jdashg 7y agoThat new dialect of C exists, and it's called C++!
- deleted 7y ago[deleted]
- ExtremisAndy 7y agoYeah, I know what you mean by using a small subset of C++. To be perfectly honest (and I'm just a hobbyist who writes simple tools for myself... so I can get away with this a little easier than a professional could) but I got really frustrated when I was learning C++ and almost decided it wasn't worth it. Then I decided that I'd basically just treat C++ as C with strings, classes, and a few nifty, ready-made containers and useful algorithms. And doing this allowed me to enjoy the language quite a bit and do some very fun and useful things in it, all without becoming overwhelmed by its size/complexity. But again... this is as a hobbyist, nothing more.
- BubRoss 7y agoThere was a language called clay that was basically C with templates, operators, destructors and move semantics (with better syntax). It produced C ABI compatible compilation units and could pretty much slide into a C project. It used llvm but has been defunct for a long time. It is a shame because I think a lot could have been learned from people at least looking at it before coming up with their new llvm based native languages.
- anand-bala 7y agoAll the things you mentioned can be found in Zig! [1] It's exception semantics are very similar to Go, but unlike Go, you have to handle the error. It has constructs like `defer` and `errdefer` which allow you do clean up at the end of the scope or on exception respectively. It has support for Generics and Metaprogramming without having to resort to preprocessor macros. It just released v0.6.0 and is actively in development with an engaging and helpful community.[2] [1]: https://ziglang.org/ https://ziglang.org/ [2]: https://github.com/ziglang/zig/wiki/Community https://github.com/ziglang/zig/wiki/Community
- Ididntdothis 7y agoZig definitely looks interesting. I may use it in a smaller project to try out.