What is LLVM? Swift, Rust, Clang and other languages behind the support

in #utopian-io7 years ago

New languages, as well as enhancements to existing languages, are gaining popularity throughout the programming environment. Rust from Mozilla, Apple's Swift, Jetbrains' Kotlin, and many other languages ​​offer developers new options in terms of speed, security, convenience, portability and power.
7130c496b853a379b7b91ff9ce0f5a26.jpg
Why is it right now? A big factor is the new tools used to build the language, especially the compiler. Among them, LLVM is the first of its kind, an open source project that was originally developed by Chris Lattner, founder of the Swift language, as a research project at the University of Illinois.

LLVM makes it easy to create new languages ​​and also enhances the development of existing languages. It provides tools to automate the least-pleasing aspects of language creation tasks: Create a compiler that transports output code to multiple platforms and architectures, and write code to handle common language metaphors such as exceptions . Its free license means it can be freely reused as a software component or deployed as a service.

There are many familiar names in the language roster that uses LLVM. Apple's Swift language uses LLVM as its compiler framework, while Rust uses LLVM as a core component of its toolchain. Moreover, many compilers have an LLVM version, such as the Clang, C / C ++ compiler (this name is called "C-lang") and is itself a project closely linked to LLVM. Kotlin, nominally a JVM language, is developing a language called Kotlin Native that uses LLVM to compile into machine-native code.
At its core, LLVM is a library that programmatically creates machine-generated code. Developers use the API to generate instructions in a format called Intermediate Proxy or IR. LLVM can then compile the IR into a standalone binary or perform a just-in-time (JIT) compile in the context of another program, such as a language interpreter.

The LLVM API provides the original way to develop many of the common structures and patterns found in programming languages. For example, almost every language has the concept of functions and global variables. LLVM uses functions and global variables as standard elements in its IR, so you only have to care about the LLVM implementation and focus on the parts of the language that you need to be aware of, rather than spending time and effort rebuilding those particular wheels.