Why Python?

Over the last few years I have been looking at various languages.  Many have great strengths, some have great weaknesses, and some are just right.  Last year I decided to start learning some Python, so I searched for a good book.  What I found was an excellent beginners book here.  Not only is the book a great reference, it’s open source.  Anyone is allowed to modify the book and redistribute.  Actually, the author of the Python version did just that.  The original book was written by a teacher to teach Java. Allen Downey, Jeff Elkner, and Chris Meyers worked Open Source magic on words, eventually publishing “How to Think Like a Computer Scientist: Learning with Python.”  I highly recommend this book as a gentile guide from other languages.

I believe Python should be a first language to introduce budding hackers to the world of coding.  Several universities teach a C-type syntax language as an intro.  Not that C-style is bad, I happen to like curly braces, but beginners always have a hard time with the approximate five lines of code needed to print “Hello World” on a console.  Beginners begin by learning debugging before anything is printed to the screen.  What to import or include, where to put the first curly brace, when to use main(), when to use semi-colons, and much more.  Python allows a beginner to focus on the logic of the code, not the syntax, except for one caveat, whitespace.  Sometimes curly braces are a friend, especially when dealing with blocks of code.  But lets forget about this tiny flaw. *smile*

Beginners can learn to use logic and work with flow control without the headache of the five line overhead.  What five lines?

#include  

 
int main()
 
{ 
std::cout << "Hello, world!n"; 
}

I guess everything could be put on one or two lines, but I’m for readability.  The above code is C++ whereas Python would simply be:

print(“Hello, world!”)

This example is using the new print from Python 3, for earlier versions, simply replace the parenthesise with spaces.

Once the beginner learns standard logic flow controls, then introduce them to the C-style languages.  I began learning at the university with C#, then learned some Java, and took two semesters of COBOL.  Although, I began writing code many years ago in a dead language called GW-Basic.  I just didn’t follow the path of the hacker until later. 

Ease of learning and use are the first reasons ‘Why Python?’, some other reasons: the language works on most every environment, is free to download and use, has a huge repository, know as the internet, on hand for code libraries and books.  This blog post is simple.  I’m not here to change anyone’s mind.  But this post will lead more posts about Python and some uses I’m planning.  Next I plan to write some about YAML (Yet, Another Markup Language) and JSON, and why XML fails at marketing.

P.S.  I forgot to mention, I’m a huge fan of readable code and variables that clearly state their objective.  Readability is one reason I didn’t choose from a host of other coding options.

One thought on “Why Python?”

  1. Agreed on all points. I'm glad I half-learned python first, then learned the basics of C, then learned python more in-depth– that gave me really good insights into strengths, weaknesses, and the basic logic of languages. 🙂

    And yes, please, bring on the YAML, and get into some details of the hows and whys of it please. 🙂 It looks interesting, but either tutorials I can find aren't that great or it's too simple and I'm trying to make it too difficult.

Comments are closed.