{"id":34,"date":"2010-07-24T22:56:00","date_gmt":"2010-07-25T04:56:00","guid":{"rendered":""},"modified":"2017-02-02T23:41:52","modified_gmt":"2017-02-03T05:41:52","slug":"why-python","status":"publish","type":"post","link":"https:\/\/trash80.org\/blog\/?p=34","title":{"rendered":"Why Python?"},"content":{"rendered":"<p>Over the last few years I have been looking at various languages.&nbsp; Many have great strengths, some have great weaknesses, and some are just right.&nbsp; Last year I decided to start learning some Python, so I searched for a good book.&nbsp; What I found was an excellent beginners book <a href=\"http:\/\/greenteapress.com\/\">here<\/a>.&nbsp; Not only is the book a great reference, it&#8217;s open source.&nbsp; Anyone is allowed to modify the book and redistribute.&nbsp; Actually, the author of the Python version did just that.&nbsp; 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 &#8220;How to Think Like a Computer Scientist: Learning with Python.&#8221;&nbsp; I highly recommend this book as a gentile guide from other languages.<\/p>\n<p>I believe Python should be a first language to introduce budding hackers to the world of coding.&nbsp; Several universities teach a C-type syntax language as an intro.&nbsp; 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 &#8220;Hello World&#8221; on a console.&nbsp; Beginners begin by learning debugging before anything is printed to the screen.&nbsp; What to import or include, where to put the first curly brace, when to use main(), when to use semi-colons, and much more.&nbsp; Python allows a beginner to focus on the logic of the code, not the syntax, except for one caveat, whitespace.&nbsp; Sometimes curly braces are a friend, especially when dealing with blocks of code.&nbsp; But lets forget about this tiny flaw. *smile*<\/p>\n<p>Beginners can learn to use logic and work with flow control without the headache of the five line overhead.&nbsp; What five lines?<\/p>\n<blockquote>\n<pre style=\"background-image: none; border: 0px none white; color: black; font-family: monospace,sans-serif ! important; font-size-adjust: none; font-size: 1em; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;\"><span style=\"border-collapse: separate; color: black; font-family: sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;\"><span style=\"font-family: monospace,sans-serif; font-size: 13px; text-align: left;\"><span style=\"color: #339900;\">#include <iostream><\/iostream><\/span>&nbsp;<br \/> <br \/><span style=\"color: blue;\"><iostream><\/iostream><\/span><\/span><\/span><\/pre>\n<pre style=\"background-image: none; border: 0px none white; color: black; font-family: monospace,sans-serif ! important; font-size-adjust: none; font-size: 1em; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;\"><span style=\"border-collapse: separate; color: black; font-family: sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;\"><span style=\"font-family: monospace,sans-serif; font-size: 13px; text-align: left;\"><span style=\"color: blue;\">&nbsp;<\/span><\/span><\/span><\/pre>\n<pre style=\"background-image: none; border: 0px none white; color: black; font-family: monospace,sans-serif ! important; font-size-adjust: none; font-size: 1em; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;\"><span style=\"border-collapse: separate; color: black; font-family: sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;\"><span style=\"font-family: monospace,sans-serif; font-size: 13px; text-align: left;\"><span style=\"color: blue;\">int<\/span> main<span style=\"color: green;\">(<\/span><span style=\"color: green;\">)<\/span><br \/><span style=\"color: green;\">&nbsp;<\/span><\/span><\/span><\/pre>\n<pre style=\"background-image: none; border: 0px none white; color: black; font-family: monospace,sans-serif ! important; font-size-adjust: none; font-size: 1em; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;\"><span style=\"border-collapse: separate; color: black; font-family: sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;\"><span style=\"font-family: monospace,sans-serif; font-size: 13px; text-align: left;\"><span style=\"color: green;\">{<\/span>&nbsp;<\/span><\/span><\/pre>\n<pre style=\"background-image: none; border: 0px none white; color: black; font-family: monospace,sans-serif ! important; font-size-adjust: none; font-size: 1em; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;\"><span style=\"border-collapse: separate; color: black; font-family: sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;\"><span style=\"font-family: monospace,sans-serif; font-size: 13px; text-align: left;\">std<span style=\"color: teal;\">::<\/span><span style=\"color: #0000dd;\">cout<\/span> <span style=\"color: navy;\">&lt;&lt;<\/span> <span style=\"color: red;\">\"Hello, world!<span style=\"color: #000099; font-weight: bold;\">n<\/span>\"<\/span><span style=\"color: teal;\">;<\/span>&nbsp;<\/span><\/span><\/pre>\n<pre style=\"background-image: none; border: 0px none white; color: black; font-family: monospace,sans-serif ! important; font-size-adjust: none; font-size: 1em; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;\"><span style=\"border-collapse: separate; color: black; font-family: sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;\"><span style=\"font-family: monospace,sans-serif; font-size: 13px; text-align: left;\"><span style=\"color: green;\">}<\/span><\/span><\/span><\/pre>\n<\/blockquote>\n<p><span style=\"border-collapse: separate; color: black; font-family: sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;\"><span style=\"font-family: monospace,sans-serif; font-size: 13px; text-align: left;\"><\/span><\/span><\/p>\n<p>I guess everything could be put on one or two lines, but I&#8217;m for readability.&nbsp; The above code is C++ whereas Python would simply be:<\/p>\n<blockquote><p><span style=\"color: #3d85c6;\">print(&#8220;Hello, world!&#8221;)<\/span><\/p><\/blockquote>\n<p>This example is using the new print from Python 3, for earlier versions, simply replace the parenthesise with spaces.<\/p>\n<p>Once the beginner learns standard logic flow controls, then introduce them to the C-style languages.&nbsp; I began learning at the university with C#, then learned some Java, and took two semesters of COBOL.&nbsp; Although, I began writing code many years ago in a dead language called GW-Basic.&nbsp; I just didn&#8217;t follow the path of the hacker until later.&nbsp; <\/p>\n<p>Ease of learning and use are the first reasons &#8216;Why Python?&#8217;, 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.&nbsp; This blog post is simple.&nbsp; I&#8217;m not here to change anyone&#8217;s mind.&nbsp; But this post will lead more posts about Python and some uses I&#8217;m planning.&nbsp; Next I plan to write some about YAML (Yet, Another Markup Language) and JSON, and why XML fails at marketing.<\/p>\n<p>P.S.&nbsp; I forgot to mention, I&#8217;m a huge fan of readable code and variables that clearly state their objective.&nbsp; Readability is one reason I didn&#8217;t choose from a host of other coding options.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Over the last few years I have been looking at various languages.&nbsp; Many have great strengths, some have great weaknesses, and some are just right.&nbsp; Last year I decided to start learning some Python, so I searched for a good book.&nbsp; What I found was an excellent beginners book here.&nbsp; Not only is the book &hellip; <a href=\"https:\/\/trash80.org\/blog\/?p=34\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Why Python?<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-34","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/trash80.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/34","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/trash80.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/trash80.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/trash80.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/trash80.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=34"}],"version-history":[{"count":1,"href":"https:\/\/trash80.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/34\/revisions"}],"predecessor-version":[{"id":53,"href":"https:\/\/trash80.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/34\/revisions\/53"}],"wp:attachment":[{"href":"https:\/\/trash80.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=34"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/trash80.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=34"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/trash80.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=34"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}