Hi guys!!!Someone posed a nice question on the forum a few days back asking me if there are any guides on programming(he meant C) in the forum and I actually wondered...There are no beginner's guides for programming as such..There are good extensive guides though and you have to ultimately go through those if you wanna dig in deeper..But i thought about creating a beginner's guide..One that teaches you the following thigs...
- Basic introduction to a programming(Be it C/C++/Python/Java)
- An overview over a wide range of topics that are used by every programming language
- And how to relate it to Android and use it to modify kernels/Roms/apks etc
So here it goes....
- Basic introduction to a programming(Be it C/C++/Python/Java)
- An overview over a wide range of topics that are used by every programming language
- And how to relate it to Android and use it to modify kernels/Roms/apks etc
So here it goes....
Basic introduction to programming
We have in our life always wondered, how come the gadgets we use, hardware we use function so well and how do they understand and perform such complicated tasks. The answer lies in one word "Programming"
What is Programming and what are these Programming languages??
-Programming is nothing but a set of commands created by a developer(human being or beings) which is then coded into the machine so that the machine{digital) performs a set of tasks depending on user inputs or independently. In simpler terms, Even a microwave or a washing machine have a set of codes programmed so that they work and do what they are intended to do
-Programming languages are nothing but ways to communicate something to the machines to make them perform the tasks which you want.There are many languages out there..Famous among them being, C,C++,Java,Python and so many more....
So why are these programming machines needed??
-Simple....because the computer understands only one language..the daddy of all languages....Binary language ( 0 & 1)...
Binary language would somewhat be like ( 0 1 01 0101 010101 0101010101....)...To us it would look crazy,To a computer or any digital device..0 means no electric pulse...1 means an electric pulse and hence everything is done in pulses...
-So what are these languages(C and all): Proper term would be an interpreter not a language. All these languages do only one thing in different ways : convert whatever you say aka code into 0s and 1s and tell the computer,mobiles, any other device to do something via binary language(010101000101)
-So why are they needed, well if you can code in 0s and 1s...umm, you'd be a champ..(Dont mean it sarcastically,you'd seriously be a champ)..But normally you need such languages to do the job.
-Which language is the best??Well they all do the same jobs but they are divided into 3 categories
>High level language
>Medium level language
>Low level language
High level languages are nothing but what we are gonna go through in this thread. C,C++,Java,Python,Perl,bash etc are all examples of high level languages.Why are they named as such. Its because they are the closest to human readable language(taking English as the standard)
Medium level language is nothing but an intermediate stage between high level language and low level or machine level language.Medium-level language is mainly an output of the programming source code written in a higher-level language.The GNU Compiler Collection (GCC)(Android tool chains you use to compile kernel) uses several intermediate languages internally to simplify portability and cross-compilation
Low level language is the lowest level of programming. Generally this refers to either machine code or assembly language. As the name suggests it is not close to human readable language. Low-level languages can be converted to machine code without using a compiler or interpreter, and the resulting code runs directly on the processor.
Example: A function in 32-bit x86 machine code to calculate the nth Fibonacci number:
8B542408 83FA0077 06B80000 0000C383 #courtesy : Wikipedia
FA027706 B8010000 00C353BB 01000000
B9010000 008D0419 83FA0376 078BD98B
C84AEBF1 5BC3
(That looks seriously scary to me....)
One advantage of this though is that it runs very fast and consumes less memory as an equivalent program in a high-level language will be more heavyweight
Disadvantage:Low-level languages are considered difficult to use, due to the numerous technical details which must be remembered.
-Why do you need to all this?? Well i for one think that in order to use a language to code something, you should know the flow of your code. how it goes, what it does and how the end result is processed
So say you write a code to add two numbers you should know that
1.You write the code(I'll tell you in later sections how)
2.It goes to your processor which loads the program into your ram
3. With the help of inbuilt functions the the intermediate code is generated
4.The compiler then converts the intermediate code to the machine code
5.The machine code is then executed
-Which language is the best and which one do i need to learn?
Every language has its pros and cons. Which on you learn is up to you and depends on what you want to do. Eg: If you are interested in kernel development, then you need knowledge in linux commands and C programming as the source of a kernel has modules built on C and linux commands are needed for compiling on linux. Similarly, Lets say you wanna create a tool, you can do so using bash(bash is a command line interpreter language: Will tell you in next paragraph),C,Java etc..
BTW, BASH is a command line interpreter for linux, technically its a programming language but it is basically used in command line(eg: command prompt in windows, terminal in linux)...in lay man's term...a line in bash can be executed from the terminal...eg. cd foldername in linux will come under bash..a bash script is executed line by line on the terminal in linux
So enough of basics,Lets head over to the next section(Check the Next post)..
Last edited: