Why Python is The Best

At the Geek Ranch we recently made a decision to implement some software in Python. Or, more accurately, I decided and there was no disagreement. Then Python gets picked as the best scripting language in the LJ Readers' Choice survey. That inspired me to write this article (and get ready for Perl and Ruby fans to start yelling at me).

To understand my position, you need to understand my background and experience. Yeah, this is is going to be long but I think it is necessary.

The first programming language I learned was Fortran with Format over 40 years ago. Fortran quickly evolved and I learned Fortran II, Fortran IV and Fortran V. For you Fortran folks, I need to explain Fortran V.

Based on Fortran IV, Fortran V was implemented on Univac 1100-series hardware (and probably other Univac systems such as the 494) by Computer Sciences Corporation in the late 1960s. It extended Fortran to include parameter statements—basically a way to define constants, conditional compilation, and statement functions—basically macros that produced in-line code.

In 1970, I went to work for Computer Sciences Corporation working on systems testing of a new timesharing system they were developing called CSTS. While some of my work was done in assembly language, the majority was done in Fortran V. For me, it was the "best scripting language" I had available. (It was also the only language I had available on CSTS itself for a while.)

Except for toying with Sympl, a language designed by CSC for systems programming that I used on CDC Cyber systems, Fortran remained my primary high-level "solve the problem" language until 1980. The other languages in my life were assembly language for various processors including the Motorola 6800, 6809 and 68000.

The one diversion from that was a bit of time with Pascal. This was somewhat accidental. I secured a part-time job teaching a Programming Style class at The Evergreen State College. The course outline made sense to me and the interview went well. The surprise was when I accepted the job and my boss said, "oh, here is the text book we use". While the class was mostly theory, Pascal was "the tool" used to put theory into practice.

Armed with a Pascal compiler for my SWTP 6809 system, I learned Pascal two weeks ahead of my students and all went well. Pascal was designed to be a teaching language and it made a lot of sense. It, for example, forces you to jump through hoops to do type conversion preventing programming surprises.

In 1980 I got a job with a company that made semiconductor wafer probers. Their past systems had been controlled with little more than a bunch of hardware logic but we were going to make the ultimate prober. That included the ability to memorize the layout of a chip and then automatically align the prober to the chips when a new die (a round silicon wafer with multiple chips on it) was placed on it.

Being the software guru, I needed to decide in what language we would implement this system. I initially thought Pascal would work and ordered two different Pascal compilers for our CP/M system. To make a long story short, Pascal wasn't ready for prime time. To make it into a "production language" it was extended badly.

This lead me to a new decision: we needed a UNIX system and we would develop in C. My boss believed me (he didn't know anything about software, UNIX or C) and I ordered everything. What he didn't know at the time was that I had never seen a UNIX system and had never programmed in C.

UNIX and C proved themselves, the project was a success and I moved on to the next company to pretty much do the same thing. But, as I got more comfortable with UNIX I decided I needed a higher level language for some of my work. After looking around a bit, I decided awk was that language. It was and, to me, still is an amazingly useful language if what you have is some character data that needs to be massaged. I even went as far as writing a web application which allowed customers to inquire as to the status of their order in awk just to prove it could be done. And it wasn't even painful to do.

In a more "awkish" venture, my old boss who was now at a company that made microprocessor hardware emulators, asked me if I could do a project for him. They were converting from a 6809-based emulator to a 68000-based one and needed to convert thousands of lines of instruction set encode and decode tables from 6809 assembly language to C. He had estimated a month to do the task assuming it would be done in C. I did it in about three days using awk and sed.

So, I was now a C programmer and an awk scripter. The problem was that there was a gap in my toolset. Unlike Fortran V where I even found a way to build and execute assembly language code within the Fortran framework, if I wanted to do anything other than process characters, I had to write the code in C. In most cases this wasn't bad but sometimes 99% of a task could easily be done in a few lines of awk but would require a lot of C.

Well, in 1999 I had the opportunity to interview Guido von Rossum, the father of Python. While I had already been playing with Python, my chat with Guido (a lot more than an interview) inspired me to get more serious. The interview actually addresses what is wrong with awk and Perl so I won't go into more detail here.

While my life in the last almost ten years has not been primarily programming, I do turn to Python as my tool of choice. Some of what I have done can be called scripting but not all. For example, I implemented a credit card processing system for Visanet (the nastiest of all possible credit card protocols) in Python. I also have done some work with Karrigell, a web framework implemented in Python.

Ok, I talked about awk's limitations and Guido helped me beat up Perl in the interview. Note that my default comment about Perl is that if you don't know regular expressions and UNIX/Linux shell programming, Perl is not the best way to get to knowing a scripting language. So, what's left? The obvious choice is Ruby.

Well, this is where my long, boring history of my Pascal experience fits in. First, let me say that I like Ruby. It is a nicely-designed and very clean language. If you don't already know Python, you should seriously give it a try. But, is it better than Python? I think not.

Ruby, while not really new, just hasn't done as much work as Python. Much like Pascal 30 years ago, Ruby looks good on paper. Pascal's claim to fame was that there were no surprises. Ruby's is that it is pure object oriented. Those are both good things. But, as Ruby does more heavy lifting, it seems likely to me that it will have to evolve. That is, its purity will get subverted much like the purity of Pascal did.

In any case, I will stick with Python. It has certainly evolved over the years but that evolution feels like taking a solid base, seeing what makes it more useful and cleanly handling the evolution. To me, Python 2.5 is easier to explain to someone that Python 1.5.2.

______________________

Phil Hughes

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Drawn to the Python Philosophy

Anonymous's picture

One thing that drew me to Python was the philosophy that there should be one best way to do everything. This fits my personality very well being someone who is often overwhelmed by the endless possibilities in software design.

not inspiring you should

Anonymous's picture

not inspiring
you should have named your article "Why Python is The Best FOR ME"
but i agree that python is the best

Ridiculous. I will type

Anonymous's picture

Ridiculous. I will type three times more to prove assembler is the best

OK, so why _is_ Python the

FF3's picture

OK, so why _is_ Python the best?

I thought I missed it the first time, so I reread your article.

Nope. Not in there. "Why Python is The Best" just never answers the question it poses, although there was a nice explanation of Fortran V "for you Fortran folks".

You got me this time, Phil. But never again. I think this is why I stopped reading your articles - No content.

So?

Paulo Junqueira's picture

So, but, why python is better? Letś get down on the subject. Actually I agree with you, pointing ruby on it equally, but take your reasons instead of telling us your carrier! hehe, sorry to be honest.

Ok, grandpa Simpson

Anonymous Coward's picture

Geez-o-pete, I guess Python is "best" for people who are not very good at getting their point across.

In his next post, Phil will be telling us about how it was the style to wear an onion on your belt...

-Bart

How is this an article on why python is the best?

Michael's picture

How is this article about Python being the best? Its a trip down memory lane!

There's no argument or supporting facts on WHY Python is the best. Zero. Call this article something else, because its not about Python being the best. Its about Phil's past experience in the good old days of 68000's and Awk.

There's only a comparison to Pascal with Ruby, and a very weak one at best.

Where's the comparison with the other scripting languages?

Honestly, this article feels like it was pulled from someone's personal blog whose title was "The Good Old Days Before Python." Or at least, a partial introduction on a job application.

C'mon Linux Journal, get better writers! Not to mention, get some better editors to! They seem to be falling down on the job.

I'm very disappointed in this article with its lack of relevance, facts, and focus.

I like trips down memory lane

Masinick, Brian's picture

Well, the article did not really go into very much detail about what makes Python well suited to a job, other than to detail Pascal's limitations and to suggest that Ruby has similar limitations, but it was a very interesting trip down memory lane.

Personally, I got my programming start in 1973, working in BASIC on a school district minicomputer accessed by a teletype device.

My first in depth programming was in a FORTRAN IV implementation that was essentially from the FORTRAN 66 specification - no "structured programming" constructs we appreciate today. However, in my first year as an undergraduate student, we used a FORTRAN preprocessor, which provided structured If...Then...Else and Do...While constructs. Shortly thereafter, I used PL/1, Algol 60, and Pascal. Believe it or not, I found PL/1 to be the most complete language for actual development use, and indeed, when I graduated, my first every day programming language was PL/1. I also spent about eight months as a COBOL maintenance programmer before finding an advanced development research project to assess the state of personal computers and small department systems - with Windows, UNIX, minicomputers, and PCs. I learned C at that time and used it on both the PC and the UNIX systems. I also learned the Bourne Shell at that time, and from that time forward spent more time programming in shell and interactive languages more than traditional programming languages.

To this day I like programming in Bash the best, but when I want a graphical interface in my tool, I often write in Bash or C and use small TCL/Tk programs to provide the glue to bring it all together. Works well for me, fast and easy.

thank you

Anonymous's picture

thank you

I second that motion

Hans Bezemer's picture

For me there are a few things that are important with a programming language:
- Productivity
- Maintainability
- Speed
- Catching errors
- Reusability
- Strengths (function set)
- Liberty
- Extensibility
- Portability
- Size

Python scores very low on the size and liberty score. It even defines how to layout your code (sic) and completely dedicated to the object oriented paradigm ("Object orientation is a particular bad idea that could only have been invented in California" - Edsger Dijkstra)! It is huge. Speed doesn't impress me as well (unless you use some addons).

For general programming I use Forth, which is a great tool for a multitude of problems. Not quite easy to learn, but when you have, you can program a dedicated XML parser in a single legal page within an hour. My version of the language is able to compile a fully functional UUENCODE in 256 bytes of bytecode. The VM is twice as fast as Python.

When I need a faster compiler or need to program system stuff there is nothing like C. It is fast, portable and produces fast and tight code with modern compilers that few other languages can beat.

For glueing the whole thing together, I like shell programming. It is still a very capable language that can be interfaced very nicely.

For webprogramming I use PHP. I know, there are issues with PHP, it is not the "cleanest" language around, but then again, the whole webprogramming is a mess. Which idiot invents a programming environment that exists of HTML (how many different versions?), SQL (how many dialects?), Javascript, PHP (how many - incompatible - versions?) and as many interpreters and programming paradigms?

So far, I've done very nicely without Python and I intend to do so in the near future ;-)

Hans Bezemer

on Python

Lach's picture

"So far, I've done very nicely without Python and I intend to do so in the near future ;-)"
Dude, have you worked for a big corporation that needs you to build something for a week or so...
Probably not,"PHP, C, Forthran,.." This is old school!!! Python or Ruby put even Java to shame

I second that motion

Hans Bezemer's picture

For me there are a few things that are important with a programming language:
- Productivity
- Maintainability
- Speed
- Catching errors
- Reusability
- Strengths (function set)
- Liberty
- Extensibility
- Portability
- Size

Python scores very low on the size and liberty score. It even defines how to layout your code (sic) and completely dedicated to the object oriented paradigm ("Object orientation is a particular bad idea that could only have been invented in California" - Edsger Dijkstra)! It is huge. Speed doesn't impress me as well (unless you use some addons).

For general programming I use Forth, which is a great tool for a multitude of problems. Not quite easy to learn, but when you have, you can program a dedicated XML parser in a single legal page within an hour. My version of the language is able to compile a fully functional UUENCODE in 256 bytes of bytecode. The VM is twice as fast as Python.

When I need a faster compiler or need to program system stuff there is nothing like C. It is fast, portable and produces fast and tight code with modern compilers that few other languages can beat.

For glueing the whole thing together, I like shell programming. It is still a very capable language that can be interfaced very nicely.

For webprogramming I use PHP. I know, there are issues with PHP, it is not the "cleanest" language around, but then again, the whole webprogramming is a mess. Which idiot invents a programming environment that exists of HTML (how many different versions?), SQL (how many dialects?), Javascript, PHP (how many - incompatible - versions?) and as many interpreters and programming paradigms?

So far, I've done very nicely without Python and I intend to do so in the near future ;-)

Hans Bezemer

I don't really agree with

Sephi's picture

I don't really agree with you Hans.
First of all, I think the way Python limits the "liberty" of programming is more a good thing than a bad one. The "There should be one-- and preferably only one --obvious way to do it" philosophy is great because you know you'll be able to understand any code you find on the internet, which, I think, is very important (especially when you use open source programs). With a philosophy of "There is more than one way to do it" (I believe it's the Ruby philosophy but maybe I'm wrong), it becomes harder to read code from the others and adapt it. Of course, with the Python philosophy you're forced to follow some rules and it could be a little disconcerting at first sight. Another thing that makes Python powerful compared to Ruby is the availability of lots of libraries.

About webprogramming, I don't agree that the whole webprogramming is a mess. If it wasn't so flexible (separating HTML from SQL from javascript and PHP), the web would be as monolithic as some OS are (I let you guess which OS I'm talking about). Combining all these technologies into a unique product would kill the freedom of choosing every brick of the wall you're building. But I agree with you that putting together these technologies is sometimes a big mess. When programming in javascript, I've always got the feeling that what I'm doing is not clean. Same thing with PHP, which is a pretty dirty language, compared to Python.

If you're interested in Python, you should try the Django framework which is by far the best web framework I've ever used.

Was a mess, is a mess..

Hans Bezemer's picture

No, it is a mess. I agree that choosing the building blocks is an advantage, but it isn't achieved by a proper and clean binding, but actually mixing the languages. Proof: I have to know them all to make a page. If I wouldn't, it would be clean. Communication between the counterparts is fuzzy, unclean or even non-existing. Proper separation is nice too, but in real life it is seldom achieved (so-called "business logic", which seeps in the interface handling). I call that a mess by any measure.

Hasty Generalization!

chromatic's picture

The "There should be one-- and preferably only one --obvious way to do it" philosophy is great because you know you'll be able to understand any code you find on the internet...

In my experience, understanding a piece of code has very little to do with enforced indentation and adherence to current community norms (just try to tell me that the one obvious way to do things in Python hasn't changed at all in even the past two years!) and everything to do with problem domain understanding, the use of clear and well-chosen identifiers, proper factoring, automated testing, and many other good software development practices which Python does not enforce.

Agree!

GaRaGeD's picture

Django is the best example of python's capabilities, I haven't done anything big with python, or any other language, but things I have done with python are always elegant, readable, robust, flexible, and they don't take tons of lines or hours to develop.

You can do a gtk/glade calculator easily, a XML based chat easily, a nice website with django really fast, the list just go and go.

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix