|
|
Log in / Subscribe / Register

Python structural pattern matching morphs again

Python structural pattern matching morphs again

Posted Dec 4, 2020 21:42 UTC (Fri) by Deleted user 129183 (guest, #129183)
In reply to: Python structural pattern matching morphs again by dbaker
Parent article: Python structural pattern matching morphs again

> sexy languages

I cannot believe that somebody wrote those two words, by each other, unironically.

> rust and zig have pattern matching

Oh, sure, those languages are fashionable right now, but in maybe, 15 years, they and their features will probably go out of fashion and style – just like, 15 years ago every language had to be object-oriented and have exceptions as the preferred method of the error handling, but apparently these things are now Evil, and new languages like Holy Rust do not have them or have them in a greatly reduced form – now procedural programming and result types are The Way.

But Python is a language that’s by now firmly established as one of the “major languages”, and we will probably still use it widely in 15 years (unless it goes the way of Perl/Raku). There’s no real reason to force some feature on it because it’s now fashionable, but when implemented badly, it could be an ugly legacy wart in the near future.


to post comments

Python structural pattern matching morphs again

Posted Dec 7, 2020 17:51 UTC (Mon) by dbaker (guest, #89236) [Link] (6 responses)

> I cannot believe that somebody wrote those two words, by each other, unironically

I actually was trying to be a little snarky, I tend to think that Rust and Zig have some nice features, but also some really bad ones :)

Python structural pattern matching morphs again

Posted Dec 10, 2020 12:26 UTC (Thu) by HelloWorld (guest, #56129) [Link] (5 responses)

What really bad features does rust have?

Python structural pattern matching morphs again

Posted Dec 22, 2020 10:08 UTC (Tue) by intgr (subscriber, #39733) [Link] (4 responses)

I think the best feature of Rust is also the worst one: lifetimes. Suggesting to adopt a "classical" language such as Java or Go to a team not yet familiar to it isn't a huge jump.

Suggesting Rust, on the other hand, requires learning a new paradigm that affects pretty much every line of code. As good as that paradigm may be, it's a hard sell if the old paradigm works "well enough".

Python structural pattern matching morphs again

Posted Dec 22, 2020 17:16 UTC (Tue) by mathstuf (subscriber, #69389) [Link] (2 responses)

I think it depends heavily upon the kinds of code you're writing. I worked on a system in Rust that just could not go down (it manages/directs our development workflow). Rust's emphasis on error handling and consideration of what can go wrong means that if anything does go wrong, it goes to a log instead of crashing the program. There's very little lifetime usage in types throughout the 50k+ lines of code in it. They have allowed us to make the parts that need to be fast parallelisable without having to do manual checks of shared memory or the like.

This system has been running for over 4 years now, gained support for non-`master` default branches in July, updated its GraphQL schema usage in June, added a couple of small features this past spring, a few trickling in over time (as they do), and hasn't really had an "oh shit" moment in over a year (I've stopped scrolling the history; there have been 2 that I can remember that weren't "gitlab or github changed something on us" (those are just error logs, not crashes) and they were logic errors possible in any language). It's also performant enough that we just deploy the debug build so the backtraces are useful (when needed).

If you're crafting your own data structures, yes, Rust is going to be a tough sell over more convenient languages (though I argue that it is still worth it). But if you're writing code that needs to be correct in production, performance is of at least some note, and where threading can really help out there, Rust is definitely the top of my list for what to implement it in.

Python structural pattern matching morphs again

Posted Dec 22, 2020 17:27 UTC (Tue) by mpr22 (subscriber, #60784) [Link] (1 responses)

> It's also performant enough that we just deploy the debug build

This is really cool, and I can't think of much higher praise for a language's performance :)

Python structural pattern matching morphs again

Posted Dec 22, 2020 21:43 UTC (Tue) by mathstuf (subscriber, #69389) [Link]

To be fair, most of the app is slinging around HTTP requests to hosting providers (GraphQL/REST), parsing JSON, and forking off thousands of `git` processes :) . But the ability to just stick a `.par_iter()` in one place and get magic parallelism when running dozens of checks on dozens of commits (it's NxM) makes it amazingly easy. I could squeeze some more parallelism out of it with ticketed locks so that projects can be processed in parallel, but it hasn't been necessary to do that kind of stuff.

I've talked about the project before on here, but it all lives here for anyone curious:

https://gitlab.kitware.com/utils

All of the "rust" and "ghostflow" repositories; the "source-formatters" repo is relevant in that it's something we point our configurations at to do formatting verification and fixing. "git-import-third-party" is relevant for anyone wanting to use the "third party" check to make sure vendored code is not modified outside of dedicated patch tracking mechanisms.

Python structural pattern matching morphs again

Posted Dec 26, 2020 19:55 UTC (Sat) by jezuch (subscriber, #52988) [Link]

> lifetimes. (...) Suggesting Rust, on the other hand, requires learning a new paradigm that affects pretty much every line of code.

To be fair, this is inferred most of the time (just like types and some other things); it's only needed (AFAICT, possibly wrongly) when you return a reference from a function which might also be one of the arguments. At least this was the moment it "clicked" for me and I learned to stop wondering WTH I need those annotations for and love lifetimes.

And besides, I think that many experienced programmers already know this "paradigm" without knowing it, so to speak.

Python structural pattern matching morphs again

Posted Dec 10, 2020 12:32 UTC (Thu) by HelloWorld (guest, #56129) [Link]

Pattern matching isn't “some feature” that is “now fashionable”. It's a feature that has been around for 50 years at this point and has a solid mathematical foundation. It's frankly an embarrassment that Python still has to do without it to this day.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds