Hacker News new | ask | show | jobs
by kzrdude 3050 days ago
When I use Python I miss Rust's enums, the pattern matching of those enums, and the static types that help refactoring (the compiler spots where one change has knock-on effects in the rest of the project..).

Especially how Rust enums and structs make it easy to define new types to guide your programs are a highlight for me.

I don't think Rust is better than Python for every task. Python is a lot simpler if you can get something done with its built in types (dicts, sets and lists). Python's dynamic types are also a great benefit for some tasks, where Rust's dynamic dispatch support is very limiting.

Crazily, handling dependencies and building a project is way easier in pure-Rust than pure-Python since it's standardized.

2 comments

Go is good middle ground between simplicity and being fast/dynamic.
Walk middle, sooner or later get the squish just like grape.
> Avoiding both these extremes, the Tathagata (the Perfect One) has realized the Middle Path; it gives vision, gives knowledge, and leads to calm, to insight, to enlightenment and to Nibbana.
But I bet Mr. Miyagi could beat up your Tathagata in a coding contest.
> Especially how Rust enums and structs make it easy to define new types to guide your programs are a highlight for me.

In recent versions Python got some nice improvements in this area, with the new way of creating NamedTuples, Data Classes and the typing module. I wrote a stackoverflow answer recently that sums it up, if anyone is interested:

https://stackoverflow.com/a/45426493/1612318

Those artifacts in Python don't really compare with what the parent laments. Rust's sum types are one of my top reasons for preferring the language.
There are not sum types though.