Re: A new language

28 views
Skip to first unread message

Jeremy Voorhis

unread,
Jun 20, 2011, 11:43:23 AM6/20/11
to ruby...@googlegroups.com

On Monday, June 20, 2011 at 12:41 AM, asterite wrote:

Hi!

Hi Ary,  
Do you think it's possible to write a new programming language in Ruby using your LLVM bindings? I just want to experiment a little with an idea I have, so I'd prefer doing it in Ruby rather than in C++. If later I find the language really usueful I might re-make it C++.
It is absolutely possible. Chris Wailes has written a quality tutorial using ruby-llvm and his own scanner / parser / AST library. http://chris.wailes.name/?page_id=97

Ronaldo Ferraz has also implemented his own mostly-functional language called Spell, using ruby-llvm and garbage collection support. https://github.com/rferraz/spell
But... is it possible using your bindings? Because I see you can dump a Module, but how do I make an "ll" file out of it, optimize it and compile it to native code? (maybe using the llvm command line tools?) And how to define and use external functions?
Unfortunately, the LLVM C bindings upon which ruby-llvm is based only support dumping ll format to stdout. There are a couple of good alternatives to working with .ll files, however. You can use the ruby-llvm JIT compiler api to compile, optimize and execute code on the fly. You can also generate bitcode files which are the binary encoding of LLVM IR. You can generate a .ll file from a .bc by using the llvm-dis utility.
Sorry, I'm really new to LLVM so I just want to know your opinion...

Thanks!
Ary
Thanks for asking, LLVM and its bindings present a new api to learn, but learning LLVM IR itself is like learning a new language. It can be a little daunting at first, the language reference manual is very helpful. http://llvm.org/docs/LangRef.html

Hope that helps,

Jeremy

p.s. I hope you don't mind that I've cross-posted this to the ruby-llvm Google group at http://groups.google.com/group/ruby-llvm so that everyone can benefit.

Ary Borenszweig

unread,
Jun 20, 2011, 10:56:18 PM6/20/11
to ruby-llvm
Thanks Jeremy, Chris and Ronaldo! This is exactly the answer I was
looking for :-)

On Jun 20, 10:43 pm, Jeremy Voorhis <jvoor...@gmail.com> wrote:
> On Monday, June 20, 2011 at 12:41 AM, asterite wrote:
> > Hi!
>
> Hi Ary,> Do you think it's possible to write a new programming language in Ruby using your LLVM bindings? I just want to experiment a little with an idea I have, so I'd prefer doing it in Ruby rather than in C++. If later I find the language really usueful I might re-make it C++.
>
> It is absolutely possible. Chris Wailes has written a quality tutorial using ruby-llvm and his own scanner / parser / AST library.http://chris.wailes.name/?page_id=97
>
> Ronaldo Ferraz has also implemented his own mostly-functional language called Spell, using ruby-llvm and garbage collection support.https://github.com/rferraz/spell
>
> > But... is it possible using your bindings? Because I see you can dump a Module, but how do I make an "ll" file out of it, optimize it and compile it to native code? (maybe using the llvm command line tools?) And how to define and use external functions?
>
> Unfortunately, the LLVM C bindings upon which ruby-llvm is based only support dumping ll format to stdout. There are a couple of good alternatives to working with .ll files, however. You can use the ruby-llvm JIT compiler api to compile, optimize and execute code on the fly. You can also generate bitcode files which are the binary encoding of LLVM IR. You can generate a .ll file from a .bc by using the llvm-dis utility.> Sorry, I'm really new to LLVM so I just want to know your opinion...
>
> > Thanks!
> > Ary
>
> Thanks for asking, LLVM and its bindings present a new api to learn, but learning LLVM IR itself is like learning a new language. It can be a little daunting at first, the language reference manual is very helpful.http://llvm.org/docs/LangRef.html
Reply all
Reply to author
Forward
0 new messages