views:

271

answers:

4

Hi, I am a programmer with strong background in Java, Ruby, Python and other high level/dynamic languages. I am facing a problem where I need to code a Linux executable (for 64 and possibly 32-bit OSes too) and none of this languages appear to suit this task, because I end up having to distribute a runtime as well.

I really can't write decent C code, so I'd like to ask for advise on a good high level language that supports sockets communications and process spawning that would produce either C intermediate code or standalone Linux executables.

+6  A: 

For python you can use Freeze.

From the wiki:

Freeze is a "pure Python" utility that ships with Python. You can use Freeze to compile executables for Unix systems.

If you want to write Python, but you don't know if your clients have Python installed, use this!

Karl Voigtland
For the record, you should note that Freeze basically distributes a Python interpreter with the Python bytecode for your program.
Chris Lutz
+5  A: 

Some choices:

  1. Learn C or C++. How hard could it be? It might be fun.
  2. Use gcj. This is the gnu java compiler.
  3. Use RubyScript2Exe
DigitalRoss
Before Chris gets here, :-) yes, item 3 is a packager, it doesn't really compile your Ruby program. But it might solve the problem.
DigitalRoss
Am I really that scary? I already upvoted you!
Chris Lutz
+3  A: 

If you're willing to give into the dark side, there are some experimental "compilers" (i.e. translate to C) for Perl. I don't know how you feel about that - a lot of Python fanatics (not that all Python users are fanatical) seem to hate it with a passion for no real justifiable reason, but I suppose people must have their religious opinions.

For what it's worth, for most "higher-level" languages out there, any real compiler is basically just going to be bundling your program with a runtime. If you really don't want that, you're going to have to use C (and even C requires a standard library, though no usable system doesn't come with one already) or C++ (see previous).

You could try Haskell, which should compile directly to machine code, but might not have mature enough libraries for your tastes, and will probably hurt your brain while you try to learn it. Or maybe Erlang, if you need concurrency badly, though I don't know if it's specifically process spawning or just generally strong support for concurrency. There should also be compilers for various Lisp dialects out there, but once again I don't know how well suited the language/libraries may be for your tasks.

Chris Lutz
FWIW, Haskell does include its runtime in compiled executables. A compiled script of only `main=return()` in GHC 6.8.2 yields an executable of 353107 bytes on my computer.
Mark Rushakoff
Most languages will do this - you kind of have to. The only difference is that the C standard library is extremely lightweight.
Chris Lutz
A: 

You might want to consider Perl as it is installed on most UNIX systems by default these days. It isn't much of a higher-level language IMHO but it is a little easier than writing C. I would grab a copy of Accelerated C++ and write it in C++. It is probably more than worth your while to learn C++ for tasks like this. Once you get your head around programming with Boost and STL, it can really feel like a higher-level language.

D.Shawley