5

Let's say that I'm a theoretical programmer hunting for a cross platform programming language, what are my options. This language must satisfy this list of requirements:

  • It must not require the user to install extra programs or runtimes (Clarification: I don't mind linking libraries etc. If I can package them with the application. The program must not require the user to install anything to be able to run my game. Basically I just want the user to be able to download my program and run it straight out of the box.)

  • Run on Mac, Windows and Linux

  • It must compile down to an executable, or the runtime be packaged with the executable (E.g. how Love2d allows Lua programmers to create executables, by embeding the runtime in the executable.) The larger size and slower speed is an issue though, so most people would avoid.

  • Free (as in beer)

Preferable but not entirely necessary:

  • Free (as in speech)

  • It can be used to program mobile apps (Android and iOS) as well.

  • Fast

  • Small executable sizes.

  • Mature and stable (as in syntax and the tools surrounding it)

So how about it? If a programmer wants to create a program that satisfies these parameters are C and C++ their only options? Java sort of satisfies these requirements but does require the runtime environment to be installed (Doesn't it?). Are there any languages out there that satisfy this niche? Not necessarily to the same maturity as C and C++ though.

*Edit: I disagree with this question being put on hold, I'm not asking which language I'm going to take up next, which is off topic and subjective. I'm specifically asking about languages that satisfy these requirements, which is not subjective. I'm also not creating a poll, I'm asking for specific pieces of technology that satisfy this list of requirements. The help center suggests leaving a comment here to get it re-opened, so would it be possible to re-open this question for discussion?

closed as off-topic by gnat, GrandmasterB, Bart van Ingen Schenau, Jörg W Mittag, Doval Feb 9 '15 at 14:57

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about what language, technology, or project one should take up next are off topic on Programmers, as they can only attract subjective opinions for answers. There are too many individual factors behind the question to create answers that will have lasting value. You may be able to get help in The Whiteboard, our chat room." – gnat, GrandmasterB, Bart van Ingen Schenau, Jörg W Mittag, Doval
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 4
    JavaScript. The VM for that is included in the browsers shipped with the platforms you mention. (Even C and C++ require supporting libraries - C and C++ runtime libs - which can require extra installs, e.g. MSVC redistributable packages.) – Mat Feb 9 '15 at 5:42
  • 1
    -1, shows no research effort. – GrandmasterB Feb 9 '15 at 6:23
  • 3
    @GrandmasterB given how many programming langauges exist out there, it is infeasible for me to go out and research each one and classify it based on whether or not it reaches my guidelines. Much easier to ask a question like this to a community of experts who have much more experience than I, is it not? – J-' Feb 9 '15 at 7:10
  • 4
    @GrandmasterB I don't appreciate the snark, I have done research. I've done enough to know that I should be asking people who know more than me to fill me in on the gaps. Please try being constructive next time you believe your down vote is talking for you, because just saying -1, no research effort. Is not very helpful, perhaps you could improve on that next time you leave a comment and not wait until someone asks you further to expand on your little quip. – J-' Feb 9 '15 at 7:45
  • 1
    Why are you looking to avoid all languages that have a run time? what's the point? Basically you can use any language that the GCC can compile... or most things that use LLVM... – AK_ Feb 9 '15 at 11:21
11

You could use some languages with compiled implementations available on all the 3 platforms, e.g. Ocaml or Common Lisp or Haskell or Scheme (or maybe Go, Rust, Opa, Haxe, ...) You could also use implementations which compiles to C or C++ code, in particular Bigloo, Hop, etc.... (At some point Mozart/Oz was doing so)

BTW, notice that even C has some runtime component: the C standard library (libc.so on Linux).

You could also embed some interpreter in your program (e.g. Lua or Guile...)

You might want to use static linking to embed the runtime in your executable. It has drawbacks.

Be aware that a programming language is a specification (often in some English document) which might have several implementations (often, some free software).

It must not require the user to install extra programs or runtimes

I feel that this requirement is ambiguous, very fuzzy and ill-defined: in some sense, when I am browsing any modern site in HTML5+Javascript, some programs (in Javascript) are installed inside my browser (but a naive user won't notice that). And would you accept to have the user download some file once (i.e. getting a self-contained ELF file for Linux/x86-64, or some .exe file for Windows) before using your program? Also, a hello-world C++ or C program requires some "installation" (either compilation of the source code, e.g. for most free software, or downloading a binary executable which will be specific to the user platform). BTW, even in C or C++ you can have dependency hells, such as DLL hells.

addenda

Notice also that with C or C++ on POSIX like systems (typically Linux) you could consider meta-programming : you'll write a program in C which sometimes generates some C code (in some temporary file), and ask the C compiler to compile that new temporary file. In so doing you don't require anything additional since you already need a C compiler in the first place. So if you generate /tmp/emittedcode.c in your program at runtime, you would run (e.g. using system(3) or popen(3)...) a compilation command such as gcc -O -Wall -fPIC -shared /tmp/emittedcode.c -o /tmp/emittedcode.so which produces a shared library that you could dynamically load using dlopen(3) and retrieve symbols in it using dlsym(3). With care you'll find equivalent API in Windows (or use some toolkit like Qt or Gtk which is wrapping them, providing some common dynamic loader API which would be the same for every supported OS).

Also, consider using some JIT compilation library like GCCJIT, libLLVM, libjit, lightning, asmjit, ... You could use them to develop your own language implementation (or consider compiling to C) or just generate useful code at runtime.

  • +1 for mentioning Ocaml, Haskell and Common Lisp. You might add Scheme to the list, since there are free and open source compilers available as well, e.g. MIT Scheme, Chicken Scheme, ... – Giorgio Feb 9 '15 at 10:05
5

If it can run in a browser, then JavaScript is available, as well as languages that compile to JavaScript like Dart, CoffeeScript, ClojureScript, and TypeScript. These are your only good choices for running on mobile devices as well as desktops and Chromebooks.

For compiled desktop apps, there's Go. At a less mature state, there's D, Rust, and Nim.

  • @Jarod I inferred from "must not require the user to install extra programs or runtimes" that you want many end users to be able to easily install your programs, and so these need to be production-quality programs. Languages like Go and Dart are good for that. Research languages like Haskell and Scala are not -- they change rapidly and contain many experiments that didn't pan out. I mentioned that D, Rust, and Nim are currently less mature because they aren't yet ready for broad production applications. – Jerry101 Feb 10 '15 at 2:00

Not the answer you're looking for? Browse other questions tagged or ask your own question.