2

I'm looking for an open-source programming language and compiler for it, such that:

  • the language is "full featured" — i.e. it's not a "toy language" (i.e. with support only for integers, or no access to system calls); notably, it should include support for:
    • integers, floating point numbers, character strings / byte arrays
    • composite data types, such as structs in C
  • the compiler builds binaries for target platform, or at least emits assembly scripts (i.e. the compiled apps don't need an extra interpreter on target machine)
    • if this is a problem, I can accept an intermediate VM language, as long as the interpreter is automatically included in built binaries, and it's simple to write a new one (the VM language/bytecode is simple and well defined & documented)
  • it should be easy to add new backends for new platforms; this may sound somewhat vague/imprecise, so to be more concrete:
    • should have at least 2 backends for different processor architectures (e.g. x86_64 and arm)
    • the 2 backends should be very well isolated; should have the same API/interface and be easily interchangeable in the main code of the compiler — so that I could easily see how to write a new backend
  • the language should be "statically typed" (at least some basic typechecking; force-casting between types can be allowed)
  • ideally, the compiler should be small and simple; the resulting programs don't have to be very well optimized;
  • the compiler itself should be reasonably easy to work on (for example, written in Go is awesome; written in strict ANSI C is ok; written in Python is not bad; written in Java is so-so, because I need whole huge JRE; written in OCaml is so-so because the language changes too fast and it may not build anymore with recent compilers).

For example, I considered MinCaml, but it lacks the following:

  • has strings etc., but has no custom data types (structs) (section 2 in PDF: "we have omitted data types (including lists)")
  • has no memory management features ("[many] interesting programs [...] can run with no garbage collection at all")
  • there are multiple backends, and they're isolated, but their documentation is so-so (the original backend for SPARC is documented in the paper, but the others are not; also most inline comments are in Japanese)

Another example, LLVM, is I think way too hard to work with (compilation of LLVM is probably not easy; also I heard LLVM is infamous for being a moving target).

  • 1
    I think the requirements are pretty well specified - actually this is one of the best-specified questions I've seen on this site. But I'm still curious (and you're under no obligation to respond): What's your intended use? Is this mainly for your own learning? – John Y May 4 '18 at 21:31
  • @JohnY Eh; what I really want, is a reasonable programming language for writing Android apps, with a super lightweight development environment (no 100s of MBs of Android Studio & stuff). I couldn't find one, so I'm asking for a language I could try to force to my needs, by trying to add a .dex backend, possibly via smali/baksmali. Maybe a stupid question, but I had to ask out of frustration. By the way, as of now I'm thinking Oberon may be an acceptable answer. – akavel May 5 '18 at 10:18
  • Kinda late, but there's Kotlin Native. It's still a WIP, but it's built around cross-platform support – user36601 May 23 '18 at 10:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.