What programming languages are compiled into an executable file?

Namely, that these languages are for Windows (exe) and Linux (elf).
Plus, to work with basic functions (Sockets, cmd (Windows), ...)
Except c++

Author: Alex78191, 2016-04-30

3 answers

Compilation or interpretation is not a property of the language itself. For almost any language, you can build a compiler that generates a native file for this operating system. The exception is probably only languages in which the source text refers to itself at runtime (for example, if the language contains goto to the number of the string calculated at runtime - and in this case, you can build a jump table).

Another thing is that to support complex features (dynamic in C#, eval) you need you may need to have the compiler available on the system at runtime.

A large list can be viewed, for example, here.

(Not all of them support, for example, working with sockets without external libraries. Well, C++ also works with them only through the operating system libraries.)

 10
Author: VladD, 2016-04-30 08:52:05

Technically, the requirement of a single executable is very weak and a whole bunch of languages are suitable for it.

You have not imposed any restrictions on what this executable file will include. And there you can vandalize so much that you can run a program in any language. In addition, it is necessary to separate the language from the implementation of the language. For any language, you can, in theory, make an implementation suitable for any of the groups below. Separation between groups, quite blurry, by the way. You'll see.

I will list a few striking examples.

Good cases

Languages that were originally designed to be compiled into native code. The source code as a result of processing by a typical language toolchain turns into an executable file, although, for any non-trivial tasks, with OS dependencies and / or dynamic linking with something.

  • C: "almost C++" (not really), but still a different language. Suitable for for obvious reasons.
  • Rust: a fairly new language in the same niche with C, in the semantics and compiler of which a good piece of static analysis is built for errors that in most languages will manifest themselves only during the program operation.
  • Haskell: radically different from the above language with an emphasis on functional style. Monads, type inference, immunability "and many other scary words".

Unusual cases

Languages where a significant part of the binary is not related to the compiled code, but only serves as support for the language. But this is, after all, part of the binary!

  • Go : the fact that programs on it are compiled into single binaries (and large ones!) is often presented as one of the main features. It may be confusing that it uses a garbage collector, but this collector is compiled into an executable file, so technically... fits.
  • Haxe: the source code in this language can be compiled into a number of languages (this is the main feature) and run in the native way for each of them. In the context of the question from this series, only C++ is interested, for it this method is: assembly into a single executable file. It's the same story here, the garbage collector is compiled into an executable file and does not require runtime.
  • Crystal: a language that is largely based on Ruby semantics and syntax, but has undergone a number of changes. modifications in order to support static typing (type inference still does not always save) and compilability in general. Also with the garbage collector, which is also compiled into the binary.
  • Scheme (Gambit): a Scheme transpiler (this is lisp such) in C with a set of supporting functions.

Severe cases

Languages where the code in the binary is represented by non-native code and runs on runtime, which, technically, can be placed in the same executable file.

  • Lua: probably the first popular embedded language. There is even LuaJIT, which already makes native code from Lua at runtime.
  • Ruby: it has many implementations, but mruby is designed for embedding. To minimize the requirements for the platform, it is possible to divide it into a bytecode compiler and a bytecode executor.
  • Python: can be packed the interpreter along with the program code (PyInstaller ' th, for example). In fact, it turns out that the code of the executable file does not contain user code, but rather unpacks it and runs it.
 7
Author: , 2016-04-30 11:54:44

In modern times, if you throw out all the esotericism, like compiling python into a binary using a mop and such-and-such a mother, there are:

  1. C++
  2. With
  3. Pascal
  4. Fortran (it is still alive on clusters).

Next - extract from the responses to the comments, read exclusively for the sake of lulz:

There are also two popular languages - hipster Go, which has a strange animal on the emblem, suffering from protrusion of the upper incisors and exophthalmos (bug-eyes). Drags a huge runtime, and requires dancing to interact with the GUI. But it compiles, and sometimes even works.

And C#. This is a corporate monster that doesn't work without its favorite runtime, doesn't work if you have the wrong version of runtime, and sometimes works if all the stars have come together and the memory hasn't run out before.

Well, there is still some Rust, but so far there are not enough bores on the market who want to do non-helloworld on it.

A assembler. Assembler - not compiled, assembler-assembled.

Compilation, this is what it is-it is an assembly from ready-made pieces. And in the assembler there are no ready-made pieces, there is an unambiguous correspondence-instruction-opcode.

 5
Author: gbg, 2017-05-23 12:39:09