4 ms·
I'm planning a summer, "write my own language" project for fun, and I wonder how well the parrot compiler tools would be for this. I imagine its a nice way to
by maximilian 18y ago
I'm planning a summer, "write my own language" project for fun, and I wonder how well the parrot compiler tools would be for this. I imagine its a nice way to get my language into an AST, even if I don't target the Parrot VM.
- Xichekolas 18y agoYeah I'm doing the same 'summer project'. I was writing my own parser/lexer by hand, but vaguely remembered hearing that Parrot had hit 1.0, so figured it'd be a good platform to experiment on. No idea if it'll support everything I want to try, but it at least seems easy to get started.
- maximilian 18y agoI tried doing that too, but writing a parser was a pain in the ass in C. I was going a little crazy trying.. I do a lot of numerical things for my masters, and I want to write a simple numerics language that is heavily JIT compiled to speed up the code. Most numerics is done in pretty tight loops (at least everything I see), so I'm hoping to get pretty good performance. Its also just fun to read about VMs and armed with a parser, it won't be as hard to target different ones and compare performance.
- chancho 18y agoYou should check out LLVM. It generates really fast code and has a JIT compiler. I don't know much about Parrot, but it seems heavily skewed toward making dynamic languages fast whereas I believe LLVM aims more toward static languages. Not that you couldn't implement any language on top of either, but take for example the fact that Apple's support of LLVM was (I think) in part so they could use it as a JIT compiler for OpenGL shaders in their software-fallback drivers. It has good support for cross-platform SIMD instructions and such, which will benefit numerical computation greatly. ------------- Also, why don't you both use something like flex and bison? Is writing a lexer/parser by hand still that much of a nerd rite-of-passage? That's the most banal part of implementing a language. You could spend your summer writing an optimizer instead.
- Xichekolas 18y agoI wasn't doing it to prove anything or even to get a working language to use... it just seemed like a fun problem to solve. I've done a bit with yacc and lex before, and had a lot of fun back in the day with the Metacircular Evaluator in SICP.
- chancho 18y agoAh sorry. You said "I wrote it by hand" and he said "it's a pain in the ass" so I mistakenly thought you felt the same way. One person's banal is another's fun.
- maximilian 18y agoI'm also planning on targeting the LLVM. I am just interested in using the PCT to minimize annoying parser work...
- krokas 17y agoI can rather suggest use libJIT instead of LLVM overkill. libJIT is both faster, platform independent, and much easier in use than LLVM (or GNU lightning). Also LLVM is not really suitable for JIT compilation. For instance, LLVM compilation time is just huge, and not suitable for real world JIT compilers. Maybe only for those small toy programs LLVM developers show on conferences. This was one of the many other reasons that for our Just-In-Time compiler we use libJIT. It has been well tested in embedded systems, industrial lasers by TRUMPF Laser division, working on Portable.NET Just-In-Time compiler, and a managed implementation of Windows.Forms. Moreoever, LLVM does not easily support many features needed for implementation of ECMA-335, Microsoft Common Language Infrastructure, Common Language Runtime, Common Intermediate Language, and Common Type System: For instance, These are just a couple of them: * the whole spectrum of ECMA 335 for CLR types and operations * async exception handling * precise stack marking * multiple custom call conventions * fast Just-In-Time compilation Try to Google for libJIT. You can have a look for more information here: http://code.google.com/p/libjit-linear-scan-register-allocator/ http://code.google.com/p/libjit-linear-scan-register-allocat... Also have a look to libJIT tutorial: http://www.gnu.org/software/dotgnu/libjit-doc/libjit.html http://www.gnu.org/software/dotgnu/libjit-doc/libjit.html