Andrii Mishkovskyi - Vacation From Python

published May 13, 2016, last modified May 17, 2016

Andrii Mishkovskyi talks about his vacation From Python, at PyGrunn.

See the PyGrunn website for more info about this one-day Python conference in Groningen, The Netherlands.

I went from Python to Clojure and back.

I am a Pythonista since 2006 and went away for a few years. This is not a very technical talk. I will talk about how I used Python, how I got disillusioned, how I switched to Clojure, and how I understood that Python still has good points and I went back to it.

I came from a C++ background, and started with Python 2.3. I was missing decorators, decimal, generator expressions. You could do crazy things like this:

None = False
assert bool() == False
with = 42

Meanwhile Python 3 (called 3000 at the time) was being developed and separated the community at the time. The libraries were not yet there, unicode in wrong places giving problems with file system access, breaking changes in the C API. At the company I worked for, we decided to stick with Python 2 at that point.

I went searching for something else. Looking for ease of deployment, better concurrency abstractions. I was not smart enough for Haskell. You can't get people to write Erlang. Then I saw a talk by Rick Hickey, the author of Clojure, about how to make things easier for ourselves as programmers. [See for example this video, Maurits]

It is a Lisp, but with a twist. Some (killer) features.

  • Immutability is the default. You have persistent data structures, you get rid of data races, don't need to use locking, or worry about changing data in place.
  • The core language is almost all in macros.
  • There is Java interoperability and it is good. So you can use any library from Java.
  • ClojureScript: write Clojure and compile it to Javascript. Many persons use it to integrate with ReactJS.
  • Easy deployment. Python at the time was just starting to use virtualenv, wheels for packaging were not there yet. With Clojure you build your dependencies in a single JAR.
  • Good REPL, Read-Eval-Print Loop
  • Recently asynchronous support in the core.

Some sadder parts:

  • There was not a debugger for long, current one is fairly new and not very powerful.
  • Standard library is very stripped down, basically just string manipulation and regexes.
  • Complicated compile routine, build systems are not part of the language (where Python has distutils), bad ideas stick around: the core folks experiment a lot and this stays in core without warnings.

After three years with Clojure I really liked the language, but I missed several things from Python, so it was time to go back. Rediscovering Python:

  • Python 3 is the Python nowadays.
  • IPython notebooks have come a long way, to share snippets of code about machine learning.
  • Standard library keeps growing.
  • Asynchronous programming: asyncio, async and await. It is good to have this in core, though it is good to have alternatives like gevent.
  • New type hinting, which I think is a good beginning, though others hate it.

Things I wish Python had:

  • Atoms, refs and optimistic concurrency. In Python it is still too primitive.
  • PythonScript, so you can write Python and compile it to Javascript.
  • JAR, though wheel is getting there, I like the direction.

Summary: don't be afraid to look around for other languages, Clojure is worth taking a look at, even if only for stealing ideas.

Questions

What about macros? Macros are nice, but they would be hard to do in Python, because the syntax is harder. There is rust. I don't quite miss it. [Audience: there is NEM which you could try.]

Did you miss the Global Interpreter Lock? No, but I don't miss the absence of it either. You just have to live with it.

What did you first use Clojure for? For a startup I needed a good network layer for an OpenStreetmap project. Another project that needed to handle tens of thousands of requests per seconds and analyze them.

Twitter: @mishok13