Colbert's White House Correspondents Dinner Speech
Fantastic stuff - slyly delivering the Truth.
java..python..eclipse..and whatever else interests me.
Fantastic stuff - slyly delivering the Truth.
Jeff Winkler, email@example.com
The person writing a script has to interact with objects in a safe environment. It's a conversation between the user - exploring, understanding the API's, and the objects and API's of the system. The goal is for the user to learn the objects by exploration...
Ideally, there would be an interactive Rhino shell.
Before the call, I was reading up on Seymour Papert, after playing with RUR-PLE, a python learning environment. I had playing with Graforth as a kid - and it was based on Logo. What makes these learning environments succesful? Hard Fun, and this, seem to articulate it best:
1 What is Logo?
Logo is a unique piece of software. In the purest sense, Logo is a programming language; it is a full-featured computer language derived from LISP, the language of artificial intelligence. More important, however, Logo is a language for learning. It is the right tool to teach the process of learning and thinking. Logo provides an environment where students assume the role of teacher. As a teacher, they must:
.. Designed at MIT as a language for learning, Logo is by its nature:
|friendly||Logo is easily grasped; we can relate to the turtle and use it as an object to think with.|
|extensible||Logo can be taught new commands and other commands can be built thereon.|
|forgiving||Logo offers immediate feedback through helpful and informative messages.|
|flexible||Logo is as useful with preschoolers as it is with students of higher mathematics.|
|powerful||Logo is a programming language, providing all the tools needed to create programs of any degree of sophistication.|
How does a person using a DOM understand what's going on under the covers, with the underlying API's?
Ward suggested using debugger to trace into the code.
Though we had a great, rambling conversation, we didn't have easy tools to take notes. Though DashTime is a "virtual place" - there's no there, there. I didn't have an IRC client, and it would be a pain to download. I was jonesing for a collaborative shared text space to take notes. An IRC applet would ease the transition; something like SubEthaEdit would be better, be cross-platform and web-based. SynchroEdit looks the part:
SynchroEdit is a browser-based simultaneous multiuser editor, a form of same-time, different-place groupware. It allows multiple users to edit a single web-based document at the same time, and it continuously synchronizes all changes so that users always have the same version.
SynchroEdit's main editor is fully WYSIWYG, dynamically displaying bolds, italics, underlines, strikethroughs, with various justifications, indents and listing styles as an author inputs them. SynchroEdit also supports a simple, text-only editor for more basic documents. To clarify the multiuser experience, the editor window clearly depicts every user's changes in a specific color and also marks where each user is currently editing with a colored flag listing the user's name.
This is a low-hanging fruit which delivers value for me, and I would see having other developers in my company use.
Given the method findbook():
DBC suggests that the contract should state, and enforce any preconditions. In my company, we do:
So, I'd like to write a script to type the "Require.notNull" bit for me. I would do:
Mark of pywinauto fame told me about nose, a unit testing tool with autodiscovery. I was slinging some python over the weekend, and needed coverage as my codebase got bigger.. so I whipped this up. I run this on a DOS window under windows. Basically every time you change any .py file, it runs tests. I call it nosy.
''' Return a long which can be used to know if any .py files have changed.
Only looks in the current directory. '''
val = 0
for f in glob.glob ('*.py'):
stats = os.stat (f)
val += stats [stat.ST_SIZE] + stats [stat.ST_MTIME]
if checkSum() != val:
I didn't get cute with lambda to squash it into a single line. This is simplistic, but gets the job done. I've sent it to Jason for improvement.
Update: A video of this is here.
Monkey is useful but doesn't yet have autocomplete or an interactive shell. I think that's needed to learn the API's, and delve further into Eclipse plugins and SWT. EclipseShell is interesting, but it's not a straight interactive console like Python's, where you can create and interact with objects. (Perhaps the Rhino console can be hooked up)
However, something is wrong.. I want to get the the active window (the window global in Monkey), but it is coming back null:
window = wb.getActiveWorkbenchWindow() print window None
Other API's work fine...
for vd in wb.getViewRegistry().getViews():
There's more than one way to skin a cat--getWorkbenchWindows() works:
wnds = PlatformUI.getWorkbench().getWorkbenchWindows()
Great! Let's try a HelloWorld..
org.eclipse.jface.dialogs.MessageDialog.openInformation( window.getShell(), Hello","World")
Traceback (innermost last): File "<console>", line 1, in ? org.eclipse.swt.SWTException: Invalid thread access
At least this has a reasonable explanation (I'm on a worker thread).
So, you can use Eclipse API's and objects interactively. Excellent. Next, I would love for Autocomplete to work. Ctrl-Space doesn't work in the console. (Bug? I think so.. the console has the Jython nature now.)
For some wierd reason, the python dir() function isn't working, returning an empty list even for a builtin class:
str = "Hello"
Normally this would return a list of methods:
['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__ ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getslice__', '__g t__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '__mod__', '__mul__ ', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', ' __rmul__', '__setattr__', '__str__', 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs', 'find', 'index', 'isalnum', 'isalpha', 'isdi git', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lst rip', 'replace', 'rfind', 'rindex', 'rjust', 'rsplit', 'rstrip', 'split', 'split lines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill ']
So close.. hopefully pydev extensions can enable autocomplete on the console. That would make for a truly interactive exploration of the Eclipse environment.