Hacker News new | ask | show | jobs
by ksec 14 days ago
Are there any other languages that offer similar compilation performance. The only one I know of or remember is Turbo Pascal.
4 comments

Everyone forgets D. It’s probably the fastest to compile, even faster than Go
Isn’t go (with cgo disabled) still at least as fast to compile?
Compilation speed isn’t that much of a factor of language as far as I can understand. It is more related to how optimization is done and how machine code is generated.

Also obviously it is about how fast the actual implementation of the compiler/build-system is.

Definitely not true. Otherwise we would have really fast C++ compilers and no one would ever have implemented hacks like precompiled headers.
You can write code that compiles slow in pretty much any language.

You can maybe even do it in C if you are generating code using scripts or abusing macros.

On the other hand, you can write sane C++ (without stdlib) and clang or gcc is able to compile it extremely fast. Because clang and gcc are really fast.

You can write a rust program without dependencies and it would be extremely hard to make it compile slow unless you are abousing generics or procedural macros. But you can write a 100 line webserver using some framework like axum and it will compile really slow. This is not because Rust is slow to compile or rust compiler being slow.

On the other hand you can write a zig file with a single test and compiling it using Release mode takes 3+ seconds on a modern computer because Zig compiler is extremely slow when using LLVM backend. This is also obviosly not because Zig is a slow language to compile since their own backend (non LLVM) has super fast compilation.

That hack is because of C.

Definitely true when using VC++ with C++20 modules and MSBuild.

It also helps not compiling everything from source as many UNIX folks do.

> Definitely true when using VC++ with C++20 modules and MSBuild.

Lol, sorry, but as soon as MSBuild is involved the compiler can be infinitely fast and you'd still need to be waiting for the build. Also the main problem of MSVC is the slow linker, and that isn't fixed by C++ modules. This is also the first time I'm hearing that C++ modules actually help with compilation speed in real world projects - the best I've heard so far is that they're a bit faster than precompiled header but not by much, which simply isn't good enough for typical C++ projects.

Follow engineering principles and actually test it.

The company behind Cadifra UML Editor is quite happy with their migration, the owner keeps posting about their modules experience on Reddit C++.

Microsoft also has CppCon talks on the matter.

All my C++ hobby projects use modules, as I only care about VC++.

What is the compile and link perfomance that you get then? Numbers on table... I know that even with MSVC, single file rebuild+link of C code at about 100 KLOC/second should be well possible.

You keep posting about obscure products like whatever UML Editor that noone cares about, why would I listen to what they say, and why do you not even link anything to look up?

This has drastically changed with "recent developments".

Iteration speed is everything now, if and only if you learn from the additional iterations.

Delphi, D, Nim, Go, C# / .NET Native / Native AOT, Oberon (any on the language family), Ada (depends on the compiler, 7 vendors),...
FWIW, IME at least Nim isn't particularly fast when building, at least when compared to C projects. E.g. in the sokol-nim bindings I'm seeing build timings like:

    32743 lines; 0.953s
...building 32k lines of code in a second really isn't fast on an M1 Mac, and that's for a debug build without optimization.
I mean Nim just compiles to C or C++, so it's bound to be slower
Depends on which compilation pipeline, I would say.