views:

329

answers:

5

Managed languages being the ones that handle memory cleanup for you.

EDIT I'm not talking about garbage collection. I was just interested in knowing about languages that would free() memory for me automatically, and still compile down to machine code.

+4  A: 

Sure there are. Java, for instance. (gcj)

However the term managed itself implies you have to carry some runtime around.

EFraim
Java VMs also use what they call JIT, meaning code gets compiled as it is executed and thus runs faster when called again. But that's probably not what Luca wants.
Stroboskop
@Stroboskop: gcj can compile to an executable without JIT.
Zifre
+9  A: 

lots:

LISP (and variants), Erlang, C# (under Mono), Haskell, Java (with gcj)

Javier
+8  A: 

You seem to be confusing "Managed" and "Garbage collection", while often managed languages (for example C# and Java) have automated garbage collection, "managed" actually refers to the fact that there is a "virtual machine" which executes your code (see http://en.wikipedia.org/wiki/Managed_code).

So for example the CLR (common language runtime) is the virtual machine executing .Net code, and the JVM (Java virtual machine) is the virtual machine executing java code.

You can in fact have Garbage collection for unmanaged languages (for example C++), and visa versa have managed languages without garbage collection (EDIT: I was looking for some but I can't seem to find any unless Objective C counts, I'm not sure it makes a huge amount of sense to create a managed language without garbage collection anyway)

Both of Java and C# can in fact be compiled directly into machine code, so they are executed directly and not using a virtual machine - for .Net code this is done using NGEN (in fact the CLR compiles .Net assemblies into machine code as you execute it, so-called "Just in time" compilation)

EDIT: As an update to the update of your question, there are in fact a number of alternatives to garbage collection in a spectrum between the extreme of complete manual memory management and garbage collection, and a lot of languages which compile to machine code incorporate varying forms of memory management which dont require you to explicitly free memory.

Can I ask - is this an "out of interest" question, or are you trying to select a language for a project - If the latter then why are you so interested in having your langauge compile down to machine code? Certainly in the case of .Net having your code JIT compiled offers a number of performance advantages (in the majority of cases), also NGENing your code doesn't remove the dependency on the .Net framework.

Kragen
i'd consider 'managed' any language where there's a significant code running 'around' your code, checking any access violations, dangling pointer, array boundaries, etc. usually done with VM, but compiling guards would still fit.
Javier
You cannot have garbage collection in C++ in any sensible way. According to Stroustrup "the language is hostile towards GC"
EFraim
I'd agree with that, all the same "Managed" is kind of an of a subjective term. Your definition includes scripting languages, and wheras I'd agree with that I've never heard people refer to JavaScript as being "Managed" before :-)
Kragen
+2  A: 

A few more, in the broader sense of "managed" meaning safe (via runtime type checking or exhaustive static analysis) and/or garbage collected:

  • OCaml
  • D
  • Ada
  • Prolog
  • Clean
  • Eiffel
fortran
+1  A: 

There is a semi-GC choice : GLIB.

Gilb use reference count to manage lifespan of object. When refrence count meet 0, an object is cleaned.

It much much more inconvienient than .NET or Java or Python, but when you have to use C, it's better than nothing.

ablmf