Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Platform Independent, Lightweight Programming Language

I need to write an extremely lightweight program (trying to get below 8Kb) that performs some simple math. The language also needs to be platform independent. Which language do you think would work the best? (Oh, and no frameworks allowed.)

like image 262
Jack Mills Avatar asked Nov 28 '22 12:11

Jack Mills


2 Answers

C. Of course you need to compile separately for each platform, but other than that, it's quite light, and platform-independent (or multiplatform, whichever expression you prefer).

like image 156
Joonas Pulakka Avatar answered Dec 05 '22 05:12

Joonas Pulakka


Which platforms are the program targeting?

So far, we have the following requirements:

  • Program must be under 8 kilobytes.
  • Must be platform-independent.
  • No frameworks allowed.

Here are some questions:

  • Can the 8 KB program be a script for a scripting language?
  • How big can the runtime environment for the program be?
  • Should the program be native code on its own?
  • Which target platforms should the code run on?
  • Is cross-compiling the code for each platform an option?

The questions that I've presented are going to affect the desirable options. If the program must be 8 kilobytes with the runtime environment, then there really isn't much of a choice other than compiling against the target environment.

If the target is an embedded device, or non-x86, then its likely that the choices will be further restricted. Small embeddable langugages such as Lua can still be used (written in C), but that would require a fairly large "runtime" for the script to execute.

If cross-compiling to the targets are an option, then writing a program in C and compiling to each target platform will probably yield fairly small native programs.

With the current requirements, there are a few questions that need to be addressed in providing a good comprehensive answer. Other than that, the best that can be done is a brainstorming of options that may or may not lead to a desirable solution.

like image 34
coobird Avatar answered Dec 05 '22 03:12

coobird