Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can a java guy write virtual machines ?

 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guyz, I wanted to ask you one question , I am very much passionate about making low level stuff's like compilers, VM, OS, drivers etc...but my knowledge is limited to only java most people have suggested me that I should master one language rather just be jack of many languages but i just wanted to know to master in all the low level apps should i need to learn low level languages like C,C++,Assembly ?
 
Anayonkar Shivalkar
Bartender
Posts: 1557
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello naved momin,

I don't know what do you mean by 'low lever', but creating compiler or OS is very high level for me. Perhaps you wanted to say 'system level'.

Well, I guess (just guess) that C or C++ is far better to do such stuff than Java. The main reason being that C/C++ gives you direct access to memory.

On other note, Java is not meant to do that stuff. It is best suited for desktop applications, distributed applications, web applications, mobile applications and so on.

I hope this helps.
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
naved momin wrote: people have suggested me that I should master one language rather just be jack of many languages

Pragmatic Programmer has something different to say- they say: "Learn an new language every year". By what they mean to learn is not just syntax, but do something substantial in that language.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49466
64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are right about using C for writing compilers and system code. Most people call the sort of code used by the machine itself “low-level”, and Java™ is a high-level language (3rd generation, I think; SQL would be 4th generation). Writing a compiler is not that difficult; it is the sort of thing you ought to do at least once in your lifetime

As for learning a new language, try FORTH. That is different. When you have learnt FORTH learn FITH.
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:You are right about using C for writing compilers and system code. Most people call the sort of code used by the machine itself “low-level”, and Java™ is a high-level language (3rd generation, I think; SQL would be 4th generation). Writing a compiler is not that difficult; it is the sort of thing you ought to do at least once in your lifetime

As for learning a new language, try FORTH. That is different. When you have learnt FORTH learn FITH.

thanks , yes i Know c,c++ would be better to write compilers but do i need to learn assembly in order to make system software's like VM, O.S, compilers and the like ?
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
naved momin wrote:do i need to learn assembly in order to make system software's like VM, O.S, compilers and the like ?


I wouldn't consider a VM or a compiler to be "system software." Those are application programs in my book. And no, you don't need to use assembly to write their code. However, if you're writing a compiler, since its output will be machine code, you will need to know the language of the CPU you are targeting, whether it's native code for a physical CPU or java bytecode for a JVM virtual CPU.

An OS is a totally different beast, and in general a far bigger project than a compiler or JVM. You could probably write one without knowing assembly language, but learning assembly would be a small task compared to learning what you need to know to write an OS anyway.
 
Henry Wong
author
Marshal
Pie
Posts: 21219
81
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
naved momin wrote:
thanks , yes i Know c,c++ would be better to write compilers but do i need to learn assembly in order to make system software's like VM, O.S, compilers and the like ?


Well, I guess it depends. In theory "no", but having worked on a few teams that worked on the JVM itself, OS drivers, compilers, etc., I don't think that I have met anyone that didn't know how computers worked at the lowest level.... IMO, you can learn assembly language in less than an hour. It is just a macro substitution to machine code. The hard part is knowing what the computer does with the machine code.

Also, interestingly, I don't think people use macro assemblers, at least not directly, anymore. The last few times that I needed assembly, which is incredibly rare as practically anything can be done in C (with C syntax), I just inline it in C -- meaning you can actually embed asm in C.

Henry
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:
naved momin wrote:
thanks , yes i Know c,c++ would be better to write compilers but do i need to learn assembly in order to make system software's like VM, O.S, compilers and the like ?


The hard part is knowing what the computer does with the machine code.

Henry

Yes that's also a thing that i would love to learn , please name some books which teaches this
 
Winston Gutkowski
Bartender
Pie
Posts: 10430
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:SQL would be 4th generation.



Can't even get any basic standards agreed on (and don't flame me about SQL-92 and all that rot).

Winston
 
Steve Fahlbusch
Bartender
Posts: 605
7
Mac OS X Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes that's also a thing that i would love to learn , please name some books which teaches this


Well yes there is a text book (out of print now?) Compiler writing in Java (or something like that) a search would bring this up.

Now to disagree with others here, while i would consider a compiler as an application - something that can easily be done in java. A VM (not talking about JVM but a true VM) that guy is gonna be c and a tad bit of assembly (but as posted earlier this can be inlined within a c routine). Now not having written a JVM, just conjecture, it could be done mostly in java, with a few native language (maybe more than a few) and those can be in c (but to optimize i still think we will still have some assembly code).

 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15369
40
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steve Fahlbusch wrote:Now to disagree with others here, while i would consider a compiler as an application - something that can easily be done in java.

The Java compiler from the JDK (javac) is itself written in Java.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49466
64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SQL is 4th generation because you can write sum() without having to use a + plus sign. If you want to write sum() in Java™ which is a 3rd-generation imperative language, you have to write something like return i + j; somewhere.
Not because it works
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper de Jong wrote:The Java compiler from the JDK (javac) is itself written in Java.

Also known by the name of "The Hen And Egg Problem"
 
Winston Gutkowski
Bartender
Pie
Posts: 10430
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:SQL is 4th generation because you can write sum() without having to use a + plus sign. If you want to write sum() in Java™ which is a 3rd-generation imperative language, you have to write something like return i + j; somewhere.
Not because it works

I remember Professor Codd telling us at a seminar that SQL was a 3.5GL because it tackled the business of coupling a non-imperative language with a structured source of persistent data (the 'R' in RDBMS), but wasn't quite worthy of 4 because it didn't include some of the issues handled by OO languages (data hiding, abstraction etc).

A few of us quipped that the lack of imperatives should have it docked at least another .5, since it was almost impossible to produce a list with line numbers. But this was 1986, remember.

Winston
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15369
40
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Martin Vajsar wrote:Also known by the name of "The Hen And Egg Problem"

Yes, it sounds funny, you have a language X and you write a compiler to compile language X to machine code, but how are you going to compile your compiler if you don't have a compiled compiler yet?

Writing a compiler in its own target language is actually a very common thing to do. See also Bootstrapping (Wikipedia).
 
Winston Gutkowski
Bartender
Pie
Posts: 10430
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper de Jong wrote:Yes, it sounds funny, you have a language X and you write a compiler to compile language X to machine code...

Ah, but it doesn't, does it? At least not in Java.

Assuming there was an "egg" somewhere, is it in some museum; or was it just binned when Sun went over to the paperless office?

Winston

 
Jayesh A Lalwani
Rancher
Posts: 2756
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's no reason you can't create a language that runs inside a Java VM .That's the whole idea behind DSL's. You define a DSL; your client specifies the behavior of the app using DSL; your java code can either "interprets" the DSL and call other java code that runs in the Java VM., or "compiles" it into Java objects, that run in the Java VM

It's VMs all the way down.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the sake of completeness, you could design your own CPU architecture with opcodes and write a simulator for it in Java.

Then define your DSL with interpreter to run on the simulator for "system software" - that would be a real education in "low level" stuff.

VMs all the way down indeed.

Bill
 
Winston Gutkowski
Bartender
Pie
Posts: 10430
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William Brogden wrote:VMs all the way down indeed.

Isn't it funny how VM has come to mean different things to different people in our biz?

When I was growing up it meant "virtual memory"; but, as usual, a company (IBM, I suspect) took it upon themselves to call it a "virtual 'machine'".

And finally, in the new millennium, we're getting there. Probably took 'em 10 years to get past all that Y2K nonsense.

Winston
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic