Learning Python - Day 2
???????????? ?????????? ?? ??
Experienced Full Stack Engineer | Next.JS, MERN
What is python?
Unique Syntax: Python syntax is unique when compared to other programming languages. Many programming languages is based on the C like syntax which mainly contains curly braces and semicolons. C. C++, Java, JS etc are examples for this. But python is not like these. Because python believes in the principles like beautiful is better than ugly and readability counts. Python relies on significant white spaces. This makes it is easier to code in python and helps to read the code better.
General Purpose Programming Language: Python is a general purpose high level programming language that can be used at multiple domains. So what is a high level programming language. We know that computers can only understand 0s and 1s and the do all the process as 0s and 1s. Normally coding with these 0s and 1s can be said as machine code. The next variation is assembly code which is little better than machine code but not good as high level programing languages. We need to code in machine code in high performance scenarios like in the embedded systems and all. These languages are called low level languages and these are extremely close to the hardware, telling them what exactly they need to do. But writing code this way is very hard to do and maintain. Here is High level programming languages comes, These languages are easy to write and understand and in an human readable level. Here we tells the system to what to do and then the language implementation transforms these high level code in to low level language which does the job that prescribed in the high level language. By doing this, we don't have to worry about the machine specifics and their internals of the computer works, and we can focus on the problem that we have to solve.
领英推荐
Multi-paradigm: programming paradigms are the methods or methodologies that used to write the code. Here python support multiple programing paradigms. Lets first look at what a program is, Lets take the program as an assembly line suppose we are building a car with that assembly line and the input we gives are the components or raw materials for that car. We can say that the final output as the car and the machines or the employees which makes the car using the components and all as the algorithms. That is, Algorithms + Data structures = programs. Python supports multiple programming paradigms including structured programming, Functional programming and Object Oriented programming. In OOPs, the algorithms and the data which acts on those algorithms are packaged as objects. A program is then built by multiple objects which are connected to each other in a certain way or another.
Python is interpreted: Programs comes with two flavors, Interpreted and compiled. To understand more about this let see how a program executes at machine level. A computer CPU only speaks its own language which is ISA, Instruction Set Architecture. Which means the set of instructions that the CPU can understand and execute. By default the code we write is not readable by CPU, Hence we have to translate it into ISA somewhere before the execution. This translation or conversion process is done by two approaches. One is called compiling and this is done by compiled languages. Languages like C++ can take significant amount of time to compile a large program. The other approach is with the interpreted programming languages, these languages have a live translator which transfers the code the way the CPU understands in the real time. This is what python does by default. You don't need to compile your code beforehand, you write a python program and the python runtime will handle the rest no mater what type of CPU it is running on.
Python supports garbage collection: The modern PCs are relying on the architecture called von Neuman Architecture which includes a set of CPU and memory associated with Input, Output, and Mass storage devices. In this architecture the program and the data acts upon it is stored in the computer, In this type of stored program computers as the program runs it reads data to and from the memory. Here if a data stored is no longer used and no action is taken it leads to memory leaks. Think of its as a used plate which is not washed, In languages like C++, the programmer needs to take care in clearing all these data. But in python this cleanup is done by itself automatically and this is known as garbage collection. Because of that we can avoid common memory leaks and problems that associated with that. It also enhances the security of the program too.
Python is dynamically typed: Python is a dynamically typed language. What is dynamic? We don't have to declare the type of variable while assigning a value to a variable in Python. Other languages like C, C++, Java, etc.., there is a strict declaration of variables before assigning values to them. Python don't have any problem even if we don't declare the type of variable. It states the kind of variable in the runtime of the program. So, Python is a dynamically typed language.