Search as you type with Seaside & jQuery example code
Before I implemented search as you type filtering in Smalltalk Labs Browser, I wrote a little test app to try it out. I had done something like this before but that was a year ago so I wasn’t sure if I still knew how to do it :)
The code for this test app is very short so I thought I’d share it so that you can easily see how to integrate search as you type into your own Seaside apps, without having to browse through the Smalltalk Labs Browser code.
Just create a new Seaside application and replace the renderContentOn: code with this snippet. This snippet makes use of jQuery so you will have to add the JQDeployment or JQDevelopment library to your application with the /config tool to make it work. I wrote this using Pharo so I’m not sure if the method asWords I use to create the test data is available in all Smalltalk implementations, it probably only works in Squeak and Pharo.
Oh no, a new blog! But it’s about Smalltalk (and Newspeak).
I never had good experiences with blogs. I never update them, I’m way too lazy for that. But I also want to document my experience with learning and using the Smalltalk and Newspeak programming languages, so I will try again. I will fail, there’s no question about that, but that’s half the fun, isn’t it?
“I tried out Squeak before, many years ago, but I was quickly turned off by… Well, everything I guess. Nowadays it looks a lot better.”
“Gilad Bracha’s vision for Newspeak and software development in general is just too cool to miss out on.”
I started learning Smalltalk about six months ago (has it been really that long?). I tried out Squeak before, many years ago, but I was quickly turned off by… Well, everything I guess. Nowadays it looks a lot better. Since I did a lot of Objective-C and Ruby development I always wanted to check out Smalltalk which heavily influenced those languages and Newspeak, which is kind of a successor to Smalltalk, intrigued me. Gilad Bracha’s vision for Newspeak and software development in general is just too cool to miss out on.
I didn’t have much time to do Smalltalk and Newspeak stuff since I’m always swamped with work on other projects, but in the little free time I had I started reading through the Newspeak tutorial, the Pharo and Squeak by Example books and then watched a few screencasts from Smalltalk Television and Pharocasts. There was a comment on one of the Pharocast videos that asked for someone to record his voice for the screencasts. I thought why not use this as a neat way to both help out and learn more about Smalltalk, so from then on I did the voice for all the Pharocast episodes and also contributed two screencasts myself.
“I was very intrigued by the idea of editing a website’s code from within the browser.”
After writing only a very tiny amount of Smalltalk code and mainly trying out the different Smalltalk implementations, I started my first real Smalltalk project about a month ago, for the Seaside web framework using Pharo. Seaside comes with a code browser that lets you edit your website’s code from within the web browser, but it’s missing a lot of functionality and since it doesn’t make use of AJAX, every click reloads the whole website which is annoying since this also resets the scroll position in all the lists. I was very intrigued by the idea of editing a website’s code from within the browser.
Smalltalk Labs Browser
I did manage to pull it off though and the first beta release is going to be available for download later today. There’s already a huge page of information and an overview and tutorial video, available on the projects site (in the menu to the left).
What I learned about Smalltalk this far
“It’s really hard for me now to use a language that doesn’t give me this kind of power”
I love the Objective-C syntax so the Smalltalk syntax is a natural fit for me since Smalltalk just removes the square brackets around methods calls and terminates a line with a dot instead of a semi-colon.
I usually write code in text editors instead of IDEs. XCode is the only IDE I ever liked, NetBeans, IntelliJ Idea and Eclipse always turn me off after a while because they are so huge and slow even though they can be very, very helpful. The more I used the Squeak/Pharo tools though, the more I started to like them. The refactoring is awesome and the ability to always be able to look up an object’s methods and the method’s implementation is very helpful. And Squeak/Pharo always starts in under a second thanks to being image based and since I can save the image where I left off, it’s just as quick as opening a text editor on some file but gives me all the power of an IDE and more.
Being able to change the tools you use so easily is something very powerful. The first thing I did in Smalltalk after only about half an hour of reading the Squeak By Example book was implementing Windows 7 style window docking (move a window to the left, maximize the window so that it fills the left half of the screen, same for the right side..). I think it took me 10 minutes to do this and that included figuring out how Squeak handles windows, the inspector tool was very handy for that.
Then, yesterday, I wanted to see a version by version comparison of a monticello package (diff of version 1 to version 2, 2 to 3, 3 to 4 and so on) but I wasn’t able to find a tool that did that. In just five lines of Smalltalk code, I quickly wrote a script that did the job by recombining already available tools and objects.
It’s really hard for me now to use a language that doesn’t give me this kind of power :)