• Post Reply Bookmark Topic Watch Topic
  • New Topic

question that has me wondering and confused.  RSS feed

 
Adam Chalkley
Ranch Hand
Posts: 518
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've tried to search this a lot but haven't found many places that have explained it but it's a questuion I thought more people would be asking so I've been programming in java for about 2 years but properly for about 4 months,I understand the basic concepts of programming and how data is stored in memory BUT one thing that confuses me is that I know operating systems and programs run on those OS's are written in many programming languages not just Java but like C,C++,Python,how is this possible how do these programming languages not interfere with each other and how would an operating System lets say written in C run a program that's written in Java?

I know it's a complicated question and I'm more than likely going to get a complicated answer but I'll do my best to comprehend it lol Thanks =)
 
T James
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I'll give it a shot.

All of the programs ever written will eventually boil down to a common language - machine language or machine code.
This language is actually the ONLY language that the target machine understands and will differ from machine to machine. (x86, ARM, MIPS, etc.)

C, Java, C++, Python, etc. are languages that were made so that we, humans, could understand how the program should work. They are known as high-level languages.
I wouldn't say they don't "interfere" with each other because programs written in different languages actually do. But I take it you mean, "How come they can get along with each other despite being written in different languages?" That is the compiler's job - to transform, translate, and/or transpose what you wanted to say in your language into machine language so the machine can understand what you want. For the machine, every application it sees are in machine language.

Things can get a little more complicated with interpreted and bytecoded programs but the back-end software that makes them run is still in machine language. Java is usually run on a virtual machine, a concept machine, yes, but a machine nonetheless. So Java programs are still compiled into machine language. How an OS is written is irrelevant to a true "write once run anywhere" Java application as long as you are able to implement the virtual machine in that OS.

I'm not sure how deep I should've gone through with this answer, but hey I tried. Let me know if this helps.

 
Campbell Ritchie
Marshal
Posts: 56553
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that question is too big for us to answer here. You have got a good start, but the OS does things like loading code into memory running it and then unloading it. It does it in such a fashion that multiple programs can run apparently simultaneously. On recent computers with more than one core, they are truly simultaneous.
You may need to find a book about how to write an OS, but it is a big task.
Most OSs are written in assembler (or a core part is), which differs from chip to chip, though many chips “share” a common “core set” of instructions, e.g. i586 is a superset of and includes the i386 instruction set. Once you have enough assembler running to start the machine at all, you usually change to a higher‑level language; I suspect C is the most popular.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!