Hacker News new | ask | show | jobs
by wavy-dingo 1230 days ago
I think comparing unit tests to a robust type system is a good way to think about typed languages. In my experience, unit tests most often catch NPEs, which a type system also does. The automated refactoring that can be done with a good type system is crazy.

Python has its place in a programmers tool belt, but I often ask questions to determine the language to use. How long lived will this code base be? How critical will be every ms of performance? How many LoC will the final product be? How many people will work inside this project? How dense and complex is the system to be built?

Python is incredible at short, utilitarian scripts that perform a single task that is not normally done inside of your main code base. It’s robust library collection lets you easily do things that other languages would need to be built from scratch. A short script to scrape twitter or analyze data can provide an enormous amount of value for time invested.

2 comments

It bothers me that people still treat python as a quick script hacking tool. You can build magnificent software with python.
I have written and am currently writing software in Python, and let me tell you: I would rather use any other statically typed language, such as Kotlin or F#.
In theory, yes. However, I have never actually seen this mythical magnificent software written in Python.
I've always found this game (in development) to be extremely impressive:

https://www.markrjohnsongames.com/games/ultima-ratio-regum/

Magnificent software is software that makes money or ads value. With Python, technical debt has a higher interest rate, but the loan amount is greater. Right now, I've worked on a webapp that actually makes me money. It took my 6 weeks with really hacky python to get it running in production and serving requests. My last company is still 4 months on their iteration of a similar product because they wanted to build it the correct way with a typed language and better abstraction.

IMHO for greenfield startup projects/POCs, I much prefer python for making things fast and getting things out to market asap. Spaghetti gets me fed.

It sounds like you scoped the requirements tightly. Kept the code simple by minimizing LoC. likely you have no interest in writing and re-writing the product to maximize or increase profits overtime. You don’t have to work with anyone else to document or explain your spaghetti.

This is good for python. It does break down for bigger more complex projects at a certain point.

https://github.com/uktrade/tamato/

This is a Django based tool to manage the tax rates you pay on any thing you might trade with the UK.

It can handle all the changes to the tax from the founding of the EU, through past Brexit when the UK has its own tariff as well.

Running it locally, it may not be straightforward to get hold of the right data (you can download it, but I don't think it's a turn key thing).

It's a bit of a hell to write anything in python that is more than a 100 lines or so and needs any amount of structure.
What's NPE?
I’m guessing you’ve never had to write Java
Null Pointer Exception