Skip to main content
•2 min read

Python Is Actually Kind of Nice

techpythonlearning

confession: i was a java person.

i learned java first. i wrote java for years. i defended java in arguments. i thought public static void main(String[] args) was just how you started programs.

then i actually tried python and uh. wow.

first impressions

print("hello world")

that's it. that's the whole program. no class wrapper. no main method. no semicolons. no curly braces.

where does the code even know where to... never mind.

things i love

1. indentation as syntax

at first: "what kind of chaos is this?" after a week: "wait, my code is automatically readable?"

forcing indentation is genius. there is no "technically valid but ugly" code. it either works and looks good, or it doesn't work.

2. list comprehensions

# what i used to write
squares = []
for i in range(10):
    squares.append(i ** 2)

# what i write now
squares = [i ** 2 for i in range(10)]

one line. same result. brain happy.

3. the standard library

want to read a json file? import json. want to do math? import math. want to make http requests? import requests. (okay that one's not standard but you get it.)

everything just... exists. and works. and has documentation that doesn't make me cry.

4. dynamic typing

x = 5
x = "now i'm a string"
x = [1, 2, 3]
# no one complains

java brain: "THIS IS ANARCHY" python brain: "this is freedom"

(i know there are tradeoffs. type hints exist for a reason. but for learning and prototyping? chef's kiss.)

things that still trip me up

  • significant whitespace when copy-pasting (tabs vs spaces war)
  • the lack of switch statements (match came later, but still)
  • virtualenv management (why is this so complicated)
  • python 2 vs python 3 compatibility nightmares

when to use what

my current mental model:

  • python: quick scripts, data stuff, ML, "i just want this to work"
  • java: enterprise stuff, when you need enforced structure, when your codebase is 500k lines

there's room for both. but for a student who wants to build things fast? python is it.


currently rewriting all my old java projects in python. they're 1/3 the length. i feel powerful.