[OT] Compilable Python-like language?

Stefan Axelsson crap1234 at hotmail.com
Tue Mar 23 07:35:52 EST 2004


Ed Cogburn wrote:
> Or maybe its just 
> because I'm lazy and will fall in love with any lean, terse, yet 
> powerful language that comes along.  :) However, we all know that for 
> some applications/purposes, Python isn't fast enough.  

Hi, well, since you didn't mention psyco it probably should. Doesn't rid 
you of the interpreter (and you mention that below), but increases the 
speed by a fair amount. It enabled me to keep the "algorithmic" code in 
Python without having to drop to 'C' or Pyrex, gaining a speedup of 
about a factor 100. (This for a bayesian classifier). Though typical 
speedup is more on the order of 2-4 times.

> For me, ocaml is the
> real surprise, it scores the same as gcc (on the Linux side, see the 
> link below).  Its not Python-like, of course, but I'm surprised to see 
> any other language score as well as gcc on a *nix system (gcc being born 
> on *nix, being one of the oldest and most heavily used and beaten-on 
> languages, as well as being optimized to death).

Well, depends on what you mean by "Python like" (here we go again). I'd 
say that it has quite a number of features that are similar to the ones 
that attracted me to Python (from O'Caml incidentally). Such as; mostly 
functional but with imperative support integral to the language (doesn't 
feel it's been bolted on afterwards), support for object oriented 
programming, relatively small and straightforward to learn. Differences 
are that it has pattern matching (plus imho), a type inferring type 
system (a plus imho, but you can have different opinions on that), and 
the syntax (which I don't much care for to be honest). And a compiler 
that produces native code that's quite good (though there's also a 
bytecode interpreter). You might want to give it a spin, there are 
several short tutorials available, and a book online as well 
(http://www.ocaml.org).

If the type system upsets you, as it has a tendency to do to some, then 
Erlang might fit the bill. It's more similar to O'Caml than Python, but 
still shares (most of) the traits mentioned above, save for a dynamic 
type system. It's mostly a byte code language though, but there is a 
compiler (HiPE) included in the distribution. It's more akin to psyco 
than ocamlopt though. Industrial strength; at Ericsson we have several 
projects weighing in at a few million lines that outdo our competition. 
Has unique support for multi processing (loosely coupled) and fault 
tolerance. You might want to have a look: (http://www.erlang.org).

Now, since we're into 'functional' languages (and you confess to mostly 
being anoyed by the LISP syntax than anything else), let me plug Haskell 
also, even though we've now moved quite far away from Python. Purely 
functional, lazy evaluation, nice (interactive) compiler available 
(GHC), though performance perhaps isn't as easy to achive as with 
O'Caml. If you're interested there's more at http://www.haskell.org.

All these are freely avaliable (both as in gratis and libre; the latter 
more or less).

Whether you'd call 'Python like' is an open question. They don't fit all 
of your original criteria, though there are perhaps more similarities 
than first meets the eye.

Stefan,
-- 
Stefan Axelsson



More information about the Python-list mailing list