Gergely
Gergely

Reputation: 196

Language choice for small memory footprint

I have a tiny VPS where the memory is very scarce. I was thinking that for fun I might want to write some servers to run on it, that use as little memory as possible. Maybe something like a git-daemon, or anything else that comes up later, there are a lot of interesting techs out there which I'd love to try out for myself.

What programming language would you recommend if memory usage has the highest priority? I'm glad (even prefer) to learn something new.

Upvotes: 3

Views: 3229

Answers (3)

arthurprs
arthurprs

Reputation: 4627

The good old C, unless you're brave enough to all way down to assembly.

Why?
You probably don't want any VMT.
You probably don't want any dynamic typing.
You probably don't want any memory hungry VM.

It's the standard non assembly language for microcontrollers (very little memory), and C low memory footprint is one of the reasons.

Upvotes: 2

Ira Baxter
Ira Baxter

Reputation: 95352

I would suggest a language that has a dense virtual machine instruction set. Another answer here suggested Forth, which is surely a VM, but which I think fails that test by virtue of using pointers (non-dense fullwords) to select execution routines.

Google's compiled version of Java, Dalvik, is supposed to be designed with the intent to minimize memory footprint while being pretty fast to interpret. Being open source, apparantly you can get it and use it for your own purposes. You can likely bend it to avoid use of garbage collection to help manage the data storage footprint.

There is also a Cint, an interpreter for C with a small VM. Probably not as fast as Dalvik, which uses simulated registers rather than a stack.

Upvotes: 1

SK-logic
SK-logic

Reputation: 9715

Forth can be extremely compact.

Upvotes: 3

Related Questions