TIL that , while amazing, isn't so amazing for quick-and-dirty coding. It's like flying the Concorde for a 1-hour car trip.

@JonYoder There are reasons I often reach for the shell for quick-and-dirty things. But for anything serious, it quickly becomes a problem. In the days of Python 2, it was a good replacement, but with Python 3's inability to correctly handle POSIX filenames, environment variables, and parameters, I wouldn't bother. Rust is actually pretty decent for a lot of quick stuff once you get used to it.

@jgoerzen What kinds of problems have you run into with Python 3?

@JonYoder I wrote a series of articles on this subject culminating in changelog.complete.org/archive . In short, I was so burned by my effort to port #pygopherd to #Python 3 -- and the utter crappiness and inconsistency of handling non-UTF8 in even the library bundled with Python -- that I consider it unsuitable for any purpose involving filenames, command-line parameters, or environment variables. One lovely tidbit is the zipfile.py tries to decode non-UTF8 sequences as cp437 in ALL cases!

@JonYoder If you want a coffee with your reading, after that first link, you can check out changelog.complete.org/archive and changelog.complete.org/archive . The upshot of it is, as far as I can tell, it is impossible to write cross-platform #Python code that handles filenames correctly on both POSIX and Windows. #Rust gets this right, and Python's attempt to assume the whole world has used #Unicode since the beginning of time is a real pain.

@JonYoder You got me thinking in more detail why I reflexively avoid #Python now, despite the fact that I wrote two large programs (#OfflineIMAP and #pygopherd) in it, and published a book about it. 1/

@JonYoder It is astonishing to me that #Python still has a Global Interpreter Lock in 2022. wiki.python.org/moin/GlobalInt Multithreading in Python is mostly a fiction. There are kludges like docs.python.org/3/library/mult which use fork, pipes, pickling, and message passing to simulate threads. But there are so many dragons down that path -- performance and platform-specific ones (different things can be pickled on Windows vs. Linux) that it is a poor substitute. 3/

@JonYoder Sure, people use #Python for things like #AI work. In this case, Python is merely a shell; the real multithreaded code is in a different language (often C). The way to get performant multithreading out of Python is to not use Python at all. 4/

@JonYoder When I started using #Python more than 20 years ago now, it was an attractive alternative to Perl: like Perl, you don't have to worry about memory management as with C, but Python code was more maintainable. By now, though, even writing a Unix-style cat command in Python is extraordinarily complicated lucumr.pocoo.org/2014/5/12/eve . All the "foo-like objects" are an interesting abstraction until they break horribly, and the lack of strong types makes it hard to scale code size. 5/

@JonYoder These days, we have credible alternatives to #Python: #Rust, #Go, and #Haskell (among many others). All three of these are performant, avoid all the manual legwork of #C or the boilerplate of #Java, and provide easy ways to do simple things. 6/

@JonYoder The one place I still see #Python being used is situations where the #REPL is valuable. (Note, #Haskell also has this). #Jupyter is an example of this too. People use #Python for rapid testing of things and interactive prototyping. For a time, when I had date arithmetic problems, I'd open up the Python CLI and write stuff there. Nowadays it's simpler to just write a Rust program to do it for me, really. 7/

@JonYoder So that leaves me thinking: We're thinking about #Python wrong these days. Its greatest utility is as a shell, not a language to write large programs in. As a shell, it is decent, especially for scientific work. Like other shells, most of the serious work is farmed out to code not written in Python, but there is utility in having it as a shell anyhow. And like a shell, once your requirements get to a certain point, you reach for something more serious. end/


@jgoerzen @JonYoder fascinating stuff, thanks for sharing this insight. You mentioned Haskell, I was wondering if you had much experience with Lisp dialects such as CL or Clojure? I imagine Clojure may have similar concerns as Java. CL is as old as the hills but it has my curiosity

@trevdev @JonYoder I used CL some back in college, and dabble in elisp from time to time, but I'm not expert in either. I found Haskell particularly fascinating as I think it takes the FP paradigm further than even those do (via laziness and segmented side-effects). But Lisps could also serve the REPL need. Maybe someone else would know more (#Scheme is in this universe too, but I'm not fluent in it)

@trevdev @jgoerzen @JonYoder

I'm into it mostly to train my brain on something that is not inspired by C. I discovered the Lambda Calculus and that made the exercise even more interesting.

I really like the syntax, it's so simple that other languages seem complicated to read for me now haha
Can feel weird at first but you get used to it : everything is expression (no statement), parentheses is the single expression delimiter, …

@trevdev @jgoerzen @JonYoder

But you can taste Scheme without parens, because Scheme lets you to tweak it if you want, it's still Scheme (draketo.de/software/wisp 👋 @ArneBab)

I don't leverage the REPL very far but I do use it pretty often.
Imagine a Python program running a Python REPL you can use to load new code to modify/extend the behavior of the Python program while it's running (more powerful than hot reload, gnu.org/software/guile/manual/ 👋 @dthompson )

@jeko @trevdev @jgoerzen @JonYoder @dthompson If you want to see how short solutions look in #wisp, have a look at the advent of wisp code 2021: draketo.de/software/advent-of- — I solved the first 12 tasks of the advent of code there, with code from elegant to "I will replace the pilot by a simple bash script" :-)

The code is always doubled—look at the required change.

If you want to have a list of awesome things about Guile, have a look at the 10 ways GNU Guile is 10x better: draketo.de/software/guile-10x

@jeko @jgoerzen @JonYoder I am not a stranger to the parens and am in no hurry to get rid of them myself :) I am also trying to expand my mind a bit here. If that expansion can be practical, all the better.

This is part of why I am looking at Clojure(Script?) closer that Scheme or CL, but I would rather get lower level if I can.

@trevdev @jgoerzen @JonYoder If you want to toy around in Clojure, take a look at babashka, a "Native, fast starting Clojure interpreter for scripting" -- it's basically Clojure built via Graal to produce a very small native executable which is great to use Clojure instead of bash.

@trevdev I went from a CL background to Clojure. IMHO both languages are fine and have their merits and issues. CL, being standardized on older Lisps has certainly more warts, but then again you have Clojure(script) based on Java or Javascript, resp. @jgoerzen @JonYoder

Sign in to participate in the conversation
Mastodon for Tech Folks

This Mastodon instance is for people interested in technology. Discussions aren't limited to technology, because tech folks shouldn't be limited to technology either!