Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions book/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,38 @@

## Languages

* [Assembly Language](languages/assembly/README.md)

* [Introduction](languages/assembly/intro.md)

* [History](languages/assembly/history.md)

* [What it solves?](languages/assembly/what_it_solves.md)

* [Advantages](languages/assembly/advantages.md)

* [Disadvantages](languages/assembly/disadvantages.md)

* [Conclusion](languages/assembly/conclusion.md)


* [Python](languages/python/README.md)

* [Introduction](languages/python/intro.md)

* [History](languages/python/history.md)

* [What it solves?](languages/python/what_it_solves.md)

* [Advantages](languages/python/advantages.md)

* [Disadvantages](languages/python/disadvantages.md)

* [Few more points](languages/python/misc.md)

* [Conclusion](languages/python/conclusion.md)


* [C++](languages/cpp/README.md)
* [Introduction](languages/cpp/intro.md)

Expand Down
6 changes: 6 additions & 0 deletions book/languages/assembly/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Here comes the chapter on Assembly Language

> This language chapter was authored by Gadila Shashank Reddy.

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.
So let's get started :)
21 changes: 21 additions & 0 deletions book/languages/assembly/advantages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Where would you use assembly ?

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.
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.

> 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.

The assembly language can be used in these types of application:

* To build software which requires serious machine level optimizations or to beat compilers in code optimization. \
For eg.: System software in an OS (not needed though as modern compilers do a pretty good job).

* In embedded programming where space is limited to an extent that higher level languages
(like C) can use more space then required or actually present.

* To access hardware features which are either platform specific or too uncommon and not
available for optimization in higher languages such as C.

* Written for custom hardware that doesn't have a mechanism to convert high level code
into binary. The Apollo 11 lunar mission is an example of this as it used code
written in assembly.
15 changes: 15 additions & 0 deletions book/languages/assembly/conclusion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# A final word

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.

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.

## Sources and reference

- [Quora](https://www.quora.com/Why-is-Assembly-Language-used)

- [Wikipedia](https://en.wikipedia.org/wiki/Assembly_language)

- [Apollo-11 Guidance computer source code](https://github.com/chrislgarry/Apollo-11)

- [RISC-V opcodes](https://github.com/riscv/riscv-opcodes/blob/master/opcodes)
32 changes: 32 additions & 0 deletions book/languages/assembly/disadvantages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Shortcomings

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.

> #include<stdio.h>
int main()
{
int x = 1;
int y = 2;
int z = x+y;
return 0;
}

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.

But there is a trade-off between the performance offered by assembly language and C.

* 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.

* 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.

* Manually writing in assembly language for large programs such as an OS for instance can be frustrating.

## Birth of the higher-level languages

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.
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.
Hence a need for abstracting assembly language itself arises which is both understandable and "programmer friendly".

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.

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.
9 changes: 9 additions & 0 deletions book/languages/assembly/history.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Creation

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.
After this several other variations of Assembly Language have been developed and higher abstractions of the language have been created.

## Purpose

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.
The very tedious part of coding in binary was relieved by assembly and it helped concentrate more on the problems.
9 changes: 9 additions & 0 deletions book/languages/assembly/intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Introduction

Assembly language or an assembler is a low-level programming language, which is the
lowest abstraction of machine languages (binary code).

There is a strong, but not complete correspondence between assembly and machine instructions.
The Assembly Language is not completely portable in the sense that its syntax and semantics
vary with computer architecture, but the core concepts, essence and
functioning remain the same.
30 changes: 30 additions & 0 deletions book/languages/assembly/what_it_solves.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Why Assembly?

Consider this instruction, where we have to add the two numbers 1 and 2.

**Assembly:**

```assembly
addi x5 x0 1
addi x6 x0 2
add x7 x5 x6
```

**Binary:**

```binary
000000000001001010000000000100110000000000100011000000000001001100000000011100101000001101100011
```

**Binary in human readable format:**

```binary
0000000 00001 00101 000 00000 0010011
0000000 00010 00110 000 00000 0010011
0000000 00111 00101 000 00110 1100011
```

**The architecture used in the examples is RISC-V (32 bit).**

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
rather than in binary. Imagine finding such mistakes in a pool of 0's and 1's!
7 changes: 7 additions & 0 deletions book/languages/python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Python

> This chapter has been authored by Gadila Shashank Reddy.

Now is the chapter on python, one of the most
popular languages with applications in a wide variety of fields. Read to find out more on what makes
python so popular that it is referred to as the "fastest growing major programming language".
29 changes: 29 additions & 0 deletions book/languages/python/advantages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Where would you use python?

Python doesn't have a target audience. It can be used for multiple purposes and there are several
libraries and frameworks built to simplify specific applications. Some fields where python can be best
used are:

*Examples of libraries/frameworks built for the particular application are given in brackets.*

* Web development (Django, Flask)

* Data analysis (Numpy)

* Machine learning (TensorFlow)

* Computer Vision (OpenCV)

* Game development (Pygame)

* Web Scraping (Beautiful Soup)

* GUI development (PyQt)

* Rapid prototyping

and the list goes on and on...

Python can also be used in places where precise numerical calculations are required because precision
in calculations in python is limited only by physical resources and not the language. This feature
makes python one of the best language to be used in scientific works.
16 changes: 16 additions & 0 deletions book/languages/python/conclusion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# A final word

It is now understandable how python became an immensely popular language and still remains relevant
even today 20+ years after creation. Very few such languages enjoy this status.

## Sources

* [Python (Wikipedia)](https://en.wikipedia.org/wiki/Python_%28programming_language%29)

* [History of python(Wikipedia)](https://en.wikipedia.org/wiki/History_of_Python)

* [Zen of python](https://www.python.org/dev/peps/pep-0020/)

* [Quora](https://www.quora.com/Why-is-Python-so-popular-despite-being-so-slow)

* [Disadvantages of python(Quora)](https://www.quora.com/What-are-the-disadvantages-of-Python)
19 changes: 19 additions & 0 deletions book/languages/python/disadvantages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Disadvantages

Given such a lengthy description on how good is python as a programming language it is easy to be
mistaken that python does not have any shortcomings. Some are listed:

* Since python is an interpreted language and it being built on C/C++ execution speed is slow. But
the benefits/advantages dramatically outweigh this issue.

* Due to the above point python scripts are slower than other scripting languages.

* Database access layers are underdeveloped in python so server side applications involving extensive
database use usually are not written in python.

* Rare run time errors due to the dynamic typing of variables.

* Errors are detected only when the buggy code is executed. In a production environment this could
be a problem.

* Migration from python 2 to python 3 is a real pain.
22 changes: 22 additions & 0 deletions book/languages/python/history.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# History

## Creation

Python started out as a "hobby programming project" in December 1989 by Guido van Rossum at
Centrum Wiskunde & Informatica (CWI) in the Netherlands. Internal releases of python appeared at CWI
in 1990. Python was released to the public for the first time on February 20, 1991.

## Purpose

On how python began written by van Rossum in 1996:

> ...In December 1989, I was looking for a "hobby" programming project that would keep me occupied
during the week around Christmas. My office ... would be closed, but I had a home computer, and not
much else on my hands. I decided to write an interpreter for the new scripting language I had been
thinking about lately: a descendant of ABC that would appeal to Unix/C hackers. I chose Python as a
working title for the project, being in a slightly irreverent mood (and a big fan of Monty Python's Flying Circus). \
— Guido van Rossum

Python was supposed to be a successor to the ABC language capable of handling exceptions and interfacing
with the Amoeba operating system. But with its strong emphasis on being "programmer friendly" it
quickly evolved as a popular choice of language among programmers for development and fast prototyping. The reasons are mentioned in the following sections.
7 changes: 7 additions & 0 deletions book/languages/python/intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Introduction

Python is an interpreted high level programming language for general-purpose programming. It has a
design philosophy that emphasizes on *code simplicity and readability*. It provides constructs that
enable clear programming on both small and large scales. This philosophy has enabled python to become
a very popular language used in fields such as machine learning, big data, artificial intelligence,
web development and in scientific research to name a few.
55 changes: 55 additions & 0 deletions book/languages/python/misc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# More about python

## Zen of python

The Zen of python is a short poem that is embedded in the interpreter summarizing the design philosophy.
Type "import this" and press enter in a python interpretor

```md
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the
rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those! "
```

## How it simplifies development process

Two examples both in python to scrape information about a particular page in wikipedia

Both examples are in python 3

```python
import requests
from bs4 import Beautiful Soup
url = "https://en.wikipedia.org/wiki/History_of_Python"
response = requests.get(url)
soup = BeautifulSoup(response, "lxml")
for i in soup.find_all("p"):
print i.text()
```

```python
import wikipedia
print(wikipedia.summary("History of python"))
```

Now it should be clear how python with its features and awesome libraries simplifies development
process. Note that internally both the implementations perform the exact same set of actions but one is much more simpler than the other.
17 changes: 17 additions & 0 deletions book/languages/python/what_it_solves.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# What it solves

Python is a very simple to learn language and attempts to make development process easier with some
of its powerful features. One of them is modularity. This has helped in the making of extremely useful libraries which
can do a job in the matter of a ready-made function call in python instead of wasting time in developing
the utilities first and then using them in case of other languages.

Several such libraries are created that can be included or "imported" as per need (modularity FTW)
and there are python libraries for virtually anything. This is one major advantage of using python
for developing anything.

> Search for what you want to do and there's bound to be a library for the same.

Python is created to be very flexible in the sense that its core is extremely bare-boned and all its
utilities are included externally in the form of modules or packages and can easily accommodate
changes unlike few other languages that have features included in their core and have limited scope
for major changes without compatibility issues.