Python – the first and last language you’ll ever need
Posted 12 July, 2007 by Juergen in Development, Python, education, misc
Ok, the title of this post is a bit controversial, I know. I’m aware that there are very good reasons why for particular tasks you would want to use particular (other) languages. However, I started to think about writing this post here when during the heated discussion that took place on reddit.com about my recent Python vs. Java speed comparison post I learned about a new way to describe Python: Executable pseudo code.
I should mention here that at SnapLogic we are developing our data integration server in Python, so obviously I have a strong interest in this language and in spreading the word about it.
Apparently, the comparison between Python and executable pseudo code has been made before, I just wasn’t aware of it. Nevertheless, I think this is an excellent description! Ever since I started to work with Python I always wondered how to best convey that funny feeling that I get with this language: The feeling that there just isn’t much standing in the way between my ideas and a running program. Compared to other languages that I was familiar with, mostly the likes of C/C++, Java, Pascal, Assembler (all the traditional ones), translating an idea into a working program appeared downright trivial. The same is probably true for a number of other dynamic languages, but Python was my first exposure to the world of power scripting languages.
So, if Python can be seen as executable pseudo code then one would think that indeed it should be ideally suitable for beginners to learn the concepts of programming. Conveniently, you can cover all the important programming and development concepts with Python, including object-oriented programming.
When we talk about teaching programming, we are not only talking about a university level course. I am also considering high-school or even younger students. I have taught programming before on several occasions. I used BASIC or even C. The nice thing about BASIC was that the very first running program (‘Hello World’) was easily written and explained:
10 PRINT "Hello world!"
Everyone could understand every single aspect of that ‘program’ without much difficulty, which helps to put the mind of the student at ease. But of course, BASIC has other limitations, and it would be nice if a more ‘industrial strength’ language could be used for teaching. So, how about C? I have actually used C in a beginner’s course before, and it worked reasonably well. But here is what ‘Hello World’ now looks like:
#include <stdio.h>
main()
{
printf("Hello world!\n");
}
Hm. Now you either need to introduce include files, functions and special characters, or you need to hand-wave a lot. It is much more satisfying for a beginner to be able to understand all he/she is doing. It can be nerve wrecking if you need to wade through more and more stuff that ‘we will get to later’ and to keep all of that in mind. It’s good to understand what’s going on.
After a while, Java appeared on the scene, and everyone thought that this is THE language to learn and to teach. So, what does our example look like in Java?
class HelloWorld
{
public static void main(String args[])
{
System.out.println("Hello World!");
}
}
Oh dear! Now I have to explain classes, member-access modifiers, class methods, argument passing, arrays… Or I need to hand-wave over a whole lot of stuff. Not at all good for a beginner.
This then brings me back to Python. What does ‘Hello World’ look like in Python?
print "Hello World!"
Whoa! That’s even simpler than BASIC! So, with Python we have a language where you can get started in teaching programming without having to hand-wave or explain too much other stuff. You can just get going. Very often you can simply write down your ideas, and it ends up being running code. This of course becomes interesting also for university level courses, where the concept of pseudo code is usually introduced.
Importantly for the teacher the same language also allows you to introduce lists, hash-tables, functions, classes, objects, (a little bit of) functional programming and almost any other concept you would like to cover in the more advanced stages. Interestingly, once I started to search around to see if other’s had similar thoughts I came across a number of other postings and opinions, which were discussing this. For example here. So, I’m certainly not the first one who thought about Python as a beginner’s language.
However, the title of this post is Python – the first and last language you’ll ever need. As discussed, it’s a good language to introduce programming and many of its concepts. But is it also a good language to build industrial strength, real-world applications from? Well, we know the answer to this already. Just ask Google and the many others who have had great success with it. We here at SnapLogic also can confirm the ease with which it enables the development even of complex applications.
So, I can imagine that entire career paths should be possible where indeed Python is the first and last language. I’m not actually recommending it, though: Learning other languages will broaden your perspective, and will give you more choice when selecting the right tool for a task. Nevertheless, with Python we seem to have a language that is equally suitable for teaching programming, as well as for the development of large-scale applications.
That, I think, is quite remarkable.
John Fisk Says:
July 12th, 2007 at 4:25 pm
Wow, what a great sell.
BTreeHugger Says:
July 12th, 2007 at 4:36 pm
Friendly note. You might want to replace:
#include
with:
#include <stdio.h>
in your markup.
Juergen Says:
July 12th, 2007 at 4:42 pm
John Fisk: Thanks!
BTreeHugger: Yes, I had just noticed that and had fixed it a moment ago. Looks like your response even was butchered for the same reason. It can only be read when you look at the raw HTML.
emacsen Says:
July 13th, 2007 at 2:50 am
Python is a great language, but to argue it’s the last language you’ll ever need…
I’ve been a Python programmer since 1999, and I can tell you that after years of Python, I’ve begun to see the holes in the language, and am moving on.
Is Python more powerful than most languages? Absolutely. Is it better than Java, I can say it’s most certainly better than Java.
But I can do more with Lisp than I could with the best Python, even after programming in Python for eight years and only knowing Lisp for a few months.
Christian Says:
July 13th, 2007 at 2:57 am
You missed the backslash for the newline in the c example (or your blogging software forgot to escape it when outputting)
Juergen Says:
July 13th, 2007 at 9:57 am
emacsen: Sure, no language is perfect. And Lisp is peculiar enough so that for a number of people it is not really a choice they consider. Python has great library support (maybe Lisp has as well, I don’t know), and so you normally can just get stuff done.
Nevertheless, consider the second sentence of my post: I am saying right up front that there will always be good cases for other languages. Consider the middle of the last paragraph in my posting.
What I would say, though, is that substantial applications are successfully written in Python and therefore it certainly seems possible to have it used at any stage during a career.
pcdinh Says:
July 13th, 2007 at 12:21 pm
I don’t know Python good enough but I can say that in dynamic language pool, PHP is superior than Python in web programming. However, it is not perfect. People in PHP world try to patch it with many enterprise-level framework lik Zend Framework (http://framework.zend.com), SolarPHP (http://solarphp.com), Symfony (http://www.symfony-project.com/). it is far easy to develop web application at any scale with PHP and with the existence of those frameworks, you will find it even easier. However, those framework force you to develop web application in OOP, MVC style.
pcdinh
Juergen Says:
July 13th, 2007 at 12:28 pm
pcdinh: I’m not a PHP expert, so I can’t say whether it is indeed more suitable for that particular area or not. However, I understand that there is quite a number of web application development framework, templating engines and such available for Python, which people have used to develop extensive web applications…
Shadowfiend Says:
July 14th, 2007 at 4:40 pm
PHP is still coming to terms with its toy-language status of yore — both in terms of reputation and in terms of language design. Python doesn’t really seem to have that problem. I’m a Ruby fan myself, but that doesn’t mean I don’t appreciate Python; at the end of the day, they’re similar enough, really.
I think the title of the post is definitely misleading, though. The point you _actually_ make, which is that Python is a language that can follow you from beginnings to real world applications, is a good one. But I dislike the idea that anyone would learn just one language (though many people do). Admittedly, when I started programming I started right off with two languages, which quickly branched to four, and then to five, and then to six, seven, and more. To me, learning another language isn’t just about having more tools in your toolbox, it’s also about seeing the extra possibilities in languages you already know. And that’s always important.
alwaysbule Says:
July 24th, 2007 at 6:56 pm
python ranked seventh by all of language…It’s so good…I will learn about it