V
V
voproser456542022-02-21 22:53:08
Programming languages
voproser45654, 2022-02-21 22:53:08

What programming language produces the compiled file with the smallest size?

I recently started learning Haskell and found that only hello world weighs 11 mb, while in C it will be about 15 kb.
Which programming language produces the smallest compiled file and why is there such a big difference?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vasily Bannikov, 2022-02-21
@voproser45654

why such a big difference?

Each has its own standard library and some kind of its own runtime, which weigh not zero.
In the case of Haskell, he still drags GC with himself.
+ The compiler can optimize your code to varying degrees.
As already mentioned above, machine codes (or assembler) will give you the minimum size if you write code directly on them. Depending on the OS and architecture, a simple program can take a few hundreds of bytes (if not tens).
Looking at slightly higher-level compiled languages, C, C++, and Rust give the most compact output, depending on compiler settings, included libraries, and features used.
In general - 11 megabytes, even for a console utility, is now a penny.

V
Vladimir Kuts, 2022-02-21
@fox_12

assembler

G
Griboks, 2022-02-21
@Griboks

Machine codes give the minimum size of a program.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question