Implementing compilers or interpreters in Julia?

194 views
Skip to first unread message

Sebastian the Eight

unread,
Sep 22, 2016, 11:43:59 AM9/22/16
to julia-users
I'm curious how adept Julia is for writing compilers/interpreters? It's fairly easy to find example toy compilers for most other languages (C, OCaml, Ruby etc), but Julia seems to be lacking any examples except for its own. I was wondering if there are advantages or disadvantages for using Julia in this way, other than being a relatively new language

Isaiah Norton

unread,
Sep 22, 2016, 12:55:01 PM9/22/16
to julia...@googlegroups.com
Any answer if going to be fairly opinion-based. That said, here are some opinions :)

some advantages:
- interactive development
- performance
- Cxx.jl, if you want to target LLVM
- multiple dispatch

some disadvantages:
- lack of ML-style pattern-matching -- though multiple dispatch on node type covers much of how this is used (and https://github.com/kmsquire/Match.jl might help too)
- for an interpreter, lack of static compilation (your language would need to carry along Julia and LLVM machinery)

Some examples of compiler-related-things written in Julia:

- Intel's ParallelAccerator compiler: https://github.com/IntelLabs/ParallelAccelerator.jl

- "green-fairy", an abstract interpreter: https://github.com/carnaval/green-fairy
   (MS thesis project, see PDF report. still WIP)
- parsers for object-file formats (DWARF, COFF, MachO, ...): https://github.com/Keno?tab=repositories&type=source


Tim Besard

unread,
Sep 22, 2016, 4:34:11 PM9/22/16
to julia-users
Op donderdag 22 september 2016 12:55:01 UTC-4 schreef Isaiah:

- Cxx.jl, if you want to target LLVM

I've been working on LLVM.jl to make this even easier:
- https://github.com/maleadt/LLVM.jl
- irbuilder + execution example: https://github.com/maleadt/LLVM.jl/blob/master/examples/sum.jl

Is going to be used to power CUDAnative, see e.g. https://gist.github.com/maleadt/ec07509c880903efce0d2fed6bded416

Tim

Reply all
Reply to author
Forward
0 new messages