Our great sponsors
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
You can go surprisingly far with C, though LLVM is probably a better long-term option for a serious compiler, because it's a tool made for the job (unless you target exotic and/or embedded platforms that don't have LLVM support - but that's fairly unlikely).
C is very easy to get started with if you don't already know LLVM. The downside is that once your compiler is reasonably complete, you may spend quite a bit of time working around quirks of C (e.g. int promotion is very annoying when you already have full type information, so your compiler either has to understand C semantics fairly well or defensively cast every subexpression).
I have a C backend in my compiler (https://github.com/alumina-lang/alumina) and it works really well, though the generated C is really ugly and assembly-like. With #line directives, you can also get source-level debugging (gdb/lldb) that just works out of the box.
There are a few goodies that LLVM gives you that you don't get with C, like coverage (https://clang.llvm.org/docs/SourceBasedCodeCoverage.html). It works when done through clang, but easily be made to track the original sources.
So how does the LLVM C backend work then?
https://github.com/JuliaHubOSS/llvm-cbe
Related posts
- I fine-tuned my model on a new programming language. You can do it too! π
- π₯The first framework that lets you visualize your React/NodeJS app π€―
- Nelua: Statically typed language with a Lua flavor
- Wax compiler β a tiny language designed to transpile to other languages
- Ask HN: What's a batteries-included framework that's React-first?