Yes, but those cassette tapes weren’t!I always though Basic, ADA, fortran and Cobol were great for portability
Yes, but those cassette tapes weren’t!I always though Basic, ADA, fortran and Cobol were great for portability
When you don't have to touch hardware, portability is a lot easier.I always though Basic, ADA, fortran and Cobol were great for portability ..
:->
They worked on all the machines I used in the 70's !!
[tldr; Hardware abstraction layers are very helpful in making programming for multiple target environments easier but often suffer from performance deficit and programmers seeking the maximum performance will use platform specific hacks to get it in a non-portable way.As a general statement, ( there are always exceptions )
Would it be true to say something on the lines of
Assuming you have the compilers etc,
for hardware, portability is mainly about how the code is structured ?
as an example,
I try to abstract bits that interface direct to the hardware into "units"
( I say units as the concept is code language agnostic )
and I try to have a "sensible" top level abstraction interface to the hardware code
so that I , or others, can just re write the hardware abstraction code for a new system if needed, leave the main code alone
Is it also fair to say
that for a software only person,
by which I mean one that talks to screen, keyboard in a OS environment
then Java running in a virtual machine can be run across machines without "re compiling "
as opposed to a exe file for W10, another for Linux A, another for Linux B
Many of the responses above answer your question well I think.Hello,
I understand that when we write a java program (the source code) we must then pass the source to another program called "interpreter" which comprises both a compiler and a JVM (java virtual machine). The job of the compiler is to convert the source code into bytecode. Byte code is NOT machine code but it is closer to assembly-like code... Bytecode is executed by the JVM which is a program that acts like an abstract/virtual hardware. The JVM does NOT convert the bytecode into machine code, correct?
Bytecode is platform independent. However, the JVM software component is platform specific: if we use Windows, we must download a Windows specific JVM, if we use a Mac a different JVM. The JMV is therefore platform dependent.
When we talk about code written in C, we say that C is not a portable language because the C compiler is platform dependent and the resulting machine code is platform dependent. More portability means "less" platform dependent. However, while the Java bytecode may be platform independent, a user still needs to have a platform dependent piece of software, the JVM, to run the bytecode. So why do we then say that Java is more portable than C?
We could write the same code in C and either compile it and share the executable with users having our same platform (OS+CPU) or directly share the C source code as long as the users have a suitable C compiler on their machine. If we wrote the same program in Java, users would still need to have a platform specific JVM. In both cases (C and Java), the users need platform specific software installed on their machine. So how is java more portable than C?
Thanks!