Why I Stopped Coding and Why I'd Start Again
Pages: 1, 2, 3, 4
This can be done in such a way that indicating a local or networked source becomes simple. An import path such as /widgets/helloworld indicates a local file path. A path such as http://helloworld.foocorp.com points to a network file store. There could be other syntax, of course, but this is one example of an easy way to do this.
Dynamically Loaded Binaries
Like many languages, Python allows you to talk to external binaries, typically written in C or C++, to talk to hardware APIs, or to optimize performance for especially CPU intensive tasks. The issue with these, of course, is that it is difficult and many times impossible to make this type of code portable because the API the C program talks to (a telecom interface, for example) does not exist on many platforms.
For this type of module, how about a slightly different syntax to tell the runtime environment to load an external binary? This also requires changes to the runtime environment, which I'll discuss later. In our hypothetical language, we'd write:
import http://1_0_9.fastfft.widgets.code.foocorp.com type=bin runonce=n as=fastfft
x = fastfft()
fft = x.transform(some_pcm_audio)
This short example adds two parameters to the import statement, type=bin and runonce=y/n. This tells the runtime engine to fetch and launch a compiled binary that will process data from the application, not unlike a DLL. The runonce parameter tells the runtime engine whether it can launch multiple instances of the binary or only one.
The runtime interpreter hides the messiness of this process from the Python application and does something like this:
- Try to fetch a copy of the binary for the target platform; throw an exception if a problem occurs (for example, file not found, CRC error, etc.).
- Launch an instance of the binary and tell it to talk to the runtime environment via interprocess communication (for example, a localhost TCP socket).
- Pass data to/from the Python app via the interprocess communication interface.
This is a simple and fairly clean way to make it easy for Python apps to use external binaries. This itself is not news. A voice-scripting language I used years ago did something similar to this, minus the dynamic load and binding trick. The goal here is to make it easy to talk to binaries, but do so in a way that does not require the user to run a build command prior to running the application.
Using the example above, I want to use a C program that does a fast Fourier transform on a segment of audio data. This is a computationally intensive task, so it'll be a lot faster in compiled C than in an interpreted language such as Python. In this framework, the runtime engine launches an instance of fastfft.exe in the background and tells fastfft.exe to talk to it at localhost:nnnn.
From my perspective, I am just talking to something that looks like any other object. When I invoke a method, the runtime engine sends a message to the external application via IPC, does its thing, and sends a response back, which gets returned to my application. Simple.
Again, the details of how this works behind the scenes are not so important. I use TCP via localhost as an example, mainly because any networked appliance will, by definition, be able to talk via a localhost socket. In a real-world version of this, C and C++ developers will have a wrapper library that provides a simple interface in and out of their programs. The key requirement here is to eliminate the need to preload external modules, without the need for a build operation prior to running the program. It's worth losing a little bit of performance to gain this flexibility.
Built-In Version Control
You may have noticed that this system has a built-in form of version control. Code repositories must explicitly create a separate path for every version of a module. Likewise, developers would be required, or at least strongly encouraged to explicitly refer to a unique version at runtime.
Bootstrapping to a Web OS
This is a simple extension of a proven language. At the very least, it will make building and sharing applications easier, though it has potential beyond that.
Imagine a minimal machine that has the basic guts you need in a computer. Storage, I/O, and a network. It has a lightweight, built-in interpreter and is designed to run only Python apps. In effect, it's a Python computer and operating system.
When you first take this computer home, it boots up with a picture of a snake and a command line. You type the name of a program you want to run. Any program. Maybe you want to run an MP3 player, so you type "PyMP3".
Your computer is brand new, and you don't have that program yet, so behind the scenes it tells itself to:
import http://pymp3.code.widgetcorp.com
It then runs this program, and because it probably contains import statements of its own, automatically works through the underlying packages it needs to run. This all happens in the background, and after a short while, the program runs, as if it had been on your machine all along.
While many companies could do this, Google is in a unique position to make a system like this a reality. With its data center infrastructure and world-class software engineers, it can easily fund a project to make the necessary modifications to the Python interpreter (as well as other languages if desired) and to operate a trusted code repository--the two key ingredients required to build this system.
With the right sponsorship, a system like this could lead to major changes in the way developers build and share software. It could do so at a surprisingly modest cost, because this system requires only straightforward modifications to existing and widely used programming tools. Just as hyperlinking was a straightforward enhancement to document markup languages that enabled the development of the World Wide Web, hyperlinked source code will bring similar benefits to software development.
Brian McConnell is an inventor, author, and serial telecom entrepreneur. He has founded three telecom startups since moving to California. The most recent, Open Communication Systems, designs cutting-edge telecom applications based on open standards telephony technology.
Return to the Python DevCenter.
You must be logged in to the O'Reilly Network to post a talkback.
Showing messages 1 through 18 of 18.
-
cheeseshop?
2008-02-22 03:11:27 thisfred [Reply | View]
I wonder if you know about buildout, setuptools, eggs and the cheeseshop, since they more or less do what you describe here, and have been for a while.
Sure, they can be a little rough around the edges sometimes, but this set of tools is so widely used in the python community now, that the speed of improvement is very high.
If you did know about them, what exactly sets your proposed solution apart fundamentally?
-
I too am baffled by the fanboys
2008-02-19 11:46:41 khiltd [Reply | View]
I'm finding that Python's sockets library is also a good deal less flexible than PHP's or Ruby's, which is odd considering its age. The default timeout on a blocking socket is "None" which, in my testing, roughly equates to about 10 minutes. That's 10 minutes your script is going to sit there doing absolutely nothing before it throws an exception because the port you're trying to connect to is blocked somewhere or because the server is down.
Now the socket object has a handy-dandy settimeout method, but passing it a more sensible value than "None" causes it to become non-blocking. This means you have to introduce all kinds of ridiculous asynchronous polling cruft in order to accomplish something that should be an incredibly straightforward task in any other language. I don't know about anybody else, but multi-threading a web app is not my idea of a good time.
To get a sensible timeout on a blocking socket you have to call the class method socket.setdefaulttimeout() which sets the default timeout value for ALL socket objects, and what's worse, it does not return the previous default value for easy restoration; you have to make a separate call to socket.getdefaulttimeout() if you want that.
15 years and this is the best "battery" they could come up with to "include" in the package?
-
Why Code(?)
2007-04-17 21:54:39 benQboy [Reply | View]
In recent years programers have grown self-conscious, perhaps because they have only lately become of age, They realize that they are now part of the drama of computer/human history, and they look to the professional Historians and Philosophers for background and perspective.
The problem with technology is the moment some major obstical gets solved, it becomes trivial.
Backwards compatable Anthropomorphasize
My Grandfather had vacume tubes ,punch cards, and sliderules.
I stopped at DOS and BASIC.
Why? If I could only tell you!
-
Python+Twisted
2007-02-01 00:57:03 jian.wu [Reply | View]
If you want a good networked programming language, you should look into Twisted + Python.
Recently, I'm working on a project to develop a high scalable service gateway using Apache Mina, I need develop a Simulator and Test Driver to test the gateway, I used Python asyncore first, then moved to Twisted. After comparing the java code I wrote for gateway and python/twisted code for simulator/driver, I should say Twisted is a great framework to write any high scalable async networking application.
-
Naming and CRC
2007-01-27 11:14:07 JohnNilsson [Reply | View]
I don't think there is a need for a namespace. Just do what Lins did for git, base IDs on a hash of the data.
This way code can be fetched from DHTs and it can be cached by the OS, even reused for multi user systems.
If upgradable libraries are required import an interface and let the runtime pick a suitable implementation based on the users policy settings.
Even interfaces can be named by hashes.
import org.google.webapi.blah <SHA-1:2fd4e1c67a2d28fced849ee1bb76e7391b93eb12> as blah
-
It's not the URLs, it's the APIs
2007-01-24 07:01:23 Dave_Turvene [Reply | View]
As a person who continues to code and enjoys
doing it in Python, I think you touch on a number of great points, but a DNS-style lookup of packages is not a significant advancement to me except in the case of small embedded devices, which I no longer work upon.
Here's why:
Currently, I generally (not always, but generally) have to follow this design cycle to integrate python packages, even standard ones:
1. Find a package that meets my requirements and possibly download it
2. Understand the API
3. Extend the API via wrappers, subclassing or decorators for my application
4. Use the custom API in my appl
5. Package everything into a single distribution
Steps #2, #3 and #4 are the big ones. In comparison steps #1 and #5 are relatively trivial.
The major work is BECAUSE everyone has a different interpretation of a "good" API. You mention your frustration with database packages. Taking extremes, the pysqlite, RSDP (from your 2005 article) and ZODB APIs are pretty nice once you learn them but they are radically different.
You seem to have choosen SQL via XML-RPC as the DBMS API of choice and, based upon that, you suggest a python standard library. However, it excludes everything non-XML and non-SQLish. Thus I see another set of "standard" libraries OR just have everyone say "There's only one way to do this", bite the bullet and use your API. Another common API problem is logging - everyone has a different logging interface.
And I didn't even talk about maintaining a logical migration path for "standard package" versions. Just look at the migration of sqlite, pysqlite2 and sqlite3 for an example.
-
It's not the URLs, it's the APIs
2007-01-24 09:55:42 Brian McConnell |
[Reply | View]
I agree that this technique does not eliminate the need to understand whatever modules you choose to use in a project.
The purpose of this is to make distribution much simpler. With this model, you'd just copy your code onto a machine. At runtime, it automagically fetches and caches the libraries it needs. At design time, your development environment would mimic what a runtime environment is going to do with the hyperlinked modules so you'll have an idea how it's going to behave in the real world.
As you mention, this is particularly relevant to non-PC devices, especially because of the potential to cache and discard infrequently used modules to deal with limited storage, etc. While that's not needed on a PC with 300GB of disk, it's nice to know that if "Hyper Python" or "Hyper ____" became common, you could build apps for either category of device knowing this would be handled for you.
-
Interesting ideas in here
2007-01-23 14:17:33 klemmerj [Reply | View]
There are many languages out there that have some of what is described but having it all would be handy. Rebol has a lot of it. NetREXX as well. I know that many will scoff at this but ObjectCOBOL could be another option for this. In fact, with a little bit of effort, the existing COBOL world could easily be brought onto the Web. And imagine the cost savings, TCO, ROI, blah blah blah that this would have. But unfortunately we don't live in an ideal world.
-
URL importing
2007-01-20 12:18:53 ianb [Reply | View]
You can do the import from URLs in Python currently, though not in quite the way you describe. Close, though. Anyway, you can see the example here:
http://svn.colorstudy.com/home/ianb/httpimport.py
I'm sure there's other similar examples out there for Python. It's a security nightmare, as your computer's integrity becomes very dependent on your network and even internet integrity.
Another way to address the issue is better bundling and packaging. We are very close in Python. Things like py2exe or py2app kind of do it, and we could actually create a much simpler system given the tools that have been developed in the meantime. The resulting scripts will be large in terms of disk space, but eh -- they can still be nice and tight in terms of effort going into them. We're very close to this, but it's really not that clear where to go from here either.
-
Why This Needs Commercial Sponsorship
2007-01-20 11:49:25 Brian McConnell |
[Reply | View]
Hi. I wanted to respond to some of the comments that have been posted or sent privately.
Clearly it is easy enough to modify a language to import from a URL (or use filesystem trickery to do this as is).
This will work well enough, except that it is inherently insecure, and more importantly, unstable. The URL might change, or the repository might disappear.
This is where a company that's in a position to set standards can do everyone a favor by hosting the code repository, and in the long run, create a DNS namespace for code. Then developers will know that the system is reasonably secure, and is likely to be around for a long time.
Also while I used Python in this example (it's my favorite language), there's no reason this cannot be implemented in other languages. I'd like to see this become standard practice.
Lastly, I did not mention this in the article, but this facility will be very useful for mobile devices, which typically have limited storage for apps. With this system, the mobile device could cache the most frequently used modules, and discard the others if space is running low (and reload them next time they're needed, if ever). -
Why This Needs Commercial Sponsorship
2007-01-22 20:52:32 donbarthel1 [Reply | View]
<<
This will work well enough, except that it is inherently insecure, and more importantly, unstable. The URL might change, or the repository might disappear.
>>
I don't think that this has to be insecure for the reasons you state. Caching can be used here. If the system is optimized (not unlike the DNS system) to cache URL-imported modules locally, at both the client and referring server (the server that hosted the code that issues the #import URL statement), then if a URL changes, the copies at the client and referring server could be used, even if expired (expired from the cache). The copy at the referring server would be unlikely to dissappear since the original program (or referring module) is hosted by it.
This whole thing needs a heirarchy of caching at the client and at the reffing server anyways to optimize performance. I'm just suggesting that this heirarchy could be used to solve the 'URL might change' problem.
-
What you are looking for is called ruby.
2007-01-20 02:52:41 malcontent [Reply | View]
See the following links.
http://redhanded.hobix.com/bits/stowingYerLibrariesOffInTheCutNPaste.html
http://redhanded.hobix.com/bits/rubyForWindowsInUnder1k.html
-
Other things that keep me from programming
2007-01-19 14:01:28 carribeiro [Reply | View]
Thanks for the article! One of the things that made me lose the pleasure of programming was the lack of good open source database support... specially in Python, which is also the language that I most like to write (and read) code. By the way - Python's is a reader's language, don't you think? I used to work in Delphi (I'm proud of being one of the first people around here, in Brazil, to have access to the 18 floppies with Delphi 1.0 beta), and this was one of the things that they got right - and eventually, Microsoft copied it (badly) and there it went. Also, I remember seeing Java code for the first time, a long way ago... when I say the class statements with something like domain names, I thought that they would do it right, and implement exactly what you propose now - but we all know how it ended.
But database support isn't the only thing in my list now. There are two other things that make me crazy right now: unicode and visual application testing. At this time, I hoped for unicode to be already well stablished, with all the quirks ironed out. But my last experiences with setting up webservers told me the opposite: it's still quirky, there are a lot of things that can go wrong, and it's quite easy to get a garbled webpage when simply porting a webapp from one server to another. Tracing it down is a nightmare, because the error can be about anywhere: in the data, in the database, in the webserver, in the client... go figure.
As for visual application testing, it's another nightmare. I really love the concept of test-driven development... but in reality, webapps are incredibly difficult to test in this fashion. It's hard to do automated regression 'the right way', with tools. There's a lot of stuff in the way, things that may look exactly the same to your eyes but look completely different for the testing tool. It's not just an annoyance, it makes automated testing impossible for small scale projects.
These are the problems that I would like to see solved - easy database connectivity, unicode that just works anywhere, and better testing tools that really work with visual apps or webapps. For now, it's just a dream, and it's what keeps me away from programming.
Carlos Ribeiro
-
Django
2007-01-19 07:52:48 seanlynch [Reply | View]
Have you looked into django
http://www.djangoproject.com/ (http://www.djangoproject.com/) ?
The django project has a great object relational mapper layer. I've started doing Rails work in the last year, but I have seen Adrian Holovaty do a few talks here in the Chicago area and django is pretty impressive.
I don't know if the django ORM layer can be extracted and put to more general use, like Rail's Active Record can, but django is pure python and it makes integration with databases a snap.
-
In the language or in the file-system?
2007-01-18 21:17:34 Paddy3118 [Reply | View]
If you had an extension to a file system that allowed (using unix as an example), the concept of a link to be extended to url's i.e:
ln --url http://paddy3118.blogspot.com/ \
/home/paddy1/blogspot
... to make everything that is served from the url automatically available from /home/paddy1/blogspot/... using normal file access, with the OS dealing with caching etc, then the language(s) don't have to change.
- Paddy.
-
security problem
2007-01-20 03:53:37 tbuitenh [Reply | View]
I was thinking the same, and there is a filesystem that does this, see zero-install.sourceforge.net . The problem is that it can be difficult to put checksums in a path. Without checksums, a malicious developer might replace a library developed by him by something else, and the system won't notice. Sticking PGP signatures to everything, like zeroinstall does, doesn't help, because you want the developer who typed the "include" to do the signing or checksum, not the one who wrote the library.
... I started writing out all the possible path rules that wouldn't work, but found one that does ...:
/http/foo.com/widget/2.0.1/1234abcdef.py -
In the language or in the file-system?
2007-01-19 01:01:03 peterhickman [Reply | View]
You could use fuse for this. Just have a script to handle the /mnt/extlibs mount point and let it take you url as the argument. I can't see this being too difficult. Indeed the /mnt/extlibs could just be installed as part of the library search path. You could then do:
import http/www.google.com/code/widgets as widgets
and when the search got to the /mnt/extlibs it would see the http prefix (or whatever convention you used) and get the code.
Works on Linux and Mac and would probably work for Perl and other languages as well.



Great ideas! They deserve to be taken up.
I hope Google adopts them as a basis for their online OS, as part of a Google computer or as part of their Android mobile phone project.