• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

why not convert java directly to binary?

 
Ranch Hand
Posts: 56
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I understand the advantages of bytecode, but wouldn't it be cool to tell the compiler to convert your code to machine code or bytecode as you wish?
 
Sheriff
Posts: 67595
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No. I rarely deploy on the same OS that I develop upon. The platform independence of byte code is crucial for me.
 
Ranch Hand
Posts: 175
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java is platform independent because when you compile Java source code to bytecode, the compiled code can run on any platform (since bytecode is platform independent).

If Oracle allows the Java compiler to compile Java source code to machine code, the compiled code cannot run on any platform (since machine code is platform dependent).
 
Ahmad Auada
Ranch Hand
Posts: 56
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes but it would be useful for development boards like the arduino where you don't have much memory for a jvm, right?
 
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nice thought, and yes it's possible and has been done.
Oracle's Hotspot JVM goes for a JIT (Just In Time) strategy, but there are other JVM's that take an AOT (Ahead of Time) compilation strategy. http://www.excelsiorjet.com/ is one example.

But I don't agree that you can do away with the JVM itself. Even if your java code is compiled into native machine code, it still needs all the stuff JVM provides other than JIT compiler - things like memory allocation, GC, thread synchronization primitives, class loading, reflection, management counters.
 
Sheriff
Posts: 22504
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, with native compilation, all that could be compiled into the resulting binary. Oracle is actually planning something similar for Java 9, where you can create a deployable that's a subset of the JVM (including its own java.exe on Windows). It's not a binary though.
 
Karthik Shiraly
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:Well, with native compilation, all that could be compiled into the resulting binary.


But the memory used by the JVM to store all the state that enables it to provide those additional services can't be avoided, even if the JVM's code was linked along with the app into a single binary.
I think OP's assumption was that compiling to native code would avoid the JVM's memory footprint, making it suitable for low memory devices like Arduino.
 
author & internet detective
Posts: 40793
828
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's a VM for devices like the Arduino.

And a Raspberry Pi is really cheap. Which is a real computer on a board.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic