Sunday, October 28, 2007

Try It Again

"They say the definition of madness is doing the same thing and expecting a different result" - The Hives

Is it sad that when I first heard this I thought of imperative vs functional programming?

Thursday, October 25, 2007

Offline Web Applications

That doesn't sound like it makes sense, does it? Why would you want to use a web application without the internet? Well, it makes sense for some things. Wouldn't it be nice to access your GMail account when your stuck at the airport and don't feel like paying for wifi access? A lot of web applications nowadays are used to store user data. The user has to log on to access it; there is nothing on the client. When the users wants access to this data when there is no net connection, we have a problem. So what do you need to build an offline web application?

For one, you need storage on the client. Remember, web applications run in the browser. The browser has only limited access to a client's machine. They can't just write massive amounts of data to the hard disk. The first requirement then, is local storage. Figuring out what to keep cached on the client is a whole other story.

Next, you need some way for the client to access your web page without accessing the internet. You need some way to cache the page(s) for the client's browser.

Lastly, your web application needs to act as though it is communicating with the server when it really isn't. You need some application logic to be stored on the client as well.

Sounds like its pretty complicated, but there are some solutions out there.

Google Gears is probably the most popular. It is still in an early developer beta though.
There is Dojo Offline Toolkit, which is nearing version 1.0.
Web2OS looks pretty interesting as well, but it is still in a private beta.
The WHATWG is also trying to come up with some standards to support these ideas.

How about rolling your own solution? Lets see how to provide the requirements for an offline web app using Java.

Technologies:
Applets, LiveConnect:
Allows javascript to communicate with Java Applets. Derby: An embedded Java database

First, the web application has a hidden applet (1px by 1px) that is loaded in the background. The applet is cached locally on the client's machine. This allows them to use it offline or online. When the applet starts up, it starts the embedded database which can store data on the client, even across sessions. They can close the browser, shut the computer down, and it'll still be there when they get back. This solves the local storage problem. Now for application logic. With LiveConnect, the javascript can call Java methods in the applet. So instead of directly communicating with the server, the client code communicates with the applet (which is also available offline). The applet can then check for a net connection and perform the appropriate action, either forward the request to the real server or do something locally. We'd have to rely on the browser's caching ability to cache the applet and javascript/HTML pages.

I suppose that may work in theory, but actually getting it to work in practice may be another story (I can image Applet security issues, browser caching issues, just to name a couple problems). Just some thoughts.
Check out Francois Orsini's presentation, Enabling Offline Web Applications with Java DB, from JavaOne 2007 for more details. He also mentions possibly embedding an HTTP server, like Jetty, in the Applet.

Friday, October 12, 2007

CS Miseducation

Computer science enrollment is down. Is it really because of outsourcing? Sure, that's probably a factor, but maybe it is because no one really knows what computer science is when they are choosing what they want to do with their lives. In most high schools, computer science is not given the same attention as other sciences like biology or chemistry. From personal experience, it seems the most common reason students chose CS is because they like fixing computers or they really like computer games. They get to school and find out that they'll never touch hardware and no one is going to teach them how to create the next great MMORPG. I talked to a freshman the other day who happened to be on campus for some "College for a day" type thing. He was very concerned with what kind of languages he would learn and whether or not they teach you how to make video games. CS education in high schools usually consists of some HTML, VB, and maybe some Java. At the high school level they focus on programming languages. That's it. No wonder enrollment is down. The computer classes at high schools make it seem like such a boring and dry major. All you do is sit in front of a computer and type lines of code all day? How boring. They do not show the bigger picture. They do not show what kind of interesting problems are being solved with computers. Students therefore think that computer science is programming; that it is sitting in a cubicle alone from 9-5 updating some bank's software for the Y2K bug.

How can this be fixed? I think colleges/universities have a lot of work to do. They need to participate with local high schools to help expose students to CS. They need to help high schools develop a real computer science curriculum for their classes. Maybe send some grad students over to help teach. This costs money though, and since enrollment is down many departments can't get the money to do anything about it so enrollment will stay down. It's a Catch-22. High school CS teachers need to be more qualified and better educated, but I'd image it is quite difficult for someone with a CS degree to go into teaching at the high school level. A survey done by the CSTA revealed that many CS teachers do not feel comfortable with the material. At my school, the CS teachers were math teachers trying very hard to stay one step head of the class.

CS is becoming an integral part of many other disciplines and each year it has a greater and greater impact on the world. If something isn't done for CS education in high schools enrollment in colleges will continue its current trend.

Thursday, October 11, 2007

First

This blog will be about adventures as a computer science major / all 'round computer nerd. It'll be primarily to work on my writing skills I suppose. I'm not really sure what the content will be like. Probably thoughts on papers/books I'm reading or things I'm working on. Yeah.