53 points · by empone · 17y ago · 77 comments
So, the author is right that we're getting more Pythonic, but he's wrong to say we'll all write in Python some day. Some day, something like Python will be the fast low level language, there will be new slower languages that are easier to use than Python, and C will be a memory. The evolution of programming languages will never end, not in our lifetime certainly, and probably not as long as we walk the earth.
I must say though that I pray for more convergence. It annoys me to write code in JavaScript and Python, having to remember subtle differences between the two as small as capitalization of true and False, and tricky pitfalls like the scope of a variable declared in an if block.
It does seem an unnecessary burden for me as a web developer to have to know a handful of languages. You can hardly make a website today without knowing HTML, CSS, Javascript, Python/Ruby, and you better know your SQL too. Then, let's talk APIs.
You probably mean a very limited number of web app frontend code. That may be true. But I think you underestimate what is being done with software.
With a language that is 200 times slower than C or Java you can't do any data analysis, graphics or image processing, machine learning, algorithmic optimisation, financial software like trading, pricing and risk management, embedded systems, bioinformatics, simulation and a whole lot more.
You're basically excluding yourself from doing anything that mankind couldn't do before. Progress it's called. Most AI tasks require massive computational power. But even just things like pickling a Python object is too onerous for Python itself. I don't think that's good enough.
I'd be happy with just winning that battle.
In the early days, the fact Unix was written in C was quite remarkable. At that time, OSs were written in hand-optimized assembly language.
I see no reason to stay with C-level languages (C was once called high-level) if we can make compilers that translate them into machine code that's faster than hand-optimized assembly.
Smalltalk/80 and the various Lisp machines are sufficient proof whole environments, from kernel to GUI, can be written in higher-than-C-level languages, provided the machine is fast enough. If we can extract speed from compilers and not from expensive silicon, I see no reason not to do it.
In a couple days I will attend to a lecture on porting the Squeak VM to FPGAs and running Smalltalk on silicon. That should be interesting.
There are Smalltalks that ditched (in one case all) their "primitive" methods written in C against the VM internals because the JIT compiler turned out to be good enough. (Agents for the all case. VisualWorks also lets much of the Dictionary functionality JIT to machine code with no primitives.)
The evolution of programming languages will never end, not in our lifetime certainly, and probably not as long as we walk the earth.
You forget to mention a big factor: speed of cultural transmission. Considering what Lisp, Smalltalk, Self and other languages have been able to achieve for high level languages, why are we still dealing with poky high level languages like Ruby and Python? A part of it is cultural expectations. We still expect HLL to be an order of magnitude slower, even though that expectation is decades out of date, technologically. (HLL should only be 70-50% slower now.)
Ruby in particular is basically Smalltalk + Lisp for regular people - it's taken a good chunk of the concepts and packaged it in a way more people are happy to work with.
First time I read about Scheme I was fascinated. Until I played with it a while and put it away and promptly went back to lower level languages (C, Pascal and M68k assembler at the time) because the syntax (or lack of ...) was just too alien for me.
Same with Smalltalk.
Yes, I discarded them over syntax. Speed never entered the equation - I dropped them before I got to evaluate performance.
Ruby is the first language I've worked with that could do justice to a lot of the concepts from Smalltalk and Lisp.
I very much doubt Lisp and Smalltalk has much hope of wider use than they see now - most of the important features are being added to other languages, and the remaining ones are not seen as useful enough by most developers to be worth the painful syntax.
The computational models and the work done on compiling them efficiently will contribute a lot though. Most Ruby implementations in the work and several Javascript implementations are all over PIC's and other concepts take from the Self project, for example.
Do I take issue over other people using other syntaxes? No. Does syntax put any kind of limitation on VM speed? No. Do I even imply that Smalltalk and Lisp are conceptually superior to Ruby? No.
What I am saying is that the current popular HLLs are behind the curve in terms of performance.
I find it funny that adult techies discard Smalltalk over syntax. There's only 5 rules, FFS. Lots of grade school kids have used it like a highly advanced multimedia Logo. That said, the traditional operator precedence of algebras is such a deep part of Engineering, Science, and Mathematics culture, that any language that doesn't add it as a convenience to those groups is probably and understandably doomed to obscurity. (In particular, Forth, Smalltalk, Lisp, Self, and others.)
If only David Simmons had better marketing and community organizing skills. Smallscript might have been where Ruby is today.
I think that's the main problem. There are lots of "Lisps" out there besides Common Lisp (which is what most people think of when they hear "lisp"). I.e. Scheme, newLISP, and Clojure come to mind.
Pick one of those three Lisps and learn it, you'll be wondering why anyone in their right mind would consider writing in any other language, unless it was a lisp. As someone once said, there's a reason people become Lisp zealots; just take a look at it.
Plenty of software is not web-based or a cron job for Linux.
Java, C# are chosen not just because of speed.
You can get vendor support from Sun for their JVM stack. You can (try to) get similar support from Microsoft for .Net stack.
Then also there are personal preferences ::
. Static Typing can be a key part of how people build complex systems in a way they feel comfortable with. When my team codes that way, may bugs are picked up at compile time versus deploy time.
. JVM has really nice remote debugging
. JVM is much closer to run-anywhere than Python
. JVM exits with hs_err files logged
And I think it's a stretch that people who use unit tests are just trying to compensate for a lack of static types. Actually, it's more than a stretch, it's false for pretty much any competent programmer.
If it were true, why would Java programmers use JUnit?
Do you really believe that?
1. It is easier and quicker to develop a correct solution in a higher level language than a lower level one.
2. Expressiveness / abstraction come at the cost of time and space efficiency.
Thus, if time and space efficiency are not a concern, then the higher level language should be preferred.
>I believe the flaw in the argument is that the higher-level languages are actually more constrained, because they have made too many broad promises and are unable to tell when they can violate them without ill effect, even though it is obvious to the programmer. We might think that your example above would be a perfect case in which we could parallelize the loop... but what if sum() had side effects, such that it would produce the wrong result if not evaluated in order? What if sum() didn't have any directly detectable side effects, but called another function which called another function which did... sometimes, from code in a runtime eval? The compiler has no way of knowing this, so it has to assume the worst, and this is why it ends up being unable to make all the optimizations that one thinks it "should" be able to make. The human looks at it and says "duh, it's called 'sum'. If it has side effects, I'm going to smack somebody up the side of the head" and proceeds to optimize in the expected ways.<
"In an ideal world, high-level languages like Python would replace all other programming languages."
That includes smalltalk, scheme, clisp, and every marvelous language not yet invented.
But then he goes on and says something very closed minded like
"Someday we will all program in python."
As if python got everything correct, and we have a perfect map of how humans think with it. The arrogance.
(map (partial reduce +) (partition 7 7 daily))
Edit: Possibly that should be partition-all from seq-utils to sum the remainder days if the length of daily isn't divisible by 7.
map(partial(reduce, +), partition(7, 7, daily))
Personally I'd be much much more happy to be using this code than the snippet in the article. In fact, I don't program Python regularly and it did take quite a while to figure out what was going on in the code.
weekly = [sum(daily[j:j+7]) for j in range(0, len(daily), 7)]
Now if you look back at the top snippet, its just normal function calls, so you can be happy to know what's going on after reading documentation for the names "partition" and "daily".
If you don't know what "map", "partial", "reduce" and "+" mean, sure you have to look up their documentation too, but they occur frequently enough that you can remember what they do after that.
The Clojure version is much more high level and less likely to introduce bugs.
Edit:
Oh and it should be said that "sum" is equivalent to partial(reduce, +) so I can now say:
map(sum, partition(7, 7, daily))
See? The code is just melting away before your eyes. Also note how I have literally no idea what either of the snippets do but am already happily changing one of them.
def partition(n, step, coll):
for i in range(0, len(coll), step):
yield coll[i:i+n]
allows weekly = [sum(week) for week in partition(7, 7, daily)]
Using Python's map() function you can even do map(sum, partition(7, 7, daily))
making it exactly the same as your example. And no, I probably haven't written more Python than you in my life.And that Python is pretty unreadable for someone who doesn't know Python.
While I appreciate the general sentiment that high-level languages will take over the world, there is very little that's new in this article and I am not impressed by the showpiece Python code from the article. For loops are the future?
I seriously doubt it. The more the compiler knows, the more it can optimize things.
What it's "daily" in this example? It could be anything. The only thing the compiler knows at compile time is that it should generate some lookups searching and calling the functions "__iter__", "__slice__", etc... Put that line into a function which receives daily as a parameter and it could mean something different at every single invocation. Human beings, looking that code think know what it does, while in fact don't have a clue. The equivalent code in clojure someone has wrote only is really equivalent under some very specific assumptions.
I know, I know, at runtime you could gather all kinds of interesting data to optimize things. But, that's not easy nor cheap and, sometimes, iterating over an array, it's just iterating over an array.
[edit:] if only... Amend to: some day, we will program as efficiently as possible, and software will do most of the annoying housekeeping.