6 ms·
I think what makes Python unique and successful as a programming language is a strict pragmatism (rejection of any ideology) and rather conservative choices in
by asgard1024 11y ago
I think what makes Python unique and successful as a programming language is a strict pragmatism (rejection of any ideology) and rather conservative choices in features to add (that is, don't add everything that someone suggest, wait until we can see it's a good idea and it cannot be readily composed from existing parts).
Scheme, OTOH, has some ideological choices. The whole notion of programmable programming language that comes with Lisp tradition (which includes s-expressions). The emphasis on teaching and small libraries. Attempt to somewhat model mathematics in numerical tower. These design choices, while interesting, are going against practicality.
I am big fan of mathematics, Common Lisp, Haskell. There is so much beauty and elegance. And yet, when I need to get something done quickly, I will just use Python because it drops the mathematical purity without prejudice, just like a physicist working on an impossible problem.
- willtim 11y agoWhen we want to get something done, we typically reach for what is most familiar.
- asgard1024 11y agoPython 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.
- yummyfajitas 11y agoPython doesn't reject ideology. It's ideology is "minimize required background knowledge and learning curve".
- beefsack 11y agoI've found in the past couple of years Go has fallen into that pragmatism bucket for me. If I need to throw something together quickly it's a good tool for the job thanks to the simple syntax, decent tooling and significant standard library.
- anentropic 11y agoI found Go quite obstructive compared to Python
- wyager 11y agoPython's design choices (imperative, untyped, interpreted, etc.) are just as ideological as Lisp's s-expressions.
- asgard1024 11y agoI would argue not. These paradigms actually encompass other models, and it that sense, they are pragmatic conservative choices (in a sense, "minimal"). You can program functionally in Python. It doesn't really gets in way of doing that, which cannot be said about functional languages, they are often designed to prevent you programming imperatively. Dynamically typed languages can be understood as having only one type, so it's in a sense a type system that encompasses all the other type systems. For fans of typing, Python added optional type annotations, again, as a very conservative choice. Interpreted - again, it's probably easier to write interpreter than compiler. Once you get into compiling, you have to make some more choices, which Python conservatively forfeits. That is not to say that these choices aren't cultural (for example, most people are more familiar with infix notation, although even here there may be pragmatic reasons - the exactly right amount of parentheses). Just that it tries to encompass various tastes and be conservative about it.
- sklogic 11y ago> it's probably easier to write interpreter than compiler It's not easier. Interpreters are much more complex and much less robust than compilers.
- mdpopescu 11y agoI've written a few interpreters during my (almost) 30 years of programming; never a compiler. The thought of 1) machine code generation and 2) optimizations scares me every time.
- sklogic 11y ago> The thought of 1) machine code generation and Don't do it. Compile into a higher level representation and reuse and existing machine code generator (LLVM, even plain C), or compile into a higher level VM with threaded code implementation (Forth and alike). Although even a full compiler with a native codegen is still much simpler than an interpreter. > 2) optimizations scare me every time As if you don't have to optimise in an interpreter. Not to mention that even an unoptimised compiler would produce much faster code than your average "easy" interpreter. Compilation is nothing but a sequence of trivial term rewriting passes. Each can be as simple as you want, doing one trivial thing at a time. Easy to understand, easy to write in a fully declarative way, easy to reason about, easy to debug and maintain. You don't even need a Turing-complete language to do it. And an interpreter is always a pile of convoluted mess, leaking multiple abstractions in between layers (if you're lucky enough to even get any distinct layers at all). I always wondered how people can even compare interpreters to compilers.
- sklogic 11y ago> is a strict pragmatism (rejection of any ideology) What? Python is very pushy on its ideology of "there should be only one way to do it", which is an exact opposite of a Lisp complete lack of ideology: "do it any way you like, turn Lisp into any language imaginable". > rather conservative choices in features to add Which is only ok if your language is extensible, while Python is most definitely not anywhere near an extensible language.
- asgard1024 11y agoWhat I mean is that Python tries hard to find a compromise solution between various ideologies. Whether or not that is an ideology I would leave up to Bertrand Russell; I think it isn't. Regarding extensibility, again, there are people who argue against it and have an opposite opinion to Lispers. Python tries to find a middle ground, conservatively. It's not super extensible like Lisp or Forth, but still quite a lot compared to many mainstream languages.
- sklogic 11y ago> there are people who argue against it These are the people who don't know any better, arguing out of ignorance, not from some valid ground. > Python tries to find a middle ground, conservatively. How exactly? I do not see any extensibility features in Python, none at all. Some dirty hacks with rewriting the compiled bytecode in runtime do not count.
- asgard1024 11y ago> These are the people who don't know any better, arguing out of ignorance, not from some valid ground. That's very unfair. Let's take Lisp-style macros. There are good arguments against macros in programming languages. For example, keeping the amount of primitives small and core language simple. I don't agree with these arguments (I am pro-macros), but it's not just ignorance. > I do not see any extensibility features in Python, none at all. Not sure what you mean, but macros are not the only way to extend a programming language. One particularly common method is called "functions" (if you have ever coded in assembler, you will know what luxury that is). Then you have classes, operator overloading, metaclasses, decorators, native C interface, AST parser in the standard library.. Not sure what more, aside from macros, you could want regarding extensibility. Python is more extensible than C and Java, which are the most common programming languages in use.
- tome 11y agoRecently I've been musing the aphorism "Quantity has a quality all of its own". I think something similar applies here too. Python goes to such extreme lengths to be (seen as) pragmatic that I can't help but conclude that "Pragmatism has an ideology all of its own".
- davidgerard 11y agoideology: things I don't like pragmatism: things I like
- PuercoPop 11y agoPython is so ideological it is not even funny. It has a crippled lambda because Guido couldn't find a syntax he liked for it. It doesn't have tail call elimination because Guido is under the, mistaken, impression that they inhibit backtraces. The zen of python spouts explicit is better than implicit as a marketing slogan to cover up a design wart with Python's lolscope. It only had local and global scope. Python Scope is still broken[0] btw. But don't worry, it is not a bug because it is documented. (╯°□°)╯︵ ┻━┻. The only reason Python passes as a language with good design is because people compare it to PHP or Javascript. How is the numerical tower impractical? Having to check for overflow/underflow after every addition is what is impractical in my book. > I am big fan of ... Common Lisp ... There is so much beauty and elegance. Idk where to people get the idea that Common lisp is 'beatiful and elegant' (in opposition to practical I may add). It is eminently practical. Have you seen loop and format (which btw Python has adopted with some glaring _practical_ omissions like list iteration ~{~}.)? The whole anything but nil is true to allow functions like digit-char-p to return a number instead of t is another practical design choice. Do you think there is anything elegant in modifying the readtable? I could go on and on. CL is a practical language that, apparently due to ESR's nirvana bullshit quote, people who haven't used it have a misconception about its design. But back to the point, Scheme's design (ideology if you want) is to play to pick features that synergize as to allow discard others as they can be expressed with the previous features/concepts. You don't need iteration, as it is a special case of recursion. You need iterators, you have map, which is just a function the user can define, etc. And this is relevant to teaching computation as it allows the teacher to waste as little time teaching a language and allows him to focus on CONCEPTS. The amount of scheme knowledge needed to finish the SICP can be taught in 15 minutes (It doesn't use macros). All the difficulty lies in the concepts it deals with. Getting the language out of the way allows to cover a lot of ground, for example in the SICP one implements a Virtual Machines and a compilers targeting it. Now if you want to argue that nowadays the student needs to learn how to pipe software together and has less need for concepts that is another thing altogether[2], but saying that Python is practical (as opposed to ideological) and Scheme's 'ideological' choices hampers the students learning is bullshit. [0]: https://bugs.python.org/issue24321#msg244357 https://bugs.python.org/issue24321#msg244357 [1]: https://twitter.com/whitequark/status/604088954816716800 https://twitter.com/whitequark/status/604088954816716800 [2]: Of which I'd quote Dijkstra: "It is the university responsibility to give society not what it wants but what it needs."
- brudgers 11y agoThe notion of a programmable programming language is an implementation of the mathematics of computation. It's as ideological as addition. COBOL allowed self rewriting code...probably because all software is [when we're at the right level of abstraction] is a mechanism for a computer to rewrite its instruction set. A programming language that does not allow self rewriting code can only come about in one of two ways: a lack of cleverness on the part of its designer or a willful decision to disallow certain types of computations. Willful decisions are driven by systems of beliefs and values. One person's beliefs are an ideology to someone who doesn't hold them. In my opinion, Python's practicality stems from its library ecosystem and that ecosystem is an accidental artifact of the epoch in which it was born and grew. The internet and open source made sharing of libraries practical. The idea that Java would be the one true language in enterprise and the economics of MatLab in academia and the public failure of Lisp as a startup in the 1980's, all helped. But "Python" is fungible with "Javascript" in any it-just-lets-me-get-things-done argument without too much problem. More people use Javascript to just get shit done than any other language.
- dragonwriter 11y ago> pragmatism (rejection of any ideology) Pragmatism is an ideology, not the rejection of any ideology. (Perhaps more generally, pragmatism is an umbrella name for a class of ideologies which are all about maximizing some objective utility function, they differ in what utility function they are maximizing.)