10 Replies - 10562 Views - Last Post: 27 October 2010 - 09:26 AM

#1 JoshD  Icon User is offline

  • D.I.C Head

Reputation: 9
  • View blog
  • Posts: 111
  • Joined: 22-March 10

Platform Independent Programming Languages

Posted 26 October 2010 - 09:00 AM

I didn't really know where to post this but I think this is probably the best place.

So my question is:
What programming languages are 'platform independent' (don't rely on a certain OS)?
I know Java is one.

Thanks,
JD.
Is This A Good Question/Topic? 0
  • +

Replies To: Platform Independent Programming Languages

#2 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5757
  • View blog
  • Posts: 12,571
  • Joined: 16-October 07

Re: Platform Independent Programming Languages

Posted 26 October 2010 - 09:20 AM

Actually, almost any language can be platform independent. It's the distributable code that usually isn't. Java code runs in a JVM. The JVM is platform specific, but theoretically Java programs will run on a JVM regardless of what OS it's installed on.

Basically, any interpreted language should run on a system the successfully implements the interpretor. No one is 100% successful at this, however; no even Java.

An executable is compiled for a specific OS. However, the source code can be completely portable. There are thousands of C and C++ programs that are said to be "cross platform" meaning they can be successfully compiled on different platforms without much pain.

e.g Firefox runs one Windows, Mac, and Linux. The code base is mostly the same, but certain modules are tweaked to allow for different architectures.
Was This Post Helpful? 1
  • +
  • -

#3 JoshD  Icon User is offline

  • D.I.C Head

Reputation: 9
  • View blog
  • Posts: 111
  • Joined: 22-March 10

Re: Platform Independent Programming Languages

Posted 26 October 2010 - 10:58 AM

I like this.

So the interpreter is the key to this really?

Cool.

So potentially, any language could work on any platform??

EDIT: I suppose that's a stupid question. Any language can work on any platform that successfully implements the interpreter.

So I guess my real question is, which languages work cross-platform without you having to do anything extra?

This post has been edited by JoshD: 26 October 2010 - 11:01 AM

Was This Post Helpful? 0
  • +
  • -

#4 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: Platform Independent Programming Languages

Posted 26 October 2010 - 11:07 AM

Quote

So the intrepetor is the key to this really?
Ultimately, yes.

Quote

So potentially, any language could work on any platform??
As long as the language semantics and requirements can be implemented. For example, if the language demands floating point semantics, there might be a problem in writing interpreters for systems without an FPU.

Quote

So I guess my real question is, which languages work cross-platform without you having to do anything extra?
That's not a meaningful question. Perhaps what you're asking is what languages have practical official implementations for Windows, Linux, and Macs.

To which the answer would be: C, C++, C#, Java, Python, Ruby, etc.
Was This Post Helpful? 1
  • +
  • -

#5 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5757
  • View blog
  • Posts: 12,571
  • Joined: 16-October 07

Re: Platform Independent Programming Languages

Posted 26 October 2010 - 11:44 AM

View PostJoshD, on 26 October 2010 - 11:58 AM, said:

So the interpreter is the key to this really?


To clarify, not all languages use an interpreter.

A computer program, any program, executes within the context of some machine. The machine itself; CPU, memory, graphics card, etc, has a set of instructions it will run. These instructions are called machine code.

Some, formerly most, programming languages are compiled into machine code. This results in a executable binary that runs directly against the machine itself. The result may be called compiled code and getting from source to binary is called compiling. Though sometimes as distinction is made between compiling and linking.

Java calls the process of going from source files (.java) to .class files compiling. However, the result can't run on it's own. The result is a preprocessed set of instructions ( p-code ) that the JVM ( interpretor ) runs. JVM stands for Java "Virtual Machine,", the idea being that .class files are machine code inside the the VM. It's a cute, if confusing, way for Java to obfuscate it's interpreted nature.

Because of the need for a middleman, the interpretor, interpreted languages are generally views as slower than their directly executable counter parts. However, the line can be blurry, depending how where the interpreting is happening. In some environments, the Operating System itself acts an interpretor for nearly everything executed.

A "scripting" language is usually interpreted, with an executable program reading the script and executing the instructions.
Was This Post Helpful? 2
  • +
  • -

#6 JoshD  Icon User is offline

  • D.I.C Head

Reputation: 9
  • View blog
  • Posts: 111
  • Joined: 22-March 10

Re: Platform Independent Programming Languages

Posted 26 October 2010 - 12:38 PM

View PostOler1s, on 26 October 2010 - 10:07 AM, said:

Quote

So I guess my real question is, which languages work cross-platform without you having to do anything extra?
That's not a meaningful question. Perhaps what you're asking is what languages have practical official implementations for Windows, Linux, and Macs.

To which the answer would be: C, C++, C#, Java, Python, Ruby, etc.

That is the question I was trying to ask, thank you!!

@baavgai - I had a basic understanding of that from my Computing A Level, however you have really explained it a lot better than my teacher did, and gone into greater depth! Thank you. =)
Was This Post Helpful? 0
  • +
  • -

#7 mostyfriedman  Icon User is offline

  • The Algorithmi
  • member icon

Reputation: 727
  • View blog
  • Posts: 4,473
  • Joined: 24-October 08

Re: Platform Independent Programming Languages

Posted 26 October 2010 - 09:21 PM

View Postbaavgai, on 26 October 2010 - 06:20 PM, said:

Basically, any interpreted language should run on a system the successfully implements the interpretor. No one is 100% successful at this, however; no even Java.


please explain :D
Was This Post Helpful? 0
  • +
  • -

#8 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5757
  • View blog
  • Posts: 12,571
  • Joined: 16-October 07

Re: Platform Independent Programming Languages

Posted 27 October 2010 - 04:45 AM

Which part?

Java "write once run anywhere" dream falters in the real world, particularly on the desktop. There's a reason Java enjoys its greatest popularity in the middle tier, where UI doesn't come into play.

The interpreter any computer user is most familiar with, you're using it right now, is the web browser. At a bare minimum, a browser must read HTML markup and render it. CSS is another layer. To even be considered viable, though, it must also contain a Javascript interpreter as well.

Even the same version of a given browser rarely renders identically on different OS platforms, even with everything else ( resolutions, hardware, etc ) being equal. The OS ultimately controls the UI and everyone does it a little different.
Was This Post Helpful? 0
  • +
  • -

#9 mostyfriedman  Icon User is offline

  • The Algorithmi
  • member icon

Reputation: 727
  • View blog
  • Posts: 4,473
  • Joined: 24-October 08

Re: Platform Independent Programming Languages

Posted 27 October 2010 - 08:10 AM

View Postbaavgai, on 27 October 2010 - 01:45 PM, said:

Which part?

Java "write once run anywhere" dream falters in the real world, particularly on the desktop. There's a reason Java enjoys its greatest popularity in the middle tier, where UI doesn't come into play.

The interpreter any computer user is most familiar with, you're using it right now, is the web browser. At a bare minimum, a browser must read HTML markup and render it. CSS is another layer. To even be considered viable, though, it must also contain a Javascript interpreter as well.

Even the same version of a given browser rarely renders identically on different OS platforms, even with everything else ( resolutions, hardware, etc ) being equal. The OS ultimately controls the UI and everyone does it a little different.


Ah I see, so what you meant to say is that there are subtle differences when a language is run on different platforms. I misunderstood what you said earlier.
Was This Post Helpful? 0
  • +
  • -

#10 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5757
  • View blog
  • Posts: 12,571
  • Joined: 16-October 07

Re: Platform Independent Programming Languages

Posted 27 October 2010 - 08:55 AM

Sometimes not subtle, but trivial. I once deployed a Java GUI application to several different terminals. On some versions of Windows, the tab key didn't work. The basic functionality was there, but users can get cranky.
Was This Post Helpful? 0
  • +
  • -

#11 mostyfriedman  Icon User is offline

  • The Algorithmi
  • member icon

Reputation: 727
  • View blog
  • Posts: 4,473
  • Joined: 24-October 08

Re: Platform Independent Programming Languages

Posted 27 October 2010 - 09:26 AM

yea yea, I got your point and I agree, I just misunderstood what you said earlier. I thought that you meant that some platform independent languages don't work on some platforms that implement the interpreter, which doesnt make sense :P.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1