Programming Tools 3

Compilers, interpreters and virtual machines.
You want to make a program for your computer, or for everyone’s computer and there is this issue of how will it run on the machine you want to run it.
You want to run it as fast as you can, but to run on as many machines as possible. You could use Java and run it on the Java Virtual Machine (use Eclipse.) How about C and C++ for Linux? Or you could target Windows and use Visual Studio and .Net and that might even run just fine on Linux using the .Net Virtual Machine Mono.
Wait you say, Virtual Machine? isn’t that some type of way of running a second OS on your computer at the same time as Your main OS? Well, there are virtual machines and virtual machines. The ones we are concentrating on here is the ones that host a single program and not hosting a whole operating system. K?
You can run a program in a few ways. The virtual machine allows making a program once to run it in many places. It also allows not having to link in all of the libraries and other pieces required to run a program and as long as the host system has the virtual machine it will run fine. It also allows running the program on different platforms without having to compile the program on each platform. Or you can use an interpreted language that does the same thing (php, basic, python, perl, html, javascript are all interpreted languages.) Again the idea here is write once run anywhere but these languages do not have the power and speed that the virtual machines have but are easier to program and are all web enabled directly where Java and dot net are only partially usable for web as only a subset of the abilities of these applications work well in a browser.
Or you can compile the program for the platform you want to run it on by using one of the more classic although still modern languages such as C++, Ada or FORTRAN (yes some people still use it and it is very good for science work.) This produces native code for the platform being used, which can be the low level or high level parts of the OS. Running natively means it runs faster, has more control of memory or disk access and can do things that this platform allows where other platforms may not. You can write a program to be able to be compiled on a number of operating systems. The Libraries that you need to compile in must be available on all platforms you target and you most likely can not use many dynamically linked libraries.
There is one other alternative, not used very often anymore. The fastest most efficient use of CPU power is to use the most difficult programming method, assembler. Since it is assembled into the CPU’s instructions and the machines bios interrupt calls it can run on any computer running the same CPU and if it has any other constraints written into the program. It should be possible to write and assemble a program to run on Windows, Linux and Mac, now that they all use the same CPU. I have tried this with simple programs on Windows and Linux and it worked for me. My fear is that some sophisticated virus writer will realize this and use it for a super virus.
Anyway there you have it, the confusing but wonderful world of different ways to prepare a program for running on different computers.

About echlinm

Computer Programmer/Systems Analyst/Hacker S31
This entry was posted in Computers and Internet, hackers, Programming. Bookmark the permalink.

1 Response to Programming Tools 3

  1. Pingback: Programming tools 6: debug | Borg or No (S31)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s