It's not a secret anymore!*
The moose likes Java in General and the fly likes can a java guy write virtual machines ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "can a java guy write virtual machines ?" Watch "can a java guy write virtual machines ?" New topic
Author

can a java guy write virtual machines ?

naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 688

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 ?


The Only way to learn is ...........do!
Visit my blog http://inaved-momin.blogspot.com/
Anayonkar Shivalkar
Bartender

Joined: Dec 08, 2010
Posts: 1502
    
    5

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.


Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3064
    
  33

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.


Mohamed Sanaulla | My Blog
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37971
    
  22
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

Joined: Jul 03, 2011
Posts: 688

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

Joined: Jan 03, 2004
Posts: 6109
    
    6

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
Sheriff

Joined: Sep 28, 2004
Posts: 18520
    
  40

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 688

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

Joined: Mar 17, 2011
Posts: 7536
    
  18

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


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Steve Fahlbusch
Bartender

Joined: Sep 18, 2000
Posts: 557
    
    7

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

Joined: Aug 16, 2005
Posts: 14074
    
  16

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37971
    
  22
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

Joined: Aug 22, 2010
Posts: 3606
    
  60

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

Joined: Mar 17, 2011
Posts: 7536
    
  18

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

Joined: Aug 16, 2005
Posts: 14074
    
  16

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

Joined: Mar 17, 2011
Posts: 7536
    
  18

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
Bartender

Joined: Jan 17, 2008
Posts: 2272
    
  28

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

Joined: Mar 22, 2000
Posts: 12761
    
    5
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

Joined: Mar 17, 2011
Posts: 7536
    
  18

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can a java guy write virtual machines ?
 
Similar Threads
Table Oriented Programming
Why starting index of array is 0
Question about Masters Degree
C++
Lisp