Hacker News new | ask | show | jobs
by soulbadguy 932 days ago
> Onyx can be used in an entirely different environment without any of these things. In fact, the standard libraries are (almost) entirely separate from the compiler (i.e. the compiler makes no assumptions about what the standard library is), so if the standard library does not suite your use case for one reason or another, you can write your own. It will be a bit of work, but there would be nothing in your way.

Isn't that true for most native languages as well ? C++ have multiple stdlibs.Rust,C and c++ can be used against bare metals.

The orthogonality of the std lib and the compiler and language semantic (maybe at the exception of the types) seems pretty common these days.

2 comments

C/C++ compilers are tightly coupled to their runtimes, including their standard libraries. GCC is particularly bad about this.

On MacOS there is only one C standard library, and it is the interface to the operating system.

On Windows, your choice of standard library is tightly coupled to your tool chain.

On Linux, you can kind of mix and match, but it also impacts your loader.

Your comment seems a bit self contradictory to me. You mentioned a strong coupling between runtime and compilers, but then go on giving example of the same compilers runtime with different runtime.

I suspect that the terminology we are using might be the culprit. Thinking of it as compilers, distribution/package and target might be helpful. Both LLVM and GCC are quite flexible in how they can be packaged and distributed to target various platform. A compiler distribution typically would include a (default) runtime, default options, std libraries and supporting tools (linker,debugger etc... etc...) for each supported target in the case of X-compilation.

A distribution is definitely strongly coupled to a host os/configuration. But the compiler proper not really.

That is a good point. I don't do a lot of embedded bare metal work, so I kind of forgot that is possible. I guess it's something that is not unique to Onyx, but a good thing to know nonetheless.
As a related fun example that I use at work all the time, take a look at newlib sometime!

https://sourceware.org/newlib/

And related to that again is https://keithp.com/picolibc/