Advantages of Python over C++

--Originally published at Luis Santana's Blog

Python is an object oriented script language while C++ is an object oriented compiling language. But they are very different languages and  their differences among them aren’t really advantegous.

As Murphy said:

  • Memory management: C++ doesn’t have garbage collection, and encourages use of raw pointers to manage and access memory. It differentiates between heap and stack, and it requires you to attend to values versus references. C++ requires much more attention to bookkeeping and storage details, and while it allows you very fine control, it’s often just not necessary.
  • Types: C++ types are explicitly declared, bound to names, checked at compile time, and strict until they’re not. Python’s types are bound to values, checked at run time, and are not so easily subverted. Python’s types are also an order of magnitude simpler. The safety and the simplicity and the lack of declarations help a lot of people move faster. Speaking of…
  • Language complexity: C++ is a beast of a language. The spec is 775 pages of language legalese, and even the best C++ developers I’ve known can be caught up short by unintended consequences in complex (or not so complex) code. Python is much simpler, which leads to faster development and less mental overhead.
  • Interpreted vs compiled (implementation): C++ is almost always explicitly compiled. Python is not (generally). It’s common practice to develop in the interpreter in Python, which is great for rapid testing and exploration. C++ developers almost never do this, gdb notwithstanding.

C++ tries to give you every language feature under the sun (circa 1990, at least) while at the same time never (forcibly) abstracting anything away that could potentially affect performance.

Python tries to give you only one or a few ways to do things, and those ways are designed to be simple, even at the cost

Continue reading "Advantages of Python over C++"

Python, it’s origins

--Originally published at Luis Santana's Blog

In case you asked yourself, where does Python comes from, who created it or any other question similiar to this. Here’s the explanation of Python.

Python was conceived in the late 1980s, and its implementation began in December 1989 by Guido van Rossum at Centrum Wiskunde & Informatica (CWI) in the Netherlands as a successor to the ABC language capable of exception handling and interfacing with the operating system Amoeba Van Rossum is Python’s principal author, and his continuing central role in deciding the direction of Python is reflected in the title given to him by the Python community, benevolent dictator for life (BDFL).

About the origin of Python, Van Rossum wrote in 1996:

Over six years ago, 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 ABS that would appeal to Unix/C hackers I chose Python as a working title for the project, being in a slightly irreverent mood ..

Python 2.0 was released on 16 October 2000 and had many major new features, including a cycle-detecting garbage collector and support for Unicode. With this release the development process was changed and became more transparent and community-backed.

Python 3.0 (which early in its development was commonly referred to as Python 3000 or py3k), a major, backwards-incompatible release, was released on 3 December 2008 after a long period of testing. Many of its major features have been backported to the backwards-compatible Python 2.6.x and 2.7.x version series.


“Hello World” origin

--Originally published at Luis Santana's Blog

You may have asked yourself where does the famous “Hello World” comes from. To explain this I will quote Herbert, “Brian Kernighan actually wrote the first “Hello, World!” program as part of the documentation for the BCPL programming language developed by Martin Richards. BCPL was used while C was being developed at Bell Labs a few years before the publication of Kernighan and Ritchie’s C book in 1972.

As part of the research for a book I was writing about the Alice programming environment, I corresponded with both Prof. Kernighan at Princeton and Martin Richards at Cambridge (when I was teaching a seminar there in the 1990’s). They helped me track down the first documented use of code to print the message “Hello, World!” Brian Kernighan remembered writing the code for part of the I/O section of the BCPL manual. Martin Richards — who seems to have a treasure trove of notes, old documents, etc. — found the manual and confirmed that the this was the original appearance of the program. The code was used for early testing of the C compiler and made its way into Kernighan and Ritchie’s book. Later, it was one of the first programs used to test Bjarne Stroustrup’s C++ compiler.

It became a standard for new programmers after it appeared in Kernighan and Ritchie, which is probably the best selling introduction to programming of all time”.

 

This “Hello World” has become in a global standard, that was the first thing I did in Ken’s class.


Differences between Python 2 and Python 3

--Originally published at Luis Santana's Blog

We can summarize it as this: Python 2 is legacy, Python 3 is the present and future.

In my opinion, I think the main difference is the print function, it is different enough that the same script won’t be able to run in Python 2 and Python 3. In Python 2 you could print “Hello”  and in Python 3 you must write print (“Hello”).

Esentially, the print statement has been replaced with print () function.

Something you should consider too is that all the libraries you used to work with in Python 2 won’t work .

We can say that the future of Python is towards Python 3, but it will take some time to get there, because it need time so other people will get used to Python 3 and start doing the stuff they had in Python 2 but for Python 3.