Creating a language that needs a good backend

I want to make a compiled language. I am currently evaluating the basics. So far I am looking at C because of its speed of execution, compilation and the small, easy-to-use TCC compiler.

After reading the discussion here about using it as an intermediate language, I'm trying to think about how to make it compatible with garbage collection and exception handling. For now, I think I can solve both, but with a lot of overhead.

Here are some of my thoughts on other possible backends:

  • Build: unsportsmanlike and complete pain for programming.
  • .NET: It feels very slow. 5 seconds to run and 5 seconds to score 1 + 2 on Ironpython and Boo. Unable to start without a large library.
  • JVM: Feels a little slower. No access to binary libraries. Unable to start without a large library.
  • LLVM: window support is not supported. I heard that the compiled executable size is 16 mb +
  • C--: looks underdeveloped.
  • C ++: possible. Can't find a nice little free one that I can associate with.

Can any of you change your mind or add more to this list?

Edit

I recently experimented with LLVM. I found out that they have precompiled binaries and that they can be compiled into an assembly.

http://www.antlr.org/wiki/display/CS652/Generating+machine+executable+binaries+with+LLVM

Here are the steps:

  • Run llvm-as on the LLVM assembly, resulting in an LLVM bytecode file.
  • Run llc in the LLVM bytecode file to get the build file.
  • Run the assembler in the assembly file to get the object file. (or run llvm-ld, which seems to depend on the c compiler installed externally)
  • Compile the executable with gcc, etc.
+4
source share
6 answers

Do you think you need to write an interface for GCC ? I mention this solely for the sake of completeness - as far as I know, the backend interface is quite complex, and the code base is huge and hard to understand.

GCC, on the other hand, is a mature product that many experienced programmers work for. At the very least, it probably provides the most solid foundation for all alternatives.

Personally, I would prefer LLVM (exciting architecture) or .NETs IL: very, very easy to use, has excellent tool support ( Reflector , Cecil , Reflexil and last but not least, the .NET reflection API) and two very efficient implementations ( namely, the canonical implementation of Microsoft and Mono).

But I can not claim expertise in any of the architectures, so take this answer with salt.

+5
source

In this case, LLVM is probably the best choice.

LLVM has Windows support, it only takes some time to compile

+6
source

C ++ won't give you much, use C instead. But if you want the language to be used on the Internet, use .NET or Java, I'm sure they load slowly, but when they are, they are as fast as C .

+4
source

For SmartEiffel, we use C as the back-end.

Tcc is a very good option for development, although not for the final version (the created object is equivalent to gcc -O0)

+2
source

Another thing to add to the list: Slava recently implemented Smalltalk on the Factor backend . I have not tried this myself, but I have the feeling that it will offer more features that you want from higher levels that are more similar to size / performance at lower levels.

+1
source

TCC is the best choice. It is portable and has a library, so it can easily be used as a backend called libtcc. The executables are smaller than gcc, and this is ANSI C.

+1
source

Source: https://habr.com/ru/post/923172/


All Articles