Native binary code?

Home » Programming & Design » Native binary code?
Programming & Design No Comments

I've read that all programming languages after being processed decode to native default binary code expressions, if so, can these default binary code expressions only be expressed one way for specific functions and is there a listed archive that displays all default binary code expressions?

Best Answer:

Laurence: The term "native binary code" can be used. It is not incorrect to say that, however it is not fully descriptive (and thus partly vague). So basically, there "is" (in a sense) such a thing as "native binary code". However the true/full answer is, all "binary code" (assuming it's executable code) is "native" to only specific CPU or hardware.

What you read IS correct. All programming languages DO become "machine code" that is executed by the specific CPU on that computer. However, the programming language must be "compiled" (or converted) to run on specific types of computers. That's why code (or software) written for a Mac will not run on a Windows computer, and vice-versa. You CAN buy Microsoft Office for either computer, but if you buy the Mac version, it will not run on Windows. You must buy the Mac version to use it (or even have it install) on your Mac. And vice-versa.

Specific "native binary code" exists only for specific hardware. This means, when a program written in a programming language (like C++) is converted (compiled)… the person who does the compiling must set settings to tell the "compiler" (a program that converts the C++ instructions into machine-code — this is a simplified version — the full process is more complex and requires more than just a "compiler"). These settings tell it (a) what CPU to make the program run on (i.e. what "CPU machine code" to convert it into), and (b) what hardware specification to compile it for (e.g. for either a Mac or Windows hardware or other), (c) and what Operating System to compile it for (Mac or Windows or other). So the compiler must be told to convert the C++ program into "machine code" that can run on (for example) an Intel i7 processor, that is designed into a Mac hardware configuration, that is running the Mac operating system. Then that compiled C++ program will be able to run only on a Mac computer with an Intel (i7 or compatible) CPU. Note that the Intel i7 processor is used on both Mac and Windows computers. And also the Mac is capable of acting as a Mac or Windows hardware (it is both). That's why you can install the Windows operating system on Mac computers; a Mac can fully be a Windows computer or a Mac computer, or both simultaneously. Not so for Windows — they don't have important Mac hardware parts.

What this means is, when a high-level program (written in perhaps C++) is converted into machine-code… that machine-code (what you call binary code)… has more than just what the C++ program specified. The final machine-code also has info about the operating system (for example, how to open a window on the OS), and also info about the specific hardware (how to read/scan the keyboard on the computer's hardware). So machine-code is VERY specific to the hardware… not just to the CPU and the C++/high-level program. Machine code "encodes" important info about the C++ code, the operating system, the hardware it's running on, AND the CPU it's running on.

Capiche? 🙂


So the broader question I believe you're asking is, is there a type of "binary/executable code" that will work/run on every computer?

The answer is "no". Because today, "(executable) binary code" is specific to (native to) specific hardware. And the world today has many/millions of types of hardware… the lowest-level difference being their unique/different CPUs.

"Binary" code (i.e. machine code) is specific to a particular CPU and hardware. So there is no "binary code" that will work on every computer on the planet.

There are attempts to make this work… virtual machines (like Java) is based on efforts… (was an attempt) to do that. However, its "binary code" was not actually machine language. It was a higher-level code that is interpreted by a larger program called the JVM (the Java Virtual Machine). Java must be installed on a computer to be able to run Java code. Many computer (perhaps every computer connected to the internet) does/did have Java automatically installed… though now it's not so safe to keep Java installed — since nefarious people found ways to use Java to spread virii all over the internet. So now, many computer manufacturers either remove Java, or disable it, or weaken it from their computers. So if Java is not installed on a computer (or it's weakened, or a different "version" is installed — as Microsoft did)… then that computer can not run Java. That's why Java is not considered a universal language — though it was on its way to becoming the one (it seems you're trying to find out if there is or can be a universal "language"/"code" that can run everywhere on every computer).

But Java could be the closest to "universal code" (I would not call it "native binary code"). It can more correctly be called "native Java code expressed in binary".


Sorry for the length, but this last point might help.

You might be asking, why are there so many different CPUs and computer hardware (and high-level computer languages)? Why not standardize on one. The answer is… people have tried (that's what the "IBM PC" standard tried to do… decades ago). That did become a sort-of de-facto standard. Even Macs conform to it (that's why Macs can run the Windows OS, if installed).

Though, our trying hasn't been good enough. We now have much fewer "hardware platforms" than in the early days of computing. But we still don't have just one. One reason is, there are many types of computing that is required. We people… need personal computers (we demand they're not too expensive). We need multiple computers installed in fighter-jets to: fly the jet, to look for enemies, to fire weapons-systems, to make the HUD work, etc (these computers are very well tested, designed to almost-never fail/crash due to redundancy, very fast, able to operate in extreme heat/cold/atmospheric pressure/humidity, be impervious to nuclear strikes/EMF/radar/radiation, and for these computers cost is not a major factor… because human lives are at stake). We have computers (large complex parallel-processors) used to forecast the weather. We have computers that run the phone-network, that run the stock-markets… etc. So to do all of these different things, at different cost levels… we've designed simple or complex or very-complex computers.

While we've tried to make "universal" computers… it's not here yet.
(in a sense, that's what DNA is… the universal computing/biological "code"… ACTG… it's not based on binary but rather quaternary code)


Not sure if this helped you, or confused more. Hopefully the former.
Feel free to edit/add to your original question if you need more info.


Other answer:

You read somewhere binary code, that's technically true but a more correct description is machine code. Or binary code that is sensible under a given hardware architecture, many have come and gone, current popular one is ARM and x86. Plus few other ones including virtual ones like Java bytecode or .NET CLR bytecode.

So in someways the source material you studied from is entirely incorrect. There's no such thing you asked for. Nor needed.

Chris P:
You are VERY confused about how programming languages work.

All programming languages are ultimately converted to machine code (which is specific to that particular processor architecture) which is actually executed by the computer.

Specific machine code instructions have specific operation codes which can be expressed in binary, as are data and operands.

For more details and some examples, read this:…

You can look at the command reference for assembly language. That's as low as you can get, in terms of the level of a language.
You're basically writing machine code at this point.

When a high-level language is compiled to machine code, the high-level commands are translated into their low-level equivalent, yes.

Think of it like translating "pick up that bottle" into "extend your hand, close your fingers around the bottle's neck, exert just enough strength to hold it firmly, move your hand upwards".

However I'm wondering why you want to know this? This is the kind of knowledge that is completely useless in the real world, *unless* you're working in a field where you should already have acquired it long ago.