Python to get Google-backed speedup
techreport.com
techreport.com
It's too low level to do compile to directly. It'd occupy a place in the stack somewhere near assembly, but with an optimizer in place. It's more of a VM toolkit than a VM itself.
Original comment: Yeah, that would be one solution, but I think the shared VM helps so you can easily access libraries written in different languages. I remember why (of Ruby fame) trying to run Ruby code on Google App Engine back when it was Python-only. He discovered that Ruby bytecode is nearly identical to Python bytecode. Like me, he didn't understand why Python and Ruby still need to be on separate runtimes.
(That was sarcasm.)
Note that the JVM and .NET runtimes do pretty much exactly what was asked--they run programs written in multiple languages on the same VM. Because the "native" VMs for Python and Ruby are so bad, the JVM and .NET VMs can even out-perform the native ones for most tasks.
The hard part comes when you want to preserve source-level semantics and provide a natural-feeling translation so that a human can understand, read, and write the source.
However, with a VM you don't have that problem. With a VM, a lossy, one-way transform is sufficient. You can easily throw away information as you compile, since you're not targeting humans consumption for the output. You can replace, say, overloaded functions with mangled names. You can turn multiple dispatch into decision trees of conditional statements. And so on. With a VM, you would want to keep enough high-level detail to efficiently JIT stuff, and it's a bit of a challenge to decide what detail is sufficiently useful to include, but it's not insurmountable.
That's what I meant. As far as I know, nobody else is taking it seriously as a primary VM for their language.
Is Parrot 1.0.0 radically better than other (non-perl) VMs?
1. Using a simple prototype VM seemed easier during initial development
2. When the language was developed, no suitable common VM existed
3. The language developers thought they could do it better for their specific case, i.e. the point of the implementation is to showcase new VM strategies
Remember that a language and an interpreter are separate things, and usually an author who wants to try an idea for one has to find some suitable stand-in for the other in order to get started.
It looks like we're at a point now where many dynamic languages are attempting to transition to a more advanced VM. This includes Perl, Python, Ruby, and some implementations of JavaScript. I assume they all want to take advantage of the latest VM techniques, and they're all making major changes anyway, so again I just wonder why they don't seriously consider collaborating now.
The Jython project was just the coolest darn thing until, from what I can tell, the lead developer got tired of maintaining a mature project with a hairy codebase and left to join (start?) PyPy, an even more ambitious project. So Jython was stuck in a coma with a pre-alpha 2.2 release for like half a decade, while CPython marched on, and no new maintainer was able to bring it back to consciousness -- despite huge demand for it, since Jython at the time was the perfect solution to problems in Java and Python. Finally Frank Wierzbicki came along a couple years ago, squeezed out the stubborn 2.2 release and is on the verge of version 2.5, at which point we can consider Jython back open for business. There's a kind of similar story with Psyco, and I think that one also concludes with PyPy being the "right answer" to the original problem.
But back on topic -- in some ways, the dynamic-language communities are collaborating on common VMs. The JVM team is trying to make things easier for other languages with "invokedynamic", the .NET world is keeping up at least (DLR? dunno), and LLVM has good traction as a compilation target.
However, I doubt we'll see anyone devote significant effort to porting Python or Ruby to Parrot until Perl 6 lands and provides a compelling demonstration. Meanwhile, PyPy is getting close enough to its goal that we might just want to wait and see if their JIT-compiler-generator solves all of these problems in one shot.
"In addition, we intend to remove the GIL and fix the state of multithreading in Python."
At Pycon last year, when I reminded Guido about the difficulty for embedded apps (that can't fork 200MB processes every time a thread is needed), he shrugged and recommended Jython or IronPython usage.
It's great to see that we'll have this problem solved in a few years. (I assume it will take that long to be production-worthy.)
I'm sure this LLVM integration and change will pretty much break/invalidate all of the embedding API, but to me it'd be worth the rewrite.
The only thing that happens in these methods in VisualWorks Smalltalk is marshalling to call out to DLLs implemented in C.
languages like Haskell, which have no side effects
Haskell does have side-effects. Most programs have side-effects. Functional languages like Haskell are designed to separate side-effects and pure functions. It gives the interpreter/compiler the ability to parallelize the pure function.I still have a LOT of perl in use simply because of my hatred of python's regular expressions and I suspect that I'm not the only one...
I think the first hint that Python wasn't developed with RegEx users in mind would be that in the 700 Page "Learning Python, 3rd Edition" - Regular expressions aren't even mentioned in the Index.
I can see that as a reason for preferring perl's syntax, but I just don't understand hating python's regex, which is what my question was about.
A replacement on python looks like this...
foo = re.compile("<") bar = foo.replace(">", bar)
this works, but it just feels less awkward to me than
$bar = s/</>/
>>> re.sub("<", "<", "something < other")
'something < other'
which seems much more readable and consistent to me than s/a/b, though the s/ syntax is great for vim users like me.I don't think this has as much to do with your programming knowledge as your python knowledge?
Heheheh, boy would that get some bees in some bonnets on the Python dev ML. :)
http://dalkescientific.com/Python/python4ply-tutorial.html#p...
He presented it at PyCon a couple years ago, response seemed to be "that's cool".
Thanks for pointing out my error, and getting me to read the actual code instead of speculating. :)
In Python, much string manipulation is done with builtins (especially string methods) and library functions. The latter work especially well when you target a specific domain (such as HTML) and will often be implemented in regexps. Writing one's own regexps are for when you actually need a small custom state machine. Many problems are too small or too large to justify the effort.
Not much of a condolence if you're screen scraping, but still.
I always thought(not based on actual experience) that running Jython or IronPython would give you all the mentioned benefits.
However, it is good that Google is putting it's weight behind this project, because anybody who uses anything built on Python (which has weaseled its way into virtually everything nowadays) is going to experience a performance boost.
A programming language is what it's developers and users make of it. Python people have worked very very hard in the last 2 years to be ahead when everybody and their uncle were going ga-ga over Rails.
Maybe this "flexibility" you talk of is not all that cracked up to be for most of the programmers. Python flourishes because it too is opinionated in it's ways and a lot of people tend to agree with the set of choices made by the language designer.
I __hate__ that