Moving from Perl to Python
Created 2021-04-27. Updated 2021-07-12.
The need for a programming language
As I'm planning a transition to a modern static site generator some scripts and utilities will be needed. The data and the content of the earlier technologies will need conversion into format compatible with the new static site generator. And writing these scripts and utilities will require a programming language.
How I chose Python
The languages that I've previously used programming include Java, JavaScript, PL/SQL, Ruby, Perl, C, C++, Pascal, Visual Basic, Lisp and Fortran.
Perl would be both the most obvious and the easiest choice for me and I would be productive with Perl starting from the first second. But I decided that this was the right time to try something different, perhaps a new programming language.
I ruled out Perl that I've been using for ages and listed some key candidates: Go, Python, Ruby, Rust. Since I was looking for a reasonable smooth transition from Perl I felt that this left out Go and Rust. So finally I had only two real candidates: Python and Ruby.
I've already been programming with Ruby but Python was a new language for me. I decided to go with Python.
These are the key benefits of Python
- as a general-purpose interpreted language it offers a smooth enough transition from Perl
- easy to read
- very likely to be alive at least ten years, so at least to year 2031
- based on my initial testing works well on both Windows and Linux
- has excellent libraries
- anything I decide to ask about Python programming Google search gives me an answer
Transition from Perl to Python
As I'm making a transition from Perl to Python as an avid Perl programmer here are some key things I've noticed.
Indentations are important part of the language. This goes so far that a tab indentation is different from indentation done with spaces and mixing them leads to an error inconsistent use of tabs and spaces in indentation.
At first I found it strange not to use { } and instead use : and indentation. But after first two hours of programming I feel that I never like to go back to those { }'s.
Perl variables indicated with $, @ and % are a mess. I don't miss them at all. Python is clearer.
Function definitions and calls always ends with () which I find very logical.