4 ms·
Python wasn't my first programming language. And I think I gave a fair chance to other languages. But there come these moments where you are like "oh, this woul
by asgard1024 11y ago
Python wasn't my first programming language. And I think I gave a fair chance to other languages. But there come these moments where you are like "oh, this would be really simple in imperative code". Ideology gets in the way; to claim the opposite is just kidding yourself.
I probably gave the most chance to Common Lisp. It's a very pragmatic language too, unfortunately (largely for historical reasons), the standard library didn't keep the pace. It's not just a matter of what you can do, it's also the design. Python standard libraries almost always put the user first and the purity second.
For instance, Python would never add versions of functions remove-if, remove-if-not, delete-if, delete-if-not. That's mathematical purity (in if vs. if-not) and letting
the onus of choice on user (in delete-if vs. remove-if) instead of conservatively making reasonable default.
At the same time, Common Lisp library lacks things like function to strip whitespace from string; you can do it, but Python has it as a function. It's just hundreds of little things like these that make Python more pleasant to work with.
I genuinely want to like Lisp more than Python (I am learning Clojure about now, which is on par with Common Lisp when it comes to pragmatism). But sometimes it is just a little more frustrating, because of ideology and not putting user first when it comes to API design.
- rhaps0dy 11y agoMaybe you will like Hy. It's a Python import hook that allows you to load files with a syntax similar to Clojure into Python. It also has an interpreter, so it can work as a standalone language or just dropped in Python projects. And it's not just the syntax, you can of course use Lisp macros! https://github.com/hylang/hy https://github.com/hylang/hy
- asgard1024 11y agoHeard about it recently, haven't used it, but certainly is an interesting project!
- rhaps0dy 11y agoI used it in a Django project for specifying the urls, to have an easier time parsing them to build client-side validators. I'm sure there are better solutions to that though, and I never got around to actually generating the validators.
- proveanegative 11y agoIf you do not declare your ideology upfront you will still end up having one, only implicit and ad hoc. This does not apply to Python, however. It does have a explicit, if not entirely serious, statement of its ideology in The Zen of Python. (For those unfamiliar, read http://c2.com/cgi/wiki?PythonPhilosophy http://c2.com/cgi/wiki?PythonPhilosophy. It has The Zen and some discussion.) Python takes its ideology pretty seriously, too, as evidenced by how much the words "pythonic" and "unpythonic" used in discussions involving the language. In discussions around, e.g., Java you will find no terms of that sort.
- asgard1024 11y agoI already explained that below, but let me elaborate. (But beware I am not a big fan of Zen of Python, precisely because I think it's misunderstood.) The thing is these rules do not really give much guidance on how to design a programming language. These don't hint whether or not the language should be functional, or should have small library, or should have classes, and bazillion other things that programming language designers tend to argue about. We can pretty much agree on these rules. And that's the point, these rules are all about making tradeoffs.