Welcome to Metalang99 Discussions! #14
Replies: 3 comments 10 replies
-
Not a question, but I just stumbled across this via a reddit thread involving Interface99. I have written some macro-heavy C and C++ code over the years (I invite you to have a look at https://github.com/emdash/goof). Long story short, I'm familiar with the macro patterns you are using here, and I would love to see some kind of community coalesce around this kind of thing, because I think it might provide a useful bridge between different high-level languages. Looking forward to learning more about Metalang99! |
Beta Was this translation helpful? Give feedback.
-
Yeah, in the short term, ML99 might have a role to play in the "C as an intermediate language" space. But I can also see (in the embedded systems use case) wanting to write ML99 directly, possibly with the help of additional ML-99-aware tooling. BTW, I have worked extensively with GObject and its related projects over the years. It's been a little while, but I was working with GStreamer and GTK pretty heavily at the time I wrote Goof. GObject is 100% about writing C libraries that can be used from any other language. It is basically a "managed runtime". If you write your library against GObject, you get bindings and run-time reflection for any supported language "for free". GObject is also "reactive" via "signals" and "properties". From the perspective of an application developer who exclusively works exclusively from Python or JavaScript, it all works great. And you really can use the same libraries from Lua, Python, JavaScript, Scheme, etc... Meanwhile, the C library author is living in the worst of both worlds between C and scripting languages: having on the one hand to deal with all the pitfalls and shortcomings of C as an implementation language, plus the boilerplate imposed by GType, and now all fun run-time chaos that dynamic typing with both early and late binding: : memory leaks, reference cycles, monkey patching of virtual methods, callback hell, etc. Maybe the situation has improved since I was actively working with it. I could also see Rust being a much better implementation language for GObject libraries, though I don't know if the official crate is taking full advantage. |
Beta Was this translation helpful? Give feedback.
-
If I am starting a green-field project on hardware I have control over, I would choose embedded Rust over C99, even though it's still early days. I already think it's a huge improvement over existing C/C++ tool-chains, especially the HAL layer which is all based on traits. I only need to write a driver for a SPI device once, and then it will work anywhere. And all the traits will be de-virtualized in the production build. If I am stuck with C, I'd at least see if I can bump it to C11 for the few nice features it offers. But C99 is alright. The main feature I would add to C, if I could wave a magic wand, is namespacing. Having to manually prefix identifiers to avoid name collisions might just be the biggest pain point in the language. When I was working on firmware, I was "manually monomorphising" Rust-style "Result" types, and this really did seem to improve the readability and maintainability of the state machine and main loop, but it was so tedious that I did start factoring code into macros that bear at least some resemblance to IF99. I ended up writing meta-programming macros that generate enums with a I understand what you're saying about M4, but the thing is, it's also additional tooling. With different environments, especially some of the commercial embedded ones, it won't play well with the debugger or the IDE's project files either. But then you must run M4 to generate valid C, whereas an external linter can run in an entirely different environment and still give me useful feedback about my code. The other thing I would say is, make sure you compile your code on different compilers. They all output different warnings and choke on different language features, even when operating in "strict" standard modes, though it's gotten a lot better in recent years. |
Beta Was this translation helpful? Give feedback.
-
Feel free to ask any questions here!
Beta Was this translation helpful? Give feedback.
All reactions