Linked by Thom Holwerda on Wed 7th Nov 2007 10:09 UTC, submitted by Chris Lattner
General Development The LLVM Compiler System is being used for all sorts of interesting things these days. It basically provides an extremely modular and easy to use set of open source (BSD-licensed) compiler libraries that can be used to build various applications from. Despite this, many people don't really understand it, and are scared away by the breadth of the project or by compilers in general. The Kaleidoscope tutorial starts out from scratch and slowly builds up a simple language to show how LLVM can help out with this. We end up with a JIT compiler for a fairly interesting little language with less than 700 lines of code. Of course, this is just the tip of the iceberg, once you start with LLVM, there are all sorts of things you can do.
Order by: Score:
becoming popular
by JrezIN on Wed 7th Nov 2007 10:58 UTC
JrezIN
Member since:
2005-06-29

From all the attention and famous cases of use, I think we'll see more and more about this one... in fact, even more with mobile computing and desktop computing getting so close these days.

Actually, this reminds me when OpenGL for BeOS was begin implemented and the engineer build a a program to build most of the OpenGL extensions, because there was so many of them, and it ended up usually better than manual coding most of them... Even if some programmers don't want to admit, solutions like this will become more and more common each day.

I wonder if Vala guys could target this compiler system to their language resulting some improvement...

Reply Score: 2

RE: becoming popular
by FooBarWidget on Wed 7th Nov 2007 11:23 UTC in reply to "becoming popular"
FooBarWidget Member since:
2005-11-11

Vala compiles to C, so its output is already in native machine code.

Reply Score: 2

Waiting for the C bindings
by jessta on Wed 7th Nov 2007 11:23 UTC
jessta
Member since:
2005-08-17

I've been planning on doing something like this for a little while and this tutorial looks like it will be a great help. YAY!

Although I might wait for the C bindings, C++ irritates me.

Reply Score: 3

Lame tutorial.
by axilmar on Wed 7th Nov 2007 12:10 UTC
axilmar
Member since:
2006-03-20

Very lame tutorial; the author's proposals do not scale in a real programming language. And he skips perhaps the most important part, i.e. type checking.

Reply Score: 1

RE: Lame tutorial.
by SamuraiCrow on Wed 7th Nov 2007 15:24 UTC in reply to "Lame tutorial."
SamuraiCrow Member since:
2005-11-19

This is probably the first example of the unified HLVM and LLVM. http://www.hlvm.org is designed to be a common runtime for most languages including "typeless" languages like Python.

Reply Score: 2

RE: Lame tutorial.
by resistor on Wed 7th Nov 2007 16:21 UTC in reply to "Lame tutorial."
resistor Member since:
2005-07-06

It's a tutorial on using LLVM to implement a language, not on how to implement languages in general. If you don't know _anything at all_ about writing a compiler, you need to read the a compilers textbook (or at least the relevant parts of Wikipedia) first.

Reply Score: 2

RE[2]: Lame tutorial.
by meianoite on Wed 7th Nov 2007 17:52 UTC in reply to "RE: Lame tutorial."
meianoite Member since:
2006-04-05

If you don't know _anything at all_ about writing a compiler, you need to read the a compilers textbook (or at least the relevant parts of Wikipedia) first.


Stay away from Wikipedia. I mean it.

Dragon Book FTW!
http://www.amazon.com/Compilers-Principles-Techniques-Alfred-Aho/dp...

Reply Score: 3

RE[3]: Lame tutorial.
by John Nilsson on Thu 8th Nov 2007 21:13 UTC in reply to "RE[2]: Lame tutorial."
John Nilsson Member since:
2005-07-06

If it's that bad. Why don't you improve it?

Reply Score: 3

RE[4]: Lame tutorial.
by meianoite on Thu 8th Nov 2007 21:34 UTC in reply to "RE[3]: Lame tutorial."
meianoite Member since:
2006-04-05

If it's that bad. Why don't you improve it?


I modded you up for the general wisdom contained in your retort. However, notice that I'm criticising this horrid trend of nowadays where people believe that reading whatever is written in Wikipedia is enough to grasp a concept, any concept, and base their work on whatever shallow article comes up on WP.

Bottom line is: buy a book. Read a book. If for no other reason than being healthier for your eyes and blood flow. Some WP articles might be very thorough, but they're no substitute to the proper literature on any non-trivial subject.

(You'd never attempt to fix a modern car engine after reading Wikipedia articles on 4-stroke engines, would you?)

Reply Score: 2

RE[5]: Lame tutorial.
by John Nilsson on Fri 9th Nov 2007 17:30 UTC in reply to "RE[4]: Lame tutorial."
John Nilsson Member since:
2005-07-06

Some WP articles might be very thorough, but they're no substitute to the proper literature on any non-trivial subject.

Agreed! It's an encyclopedia, a place to get a quick overview of the topic, enought to know what to look for next.

Reply Score: 2

RE: Lame tutorial.
by meianoite on Wed 7th Nov 2007 18:09 UTC in reply to "Lame tutorial."
meianoite Member since:
2006-04-05

Very lame tutorial; the author's proposals do not scale in a real programming language. And he skips perhaps the most important part, i.e. type checking.


Have you ever seen any tutorial that describes every aspect of building a real-life implementation of whatever the tutorial subject is?

Tutorials are simply things that point you to the direction of how things are done under a given environment. It won't give you a step-by-step breakdown on how to write your own operating system, or to build your own your own Gothic cathedral.

The sole purpose of tutorials is to present concepts you're familiar with on ways that match the environment you're working with at the moment. If you need to go beyond that, then you need a "For Dummies" book, then there's a natural progression to books named after the subject, then books named after the subject with an "Advanced Topics" subtitle, then "Subject: the reference manual", then after half a decade or so "Subject: becoming more productive", "Subject: a modern approach", and finally you manage your way around a simple cheat sheet.

See, tutorials are polar opposites of "cheat sheets".

(and yes, it gives me the creeps when I see newbie Python programmers using cheat sheets and coming up with sloppiest solution ever for a given problem, coated with the shiniest syntactic sugar...)



Edit: I'm past the edit time for my previous message, but I just found the link to Dragon Book, 2nd ed. on Amazon, and I think it's worth sharing:
http://www.amazon.com/Compilers-Principles-Techniques-Tools-2nd/dp/...


Edited 2007-11-07 18:16

Reply Score: 3

RE[2]: Lame tutorial.
by axilmar on Thu 8th Nov 2007 14:15 UTC in reply to "RE: Lame tutorial."
axilmar Member since:
2006-03-20

No, I have seen tutorials that are small scale but what they show have real value.

If his purpose was only to show LLVM, he would have skipped lexing and parsing and AST and he would have gone straight to how LLVM is used to produce code.

His tutorial can be summarized into the following simple phrases:

step 1: LLVM has a library which contains classes which can be used to represent a program; LLVM knows how to interpret the instances of these classes to assembly code.


step 2: In order to provide optimizations, you tell the compiler engine which optimizations you require and then you call the engine to optimize the objects produced in step 1.

Reply Score: 1

Books
by Treza on Thu 8th Nov 2007 08:30 UTC
Treza
Member since:
2006-01-11

There is also the fine "Modern Compiler Design" book which I recommend :

http://www.wiley.co.uk/wileychi/grune/

Edited 2007-11-08 08:31

Reply Score: 1