News for hackers. Stuff that matters.
Re:How I wrote a self-hosting C compiler in 40 days by nickpsecurity on Monday December 14, 2015 @12:56PM (#10732559)
There's quite a few decent alternatives. I often suggest Wirth's Compiler Construction and Oberon sources because they're straightforward lessons plus give experience with Wirth style of simple, safe, efficient languages. Then, they can improve the Oberon System or compilers for personal projects and improvement.

That said, I typically recommend compilers get written in an ML or LISP given it's so much easier to do in those languages. Ocaml and Racket are my main recommendations for modern work. One can also use techniques for deriving imperative code from functional programs if one wants to re-implement that compiler in specific imperative language on a machine. The constructs are even straight-forward enough for macro assembly for those that want to understand it down to bare metal.

Re:How I wrote a self-hosting C compiler in 40 days by sklogic on Monday December 14, 2015 @01:49PM (#10732949)
Yes, functional side of things is interesting and rarely covered in the standard compilers courses.

There is an old but good book, often overlooked: "Functional Programming" by Anthony J. Field and Peter G. Harrison (1988). Despite the title, it's more about various compilation techniques.

Also an old but still relevant (it is missing the STG, but otherwise full of interesting stuff): http://research.microsoft.com/en-us/um/people/simonpj/papers...

It also worth following this blog: https://wingolog.org/

Re:How I wrote a self-hosting C compiler in 40 days by nickpsecurity on Monday December 14, 2015 @02:42PM (#10733264)
I got the 2nd link here before, maybe from you. Might be old but very thorough treatment of about every aspect of functional compilation. I have it saved in djvu and pdf in case I neet someone starting in that area. :)

The other two are new to me. Thanks for those.

Re:How I wrote a self-hosting C compiler in 40 days by urs2102 on Monday December 14, 2015 @02:06PM (#10733059)
I definitely agree with ML and OCaml, but why do you recommend Lisp for compiler work? I love working withs Lisps, but how do you deal with dynamic typing bugs in compiler work? I prefer OCaml/Haskell/ML for its really strong static type checking for compiler work. Just curious though...
Re:How I wrote a self-hosting C compiler in 40 days by nickpsecurity on Monday December 14, 2015 @02:35PM (#10733223)
LISP js easy to parse, transform, build clean-slate, verify, and do fast. My first 4GL tool was a BASIC w/ macros compatible with C and C++. When converted to LISP, it was vastly easier to do transforms and macros plus productivity boost with incremental, per-function compilation. Turns out, Julia did something similar by converting the source into AST's that are LISP expressions with compiler being femtolisp.

Far as safet, you can build checks into your code for protection or use a typed subset of LISP (eg Typed Racket). Shen goes further by embedding whole sequent calculus for custom, per app/module, type systems.

So, not saying LISP is ideal for compilers but does have some ideal and good attributes. Ocaml is my default given it combines conciseness, correctness, decent performance, ease of learning, and some helpful libs.

Re:How I wrote a self-hosting C compiler in 40 days by sklogic on Monday December 14, 2015 @05:02PM (#10734278)
ML got ADTs and static type guarantees, but Lisp got macros, which allows to implement things like http://andykeep.com/pubs/np-preprint.pdf - which is significantly less boilerplate than in ML. An ideal language for compilers would have combined both properties, but to make it happen, an expression problem must be solved first.

See a relevant discussion here from not long ago:

https://news.ycombinator.com/item?id=10712566

Re:How I wrote a self-hosting C compiler in 40 days by nickpsecurity on Wednesday December 16, 2015 @10:15PM (#10749258)
A commenter elsewhere said Racket had ADT's with langplai but also with langracket via subtypes of struct type with match macro. Said it was same style of programming.

So that's static typing (Typed Racket) and macros for sure. Possibly ADT's depending on whether you object to claim above. Should cover your list of requirements.

Re:How I wrote a self-hosting C compiler in 40 days by sklogic on Thursday December 17, 2015 @03:38AM (#10750279)
The problem here is that a single variant tag does not uniquely define a type, as all such type systems expect.
Re:How I wrote a self-hosting C compiler in 40 days by nickpsecurity on Thursday December 17, 2015 @11:15AM (#10752296)
You think it could be modified to handle that?