Skip to content

Commit 1992701

Browse files
authored
Merge pull request #29 from gadilashashank/master
Add chapter on assembly and python
2 parents 4ea28a7 + 973bc3e commit 1992701

16 files changed

Lines changed: 326 additions & 0 deletions

book/SUMMARY.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,38 @@
66

77
## Languages
88

9+
* [Assembly Language](languages/assembly/README.md)
10+
11+
* [Introduction](languages/assembly/intro.md)
12+
13+
* [History](languages/assembly/history.md)
14+
15+
* [What it solves?](languages/assembly/what_it_solves.md)
16+
17+
* [Advantages](languages/assembly/advantages.md)
18+
19+
* [Disadvantages](languages/assembly/disadvantages.md)
20+
21+
* [Conclusion](languages/assembly/conclusion.md)
22+
23+
24+
* [Python](languages/python/README.md)
25+
26+
* [Introduction](languages/python/intro.md)
27+
28+
* [History](languages/python/history.md)
29+
30+
* [What it solves?](languages/python/what_it_solves.md)
31+
32+
* [Advantages](languages/python/advantages.md)
33+
34+
* [Disadvantages](languages/python/disadvantages.md)
35+
36+
* [Few more points](languages/python/misc.md)
37+
38+
* [Conclusion](languages/python/conclusion.md)
39+
40+
941
* [C++](languages/cpp/README.md)
1042
* [Introduction](languages/cpp/intro.md)
1143

book/languages/assembly/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Here comes the chapter on Assembly Language
2+
3+
> This language chapter was authored by Gadila Shashank Reddy.
4+
5+
The assembly language is the lowest language that exists after direct machine instructions. At the time it presented a starting leap towards higher-level languages.
6+
So let's get started :)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Where would you use assembly ?
2+
3+
Currently assembly is used very rarely, because nowadays we use higher-level languages which are "translated" through an assembler to assembly and then assembly makes machine code out of it.
4+
Since machine code and assembly are tied together, assembly can be used in applications where speed and performance is of importance, to optimize directly the machine code.
5+
6+
> The Computers on-board of the spacecraft of the Apollo missions used assembly, if the entire code would be printed out it would occupy about 5 feet in height.
7+
8+
The assembly language can be used in these types of application:
9+
10+
* To build software which requires serious machine level optimizations or to beat compilers in code optimization. \
11+
For eg.: System software in an OS (not needed though as modern compilers do a pretty good job).
12+
13+
* In embedded programming where space is limited to an extent that higher level languages
14+
(like C) can use more space then required or actually present.
15+
16+
* To access hardware features which are either platform specific or too uncommon and not
17+
available for optimization in higher languages such as C.
18+
19+
* Written for custom hardware that doesn't have a mechanism to convert high level code
20+
into binary. The Apollo 11 lunar mission is an example of this as it used code
21+
written in assembly.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# A final word
2+
3+
Assembly language is a big leap from machine code towards higher level languages, but like any other programming language assembly also has its own set of advantages and disadvantages.
4+
5+
You might be wondering why only C was used as a comparison. The reason is that C is one of the few high level languages that offers similar speed and performance as assembly or other low level languages and is also highly portable.
6+
7+
## Sources and reference
8+
9+
- [Quora](https://www.quora.com/Why-is-Assembly-Language-used)
10+
11+
- [Wikipedia](https://en.wikipedia.org/wiki/Assembly_language)
12+
13+
- [Apollo-11 Guidance computer source code](https://github.com/chrislgarry/Apollo-11)
14+
15+
- [RISC-V opcodes](https://github.com/riscv/riscv-opcodes/blob/master/opcodes)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Shortcomings
2+
3+
Consider the same example as in the previous section to add two numbers, lets say 1 and 2, but this time it is written in C.
4+
5+
> #include<stdio.h>
6+
int main()
7+
{
8+
int x = 1;
9+
int y = 2;
10+
int z = x+y;
11+
return 0;
12+
}
13+
14+
As the reader might have observed coding in C turns out to be much more easy than assembly, because it's less verbose and each line of code is more intuitive compared to either assembly or binary.
15+
16+
But there is a trade-off between the performance offered by assembly language and C.
17+
18+
* Coding in assembly sometimes is not intuitive and requires a lot of time to understand the code compared to higher level languages such as C, which is less verbose and is more descriptive.
19+
20+
* The entire code in assembly language could turn out to be monstrous in some stage cannot, because of which it cant't be handled or maintained easily.
21+
22+
* Manually writing in assembly language for large programs such as an OS for instance can be frustrating.
23+
24+
## Birth of the higher-level languages
25+
26+
Even though assembly language offers high performance it cannot be effectively used to build user applications, because a higher abstraction is necessary to do so.
27+
Also it is not "programmer friendly" in the sense that it still remains a low level language and can be difficult to grasp or understand.
28+
Hence a need for abstracting assembly language itself arises which is both understandable and "programmer friendly".
29+
30+
From this need new assembly languages were born with a higher abstraction, which were more "programmer friendly" than the initial low level assembly languages but they still remained assembly languages.
31+
32+
Afterwards even higher level languages were introduced which acted like an abstraction of assembly language itself. One of the most notable languages among these is C.

book/languages/assembly/history.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Creation
2+
3+
The first Assembly Language was developed by Kathleen Booth in 1947 for the ARC2 at Birkbeck, University of London following work with John von Neumann and Herman Goldstine at the Institute for Advanced Study.
4+
After this several other variations of Assembly Language have been developed and higher abstractions of the language have been created.
5+
6+
## Purpose
7+
8+
Back in the day it was extremely tedious, error prone and time consuming for programmers to "code" in binary. Even the smallest of the tasks required huge amount of thinking and calculations. Building huge programs back then was a mammoth task. So the assembly languages have been created to get rid of.
9+
The very tedious part of coding in binary was relieved by assembly and it helped concentrate more on the problems.

book/languages/assembly/intro.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Introduction
2+
3+
Assembly language or an assembler is a low-level programming language, which is the
4+
lowest abstraction of machine languages (binary code).
5+
6+
There is a strong, but not complete correspondence between assembly and machine instructions.
7+
The Assembly Language is not completely portable in the sense that its syntax and semantics
8+
vary with computer architecture, but the core concepts, essence and
9+
functioning remain the same.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Why Assembly?
2+
3+
Consider this instruction, where we have to add the two numbers 1 and 2.
4+
5+
**Assembly:**
6+
7+
```assembly
8+
addi x5 x0 1
9+
addi x6 x0 2
10+
add x7 x5 x6
11+
```
12+
13+
**Binary:**
14+
15+
```binary
16+
000000000001001010000000000100110000000000100011000000000001001100000000011100101000001101100011
17+
```
18+
19+
**Binary in human readable format:**
20+
21+
```binary
22+
0000000 00001 00101 000 00000 0010011
23+
0000000 00010 00110 000 00000 0010011
24+
0000000 00111 00101 000 00110 1100011
25+
```
26+
27+
**The architecture used in the examples is RISC-V (32 bit).**
28+
29+
The purpose of an assembly language can easily be seen with the help of the above example. Assembly language with the help of its syntax makes it easier to code and not worry about trivial tasks such as opcodes, address calculations, etc. Mistakes if any can easily identified in assembly
30+
rather than in binary. Imagine finding such mistakes in a pool of 0's and 1's!

book/languages/python/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Python
2+
3+
> This chapter has been authored by Gadila Shashank Reddy.
4+
5+
Now is the chapter on python, one of the most
6+
popular languages with applications in a wide variety of fields. Read to find out more on what makes
7+
python so popular that it is referred to as the "fastest growing major programming language".
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Where would you use python?
2+
3+
Python doesn't have a target audience. It can be used for multiple purposes and there are several
4+
libraries and frameworks built to simplify specific applications. Some fields where python can be best
5+
used are:
6+
7+
*Examples of libraries/frameworks built for the particular application are given in brackets.*
8+
9+
* Web development (Django, Flask)
10+
11+
* Data analysis (Numpy)
12+
13+
* Machine learning (TensorFlow)
14+
15+
* Computer Vision (OpenCV)
16+
17+
* Game development (Pygame)
18+
19+
* Web Scraping (Beautiful Soup)
20+
21+
* GUI development (PyQt)
22+
23+
* Rapid prototyping
24+
25+
and the list goes on and on...
26+
27+
Python can also be used in places where precise numerical calculations are required because precision
28+
in calculations in python is limited only by physical resources and not the language. This feature
29+
makes python one of the best language to be used in scientific works.

0 commit comments

Comments
 (0)