3 ms·
I love to see slim alternatives to bigger, older tools (acknowledging that both versions have their place in the world). However, I have to ask: why C? Apparen
by nerdponx 4y ago
I love to see slim alternatives to bigger, older tools (acknowledging that both versions have their place in the world).
However, I have to ask: why C? Apparently the author is very comfortable using it, and I'm sure using C has enabled them to make a very efficient implementation with a small binary size.
But this program is just slinging around strings, right? Is manual memory management actually important, or even desirable?
- stabbles 4y agoBecause of bootstrapping
- albertzeyer 4y agoRust would have been a better option. But probably it's just because the author is more familiar with C. Maybe also because the author wants it to be more cross platform.
- aldonius 4y agoI'm a big Rust fan in the sense that it's the language I go to nowadays to write anything serious. But it's quite a lot in terms of bootstrapping. Whereas this? Just the very basics, fully portable, pretty much any C compiler has you covered.
- phoebos 4y agoEveryone and their dog can compile C, and the initial purpose of this project was to get something working on Windows. As you say, this is a relatively uncomplicated program, and there's certainly no need for higher-level features. Is the only time you choose C when you need manual memory management? I suspect that had nothing to do with their decision.
- pmarin 4y agoHe implemented this alternative explicitly to be included on his own C Windows development environment, w64devkit.
- hobo_mark 4y agoWhy anything else? It is a very small tool that is needed to bootstrap a build, C is the lowest common denominator. Similarly, few things infuriate me more than the installation of some random Python package having to pull an entire Rust toolchain with it.
- mariusor 4y agoChris mentions explicitly that he used a byte buffer plus length pair backed by an arena allocator for the strings in the application.
- jcarrano 4y agoANSI-C (and to a lesser extent C99) is pretty much the only language which you can compile anywhere, forever. For this project portability is the #1 requirement. If he used, say Rust, then the target system needs a rust compiler, and furthermore, the language is not even close to being as standardized a C is at the moment, i.e. who knows if in the future you will still be able to compile your program that you write on 2023's dialect?
- arp242 4y agoLua is pretty small, portable, and easy to build; you can ship the lua source code with a "lua-pkg-config" so you don't need to install anything else. Lua is not my favourite language, but for something like this it might be a nice fit. I think C is also fine though.
- phoebos 4y agoYes, the official Lua implementation is written in a very widely supported subset of C, so is probably one of the most portable languages along with C. Lua might well be a bit more concise for a task like this string processing, but in such as case it's just syntactic sugar really. The C is uncomplicated and efficient.