Sunday, 21 August 2016

Compiling: Turning Words into Computer Instruction

Once your source code is finished, it is time to compile. Compiling is the process of taking all of your source files and building bytecode.
Unity 3D (Game Engine) uses Mono, as it is a compiler to generate the bytecode, but Unity 3D does this automatically. Mono is an open-source compiler that runs on many different processors and operating systems. The combination of central processing unit (CPU) and operating system is often called a platform.

Each platform requires a unique native machine code to execute or run. Building code for each platform is called a target. Unity 3D converts the bytecode into a native machine code and can target Mac, PC, Android, and iOS.

Native machine code is the set of instructions that directly talk to the CPU and operating system. Unity 3D is a simple way to generate the complex set of instructions for your computer to run.
Code that talks directly to the hardware is referred to as “low-level” programming.
There are layers of software between you and the computer’s hardware.
When writing C# for games using Unity 3D, your code is compiled by Mono.
Unity 3D then takes the bytecode from Mono and com- piles for a target platform into a native machine code.

Both Unity 3D and Mono are the layers underneath your code and the computer’s hardware putting you on a higher level. This is often referred to as a computer layer abstraction.
That is why C# is usually considered a high-level programming language.
Programming at a lower level requires much more knowledge of memory management and a wide variety of other APIs that might include graphic cards, physics, sound, and everything else that runs a game.

Writing for a layer involves an in-depth knowledge of both the layers below and above the one you’re writing for.
The computer hardware, such as CPU, graphics card, memory, and storage, live on the lowest level. Above them is the basic input/output system (BIOS) and software that starts the hardware when you press the Power button.

Above that is your computer’s operating system and drivers that talk to the hardware. Finally, Unity 3D lives above the operating system, and then your code lives above Unity 3D.
That is why we’re going to use Unity 3D to write games, and not starting from scratch in raw C++. Otherwise we’ll have to spend a few years learning about physics, rendering, and assembly language, or the instruction set that your CPU uses to think.
No comments :

No comments :

Post a Comment