▲ | Mawr 8 days ago | |
The Python version is straightforward to read and understand to a programmer of any language. The Ruby version is an idiosyncratic symbol soup. If I were tasked to modify the Python version to say, handle the case where `item` is an int, it would be immediately obvious to me that all I need to do is modify the `match` statement with `case int() as i:`, I don't even need to know Python to figure that out. On the other hand, modifying the Ruby version seems to require intimate knowledge of its syntax. | ||
▲ | pansa2 8 days ago | parent [-] | |
I think for someone with a basic knowledge of both languages, the Ruby version is more understandable than the Python. It's a combination of basic Ruby features, whereas Python's `match` statement is much more obscure - it isn't really Python at all, it's "a DSL contrived to look like Python [...] but with very different semantics" [0]. I don't particularly love the Ruby code either, though - I think the ideal implementation would be something like:
[0] https://discuss.python.org/t/gauging-sentiment-on-pattern-ma... |