Hacker News new | ask | show | jobs
by annywhey 2828 days ago
This looks like it takes influences variously from Haxe, Rust, and Haskell, which are all great in my book. But the first thing that crossed my mind was, "could it compile to other languages besides C?"

The reason being that I think the way to really move up the baseline is to take another page from Haxe and aim for cross-compatibility between different systems languages, becoming a "language that unites them all". So that could mean relatively new and hip ones like Rust, D or Zig, or older ones like Pascal(Delphi), Fortran, Cobol...

And those are niches relative to C, but they're nearly unserved niches AFAIK.

3 comments

AFAIK languages "compile to C" mainly because they use C as an intermediate representation and the C compiler as the last stage of the compile/link process, so kitlang itself doesn't need to support code generation for various CPUs, and also doesn't need to implement an LLVM frontend. Instead it uses the target platform's C compiler, which is a lot less work but has basically no downsides.

Also the C IR code might make it easier to interop with other languages, since C is basically the 'lingua franca' that all other languages can talk to in some form.

> Instead it uses the target platform's C compiler, which is a lot less work but has basically no downsides.

The downsides of leveraging a platform's given C compiler as your backend is that now you'll be spending a large chunk of time learning the hard way about all the various incompatibilities in C compilers, and adding workarounds in your frontend for the otherwise-unpatchable behavior encountered in every old version of every major compiler on every platform you wish to support.

Conversely, the advantage of using a single known backend is that you can automatically know what code your users are running when they submit a bug report, and you can fork and ship the patch yourself rather than trying to convince an upstream C compiler to accept the patch, then convince the upstream distro to ship the new version of the compiler, then convincing all your users to update their platform C compiler.

Walter Bright concurs: https://news.ycombinator.com/item?id=16195031

Kit may have an easier time of it if it's intended only for games, since that narrows down its supported target platforms substantially. The harsh truth is that most game devs only care about one platform (Windows) and one toolchain (MSVC), so at least it can tailor its output to appease MSVC specifically.

No, I'm targetting C89 (because of msvc) and there almost no platform quirks than some line length limit on msvc. c99 would be nicer of course.
Most game devs also care about consoles, which adds several more platforms and toolchains.
I've used Haxe a lot and at this point I see its wide array of targets as not only a strength but at times a major weakness. I used the C++ target most often, but didn't have access to all of C++ features because they had no analog on other targets like Lua or Python - essentially Haxe becomes a least common denominator of all its targets. Focusing entirely on C lets me have a great interop story, and C is highly portable already.
It probably wouldn't take a huge amount of effort to compile into C++!