On Sun, Feb 3, 2013 at 12:19 AM, Ben Johnson <benbjohnson@xxxxxxxxx> wrote: > Tim- > > I talked to you a bit on Twitter about LLVM but I'll give you some more > details here. I wrote an LLVM language that was similar to C but with some > Java-style syntax and features for an open source database I wrote called > Sky (http://skydb.io/). I used the LLVM C bindings instead of the > standard C++ API. I eventually abandoned my language in favor of LuaJIT > though because the complexity of writing a language and database at the > same time is too much. > > Pros: > > - LLVM is well supported and, once you start to understand it, it just > seems to work how you'd expect it to. > > - It's extremely fast. My language ran at C speeds. LuaJIT seems to run at > about half the speed but that's pretty incredible considering how dynamic > Lua is. > That's good to hear. > > - There are a lot of open source LLVM-based compilers (Clang, MacRuby, > GHC, Emscripten) so you can compare LLVM IR (intermediate representation) > and fix most problems you come across just by seeing how someone else did > it. > > > Cons: > > - It's big. When statically linked, it added about 10MB to my executable. > In contrast, I'm now statically linking LuaJIT, LevelDB and 11K SLOC of my > own C code and it's only 1.5MB. Maybe I did something wrong though because > not all tools with LLVM dependencies are this large. > > This may be a showstopper. I want something tiny. > - Users need to have LLVM installed and it takes forever to compile. You > can build binaries with LLVM linked in and distribute those. The Julia > language does this (http://julialang.org/). > > I dont want any external dependencies my users have to install. > - You need to learn a whole new language (LLVM IR) to really know what > you're doing. LLVM IR is fun after you understand it but I found it tough > to wrap my head around it at first. > not a problem. - LLDB (the debugger) doesn't support debugging of JIT code. This can make > debugging a huge pain. > I'm used to not having a debugger > > > I haven't used Parrot at all. You might also want to look at V8 ( > http://code.google.com/p/v8/) to see if you can bypass the lexer/parser. > Or, if you're already compiling Jack to JavaScript then you could just pass > that JavaScript directly to V8. It's incredibly fast. > > > > Ben Johnson > > > > On Feb 2, 2013, at 8:02 PM, Tim Caswell wrote: > > I'd rather not compile to lua because then I need a lua compiler in > addition to a jack compiler. I guess the problem with generating my own > luajit bytecode is I miss out on all the optimizations luajit does as it > generates the bytecode from lua. I wonder if there is a way to give luajit > IR code and have it optimize it and generate the final bytecode. I would > still be skipping all the lua lexer/parser/code-gen steps and the lua > standard library. > > If luajit isn't meant to be used this way, does anyone have experience or > opinions on LLVM or Parrot? I'm also considering using those. I really > like llvm because of it's many targets. But I don't quite understand how > much runtime is required to compile llvm based languages. I don't want my > users to have to install llvm to be able to compile Jack code. > > I do plan on porting my lexer/ parser/ code-gen code to Jack itself so it > can be self-hosting. I just need a runtime bytecode format to use that I > can bundle with the binary. > > > On Sat, Feb 2, 2013 at 5:46 PM, Pierre-Yves Gérardy <pygy79@xxxxxxxxx>wrote: > >> On Sun, Feb 3, 2013 at 12:06 AM, Pierre-Yves Gérardy <pygy79@xxxxxxxxx> >> wrote: >> > >> > and the enforcement of the "density" of the list type. >> >> >> Scratch that. Since the list and hash types are different, you could >> use __newindex() to check efficiently whether the index is legal or >> not. The same goes for tuples. >> >> Adding some more, if you were to take the compile to Lua route, you >> could easily make a standalone binary by embedding the parser/compiler >> as a boot script in a C header. >> >> for the generic loop, you could use the generic for loop, and wrap the >> "in" clause in a dispatcher. >> >> function forDispatch (first, ...) >> -- custom iterators? >> if type(first) == "function" then return first, ... end >> -- lists, tuples? and hashes >> if type(first) == "table" then >> local m = getmetatable(first) >> if m == listMT then return ipairs(first) >> else if ... >> -- I guess you catch my drift... >> end >> error("Invalid type") >> end >> >> -- Pierre-Yves >> >> > >