4 ms·
It really is amazing that over 50 years later, we are only finally getting languages that are working on replacing C. Most went in the direction of being Big Id
by Decabytes 3y ago
It really is amazing that over 50 years later, we are only finally getting languages that are working on replacing C. Most went in the direction of being Big Idea languages that tried to supplant domains like C++ and Java. The language that is probably the closest is Zig, but I hear Odin is pretty good too (the website specifically mentions it as a C alternative)
The things I like about C aren't really about the language itself. There just aren't many programming languages that do these things well
1. Cross platform across Linux, MacOS (Intel and Arm), Windows (Without the use of MinGW And Cygwin), *BSD
2. Ability to create an executable
3. Small programs that start quick
4. Simple syntax that does not obfuscate when allocations are occurring
For GCed languages GO is probably the one that best fits this criteria for most people.
Sometimes I wish someone just took C and improved it. Instead of looking at C++ and thinking "what features should C have that C++ has" It should look back at C and go "What features does C not have, that it should"? Some that come to mind are
1. A better syntax for creating pointers and dereferencing them
2. Fixed const so that it works with array initialization
3. Modules instead of headers
4. Cross platform string types that encoded length
5. Hash tables
6. Remove preprocessor macros and replace common use cases with things built into the language
7. Build system that didn't rely on Make, Cmake, Ninja, Autotools, configure etc
8. Easy interop with C
Maybe this is a lot to ask, but most languages I see are solving waay more problems then this.
2,4,5, can be done without leaving C, which is why most people homebrew their own solutions. I think Pascal actually comes close, but it's held back by the fact that the editor support is pretty poor. Pacal-Mode in Emacs is not good, and Lazarus with its multiple floating windows is infuriating to have to alt+tab multiple times to switch to and from it. Plus I could never actually get it to build my programs properly without throwing some dwarf errors.
Recently I've been playing around with Gambit-C and it seems to suit most of my needs. It compiles to C, and then the C code is compiled with Clang, MSVC, or GCC depending on what your platform is. I get the benefit of a language that has more features than C with it being R7RS (but still being small because it's Scheme) and implementing the most common SRFIs (including hashes), but with all the portability of C. It also has dead simple interop with C using the C-Lambda and C-Define special forms (you can write C directly inside the Gambit code)^1 which means you can leverage C code with hardly any effort. There are tradeoffs with this approach, but IMO almost all of them are ecosystem related which can be fixed, as opposed to language related, which might be impossible to fix without breaking compatibility with existing code
1. https://www.deusinmachina.net/p/gambit-c-scheme-and-c-a-match-made https://www.deusinmachina.net/p/gambit-c-scheme-and-c-a-matc...
- deleted 3y ago[deleted]
- pjmlp 3y agoActually Modula-2 came in 1978, Ada in 1983, Mac OS shipped with Object Pascal in 1984. But UNIX being free beer gave another push to C, that those languages did not have.