Three Things I Learned about Software in University

Posted by Jerry Sat, Jun 30 '07

Spotted this on Reddit (many insightful and funny comments I’d relate to), so I thought I’ll hop in and make up a list. :) Not officially graduated yet, and don’t have enough experience in work or hobby programming to make up a “While not in college” list, so here’s my take on just the three things I learned about software in university:

  • On programming: Code flows out better at the time period between 3am and 7am in the morning. Bugs are solved better at the time period between 8am and 12am in the morning (after a good nap and caffeine beverage).
  • On code quality: Time and effort spent notwithstanding, there is always A Bug in the code. There are no exceptions, period. (Or more commonly put, “Bugs are a fact of life.”)
  • On peers: As a twist on the old joke – there are 10 types of people in the IT faculty. Those who “get it”, and those who don’t. And never will, or simply do not care enough to do so. Way over-quoted, but really very bluntly mirrors the kind of people you meet.
# Posted in 10 years ago comments
 

Random thoughts on Comet

Posted by Jerry Fri, Jun 29 '07

Went down to Gold Coast with Chad and Zee today to see a client – a car sales agency, as a matter of fact. Young, chinese guy, smartly dressed. He had some pretty clear, not exactly in depth, but straight to the point requirements: See this (future rival) car auction website here, with its real-time bidding features? Now, build me one. In PHP, chop chop.

Ok, I kid… not quite the exact words, but you get the gist. Logically, I should comment on said rival website a bit. It boasts a pretty sound design: access the bidding page, and it loads a Java applet seamlessly, draws a simple textbox and a Big Red Button ('Bid’), rotating carousel of car photos, and generic auction details. Bids show up in textbox while they occur, it is linked to offline auctioning as well, and you click on the Big Red Button to add $200 to current going price. I’m guessing notifications are done either with sockets or dispatching HTTP calls, but judging by the speed of activity updates at times I’m betting sockets. I forgot to check what language the server would be on. I’m guessing PHP. So, let’s reverse figure out the design:

Applet (on the client’s Java VM) creates socket, server maintains an in-memory collections of connected ('subscribed’) clients, sends data stream down socket, applet read()'s, updates.

Not too complicated, but in the age of APIs, Rails-killer frameworks and Web-2.0-ness, perhaps dwelling a little too low-level on the client side. Still understandable, I suppose even though everyone thinks applet’s are sooo 1995, there’s still a certain supply and demand chain of Web 1.0 developers going on. Second mistake: no mention that the page uses Java – the client casually but specifically mentions the fact that he ingeniously figured out it needed the JVM. That’s one point off portability, and another off usability – and no, while Java is inherently cross-platform, the browser plugins are horrible on lower-end machines. Why else did the applets trend blow over and people migrate to Web Start? (See Wikipedia’s take)

Now this is where Comet (wiki) seems to fit perfectly. So it was quoth:

Comet is a programming technique that enables web servers to send data to the client without having any need for the client to request it. It allows creation of event-driven web applications which are hosted in the browser.

To explain further, instead of the “pull” paradigm in traditional HTTP apps where you query the server for a response, the server keeps clients updated by somehow “push“ing notifications of events to clients. (Some wavy hand motions through the air usually help to speed up comprehension.) Think Meebo and chat on Gmail. Recommended reading: HTTP streaming, push technology. Ok, perfect. Now implementing is the hard part, because simply reading a bunch of articles on Ajaxian last year doesn’t count, so some research is in place…

To tally current implementations,

  • Wikipedia lists several commercial and non-commercial Comet engines. There is the open source Cometd, and a number of articles that cover the iframe/javascript method.
  • Dojo seems to be the prominent Javascript library for Comet, but I suppose basic Javascript + any Ajax library would do.
  • One notification-based implementation is in PHP, but it really just is a socket-server-client prototype.
  • Most immediately-available (?) engines either directly implement the server (as a HTTP daemon or middleware app – I spot ICE!) itself, use J2EE, or a second medium for managing communications (e.g. Flash).

Now, the problems,

  • The client insists on PHP (which, none of the three of us have mastered).
  • I believe he uses shared hosting, on Apache.
  • Note that there doesn’t seem to be any directly pluggable libraries like the J2EE WARs to support Bayeux...
  • And since installing custom Apache modules to extend and implement efficient streaming is likely out of the question…
  • And Comet may require certain implementation shifts on the server side to work properly (e.g. not closing HTTP sockets prematurely)...
  • And from the Cometd mailing lists and other Googled sites, Apache (or at least, the fork version; I’m not sure if this is what his hoster uses) seems to be notoriously bad in terms of scaling. Keeping 1000’s of persistant connections open = need high efficiency.
  • And finally, though it’s none of my business, I do worry about his quota and server hoster… Don’t they used to ban high-traffic generating software like CGI chat?

Hmm, dai pinch? Quick ideas,

  • Scrap Comet. Poll server with Ajax calls every x seconds (where x is between 0.1 and 1).
  • Scrap performance. Just use the iframe/javascript method, and explicitly tell the client not to leave their browser for prolonged periods.
  • Scrap high-level stuff. Implement PHP sockets with PEAR library, and optionally use Java on client-side. Unlikely to work on shared hosting, isn’t it?
  • We haven’t asked for more in-depth details. Ask if possible to use mod_jvm. Highly unlikely though.
  • Scrap PHP. Move the whole darn site to Ruby on Rails! (We were joking over the RailsEnvy videos after the meetup)
# Posted in 10 years ago comments
 

Kitchen experiments: burgers and mustard meatballs

Posted by Jerry Tue, Jun 26 '07

Woke up to a rainy Tuesday afternoon (yes, my sleeping cycle has been utterly destroyed by the advent of this month-long holiday) after a long night of gaming (Battle for Wesnoth's Scepter of Fire level). With pangs of hunger and half a pound of unplanned-of ground beef defrosting in the fridge, what’s a guy to do but to make a nice hot thick burger? Randomly conjuring a recipe off the top of my head, I packed tightly a handful of beef, fried in an omelet pan with a little bit of oil, and sandwich between slices of cheap post-microwaved wholemeal bread. Not exactly good ol’ Ramly Burgers, but good nonetheless.

'Crap, now what do I do with the rest of the beef?’ I thought (3/4’s of a box = still a lot left over)... Google-Based for some recipes and decided to pick a random one. Thus:

Ingredients

  • Ground beef 10 full tablespoons (I’m just assuming that one meatball = 1 tablespoon scoop of beef)
  • Full-grain mustard half tablespoon (aka the first seasoning I found sitting in the fridge)
  • Soysauce (Original recipe called for worcester sauce. Didn’t have any, so I just grabbed something salty and black. Approx. 4 tablespoons)
  • Milk
  • Salt and black pepper

Instructions

  • Add beef, mustard, soysauce and seasoning to large bowl and mix. Pour in a liiitle bit of milk and mix, adding until I got a pasty consistency.
  • Heat up some oil in pan (I just reused the cooking oil and omelet pan from my mini burger adventurette).
  • Using a tablespoon, scoop some beef and shape into round balls (or whatever appropriate shape… no one’s stopping you from making square meatcubes…) with fingers and place in pan. If your pan was too hot, you’ll learn the very important lifelong lesson of how cooking can be very painful to a newbie this very instant.
  • Fry on all sides on medium-ish heat for about 5 minutes. Try splitting one with spatula or eating one to see if cooked.
  • Transfer to large dish layered with paper towelettes. Things are going to get messy with all these juices…
  • Eat contentedly while watching anime.

Notes to self

  • Possibly use less soysauce or none at all for better flavor.
  • Keep juices next time.
  • Herbs, onions, garlic or other veggie bits would be awesome.

Disclaimer: The author is completely untrained in the arts of cooking and food safety. By reading this statement you agree that he will not be held responsible for any ill effects, food poisoning, cooking accidents, mental trauma due to incredibly bad taste, or any related medical problems directly or indirectly caused by following the instructions recorded in this recipe blog-post.

# Posted in 10 years ago comments