not sure if this is a right place.....but what exactly does it mean if a programming language is portable?

Recommended Answers

All 16 Replies

It means you can use it on different kinds of computers.

could you explain that a bit more.

There is nothing left to explain.

Generally it means not too many assumptions on underlying computer, for example ltitle or big endian, or operating system services.

so as longs as its compiled for a certain CPU architecture (say 80x86) it will run on every computer that uses that type of CPU?

Portablity is not usually considering only raw iron but also operating system. The content of those registers can be filled somehow and the results must go somewhere.

There is standard C programs of very simple nature, but still they must be compiled according to operating system. Interpreters are themselves big programs that need to be installed in the operating system to offer programming language and access to underlying operating system.

If you have calculation routine in 80x86 of course it is possible to utilize that routine from different operating systems and programming languages, but that is library routine and not connected closely for portability issue.

if someone rote a program that didnt use any os services or interact with the os in any way.....would it run on all computer(same cpu architecture) no matter the os

Yes, say math library, but it would need to be linked to other parts of program which make the connection to actually use it.

That math library would be quite challenging to write efficiently to use with different processors (even variants of x86) and order bytes in memory, level of floating point support in processor....

what if someone wrote a program that used no liberies of any kind. then would it run on all?

Sure it runs, for example simple controller which reacts button push from one input and gives result from other pin in processor. Program would be one loop waiting button press to happen.

The program would not be portable because it would be expressed in low level assembler with certain numbers for input/output pins, type of controllers communicating...

what about something in c or c++. are those "portable" launguages?

what about something in c or c++. are those "portable" launguages?

Can you use C or C++ on different kinds of computers?

C (and maybe C++) are considered very portable. For example, one of secrets of success, and wide availability to different computers, of Linux is relying much only C coding with minimal assembly language.

C and C++ are considered to be very portable but compiler differences can be significant. A language like perl or J is probably much more portable in practice for a wide range of programs across different OSs.

There are different degrees of portability. Probably the best you can hope for in terms of portability is a language that either runs on a virtual machine (then your code is as portable as there are virtual machines for different computers) or in an interpreter (ditto, for interpreters) and even then if you try to do hardware or OS specific things, it won't work. Examples:

portable: a Java program that has two integer variables declared statically at compile time, with values A and B, and the program computers the average and puts the answer in a third variable declared at compile time initialized to 0.

not portable: a program written in assembly language that controls a robotic arm and hand and saves the data in a parallel file system across a distributed network of heterogeneous hosts. Oh and it does some vector processing on the side.

not sure if this is a right place.....but what exactly does it mean if a programming language is portable?

It means that there exists compilers/intepreters of that language for many different kinds of computers/OS.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.