• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java & microprocessor

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Today somebody just asked me what is the link between microprocessor and java.

i was confused .... Then i said java is machine independent That really mean os independence... He argued we use microprocessor level stuff in java.
i asked can you write or read value from any register..... then he took a pause.

He suddenly start explaining int a=10 and then multiply a*10.
then he was trying to saying moving into register and mulitplying all those concept. But my argument was this java does not do anything right it is the interpreter or jvm does it.

I think he is insane , he is trying to say we are going to program on the processor based.He seems to be system architect.

But from a java programmers perspective ... where does these fit . Definitely a programmer should know all the memory management stuff.

After all these years i believe am i missing something...
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
He could be talking about doing all those in Assembly (very low level).

Knowing how to manage memory is good for any programming language. In C/C++ you need to manually free up memory. In Java the JVM does it for you to some degree but once in a while you will come across OutOfMemoryError or StackOverflowError or some exception that is memory related.
 
vijay jacob
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But a java programmer does not do in assembly .

can we access registers of microprocessor using java ..

I believe we write independent of the backend microprocessor.It is the JVM which does the translation based on the microprocessor.

Am i right?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, you cannot access the registers of the microprocessor directly from Java.

Java bytecode is like machine code, except that it's not specific for a certain brand and model of microprocessor. It's machine code for the Java Virtual Machine. The JVM translates Java bytecode to machine code for the specific microprocessor that the program is running on, at runtime.

This has a number of advantages. For example, you don't need to know in advance on what brand and model of microprocessor the program is going to run - you don't need to compile it to native machine code for that specific processor in advance. That makes Java bytecode independent of the processor it's going to run on. Also, the JVM can at runtime optimize the code specifically for the processor that it's running on.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

vijay jacob wrote:I think he is insane , he is trying to say we are going to program on the processor based.He seems to be system architect.


Not insane, just from a different planet.

But from a java programmers perspective ... where does these fit . Definitely a programmer should know all the memory management stuff.


I'd argue even that. One of the most stubborn problems with people from a C or C++ (or assembler) background is to get them to forget about memory. In 99% of cases in Java it simply doesn't matter - and in a good percentage of cases where it DOES matter, it usually indicates a design or configuration problem.

Memory and its management is the JVM's problem, not yours. Create objects; use 'em; let the GC collect 'em - it's really that simple - and obsessing about memory is a distraction. Furthermore, it's one that tends to lead to premature (or, even worse, micro-) optimization; and that's a cure that is often worse than the problem.

As for your friend: Tell him he's playing with the big boys now, so things like register manipulation should be behind him. You can also tell him it's highly likely that, if it's needed, the JVM is far better at it than he is.

Winston
 
permaculture is a more symbiotic relationship with nature so I can be even lazier. Read tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic