Wednesday, December 18, 2013

I'm Using Python Now

I have a confession. All these years I've been evangelizing strongly statically typed languages, I've been going home at night and using Python. Not all the time. It's more like the hungry vegetarian graduate student who comes to the free lunch and discovers only meat dishes. Sometimes you have to do what you have to do.

It started with small things here and there. Because of its libraries, Python has been my go-to language for web scraping jobs. Because of its relative concision to Java and its relative principles to PHP, Python has become my go-to language for web backend programming. And as the web is getting fancier and fancier, I've been doing more of this. As the web has been getting fancier, my research has also involved more of this. Web backend programming. And also Python.

It's true. I'm now doing research programming in Python*. For my PhD, I've been developing Jeeves, a new programming language (and soon-to-be web framework) for automatically enforcing privacy policies. Jeeves makes the programmer's life easier by making the language runtime responsible for keeping track of the privacy policies policies. As this approach happens completely at run-time rather than compile-time right now, it is a great fit for embedding into Python, which does most things dynamically (at run time). And so we switched from the Scala implementation we had been maintaining for a couple of years to Python.

The initial reason for switching to Python was that it is my favorite popular language for web backends. Popularity matters: a web framework is a big piece of software. Lots of people using it usually corresponds to lots of people developing and maintaining it, as well as more documentation for how to use it. I had found both of these to be issues with Scala web frameworks: the two popular Scala web frameworks, Lift and Scalatra, have learning curves that are quite steep. The people-power behind development, maintenance, and documentation also means that it is likely that lots of people will continue using it.

Another reason for the switch was that Python is what the (MIT undergraduate) kids are learning these days. I had thought that I could push Scala upon undergraduate research assistants using the force of my charisma, but this is harder than it might sound. It can take upwards of half a semester to teach even a motivated, bright undergraduate Scala. And given that undergraduates tend to be around for about a semester, that does not leave much productive work time.

After switching to Python, I learned that playing with language features in Python is much faster than in Scala. Much of the time spent coding in the Scala implementation involved an intricate dance with Scala's type system. While it's thrilling never knowing if your new tricks will allow you to save yourself from writing type-casing boilerplate, it takes a lot of time to convince the Scala type-checker that you're doing something reasonable in all cases. Sure, people might object that writing in Python is like swimming without a life jacket or something, but if you're an experienced swimmer trying out different moves in a small body of water, a life jacket is just going to hinder you. Same effect for experienced programmers prototyping a research language...

Something else that I've discovered is that people outside of programming languages seem much more excited about using my language when I tell them it is embedded in Python. These people include computational biologists, computer scientists working in areas other than programming languages (systems; the web), and undergraduates who are trying to work on our research project. A computational biochemist I spoke to who has been using logic programming was quite excited that we were embedding our language in Python. There are already many biological modelling toolkits written in Python, he said, so he could easily envision people picking up our tool.

I'm not saying everyone should use Python instead of Scala. I still stand by everything I say in my other blog post praising Scala: Scala is a less pretty version of the ML family of languages that is potentially way more usable because of its interoperability with Java. If you're trying to do quick-and-dirty language prototyping or trying to build a web framework, however, Scala may not be the tool for the job.

I know I'm not going to be able to check my Python programs before I run them. And I know I'm never going to be able to run my programs super fast. But I've looked into the tradeoff space and made my choice. Good thing Python is for girls.

* In the past few decades, the fashion has been to conduct programming languages research using statically typed languages with strong type systems. The idea is that since we have the compute power to check our programs before our run them, it is irresponsible not to. Thus using something like Python is considered somewhat scandalous.

22 comments:

Philip Guo said...

Jean, you are very brave. I support your decision to come clean.

Anonymous said...

python is great. visit indiago.com

Albert Net said...

I think you would love Ruby if you try it. Hope I could convince my supervisor to use Ruby for my PhD study of building one compiler.

Unknown said...

You can see this:

TIOBE Index for February 2014

February Headline: VB.NET enters top 10 for the first time
Visual Basic .NET has entered the TIOBE index top 10. This is quite surprising for 2 reasons: VB.NET is the successor of Microsofts well-beloved classic Visual Basic 6.0 version. Since VB.NET needed to run on Microsofts .NET platform the language has changed drastically. Many software engineers refused to migrate to VB.NET. For this reason VB.NET has been critized through the years. The other reason why this is surprising is that Microsoft seemed to slowed down further development of VB.NET. For example, the latest Visual Studio version 2013 doesn't contain any new VB.NET language features.

The TIOBE Programming Community index is an indicator of the popularity of programming languages. The index is updated once a month. The ratings are based on the number of skilled engineers world-wide, courses and third party vendors. Popular search engines such as Google, Bing, Yahoo!, Wikipedia, Amazon, YouTube and Baidu are used to calculate the ratings. Observe that the TIOBE index is not about the best programming language or the language in which most lines of code have been written.

The index can be used to check whether your programming skills are still up to date or to make a strategic decision about what programming language should be adopted when starting to build a new software system. The definition of the TIOBE index can be found here.

Feb 2014 Feb 2013 Change Programming Language Ratings Change
1 2 C 18.334% +1.25%
2 1 Java 17.316% -1.07%
3 3 Objective-C 11.341% +1.54%
4 4 C++ 6.892% -1.87%
5 5 C# 6.450% -0.23%
6 6 PHP 4.219% -0.85%
7 8 (Visual) Basic 2.759% -1.89%
8 7 Python 2.157% -2.79%
9 11 JavaScript 1.929% +0.51%
10 12 Visual Basic .NET 1.798% +0.79%
11 16 Transact-SQL 1.667% +0.89%
12 10 Ruby 0.924% -0.83%
13 9 Perl 0.887% -1.36%
14 18 MATLAB 0.641% -0.01%
15 22 PL/SQL 0.604% -0.00%
16 47 F# 0.591% +0.42%
17 14 Pascal 0.551% -0.38%
18 36 D 0.529% +0.23%
19 13 Lisp 0.523% -0.42%
20 15 Delphi/Object Pascal 0.522% -0.36%

Anonymous said...

What do you think of python 3? :O

Unknown said...

Hi, I'm just curious - do you still believe that "It is, however, bad to stay in Pythonland for too long because Python enforces no good programming practices. (You get too far being a bad programmer and so become in danger of never becoming a good programmer.)"

Anonymous said...

thank you for sharing opinion.web programming tutorial
welookups

brightwoods said...

cplusplus programming examples for amateur coders
c++ sample code Creates a file using fstream

nhuthuy said...

Thanks for sharing, nice post! Post really provice useful information!

Giaonhan247 chuyên dịch vụ vận chuyển hàng đi mỹ cũng như dịch vụ ship hàng mỹ từ dịch vụ nhận mua hộ hàng mỹ từ website nổi tiếng Mỹ là mua hàng amazon về VN uy tín, giá rẻ.

rohanrj said...

Connection connected with a radical new key materials. Whereby what's more might well anybody find that might style of research material with their repeated substantive method for putting.
marijuana delivery canada

Anonymous said...

I am always searching online for articles that can help me. There is obviously a lot to know about this. I think you made some good points in Feat ures also. Keep working, great job! mechanical engineering edmonton

Anonymous said...

I really appreciate spending some time to talk about that, I believe firmly regarding this and so really enjoy understanding more about this kind of subject. wellhead machining

Anonymous said...

I was very pleased to find this site. I wanted to thank you for this great read!! I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you post! fiberglass reinforcing bars

Anonymous said...

Nice information, valuable and excellent design, as share good stuff with good ideas and concepts, lots of great information and inspiration, both of which I need, thanks to offer such a helpful information here. cannabis business Canada

Anonymous said...

Such a very useful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. cannabis extraction business

Anonymous said...

The post is pretty interesting. I really never thought I could have a good read by this time until I found out this site. I am grateful for the information given.your writing is also very excellent. Thanks for nice post.From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! keep up the good work! ειδήσεισ τώρα στην ελλάδα live

Anonymous said...

This is really a nice and informative, containing all information and also has a great impact on the new technology. Thanks for sharing it. CBD retail business plan

Anonymous said...

Very Useful information, this is both good reading for, have quite a few good key points and I learn some new stuff from it too. THANKS. 4 Seasons Swing Chair

Anonymous said...

Your blog provided us with valuable information to work with. Each & every tips of your post are awesome. pompano beach fl vacation rentals

Anonymous said...

Delightful web blog. Almost everything here's superb. The facts usually are completely mind-blowing! My partner and I would like to examine this information again tomorrow. And also I most certainly will examine it. pintu tahan api

Anonymous said...

Great post full of useful tips! My site is fairly new and I am also having a hard time getting my readers to leave comments. Analytics shows they are coming to the site but I have a feeling “nobody wants to be first. Which Casinos

veera04 said...

Hi,
Great Post sir,Thank you For sharing this awesome blog with us.

keep updating more posts like Technology & software related ones.

Thank you....

Intrested guys check it out our blogs ones,

Netsuite Training

CyberArk Training