Free DNS provides easy shared DNS hosting & URL forwarding

Wednesday, January 9, 2013

Is there any design behind Python language?

I gave Python another try (fourth or so). In the past I found it to be a terrible designed language. Lots of things in the language itself felt like they were scraped from all other existing programming languages. And the worst part, that it didn't feel familiar at all, even if you know those languages.

This time I tried Python 3. I went with the Dive Into Python 3 book (ofcourse).

Some of the weirdest things I noticed while reading:
1. Python's goal was to be a programming language that is as easy to read as plain English, right? Then why use def instead of define, why use try...except instead of try...exception. I mean, unless you know what try...except does, you'll think it will try to do something, except some other thing.

2. You add items to lists using list method like a_list.insert(), or a_list.append(), but you delete them using del keywork (del a_list[0]). What is that?

3. You define tuples with (1, 2), but (1) is not a tuple because ( ) are used for math. You need to write (1,). Makes sense, but whoever added the tuples feature did not see this coming? Were they not enough symbols on the keyboard that they had to recycle ( )?

4. You define sets with {1, 2}, but {} is a dictionary. What? Yes, for empty sets you need set().

5. Printing an empty list shows [], an empty tuple shows (), an empty dict shows {}, but and empty set shows... set()? boooh!

6. Lists have extend() and append() methods, but sets have update() and add().

7. List don't have discard() method (i.e. like remove() but doesn't raise exception), but sets do. Logic for that is?

List goes on, but I got tired of keeping track. I finished reading the book eventually (quite fast I would say considering my "go away Python" bias)  and I have to admin Python 3 is much better designed than 2.

However, it wasn't the language itself that got me hooked on the book, but it was the book itself. It's full of non-Python related technical info and generic programming tips. It ties well to other topics without going into much detail. I recommend reading it.

No comments:

Post a Comment