No I object to it on usability grounds. It took more than 30 years for the committee to admit it but C++ now has typesafe std::print/std::format finally, after admonishing programmers for using `printf` in C.
1,004 karma · joined November 6, 2012
No I object to it on usability grounds. It took more than 30 years for the committee to admit it but C++ now has typesafe std::print/std::format finally, after admonishing programmers for using `printf` in C.
But - I concluded that language matters a lot less compared to APIs. Yes, the language should have enough good features to let the programmers express themselves, but overall well designed APIs matter a lot more than language. For example -tossing most of the C stdlib and following a consistent coding style (similar to one described here -[1]), with using Arenas for memory allocation, I can be just as productive in C.
[0] - https://odin-lang.org [1] - https://nullprogram.com/blog/2023/10/08/
I've always wanted to use Lua to generate boilerplate C code (like typesafe vectors) instead of relying on macros, so might actually start thinking in this direction going forward.
[1] - https://hledger.org
I still drive a manual transmission car, but don't mind the one-pedal if I were to switch to an EV.
Now there are languages like Odin, Zig and C3 that are trying to fill that niche but having C evolve slowly to accommodate such users is also a great idea.
C99 added Designated Initializers which IMHO is probably the most innovative declarative syntax to initialize anything and it took C++ roughly 20 years to adopt such a thing (and then they had to nerf it).
Ok I understand now. I think even having such a tool i.e. to generate bindings from a C header file would be godsend.
> WebGPU is a mess regardless.
Interesting, it's not perfect but better than writing shaders in multiple languages and maintaining multiple render pipelines. Right?
I completely agree that this a giant PITA. But glad it's being considered to be part of toolchain. I would also suggest you reconsider the functionality of importing C headers directly. Yes, they won't be as nice as Odin bindings but they'll definitely give a nice stop gap. Just recently I had a project that uses WebGPU but couldn't generate Odin bindings automatically or find an existing one. So had to go with C++.
Another aspect is, many times I deal with proprietary APIs that have headers with all sorts of macros, bitfields and byte paddings. Having a direct C header import might also help with this case. Yes that API will still be ugly and less ergonomic but everything else would be nice. A bit like Futhark for Nim[0] or lcpp for LuaJIT[1] would really help to write more Odin.
Standard Library - I don't remember off the top of my head but I tried strconv procs a while ago to parse OBJ files and found that the floating point parsing to be slower than strtod. Maybe it's not the case anymore I'll give it a try again and open issues on Github for any feature requests.
Bitfields - In my line of work this is a must-have.
[0] - https://github.com/PMunch/futhark [1] - https://github.com/m-schmoock/lcpp
These simple rules coupled with great modern C++ syntax sugar like lambdas, tuples and 'auto' along with the basic data structures in it's standard library makes it a breeze.
But I've found out that using functional parts of modern C++ (bear with me) as a higher level language with C underpinnings also works very well. But you need tremendous discipline to do it successfully. For eg - using only C POD structs, no constructors, no exceptions, no inheritance, limited template usage etc. Some would say a very C style C++ with a lot of syntax sugar.
- A way to generate bindings automatically from C Headers or even better - not having to generate bindings separately and just import C headers directly.
- Better tooling and standard library improvements.
I think Odin & Nim are my two favorite "modern" languages but they fill different niches. I see Odin as mainly replacing C while Nim is more a C++ replacement (but with Python like rapid development). I'm always amazed at how productive Nim is but the language has many areas that I'm not familiar with (the AST Macros for example). But Odin mostly fits in my head.
Highly recommended for indie/small teams.
I have high expectations from Odin going forward, but there are some pain points hopefully will get resolved in the future. - The toolchain is alright at best (I know this is being worked on right now). - Discord only communication with the community. They're all very nice but sometimes I wish a lot of these discussions should be indexed by a search engine.
[0] - https://odin-lang.org