0

Instead of needing something like Java, is there a way I could make a program that has a small piece of machine code to compile itself?

  • 1
    While interesting I think it is not good question for SO. It is clearly possible (i.e. just bundling up everything together is possible answer), but it is not clear what practical task you are trying to solve. – Alexei Levenkov Dec 29 '12 at 07:28
  • 1
    Do you mean something like [py2exe](http://www.py2exe.org/index.cgi/Tutorial) or am I mis-understanding the question? – Joachim Isaksson Dec 29 '12 at 07:28
  • IIRC last years IOCCC had a winning entry for (portable) machine independent JIT compiler. But as the nature of the contest suggest, it might be a little hard to read. – Aki Suihkonen Dec 29 '12 at 07:41
  • much narrower in scope (java on windows), but this might help: http://stackoverflow.com/questions/2258932/embed-a-jre-in-a-windows-executable – radai Dec 29 '12 at 08:03

1 Answers1

2

It is theoretically possible. But in practice, it would be a lot of work, and the result would not be a small program. In fact, it would be roughly equivalent in size and functionality / complexity to a standard JVM. Which leads to the obvious point that it is unlikely to be worth the effort.

I suggest that you just use a standard JVM, and leverage the (probably) hundreds of man-years of effort that the implementors have put into building high quality JIT compilers ...

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216