August 26, 2015

Techniques after using Swift for a month

At work, I was put on an iOS/iPad app project a little while ago. I've never written anything in the iOS ecosystem so I spent about a week to research before digging in.The transition was smooth primarily because I'm using Swift--a much more succinct and modern language than Objective-C--and my somewhat dated Android experience and very dated Windows dev experience provided me with all of the patterns I needed to understand iOS. Also, coming off of Groovy development, Swift's syntactic sugar was immediately understandable.

I came up with two small techniques for the project. One helps with data persistence using Core Data with models and entity managers, a la JPA. The other technique simplifies updating multiple views using the Notification Center with type safe additions. They've helped to speed development and--the thought of every developer who thinks they've discovered something new--some aspects aren't commonly known (which could be good or other).

My Core Data code starts with the NSManagedObject model generation. In a separate file, I create an extension class so that the model can always be re-created without wiping out my custom methods. I also create a class derived from a DAO utility class to implement all CRUD methods using generics. The DAO util:

class DaoUtil {
    var managedObjectContext: NSManagedObjectContext
    var managedObjectModel: NSManagedObjectModel
    var entityName: String
    init(managedObjectContext: NSManagedObjectContext, managedObjectModel: NSManagedObjectModel, entityName: String) {
        self.managedObjectContext = managedObjectContext
        self.managedObjectModel = managedObjectModel
        self.entityName = entityName

    // ... create, find, count, and delete methods


The find, count, and delete methods come in an *All() version and a *(fetchRequestName: String) version. The implementation for a User model would be as follows:

extension User {

    // ...


class UserDao: DaoUtil {
    let EntityName = "User"
    init(managedObjectContext: NSManagedObjectContext, managedObjectModel: NSManagedObjectModel) {
        super.init(managedObjectContext: managedObjectContext, managedObjectModel: managedObjectModel, entityName: EntityName)
    // ... custom methods


This design favors the data mapper pattern over the active record pattern, which I think is more common in iOS. I prefer a separation of data object and persistence.

The other technique is a type-safe wrapper around the notification center. iOS's notification center calls reminded me of Windows SendMessage (and, with dispatch queues, PostMessage). One potential issue with these is the lack of type safety since you're effectively passing around a void pointer. Using Swift's generics again allows us to create small, typed versions based on a named string constant, an event (e,g, BeforeUpdate or AfterDelete), and an object type.

The core of the implementation:

    private func observe(id: String, event: Event?, notify: (observable: T?) -> Void) -> NSObjectProtocol {
        var observer = notificationCenter.addObserverForName(id, object: event, queue: NSOperationQueue.mainQueue()) { notification in
            if let userInfo = notification.userInfo, observable = userInfo[id] as? T {
                notify(observable: observable)
            } else {
                notify(observable: nil)
        return observer
    private func notify(id: String, event: Event?, observable: T?) {
        if let observable = observable {
            notificationCenter.postNotificationName(id, object: event, userInfo: [id: observable])
        } else {
            notificationCenter.postNotificationName(id, object: event)
    func observeUser(event: Event?, notify: (equipment: User?) -> Void) -> NSObjectProtocol {
        return observe(NotificationService.Name.User, event: event, notify: notify)
    func notifyUser(event: Event?, user: User?) {
        notify(NotificationService.Name.User, event: event, observable: user)

With this, I can trace publishers and subscribers by type and event, but still take advantage of the built-in message queue. Still much to learn ...

posted by sstrader at 11:41 PM in Programming | permalink

December 15, 2011

Some thoughts on Ruby after finishing a week (minus one day) of training

Ruby's been my go-to language for any medium-trivial scripts that might need to be written. At work, I'd used it for some log file manipulation and for converting CSV files to SQL INSERT scripts, plus minor misc. one-offs. It's benefits are its portability and terse power. Being a Java developer, I'd honestly prefer to have used the almost-identical Groovy language, but it requires the JVM and who wants to always rely on that behemoth (useful as it is)? Passing around a few rb files plus an exe and a dll is just too simple.

This training (for the new job) is covering Ruby proper plus Rails. Much of the framework maps easily onto what is offered either in the JEE Web container and Servlet API or in the JPA/Hibernate API. There's a template library, request filters, URL mapping, and general data persistence and query support. Knowing one definitely helps in learning the other.

Monkey patching/duck punching is de rigueur, so classes are commonly rewritten at runtime as part of the standard framework. You just need to know that a class will look a certain way. Also, interestingly, any number of unintuitive methods will be dynamically added based on a callback named method_missing. This is called whenever a ... method is missing (doy). Frameworks will use it to allow loosely defined methods to be generated at runtime (e.g. by parsing intent from a method name, such as "find_by_name_and_age_and_zip"). All of this tacit interface generation adds to the general confusion when learning. Much is non-explicit in the code.

Readable, English language code is a goal. Ruby's functional roots make this easier to achieve this goal than, say, C++ or any C-derived language (although the Boost library's Spirit parser does an excellent job of using C++ operator overloading to replicate BNF). Because of the emphasis on readable code, Ruby library developers will talk about creating DSLs as opposed to simply APIs. This seems like an odd affectation.

The functional bits are familiar enough if you know C++'s function objects or Java's anonymous inner classes. Doing these tasks in Ruby is, however, much cleaner. (Notably, C++11's lambda functions offer promise, as does Java8's closures.)

posted by sstrader at 8:59 PM in Programming | permalink

December 9, 2011

Links on the singleton pattern

I'd been going to interviews over the past month and the singleton is still the most popular point of discussion. I would try to bring up other patters (let's discuss the visitor!) but to no avail. It's popular beyond its usefullness, and so I just hate discussions on it. However, it did force me to dredge up memories of discussions on the difficulties in managing the lifetime of a singleton in C++. The links:

  • To Kill a Singleton John Vlissides' detailed analysis of the problem and possible solutions
  • Double-checked locking - I'm embarrassed to say that I'd never heard of this (though may have used a form of it before). Check the singleton for construction and grab a lock if it needs constructed. Once getting the lock on an object, you have to re-verify that it needs constructed since it could have happened while you were obtaining the lock. Neat.
  • Once Is Not Enough - Jim Hyslop and Herb Sutter's discussion on the similarities/differences of singletons and global variables
posted by sstrader at 9:19 AM in Programming | permalink

October 29, 2011


I just published an Android app that lets you develop applications from your phone. It's a simple IDE with a script language and interpreter, visual screen layout, database management, etc. It's a v1 that has had a beta tester of just me, so beware.

You can review the Developer's Reference for a quick idea of what's what. And it comes with some sample applications for basic examples of what can be achieved.

(The marketplace is refusing to update images and text right now. Apologies if the copy editing is wonky.)

posted by sstrader at 6:37 PM in Phonebot , Programming | tagged android, mobile development | permalink

September 4, 2011

The labeled break in Java

Trying to optimize the Android app I'm working on and found this Java feature that I'm sure I knew at one point but ignored as useless. My mistake.

The code I'm working on is in the script parser. The parser has one class method per grammar rule (e.g. parser.processStatement() or parser.processExpression()) following general top-down parsing practice. Within each method/rule, the parser can fail on a token without being certain that the token won't satisfy a subsequent rule. For example: if processStatementLoop() is called before processStatementConditional() and an "if" is the first token encountered in the script, the token stack (and possibly other internal structures) needs to rewind after processStatementLoop() fails on "if". The parser needs to know that the grammar has not yet accepted the "if" as valid. So, a rule may fail on a valid script.

When the grammar was small, I started with various conditionals peppered through each method, unwinding the relevant structures if the rule failed. I changed the conditionals to exceptions because it was easier to manage multiple failures within a single rule. However, the exceptions could be thrown either because of an error in the script or because of simple backtracking in the grammar. The latter isn't a true exception, and so this could be considered misuse of the exception construct.

	private boolean processStatementLoop() {
		try {
			if (!processToken(TOKEN_FOR, true)) {
				throw new ScriptException(tokenizer);

			// ...

		} catch (ScriptException e) {
			return false;
		return true;

And so I pondered and searched on a substitute for the exception in this instance. I'm not sure how I found it, but the Java doc article Branching Statements described the mysterious labeled break. Using this, you can break out of a block a la the "beloved" retro GOTO statement:

	private boolean processStatementLoop() {
		Transaction: {
			if (!processToken(TOKEN_FOR, true)) {
				break Transaction;

			// ...

			return true;
		return false;

This (should) avoid the cost of exception construction and stack unwinding, but more importantly it more closely maps the code's intent.

posted by sstrader at 11:27 AM in Programming | permalink

July 1, 2011

Recent code project

Back in the middle of may, the web host that I use for Java projects--Lunarpages--dropped one of my sites because it was getting more hits than was permitted on a shared server. Their proposed solution was for me to purchase a dedicated server, trading an $8/month service for a $100/month one. I was kindof irritated that there was no inbetween, but you get what you pay for. Their business model was probably always to force the more active sites onto expensive servers contracts. I was lucky that I had the means to relatively quickly re-host, but others are probably more limited in their choices.

That killed a few weeks of productivity setting things up and tweaking and monitoring the new server. Once finished, I got back on my current Android project: an application that will let you create applications on the phone. For the past two weeks have had my head buried in code. This week, I got the basic script interpreter written and have it plugged into the application/module/control object framework. Still a lot to go, but as with any good project it has many areas to keep me interested.

posted by sstrader at 7:33 PM in Programming , Where was I? | tagged android, radiowave | permalink

May 13, 2011

The untimely demise of RadioWave

For the past month, I've been struggling with keeping RadioWave up based on complaints from the web hosting company, Lunarpages. I'm on a shared hosting server that's gone up from hosting ~300 sites a couple of years ago to >500 now. In the same time RadioWave has grown from ~5,000 hits/day to ~15,000. After the initial complaints, I moved the databases to a non-Lunarpages server. That helped for two weeks, but earlier today Lunarpages finally took RadioWave completely offline due to "extremely high traffic". The solution they offered was to purchase a dedicated server for $110/month (up from the $8/month I'm paying now). Even if I decided to dump ads on the site, it's unlikely that enough would be brought in to make it worth it.

I started RW in 2004 (a little over six years ago), and it's still a site I go to almost every day. I listen to internet radio a lot. It was also the first Java code that I wrote--some of which is looking quite hairy now. Every few months I'd get an email suggesting a new station or providing a corrected stream link, so it was nice to offer something useful to a few people. This is a busy weekend, but some of it will now be spent researching hosting companies. meh.

posted by sstrader at 5:52 PM in Programming | tagged radiowave | permalink

March 30, 2011

Reuseable frameworks for building applications

A month or so ago, I started working on an Android app that will allow you to develop applications on the Android itself. I'd found one application that allows you to add minor scripting on phone events, but haven't found anything as encompassing as what I'm working on. It could be out there, certainly, but the task is the fun part no matter if it's been done before.

Working through the application, I'm remembering how many times I've encountered this before. I'd written several script interpreters, the best of the bunch using the brilliant Boost Spirit Parser library. Where I currently work, they use a Sterling Software application to create order capture pages. Two previous companies I'd worked at (not Sterling) had products that were also based on building applications within an application. At one, I ported a very simplified version of the desktop version to WinCE. Similar to DSLs, these were domain-specific platforms. You couldn't write a word processing application within them, but you could write a training application or a set of intelligent data entry forms. I know I've thought this before, but as often as this task is written and rewritten, can't this be made generic somehow?

posted by sstrader at 8:45 PM in Programming | tagged android | permalink

November 11, 2010

My second Android app

Just released a pay version of the GPS bookmarking app I first published three weeks ago. The new version, ArgotPlus, adds several nice organizational features (a tagging system, viewing neighboring bookmarks, cardinal directions, and a link to maps) and will be the version I actively develop.

Share photos on twitter with Twitpic

Interesting report from yesterday, all handheld OSes except Android have lost market share in the last year:

posted by sstrader at 8:58 AM in Programming | tagged android, argot, mobile development | permalink

October 19, 2010

My first Android app

I just published my first Android app to the Android Market. It's an idea I had a year or so ago and, after getting my new HTC Incredible a few months ago, finally got the opportunity to write it. It's called ::Argot and it's a tool to bookmark locations to revisit them later. I had the idea during last year's Cabbage Town Chomp and Stomp. It was packed as usual and after wandering around I could never find my way back to where friends were camped out. The v1.0 is pretty basic, but I plan on adding features and creating a more robust premium version to maybe sell for a buck.

I've been very happy with the development tools for Eclipse and there's a strong community of developers and code samples on the internet. I was seldom stumped with a problem for very long. It felt good to get back to application development after doing primarily web development for so many years.

After the updates to Argot, I'll probably create a front-end for RadioWave. I've been listening to streaming stations in the car, and it would be nice to "dial" through their schedules to find something to listen to.

posted by sstrader at 8:13 PM in Programming | tagged android, argot, mobile development | permalink

June 28, 2010

Bug in ListCookieHandler Java class

The ListCookieHandler class is referenced on many web sites and the source code is provided on a subset of those (one instance at java2s). It's credited as coming from the book Java 6 Platform Revealed, however I couldn't find the implementation within that book searching via either Amazon or Google Books. Either way, there's a couple of errors in all of the implementations I've seen where two for-each loops are used with remove methods called on the collection within the loop. This is not allowed for obvious reasons and results in a ConcurrentModificationException being thrown.

posted by sstrader at 12:25 PM in Programming | permalink

April 23, 2010

A content voting microformat

There needs to be a standard specification for adding user voting to content. Currently, there are a range of disparate methods for valuing content:

  • Up- and optionally down-votes for an article or comment
  • Link click-through count, relative to other links on the page
  • Unique views per page
  • Average view duration per page
  • Page popularity based on region

Microformats are used to semantically tag information on a page (rss feeds, business cards, etc.). A microformat should be created to mark rated content, specify it's rating value, and specify how it's been rated. The act of rating, currently, requires specific tracking by the web site designers themselves. A third-party site could be created, similar to visitor tracking sites like Sitemeter or validation sites like the W3C's Markup Validation Service, to manage the vote logging.

Such a standard and complementary web site would make it easy for web developers to add customized content voting without implementing complex server and database support code.

posted by sstrader at 4:34 PM in Programming | permalink

April 13, 2010

iPhone, the platform most hated by developers

The new TOS for the upcoming iPhone OS 4.0 introduces additional restrictions on how developers can create applications for the device. Any application must be originally written in Objective-C, C, C++, or JavaScript as executed by the iPhone OS WebKit engine. In other words: no cross compilers. Cross compilers provide a single development environment that compiles a single code base to multiple platforms such as the iPhone, BlackBerry, and Android. This saves developers hundreds and thousands of hours of development time they would otherwise have to spend creating multiple code bases. The biggest company affected is (natch) Adobe and their upcoming release of Creative Suite which adds a much-touted Flash-to-iPhone compiler. Several smaller, but no less important, tool makers are affected as are the many developers that make a living off of games and whatnot written using those applications. Developers are now faced with the choice of supporting multiple code bases or being locked in to iPhone development.

Apple's choice, if we can divine intent, was a strategic move to lock developers in to the iPhone over other mobile platforms. Cross compiler companies' choice is to lock developers into their cross compiler over other, single platform compilers. Developers are offered a clear benefit by choosing the latter's lock in, not so with the former's.

I don't have a dog in this race, but I'm a developer and love the tech and social aspects of our mobile web present and future. Apple can do whatever it wants with the iPhone/Pad, just as Microsoft did whatever it wanted years ago to attempt to lock in developers with the Visual J++ mutation of Java. However, it's important to note the costs developers should consider when choosing the route of lock in. Short-term gains may have long-term drawbacks.

Some reading:

Geeks insist the iPad is for "their moms" to use as they stand in line to purchase one (or more) for themselves. This self-deceit is used to justify the purchase of what would otherwise be considered a grossly limited netbook. When developers choose to develop on the iPhone for the chance to get rich (many do), they also choose to navigate the capricious business dictates of Apple. Developers generally don't seek out arbitrary corporate limitations when choosing projects either fun or profitable, but with "do what works" as a common mantra, neither are they an overly principled bunch. We'll see if Android benefits from this.

posted by sstrader at 12:25 AM in Phones , Programming | tagged android, iphone, mobile development | permalink

January 5, 2010

Singleton for Java

Abstract generic class to use when you need class-level singletons (i.e. everyone's favorite factory pattern):

public abstract class Singleton<T> {

	protected T t;

	protected abstract T init();

	public T get() {
		if (t == null) {
			t = init();
		return t;

	public void clear() {
		t = null;


Simple use:

public class MyClass {

	protected Singleton<MyResource> myResource = new Singleton() {

		protected MyResource init() {
			return new MyResource();


	public void doWork() {

posted by sstrader at 11:03 PM in Programming | permalink

October 25, 2009

Opera (and Eclipse)

A few weeks back, I found out that a beta of Opera Mini 5 was available for my Blackberry Storm (out ~a month prior). The move from 4 to 5 added tabbed browsing, near-desktop speed (using Opera's proxies), and just a generally more elegant layout. Their functional tabbed browsing solution on such a small form factor is reason enough for a trial.

I started using Opera I don't know how many years ago. I remember it was when they still had ads at the top, so it was probably version 5 sometime at the end of 2000. It wasn't the most elegant software to work with, but this was years before Firefox was even a dream, so non-IE choices on Windows were few and squirrely. I'm not sure how, but I've stuck with it ever since and only in the last few years has it become really brag-worthy. Stick with something long enough and every little advance makes it seem worth while.

Yesterday, I was helping my brother with some web sites he uses for real estate. They're a mish-mash of multiple installs of WordPress with shared style sheets and several branches of dead code that is undocumented. He inherited this, and we learn a little more of the madness contained each time something needs changed (update the logo? edit two images and three css files...). Opera's Dragonfly is invaluable for tracking down layout idiosyncrasies and resource file locations. The same thing can be done with Firefox's Firebug, but with Opera you have one, small download to get everything you need.

Oddly, whereas I appreciate Opera much for its single packaging of every tool, I use Eclipse for development which is more akin to Firefox with its plugin approach to features. Although I run pretty lean at home, at work we use the ClearCase and ClearQuest plugins--two large installs that would be completely unnecessary for 90% of the people using Eclipse and so sensibly pluginable. And I guess that's the difference between my choice of an all-in-one browser cf. a piecemeal IDE (barring the very real possibility that I chose them because they both happen to be FREE): browsers' features can be lightweight; IDE features will more likely be much heavier. E.g. I don't need a Fortran IDE when all I'm writing is Java and sometimes C++.

posted by sstrader at 10:34 AM in Internet , Programming | permalink

August 5, 2009

EtherTV: video playlist editor

At the beginning of this year, I had an idea for a web site that would allow you to string together videos from other sites to make video mix-tapes. I've called it EtherTV, and it's located at (similar to my streaming radio station aggregator RadioWave at Basic information, along with any updates, can be found on my public wiki here.

EtherTV allows you to create and share streaming video stations by aggregating videos from web sites like YouTube. Each station broadcasts the videos in a fixed order then repeats when all videos have been shown. Like broadcast television, anyone watching a station at a specific time will watch the same video, at the same location, as anyone else who is watching. However, viewers can choose to skip to any other video in the station any time they like. Viewers can also easily return to the current location in the broadcast.

It's light on features right now, but I'll be continuing work on it to slowly implement my feature list. If you find it useful, recommendations are welcome.

posted by sstrader at 9:05 PM in Programming | permalink

July 22, 2009

The Concepts feature removed from C++0x

Bjarne Stroustrup discusses the standards committee's decision to remove Concepts from C++0x in DDJ [ via Reddit ]. A description of the feature has already been removed from the C++0x Wikipedia entry, so you have to go back to a previous version of the article to read about it. Simply: concepts are a form of rule-based verification of the duck typing found in templates. Compile errors stemming from invalid template parameters are currently reported only after a template is expanded and it becomes clear that the resulting code disallows the type. Concepts would be syntactic rules attached to template that provide more explicit hints about parameters' requirements.

Also read Stroustroup's paper defending the use of concept maps [ via endnote #1 -> "The Removal of Concepts From C++0x" ]. A little heavy, but it pointed me to Stepanov and Paul McJone's new book (out 3 days ago!) Elements of Programming.

posted by sstrader at 4:08 PM in Programming | permalink

April 29, 2009

Clojure on Google AppEngine

Last night, I went with a co-worker to an Atlanta Clojure User Group meeting about Clojure on Google AppEngine given by John Hume. I'd watched a few videos on AppEngine and read up a little on Clojure beforehand but still ended up with more questions than answers. Thus:

  • Even though they use JDO, GoogleAppEngine's approach to data seems informed more by its MapReduce/massive data access approach and is sorta schema-less. My first thought was that relational databases manage statically typed data and GAE's datastore manages dynamically typed data. Dunno. Someone at the meeting compared it to CouchDB.
  • Afterwards the discussion of the value of stored procedures came up and it seemed to have some relevance to datastore issues. Many design decisions hinge on where you draw the line between data type and data manipulation. At its simplest: a type is a number or string or somesuch, but type systems can also define mutability or basic validation, etc. At what point does the definition of a type stop being type and start being business logic? (Answer: depends on your tools.) I'm currently working on a defect at work where the SQL DDL puts restrictions on a field, but code "has to" exist in both the HTML and Servlet layers to perform similar validation. This seems to me to be a type system defined across three domains, although it may be poor design. Considering how often I see this, I suspect it's a limitation of the languages involved.
  • After you use your application, GAE will generate an XML file that describes what indexes you'll need. Neat.
  • Middleware: Ring (Clojure), WSGI (Python), Rack (Ruby). Trying to map their similarities/differences with Servlets (Java).
posted by sstrader at 9:40 AM in Programming | permalink

April 14, 2009

Reading an rss feed using JavaScript

Wrote this last night for my brother. It's a simple JavaScript class that reads from an rss file on the server and loads the entries into an HTML element. He has a blog (Wordpress) and a separate, static page that he wanted to be dynamically updated with recent posts. JavaScript and Ajax (plus some ghetto-parsing) was the quickest way I could think to get it done. Could XSLT be integrated somehow? I'm not sure.

The JavaScript file is called feed-injector.js and it requires Prototype 1.6+. Thanks to Alex Vollmer's article on object-oriented Ajax (along with his many commenters) to clean up the callback code.

There's very little magic here. Basically, the code makes an Ajax call to the requested rss file, parses out N entries containing title, link, and description elements, and then generates divs in the specified parent div. Example use (also using Prototype for the window load event):

  1. // For
  2. Event.observe(window, "load", function() {
  3.     var fi = new FeedInjector("/mysite/mysite.rss");
  4.     fi.load();
  5. });

Ajax can't call across domains so no funny business, mister. This is usually resolved by a "proxy" on your server that makes the remote call (i.e. -> -> and back). YMMV.

[ updated 29 Apr 2009 ]

Or, you could just create a FeedBurner account. These articles are ad-heavy, but they or their comments may add information: Display and Show Feed on HTML Website with FeedBurner BuzzBoost, Google Lets You Embed Feeds on Your Site. Another article, How to Embed RSS Feeds into HTML Web Pages - The Easy Way, shows how to add feeds to your Google home page and has many comments with other possible solutions.

posted by sstrader at 3:23 PM in Programming | permalink

April 8, 2009

Twitter moving to Scala, language wars reignited

Language wars can be fun. I learn much from the pompous-yet-informed missiles that get launched during a good language war, and Twitter's announcement [ via Slashdot ] of their move from Ruby to Scala is no exception. (Also see Joel Spolsky's absurdist attacks on Ruby for being untested while at the same time praising his own company's home-grown language.)

The Slashdot summary links to several good reports/interviews on the change and the comment thread includes further insights. Twitter's homegrown message queue, Starling, is brought up as an embarrassingly flawed implementation. I'd read about Starling around the time it came out and was intrigued that it was written in Ruby. Perhaps I shouldn't have been. Another link suggests that (1) the Twitter devs are blaming Ruby for their own bad code and (2) the Twitter architect is coming out with a book on Scala, so his opinion is suspect. Regarding (1), you should always assume the worst covering-their-ass intentions when a developer starts griping about a technology. Technology-blamers are usually notoriously poor workmen. Regarding (2), well that's just specious logic. Someone who's done detailed research on a language would have greater authority to recommend it, so if he was interested enough to write a book it's likely he found reason to use the language in a large-scale project. Also, he's going to be eating his own dog food, so increased book sales (on a fringe language) would be poor compensation for having to manage an unwieldy code base.

Whatever the outcome, academic theories on GC and nullable objects are merely interesting once the language is put to the test on a system that has the traffic that Twitter does. Should be interesting to watch the battles that continue.

posted by sstrader at 6:32 PM in Programming | permalink

March 26, 2009

YouTube API having issues with seekTo()

At around midnight last night, while working on code that uses embeded YouTube video with the YouTube API, my JavaScript that loads a video and seeks to a specific location started failing on the load (on one page) and failing on the seek (on another). I was working on an unrelated area and so took the opportunity to add more JavaScript logging via Log4JS (highly recommended). The problem persisted, code was moved around, and finally all logging was removed with the idea that watching the JavaScript somehow changed the event sequence. No luck. Eventually, I backed up the changed code and re-got the "working" versions from svn. Still broken. So I went to my reference app and received the sad news that the call is, in fact, no longer working as it had. Sometimes, it is that third party library that's causing problems!

The only reference I've found is a thread back in Feb 19th that actually duplicates my issues on the YouTube reference page: using the "Load video" with a non-zero "Start at" value fails to seek. The thread also contains a suggested workaround: wait until after the video is done buffering before performing the seekTo(). To be continued...

"seekTo fail in chromeless if video not already playing" in the YouTube APIs Developer Forum reports this in July of 2008. Suspicion is that it happens during queueing and with lower-quality videos.

[ updated 28 Mar 2009 ]

The solution is to call seekTo() after the playing event (1) has been received. So, the sequence is:

  1. onYouTubePlayerReady(playerId)
  2. onPlayerStateChange(newState == 1)
  3. player.seekTo(offset, true)

In my tests, I'd also seen error 100 (requested video not found) returned if I called seekTo() too quickly after onYouTubePlayerReady() fires. So, this is probably not a YouTube issue, more of a Programmer Is a Bonehead (PIB) issue.

posted by sstrader at 9:36 AM in Programming | permalink

March 11, 2009

Of note: RMI libraries

Article via Reddit comparing the Thrift RMI protocol developed by Facebook and open sourced to the Apache project, and Google's protocol buffers protocol released under BSD. The primary benefit of both is that they're much (much) leaner than XML and SOAP. The interesting point of the linked article was that (with the implementations used...) using compressed JSON was faster. Neat.

I've never been impressed by the incessant bitching from developers who decry the bloat of SOAP. I can understand the potential need, but I suspect that most of the time we're fighting server speed and not throughput. Slashdot discussed Thrift two years ago. There are a few gems in the comments--albeit buried under the usual jags about NIH syndrome. Meh. Many good libraries come out of NIH along with many bad ones. I know I've benefitted greatly from open source so, like the argument against "useless blogs," useless code is harmless when ignored.

posted by sstrader at 4:27 PM in Programming | permalink

February 12, 2009


Coincidentally (after reading about the NL plugin for Firefox) came across a year-old article in some programming rag at work describing the ins-and-outs of parsing C with lexx/yacc. You couldn't pay me enough to write a C parser (unless, of course, you're a potential employer reading this, in that case I'd love to write a C parser (but I'd seriously question why you need one)). What with the wacky declarations and struct tags. Despite the clear-yet-recondite rules for visually parsing declarations, the stack probably gets pretty hairy.

posted by sstrader at 9:51 AM in Programming | permalink

January 29, 2009


Just received my copy of Time Within Time, the diaries of Andrey Tarkovsky from 1970 to 1986. Did several one-page-tests* and all turned out fascinating. Of note, a quote he wrote down from Gustav Mahler on 26 August 1977:

What our contemporaries say about great art not being necessary for the creation of a work of art is utterly senseless. It would be nearer the truth to say that a huge investment of artistic means into everything from the first, general outline to the last detail, is a necessary condition for the creation of the kind of perfect work that could not be imagined in the wildest dreams of our naturalist friends--those impotent creatures!

And anything that is not imbued with that supreme craftsmanship is doomed to die before it even sees the light of day! (Mahler, quoted by Natalia Bayer-Lekhner, July 1896)

* (The one-page-test being the indisputable measure of a Good Book: open book to a random page; read it; judge the entire book by the contents of that page. Infallible.)

(The notes and drawings and ephemera remind me of another favorite book of mine, The Notebooks of Anton Checkov. )

Ignoring the critical approach of historicism towards this quote, and ignoring Mahler's psychology in general, I was reminded of a Dijkstra quote I'd come across days prior (via Reddit -> Peteris Krumin's blog article "MIT's Introduction to Algorithms, Lectures 17, 18 and 19: Shortest Path Algorithms" -> "Edsger Dijkstra - Discipline in Thought"):

Elegance is not a dispensable luxury but a factor that decides between success and failure.
posted by sstrader at 12:57 PM in Cinema , Programming | permalink

January 8, 2009

Recent code project

Had some fun over that last few days finally getting to a project I'd thought of in December. I have my MP3 folder available to my web server, but there's no easy way for me to access it remotely if I'm at work and want to listen to a ripped CD or two. To get around this, I wrote a few PHP pages to browse the folders from a web page, build a playlist, and dynamically serve up an M3U file to stream the tracks. Very convenient. The only issues I've had are with my flaky Apache server. Everything's pretty much up-to-date (Apache/PHP/etc.), but it can leak memory pretty badly, so I schedule a restart of Apache every hour. On the restart, the current track will pause and restart at the beginning. Meh.

posted by sstrader at 1:12 PM in Programming | permalink

September 4, 2008

Have you seen this image?


(If so, your browser can't pass Acid3...)

posted by sstrader at 10:41 PM in Programming | permalink

December 14, 2007

Dev fun

Got my home development environment cleaned up to allow me to do more remote work:

  • Made sure MySQL is locked down and exposed it through my web server (beware of default users!),
  • Upgraded from Eclipse 3.1 to 3.3 (minor niceties),
  • Moved from SourceSafe to Subversion and exposed access to Subversion through Apache (invaluable information here and in the comments),

I'm still running an hilariously old version of MySQL (because of an equally old version of MovableType), but that upgrade can wait. Now, I believe Fresh to Order across the street has some free wifi and a bottle of wine with my name on it...

posted by sstrader at 3:33 PM in Programming | permalink

October 30, 2007

Currying in JavaScript and Groovy

In the Groovy User Guide, the section "Fixing Closure Arguments to Constant Values Via Currying" gives a quick example of currying using Groovy closures:
def c = { arg1, arg2-> println "${arg1} ${arg2}" }
def d = c.curry("foo")
Basically, you bind one argument to a function taking multiple arguments but don't call the function until the remaining arguments are passed in.
Currying in JavaScript is a do-it-yourself affair. For references see these blog entries (in no particular order): "Curried JavaScript functions", "currying in javascript", "JavaScript currying". These are somewhat verbose and invasive.
The best option is to use prototype 1.6.0's curry function added to Function.prototype:
function sum(a, b) {
    return a + b;

sum(10, 5) // 15
var addTen = sum.curry(10);
addTen(5)  // 15
If you don't want to adopt prototype, you can use the following implementation:
function curry(f, args) {

    var thisF = f;
    var thisArgs = Array.prototype.slice.apply(args);

    return function(args) {
        thisArgs = thisArgs.concat(args);
        if (thisF.length <= thisArgs.length) {
            return thisF.apply(thisF, thisArgs);
        } else {
            return this;

With the canonical summation test:
function sum(a, b, c) {
    return a + b + c;

function test() {

    sum(1, 2, 3); // 6
    x = curry(sum, [1]);
    x([3]); // 6
    x = curry(sum, [1]);
    x([2, 3]); // 6
This has not been put through a lot of testing, so YMMV. After looking at the other examples provided in the blogs above, I was astounded how little code it took me to write. As I test more and across multiple browsers, I'm sure it will start bloating...

[ updated 17 Jun 2009 ]

Cleaner implementation from #Javascript on IRC:

Function.prototype.curry = function() {
  var func = this, a =, 0);
  return function() {
    return func.apply(this, a.concat(, 0)));
posted by sstrader at 11:07 AM in Programming | permalink

October 6, 2007


I can't heap enough praise on the JavaScript library DWR (direct web remoting). It came to my attention a few months back, but I've only now been able to really dive in an use it. DWR dynamically generates JavaScript classes from the Java classes of your choice. Any calls beyond simple set/get are implemented as Ajax calls back to the server. DWR allows you to leverage your existing Java code without reimplementing in JavaScript.

Given the Java class Users that manages system users with the User class, we could have the following simplified script in a page:

<script type="text/javascript">
    // Ajax call to server with JavaScript callback

    // Callback passed collection of User objects, populate page as needed
    function showActiveUsers(users) {
        $A(users).each(function(user) {
            new Insertion.Bottom(
                "<p>" + + ": " + + "</p>);

Voila. JavaScript code becomes an extension of your Java code (with a little help from the equally invaluable Prototype library).

posted by sstrader at 12:35 PM in Programming | permalink

September 3, 2007

Menu search on EventNett

I've added the ability to search restaurant menus on EventNett. Users can edit restaurant entries and add URLs for their menus. EventNett will read the contents of the menus and update the database with menu items, descriptions, and prices. You can then search for specific dishes. Here's a list of events at restaurants in Midtown that serve lamb. You can view the full menus and links at the bottom of the restaurants' location pages. Here's Ecco's page with their late night and dinner menus. Price ranges are also displayed.

This is a first draft, so bla-bla-bla. There's so far few menus added, it doesn't parse PDFs yet, and the HTML on a very few menu pages is so chaotic that EventNett can't find anything of value and may return nonsense. Finally, screen-scraping is an uncertain art at best, so menus will be only 90% accurate. It remains to be seen whether that's valuable enough.

I had the idea last weekend when Lisa & I were out trying to remember where we had mini-burger appetizers. We never figured it out, but the a-ha moment came soon after.

posted by sstrader at 1:04 PM in Programming | permalink

May 24, 2007

Programmer's notebook, May

(new concept, tryin' it out...)

For RadioWave, I continued cleaning up my messy, messy code. Much of it was carried over from when I was learning JEE and so required a tear-down/rebuild. Along with some JSP refactoring, I began converting code over to the data framework I developed for EventNett. It cleanly abstracts objects into classes for HTTP forms, database ResultSets, and read/write POJOs. They make it easy to copy between the different domains and are far better than my first fumblings in Java (without forcing an more invasive, 3rd party framework on the code). All of this refactoring unfortunately means shakier code in the short term as bugs get worked out but a more stable site in the long term.

I added Classic FM, a station in Australian (recommended by a European listener) which has its own weird time zones, and the music and news feeds from KCRW. Along with this new content, I broke out the detailed listings from shows that list tracks they will be playing but that don't say when they'll be playing them. In RadioWave, these un-timed tracks show up with the same schedule range as their parent show, but with the schedule times light gray instead of white.

I also finally got the Arizona stations in the correct time zone. Although, we'll only know for sure when daylight savings (which they don't follow) hits again.

I moved hosting from my server to LunarPages last month. They have something called an add-on domain that is a very inexpensive way (free, +$2/mo. for JSP) to host a new domain using your existing space. They seem to be down for ~15 minutes every week, but the price is right for JSP hosting.

For EventNett I primarily focused on getting the time zone conversions right--converting the GMT database time to the users' times. That was a bitch and it shouldn't have been. Live and learn. The knowledge will eventually be useful for converting RadioWave's times from GMT.

The only other notable update was fixing the JSP/CSS for the embedded feed (you can see an example here). The CSS had kinda skewed from the main site. Most of the problems were with IE's handing of TABLEs that have their widths specified. If IE can't determine the width of a TABLE's parent DIV, it will use the page width. Nice. The solution--as I now know and will cherish--is to create a DIV between the TABLE and its parent and specify a width of 100% in its CSS (not in its width attribute).

Finally, work (isn't it always the least interesting?). I had been struggling with getting the data sent from an existing utility to be received properly by a servlet I had written. The utility had been in the field for years with no issues (AFAIK), but when it sent data to my servlet--via HTTPS PUT--every other message was garbled. Unencrypted data came across fine, but SSL failed. What to do?

After getting schooled in the use of Wireshark from a co-worker, we poked and prodded with the packets for a few days, trying to learn what SSL should look like. I first wrote a Java utility to make the same calls, but it didn't reproduce the mangled packets. Finally, I wrote a C++ utility, mimicking the Win32 calls that the actual application was using. Testing with that, I found that the problem occurred only if data was sent from a Win2000 machine. I did some googling and found that the Win32 calls weren't being passed the correct flags; still waiting on verification though. Man, I hope that fixes it, 'cause I'm all out of ideas.

posted by sstrader at 6:46 PM in Programming | permalink

February 8, 2007

boolshit (definition)

adj. -tier, -tiest

  1. code that performs a conditional test for true or false in order to set a Boolean value: if (isActive == true) {doProcessing = true} else if (isActive == false) {doProcessing = false}, cf. doProcessing = isActive
  2. a programmer who writes such code
  3. what you say under your breath when you encounter boolshit code in anticipation of the subsequent gaffes you will have to deal with and debug
posted by sstrader at 9:35 AM in Language & Literature , Programming | permalink

January 24, 2007

Everything is a class

A good general rule of OO is to look at everything as a class. If you design with classes in mind, you get all of the benefits of polymorphism-encapsulation-inheritance and all of that other crap you need to spew out in interviews. This approach of class-centric design should be remembered even when using raw data types--a point that is easy to forget.

I recently ignored this rule on some simple code I was working on at home. The code manipulated an array of days ("Monday," "Tuesday," etc.). Halfway through coding some bloated utility functions, I came to my senses and quickly refactored. The value of OO--encapsulation specifically--was immediately apparent. Sometimes you get sloppy and forget, and sometimes you file it under "To Be Fixed Later." Far too much corporate code gets written in that way. It's easier to add comments to your code as you're writing it than at a later time (which never comes). Similarly, it's easier to encapsulate data earlier.

This shoud be, and indeed does sound like, a very duh point, but it's one that gets ignored.

So anyway, the day array began as a simple string array. A collection class provides sort and search and management methods, so I didn't design any further than the collection class. Almost immediately, utility methods started appearing: convert from a delimited list, convert to a delimited list, check for a weekday, check for a weekend. All of these were small but invasive to the surrounding code. In a situation where a simple true or false result was needed, access to the collection required a search and comparison that included one or more temporary objects. If only one spurious type is involved, then your code would not get too mangled. However, many similar nearly-basic types are used throughout programs, and those incur an unwieldy increase in local noise in the form of utility code. As local objects and line lengths increase, readability decreases. It's never one or two extra lines that you're adding, it's the potential for 10s or 100s.

I caught my lazy error early, and the simplification to the code was ... breathtaking. An added bonus--as always with encapsulation--was that the newly created class provided a chance to add additional safety checks that would be avoided the in already-complex surrounding code. Again, this seems like a simple Programming for Dummies recommendation because it's so obvious, and yet it is too often avoided with no good excuse. LOC numbers may go down, but so do headaches.

posted by sstrader at 2:21 PM in Programming | permalink

November 3, 2006


Another troublemaker tries to denounce the efficiency of C/C++ and gets the smackdown. Good discussion. Check out especially the shootout results and the short digression on template metaprogramming. It's statements like this, along with their responses, that produce useful information; it's only when you state your biases publicly that someone can correct them (or support them). This is the only context where I might praise a silly language war.

posted by sstrader at 10:40 AM in Programming | permalink

September 1, 2006

Joel v. Ruby

I stopped reading Joel Spolsky a year or so ago simply because he's a blowhard. Any slight good in an article was undoubtedly surrounded by moderate to heavy non-good or out-and-out dogma. It's good to see someone take the time to call him out on his ramblings against Ruby. The closing quote shows just what you get when you mix arrogance with malicious deceit.

[ updated 8 Apr 2009 ]

Link above dead, article only available in the Sep 2006 archives under "Was Joel's Wasabi a joke?"

posted by sstrader at 8:38 AM in Programming | permalink

August 6, 2006

New Mindstorm

The new Mindstorm is out! And there's also a book for developing Mindstorm robots with Java by Brian Bagnall. Wikipedia has a brief but useful entry with lists of supported languages and links to relevant source material.

I'm assuming that languages developed for first generation Mindstorm (RCX) will not work for NXT. Brian Bagnall is one of the contributors to the LeJOS VM (used to control a robot that visited the ISS in 2001!) and wrote the Core Java book on programming the RCX, but LeJOS's SourceForge page hasn't been updated since January.

The built-in language is LabVIEW, a visual programming language with lots of drag-and-drop fun (this is a toy, after all). In November 2004, I had looked at a very high-level visual programming language called Alice that is intended to teach programming through narrative. The demos were amazing. LabVIEW appears to be a little more gritty but still very kid-friendly. All the same, I'd stick with Java.

Continue reading "New Mindstorm"
posted by sstrader at 11:40 AM in Programming | permalink

July 18, 2006

Build scripts and linguistics

In different types of languages, meaning can be represented to varying degrees through morphology or syntax. Meaning is expressed with morphology by, for example, adding "s" for plurals of nouns or "ed" for past participles of regular verbs. In this domain, morphemes are combined through declension and conjugation to generate word-forms with different meanings. Meaning is expressed with syntax by word order and subcategorization. For example: the determiners "the" or "a," when present, must be the first word in a noun phrase; the verb "sympathize" must subcategorize for a "with" clause. The lexical alterations of morphology are replaced with structural alterations of syntax.

At work, we've recently moved from Ant to Maven to manage our build process. Ant uses XML files to define build scripts that contain similar functionality to those of make files, declaring commands that define dependencies, create directories, or that compile and copy files. Although Ant build files are in XML format, they act basically as a procedural script. Maven also contains XML files, but they contain considerably less information and instead rely on a directory structure to define tasks. The presence or absence of a specific folder decides whether or not a standard build action will be executed on the contents of that folder.

The Ant language's imperative emphasis depends largely on morphology; Maven's structural emphasis depends largely on syntax. This is somewhat of an over-generalization but it is useful in understanding the different approaches, which can be jarring. Ant's tasks have structure that serve the same purpose as Maven's directories, yet the Ant tasks read more like word-forms and the Maven directories read more like subcategorization.

posted by sstrader at 12:59 PM in Programming | permalink

June 30, 2006

Script block

Reading some of the comments at /. covering GWT. Several posters bring up the opinion that toolkits are wrong because beginners will use them before first learning "the basics." This opinion has come up recently in different contexts--all presented as a grievous flaw that teaches bad habits to those kids (e.g. the Java-doesn't-have-pointers complaint that appeared a few months back). The problem presented with the GWT is that it generates JavaScript from the user's Java code in order to push HTML and JavaScript from the web developer domain to that of the application developer. This is also its benefit: working in one domain can simplify development.

Critics look suspiciously at the process of skipping the pain of hand-coded JavaScript (and HTML for that matter). Such a position stinks of an elitism that's been around long enough to evoke weathered jokes about programming with only zeros or about what language "real programmers" use. I remember interviews for Windows MFC development where I'd be grilled on the Win32 API. The interviewer would invariably mock the ineptitude of those who didn't cut their teeth on Win32. I'd counter that programmers coming from Win32 were inept in their understanding of vtables and templates. Snobbery should always be defused by an even greater snobbery.

And that gets to the core issues and differences. Is it a problem of language or framework? MFC is a C++ framework that wraps the Win32 C API (an addition to the C language). GWT is a Java framework that wraps a subset of the JavaScript language. Both MFC and GWT--as with all frameworks--reorganize a more raw, low-level domain in order to simplify common tasks. Frameworks are, in a way, narrower manifestations of relative language abstraction and whether you're working in a high- or low-level language. Frameworks are intermediate steps that a language can take to make it a higher-level language.

A well-written framework should strive to elide the necessity to use its lower-level components. Ruby programmers don't need to be conversant in the C language that it was written in, although it would help them understand garbage collection, reference management, etc. C programmers don't need to for Assembly (stretching the argument since most are probably written in C), although it would help them understand stack memory or thread management. That knowledge would always help--and many programmers will eventually dig deeper--but its absence doesn't imply ignorance.

posted by sstrader at 12:36 PM in Programming | permalink

May 20, 2006


Short discussion on LtU about the Google Web Toolkit and commenting on its relationship to the Links programming language (which I had previously puzzled over). The GWT, on the surface, looks like a wonderful tool for Web development. More later...

posted by sstrader at 1:31 PM in Programming | permalink

May 2, 2006

The Links programming language

The Links programming language [ via Lambda the Ultimate ] is an experimental one-tier language that encompasses the three-tier Web model. A single Links program compiles into JavaScript to run on the client and into SQL to run on the database. Groovy, I say. Check out their short, 12-page paper [ PDF ] describing this accomplishment.

I began thinking it was amazing-yet-misguided. Existing technologies are duplicated within its syntax (e.g. XQuery), and toy programs--though mandatory as communicative examples--necessarily avoid the pitfalls of scale. However, I'm beginning to think that I'm just prejudiced by the ubiquity and expressiveness of SQL, and maybe holding too tightly to the opinion that the current domain languages are separate because they must live in separate domains. Just because JavaScript exists on the client should we have to write to it? Maybe flattening can also simplify, and maybe Links is appropriate as sort of a 4GL Web language that sits atop several, grainier languages.

But then, what of the nightmare of HTML embedded in PHP, Servlets, et al.? Don't maintenance issues appear when hasty design flattens the different domains? What about the ideal: separation of layout (CSS), static structure (HTML), client logic (JavaScript), dynamic content (JSP script), and data management (SQL)? That separation exists for the similar reason that we create small methods, classes, and files: modules should only do one thing. The reason that Links seems like a natural progression is that we can so often blur the interface between the different domains. Is that blurring a hint that a single-tiered language is the answer, or simply the artifacts of ideas sketched quickly but not yet complete?

posted by sstrader at 11:13 PM in Programming | permalink

Resurgence in C++?

C/C++ Users Journal died a couple of months back, and my subscription was extended with DDJ. This seemed like one of those "signs" that everyone's been talking about for the past five-years-at-least. Even as magic was being accomplished with template programming (the main proponents being the guys at Boost and Alexandrescu), C++ was being relegated to the basement of low-level development.

Just a week ago, Google released their Ctemplate library (different type of templates) for separating layout and content. It basically brings C++ closer to the world of Web scripting languages. For the past several months, I've been getting at least one unsolicited email a week presenting C++ programming opportunities. Anecdotal, but interesting. And a friend just started a job that is--although I don't think exclusively--heavily involved in C++.

Maybe "resurgence" isn't quite right.

posted by sstrader at 12:13 PM in Programming | permalink

April 29, 2006

Templates as type-checked dynamic typing

In C++, templates provide compile-time polymorphism (similar to parametric polymorphism) by expanding templates into different type-checked functions and types during compilation. std::vector<MyObject> is a unique vector<> type because it implements the required interface, and the determination of the "derived" vector<MyObject> type occurs at compile-time. Circle is a unique Shape type for the same reason, but the determination of derived type (given a Shape reference) occurs at run-time.

Using MyObject within vector<> means that you've entered into a contract stating that MyObject will provide those features that vector<> expects. This contract is different from polymorphism using inheritance because the is-a relationship does not exist. Types used within templates do not need to exist in a specific class hierarchy. However, those types must contain an implied interface--one which the template expects. This implied interface is managed similar to how dynamically typed languages manage accessing interfaces on class instances. A dynamically typed language only determines if FunctionA() exists on MyObject at run-time and at the point of the call. With templates, FunctionA() is only required at the point of the call, but checking occurs when the code is compiled. In both dynamically typed languages and statically typed templates, an object can be missing the required method if the code never gets called.

Using the following class (in pseudo-code):

class MyClass

    function set(String param1) {do something;}


In a dynamically typed language, a specific interface is validated only if the code is called:

function FunctionA(param1)

    param1.set("a string");


function FunctionB(param1)

    // Run-time error here, only if MyClass passed in.


MyClass myClass;

With run-time polymorphism, a specific interface is required but accessed only when the type is used:

class AnotherClass extends MyClass

function FunctionA(MyClass & param1)

    param1.set("a string");


function FunctionB(MyClass & param1)

    // Compile-time error here, even though it is never called.


AnotherClass anotherClass;

With compile-time polymorphism, a specific interface is validated only the the type is used:

template MyTemplate<type MYTYPE>

    function FunctionA(MYTYPE param1)

        param1.set("a string");


    function FunctionB(MYTYPE param1)

        // Compile-time error here, only if this method is referenced.



MyTemplate<MyClass> myTemplate;
MyClass myClass;

This gives templates the flavor of dynamic typing (classes need not be of a specific type) but with the benefits of static type checking.

posted by sstrader at 1:33 PM in Programming | permalink

February 28, 2006


Interesting discussions (several clicks deep with comments all along the way) on virtual machines--JVM, CLR, etc.--via Lambda the Ultimate. Mastering a language is trivial, mastering the libraries is where the real effort lies. The common line of reasoning that goes like this 'She knows C++ therefore she will be able to pick up programming on platform X in no time', is becoming increasingly fallacious.

posted by sstrader at 5:53 PM in Programming | permalink

January 9, 2006

It's simple, but it says it

Looking at the code to randomly pixelize the Google logo, I'm amazed at how utterly more efficient others' code is than mine [ via Digg ] (and a perfect example of how idiotic Digg comments are). This is always in the back of my mind, but since reading about the 100-line Lisp project that implements Reddit, I've been considering it more. Although much of the efficiency and terseness is in the additional libraries (both examples) and the more compact syntax (Lisp), a simple solution is something to admire and study.

I'm also reminded of the power of C++ (as I'm entrenched in Java). Many of the gee-wiz functional programming techniques used in Lisp (but by all means not all) can be duplicated with some fancy template programming (for example, using Alexandrescu's generalized functors). I still have template programming stuck in my head and have not had the opportunity to use Java's generics.

posted by sstrader at 11:24 PM in Programming | permalink

December 29, 2005

Resolving spurious project errors in Eclipse

Opening a workspace with several projects, I was presented with the following error for two of the projects:

The project cannot be built until the build path errors are resolved.

The resolution was to force a resave of the selected projects (and their .classpath files):

  1. Open the project properties
  2. Select Java Build Path > Libraries
  3. Add a new, arbitrary library (to be deleted later) > OK
  4. Wait for the workspace to refresh (or force a refresh of the project)
  5. The error(s) will go away
  6. Remove the dummy library

The only other references I could find were to make minor alterations of contents of the .classpath file.

posted by sstrader at 11:41 PM in Programming | permalink

December 21, 2005

Programming languages and direction

Interesting articles currently being browsed:

There's a wealth of information and opinion on Java/Ruby/Perl/Python/etc. in the Java discussions.

Continue reading "Programming languages and direction"
posted by sstrader at 4:19 PM in Programming | permalink

December 2, 2005

Allowing chaos

One of my cube neighbors, a new-ish employee, said that he didn't want to keep his desk clean because he did not yet have a clear understanding of the product he's working on. I understood what he meant, and I think it's important. Only after he understands the system can he organize his environment to fit that system. My note-taking process begins on a small stack of paper-to-be-recycled, white side up, sitting in front of my keyboard. I scribble notes and drawings and UML diagrams as needed. From there, if they're valuable and not just scribbles, I move them to my development wiki in the appropriate location and HTML-ify them with wiki links and external links. Eventually, I may add further notes, link other articles to them, or move them into a more appropriate location as I get a better understanding of the domain...

Continue reading "Allowing chaos"
posted by sstrader at 6:54 PM in Language & Literature , Programming | permalink

November 25, 2005

Today's reading list

  • The Man Who Sold the War [ via Rolling Stone ]
  • The CIA paid the Rendon Group more than $23 million dollars to help bring down Saddam Hussein through propaganda and media manipulation. That propaganda, fed to Judith Miller among others, once reported was used by the administration to bolster support for the war. In one breath John Rendon criticises the media for reporting unflattering and incorrect information about the war, in the next he boasts of feeding incorrect information to that same media. Jackass.

    It reminds me of the essay "Astroturf: How Manufactured 'Grassroots' Movements are Subverting Democracy" from The Best American Nonrequired Reading 2003. In it, Jason Stella outlines how propaganda--lies--from the Kuwaiti government was used to push lawmakers to vote for the first Iraq war.

  • Crisis in Cosmology [ via In Defense of Marxism ]
  • First, I find out that string theory is in question, now the big bang too? My head is spinning. All of those problems that still exist with the theory could eventually bring it down--and in the process describe a universe that is at least 70 billion years old instead of 13! This is big. At the center of the dispute is plasma cosmology.

    The article is, however, absolutely dispicable in the way it presents modifications that occured in the big bang theory. At several points, scientific adjustments are presented as some sort of weasling out on the part of the scientists. Look: theories are meant to adjust as new facts are presented. That's what science is. If the theory eventually falls apart--which the big bang may-or-may-not--then the theory that best represents the new facts will replace it. Too much sensationalist science reporting. Jackasses.

    This, oddly, makes me wish Brian Greene had a blog. I wonder what the discussions are in the physicist and cosmologist circles...

    And, bravo to Eric Lerner for his vigilance in keeping the Wikipedia entry on plasma cosmology unmolested by rabid graduate students. New science is new science and it needs to be presented with fact and not ridiculed with emotion.

  • TiddlyWiki
  • Self-contained wiki based on JavaScript contained within the HTML pages. Basically, you can save your entire, functioning wiki to a single HTML file. Client-side scripting at its best. Now I have to think about porting my development wiki, and maybe even my blog, to this.

November 22, 2005

Web standards

Finishing up layout for a bunch of Web pages: they look perfect in Opera and Firefox but are completely messed up in IE. The causes were: missing selector support, padding or margin differences with LI elements, differences in TABLE width with TABLEs contained in multiple DIVs, and the often-reported DOM differences. All is almost well now, with the only serious problems left involving the CSS menu system. I can either consider it a "learning experience" or be pissed off at IE. Considering that I'm following CSS specs dated 1998, I'm leaning towards the latter.

Continue reading "Web standards"
posted by sstrader at 12:19 AM in Programming | permalink

November 16, 2005

Crystal Reports: displaying a graph of the most recent data

I had to create a report in Crystal Reports--containing graphs of historical data within subgroups of users--that ended up being more complex that I had expected. Much of the information comes from the Crystal Reports Knowledge Base article C2011945 with little else available on the Web. Here are some notes using CR10:

Continue reading "Crystal Reports: displaying a graph of the most recent data"
posted by sstrader at 12:36 PM in Programming | permalink

November 10, 2005


From /.:

Sony just loves everyone $sys$anally. They are the greatest company ever when it comes to technology $sys$that $sys$sucks. Everyone is gonna love $sys$to $sys$hate Sony, and they will $sys$not buy any Sony product that they see. It's because Sony loves $sys$to $sys$fuck $sys$with their customers.

Good joke. Poorly implemented, but still a good joke. And we really do need to start spreading around the phrase "infected with DRM." Sony's rootkit is the perfect catalyst.

posted by sstrader at 1:48 PM in Programming | permalink

November 3, 2005

Accursed serial numbers!

That serial numbers site saves me again! And for the same reason: we own the software, but no one had written down the serial number (probably provided on the disposable packaging).

posted by sstrader at 5:36 PM in Programming | permalink

Crystal Reports bug: tables from multiple databases can only have one link

Using Crystal Reports prior to version 10, tables from different databases cannot be linked using more than one column. So, if two tables are joined by the columns id1 and id2, you can only specify a link for one of those columns. More than one join will display a message box with the error "Invalid file link. Not all fields in same index expression."


I tested using the demo version of CR11, and could successfully link multiple fields.

posted by sstrader at 3:12 PM in Programming | permalink

Crash: C++ objects moved in memory after construction

I encounted a crash a few days ago that took two days of testing to resolve. It was caused by the addition of an otherwise simple 20-line header file.

Continue reading "Crash: C++ objects moved in memory after construction"
posted by sstrader at 12:46 PM in Programming | permalink

September 12, 2005

Recent work

I reached a milestone of sorts with EventNet this past week. I have the filter for date ranges, relative dates, and keywords written. It's a little slow right now, possibly because some of the schedule logic is executed in code and not on the database side, but that's a point for refactoring later. I also have the basic views written--calendar, timeline, and list--with links to drill-down by week and day, and pagination of longer lists. Most of the read-only aspects of the site are written, with the most important part--user editing--yet to be done.

The past few days have been mostly finishing a couple of site aggregators. I had realized that, like RadioWave, an app on the server could populate the database by screen-scraping from the information that's already out there. Duh. It was oddly easy to write a bot to spider the information from a major-events-calendar-site-who-will-remain-nameless. Instant data, tagged and scheduled.

The primary issue has been the constantly nagging decision of how much work to offload to the database and how much to put in code. That's always an issue and resolved generally case-by-case. You want the code that represents database objects to be as generic and reusable as possible, but often need to write very specific queries to retrieve the data you need. And there's a balance between executing repeated queries but getting hit with extra memory allocation, and executing fewer queries but taking up extra CPU cycles in code. Ideally, the design should be such that you can easily make alterations in either direction. Ideally.

Anyway, production may slow considerably, what with the new job starting this Wednesday. A change, and a return to C++, will be good.

Continue reading "Recent work"
posted by sstrader at 11:51 AM in Programming | permalink

September 6, 2005


Had a good interview this morning. Well, "good" as far as I could tell--my "good" interview meter is generally broken. At least I think my Tourettes of Cracking Wise was kept in check. And we were in general agreement that Eclipse really needs to fix that problem with duplicate views of a file getting out of sync. Overall it was a fun interview: I like hearing how other companies' development groups work and talking out the pros and cons of such things, even if I dislike the stiffness of the surroundings. All interviews should be done at a bar!

posted by sstrader at 2:45 PM in Programming | permalink

August 29, 2005

Eclipse gotcha

Eclipse will sometimes allow you to have multiple views of the same file open. Often when debugging, it will open a new view of the file when it stops on a breakpoint. If you leave these multiple views open, you run the risk of editing one and losing changes in another. Ouch. I had read about this problem in a review of Eclipse, had kept an eye out for it, had see it happen several times and dodged it, but was just recently stung. So watch out. Sometimes the bug is smarter and more vigilant than the user.

I'm still enjoying Eclipse, it's just that I'm now rubbing the bump on my head where it hit me with a frying pan, and looking at it warily: "Oh, you ... (wagging finger with a slightly pained expression) ..."

posted by sstrader at 2:51 PM in Programming | permalink

August 25, 2005

Encoding URLs

If you're going to reference URLs in a Web page generated through code, you need to encode the search part of those URLs to have acceptably escaped HTML characters. In Java you can do the following:

import java.lang.*;

// Copy our raw URL.
String encodedURL = rawURL;

// Determine if the URL contains a query.
URL url = new URL(rawURL);
if (url.getQuery() != null) {
    // Encode only the query part.
    int queryIndex = rawURL.indexOf(url.getQuery());
    encodedURL =
        rawURL.substring(0, queryIndex) +
        url.getQuery().replaceAll("&", "&amp;");

Friday 26 August 2005

Code changed above. Instead of using URL.Encode() to encode the query, just replace ampersands with their HTML escape. We don't want any equal signs encoded.

Continue reading "Encoding URLs"
posted by sstrader at 11:56 AM in Programming | permalink

JavaScript gotcha

A recent (humbling) discovery: you need to explicitly define looping variables in functions called recursively. So, in the following pseudo-code, the "var" was left out and a single "index" variable will exist across all calls (probably screwing up your intended results):

function recurse(collection)
    // Ouch! Forgot the var.
    for (index = 0; index < collection.length; ++index)

I hate that I still have scoping issues with JavaScript. Curses.

Continue reading "JavaScript gotcha"
posted by sstrader at 11:15 AM in Programming | permalink

August 22, 2005

Recent work

Along with the EventNet project, I've been refactoring the aggregation code behind RadioWave within Eclipse. The debug tools there have been helpful in cleaning up the mess that can occur when learning new techniques. Yeah, excuses excuses. Anyway, while finding my way around Eclipse, I fixed some problems with duplicate entries in BBC 4, eliminated failed updates of file-based Web sites, and sped up the database access. However, with all of that reorganization and testing some of the existing recordings were lost. Duh. Still, it always feels good to clean house.

Kevin recommended WREK's Tuesday show "Loud Smoky Rooms," but their stream hasn't worked over the last few days, so I don't have too much hope of it getting recorded. The two problems with aggregating streaming radio have been lack of online schedules and obfuscated or missing stream links. Independent and public broadcasting stations seem to be the most open with both, with commercial and (surprisingly) college the least. There's a lesson in there somewhere.

Continue reading "Recent work"
posted by sstrader at 5:14 PM in Programming | permalink

More on semantics

This HP paper on tagging systems explains well what I had previously explained so poorly. From the paper:

Like a Venn diagram, the set of all the items marked cats and those marked africa would intersect in precisely one way, namely, those documents that are tagged as being about African cats. Even this is not perfect, however. For example, a document tagged only cheetah would not be found in the intersection of africa and cats, though it arguably ought to; like the foldering example above, a seeker may still need to search multiple locations.

This illustrates the limitations of both folders and tags, and how an ontology however achieved is required to provide more encompassing results. A user should be able to specify "Africa" and "cats" and the system should understand all of the hyponyms of "cats" ("cheetah" etc.) as well as those of "Africa" ("Egypt" etc.). A taxonomy gives us this.

People have complained about the brittleness of these implemented tagging systems. I agree that they are not ideal, but as this HP document shows, their existence and popularity allow us to examine how a system could improve on them.

posted by sstrader at 10:26 AM in Programming | permalink

The semantic players

Re-reading some entries on the semantic Web and found Burningbird's link to this summary by Peter Van Dijck of the major concepts being discussed and the people discussing them. With pictures!

The biggest problem here, I think, is the top-down v. bottom-up issue: that v. really needs to go. The argument is that of (primarily) a defined versus an emergent global ontology. The Van Dijck article points out an emotional source to this issue, but I think it originates from the AI realm and the top-down-bottom-up battles there. A power metaphor is compelling but only after the fact.

posted by sstrader at 9:46 AM in Programming | permalink

August 18, 2005


The Eclipse [Wikipedia] IDE has completely amazed me as I've been using it for my new Java project. I had learned Java/JSP development on the long-defunct Forte IDE from Sun. Forte was powerful but very quirky and has become pretty outdated, so it's nice to get on a more modern IDE. From my basic experience within .NET I think that Eclipse is at least comparable, but I've still considerable digging around to do.

I haven't looked at the C/C++ side of it yet (the C/C++ Development Toolkit). This article provides a simple overview of the C++ tools for Eclipse and points to a demo for configuring MinGW with the CDT. With this configuration, I'm not sure if I will also need gdb and make.

Continue reading "Eclipse"
posted by sstrader at 12:54 PM in Programming | permalink

August 12, 2005


Today I became a Perl programmer. Not a good Perl programmer but a Perl programmer all the same. It's almost readable to me now! Except ... well, and this is probably one reason why I'll never get a valid nerd card: I despise regular expressions. Yesyesyes, I understand their power and all, but the sheer unreadability and brazen obfuscatalogical syntax is just irritating.

Anyway, there you have it. I kicked around in the MT code to add some spam filtering (task 2 of my current short-term sabbatical), and let-me-tell-you it was way overdue. There'll be some continued tinkering--even if it's not needed, just so that I can play around some more--so we'll see how that turns out. Ultimately, let's hope we're approaching the end of those jackass spammers around here.

Time to update my resume.

Continue reading "@_"
posted by sstrader at 3:46 PM in Programming | permalink

July 24, 2005

Artificial culture

Scientists across several European universities are working on creating a simulated computer environment, a la The Sims or the upcoming Spore, whose AI inhabitants will create their own culture and language. Although their intent is to study the basic processes of language and culture, some scientists feel that an artificial environment will only illuminate artificial processes. There's always value with simulations as long as the relationship and bounds of the simulation's rules and those of the real world are understood.

At the very least, the experiment will be interesting as an accomplishment of NLP and AI programming.

Continue reading "Artificial culture"
posted by sstrader at 3:09 PM in Programming | permalink

July 6, 2005

Hack the Earth

Google has provided the schema for the XML of Google Earth data files [via /.]. Their code site points to GE's documentation and a tutorial. Woot.

Continue reading "Hack the Earth"
posted by sstrader at 2:52 PM in Programming | permalink

June 30, 2005

Conditionals and polymorphism

I've always had a nagging issue with the refactoring item replace conditional with polymorphism. The concept is that you have a bunch of objects that are acted upon in the same situation but with different underlying actions. With the canonical Shape class and its Circle, Square, and Triangle subclasses, a poor design would have the draw method in Shape and a conditional within that method to draw each possible type. That's a little contrived because of the simplicity of the example, but real-world examples are common resulting from tree-forest syndrome in bulky classes, or from code bloat as more and more classes are added--requiring copy-pastes with small alterations to the conditional.

This refactoring method converts the multiple-line conditional blocks into single lines of code that distribute their work across an already-existing class hierarchy (see below). The problem I have is that, while the superfluous conditionals are removed, there's always one or two that must remain: those that create the separate objects in the first place.

if x then
else if y then
else if z then
end if


base->process() - - - - > calls x or y or z

That "redistribution" is key, and eliminates so much noisy, conditional code that I'm sometimes unjustly suspicious of every conditional I see. This is similar to how the standard's algorithms have made loops suspicious--breaking them up into templates (find<>, for_each<>, set_intersection<>, etc.) and predicates. Absolutes are never so absolute, so there are times to use loops and conditionals (and times when the standard binders justdon'twork). The Boost library and features in updates to the C++ standard and especially some of the functional magic going on in Alexandrescu's techniques are all helpful in this regard.

Continue reading "Conditionals and polymorphism"
posted by sstrader at 6:29 PM in Programming | permalink

June 22, 2005


Am I insane?

I recently sat through a rant against OOD because of its (1) over-abstraction and (2) inefficiency. The ranter in question was seething over some guy that was in love with his own code because he designed detailed object relationships. It's tough to argue about code you haven't seen, a coder you don't know, and all of this in relation to a common ailment with coders. I'll only relate this as a simile, but it's like impugning an artist for being in love with their own work. That's a given. However, that being said, I've heard too often that OOD is anathema.

Continue reading "Anti-objectivists"
posted by sstrader at 1:43 PM in Programming | permalink

June 8, 2005

A truly decoupled visitor

From the Design Patterns [Amazon] book to Modern C++ Design [Amazon], I've been frustrated that the technique I use to implement the visitor pattern is not offered or even refuted. I'm either on to something or, quite the opposite, off of something. Or maybe simply on something.

Continue reading "A truly decoupled visitor"
posted by sstrader at 4:09 PM in Programming | permalink

Generalized functors

Required reading for C++ programmers: Alexandrescu's Modern C++ Design. I've been re-reading his chapter on generalized functors in the hope of seeing how I could have improved my recent code with abstracted database access. I wrapped specific MFC database actions in functions or function objects that are passed to a main function for execution. The main function catches the different MFC errors and checks return codes, then converts them into a custom exception hierarchy. This simplified the main code by eliminating multiple exception handlers around the code and multiple error checks inside the code. However, my function objects had limited versatility because their signatures had to stay the same.

Alexandrescu's generalized functors would have been ideal. He has created a small library that can wrap every type of callable entity (C functions, C function pointers, references to functions, functors, and member functions), along with parameter binding, in a single template. Very nice.

Continue reading "Generalized functors"
posted by sstrader at 12:28 PM in Programming | permalink

June 7, 2005

User-scripted windows

A co-worker is working on a VB form that reads custom XML files that define layout and validation. It will communicate with a back-end database and the layout will presumably be tweaked by the customer. This is an extremely common task. In my previous job, I wrote a system on CE that used HTML for layout, XML for data, and JavaScript for validation (sadly, I just heard that upon my leaving, it was declared "unuseable" by the other programmer on the project and completely rewritten). Before that, I worked at a company whose main product was an IDE that allowed users to design and script windows for simulations. The goal in both of those was to allow the client to create applications within a limited domain and with varying levels of complexity. It's unfortunate that these tools probably cannot be made generic enough for portability between projects. That "limited domain" is always so different that very little intersection exists.

posted by sstrader at 1:22 PM in Programming | permalink

May 27, 2005

Exception handling in a limited domain

Two of the best features of C++ exception handling are transparency and the propagation of rich content. With good design, exceptions can eliminate intrusive error checking and the related structural code required to support that checking, making your error handling effectively transparent. Along with that structural code, error information based on POD types is replaced with class hierarchies that can provide a richer set of information on errors. I'm still refactoring code at work and have just ran across a good example of how exception handling simplified an area I was working on.

Continue reading "Exception handling in a limited domain"
posted by sstrader at 11:14 AM in Programming | permalink

May 16, 2005

The alternative to emergent ontologies

I recently summarized a few thoughts about merging the top-down and bottom-up systems of WordNet and tagging as a good solution to fixing the brittleness of a tagged ontology. Clay Shirky suggests that combinatorial principles [Wikipedia] could be used to find the ontology inherent in the set of tags. Instead of merging a semantic hierarchy with search engine predicate calculus, the sematics would be derived from the liklihood that tags occur in specific combinations.

In natural language processing [Wikipedia], many parts of speech taggers will use a similar method (as a hidden Markov model) to tag unknown words based on the surrounding, known words.

It's a compelling argument, and I should have considered it.

Still, if the comparison can be continued, there are no completely probablistic POS taggers. They at least will know about syntactic items such as articles or common morphemes in order to tag the unknown words. It's a popular method, though, and the principle could be useful for tagged ontologies.

Continue reading "The alternative to emergent ontologies"
posted by sstrader at 3:43 PM in Programming | permalink

May 13, 2005

Data and syntax errors

Joel has a new rant about Hungarian notation and exceptions. In it, he outlines the principle that you should code in a manner that makes bad code more apparent. He uses an example of passing string values that must have special formatting in some instances and not others (safe string variable, sValue, and unsafe string variable, usValue). As usual, he goes step-by-step to slowly improve a bad situation. While he generally surprises me by going further than I can imagine with techniques to clean up the code, this time he stopped too soon.

He argued that Hungarian notation would alert programmers when they attempt to copy a normal string variable to a location that requires a formatted string variable (usValue = sValue, wrong). But in his frenzy to praise Hungarian notation (offering up yet another retelling of the history of it) and complain about poor operator overloading (hint: it's bad) he failed to provide a real solution to the problem.

Yeah, tagging variables with clues about their appropriate use is nice, but why not just create classes that forbid inappropriate use. Instead of staying in the realm of data error, use your compiler to notify you of errors.

class String {...};
class FormattedString {...};

String value1;
FormattedString value2;

// This won't compile.
value1 = value2;

Tada. Am I missing some other point he was trying to make?

posted by sstrader at 2:14 PM in Programming | permalink

May 7, 2005

Tags and emergent systems

I had previously lamented the limitations of a semantically empty tagging system (e.g., and suggested that incorporation of the wonderful WordNet would solve that. The same tag system would be used, but a search tool would be added that allows ontological searches (e.g. a search "flower" would match the "Hydrangea" tag).

Before that post, I also rambled about tagging as a subset of centralized emergent systems on the Web (e.g. flickr or MySpace) as opposed to distributed systems (I had suggested harnessing existing Web sites to create more specific tools, a la Paul Rademacher's stunning use of Google Maps to automatically map Craig's List apartment listings).

The benefit of an emergent system is that you only need to define the rules of the system, not the content. AI long ago discovered the brittleness of creating top-down systems (e.g. write every rule of logic) compared to the fuzzy elegance of bottom-up systems (have genetic algorithms discover those logic rules). Often, these two approaches are merged to harness the benefits of both. Tags seem to be a dumb form of bottom-up system. This could be merged with WordNet (or something similar). I originally felt that the deficiencies of tagging were fixable-but-flawed. Based on a project I'm about to start, I'm now beginning to think that emergent systems are the best method for creating Web content that will evolve. Rather than being "brittle" ontologies (as Tim Bray suggested), I think tags should be viewed more as emergent ontologies.

Continue reading "Tags and emergent systems"
posted by sstrader at 12:00 PM in Programming | permalink

April 25, 2005

Representing time in C, C++, SQL, MFC, and Java

Options available in representing date and time values:

Continue reading "Representing time in C, C++, SQL, MFC, and Java"
posted by sstrader at 10:41 AM in Programming | permalink

March 22, 2005

Compile- and run-time polymorphism

I recently had an interesting, small-scale class design that takes advantage of some template tomfoolery. Alexandrescu's Modern C++ Design has some great concepts for compile-time polymorphism, but they're difficult to absorb without implementing. I've used policies many times before but decided to take a slightly different approach this time.

Continue reading "Compile- and run-time polymorphism"
posted by sstrader at 1:54 PM in Programming | permalink

March 19, 2005


Amazon's A9 is pretty sexy (and loved by all who obsess over short domain names). I am such a Google-head that I don't use A9 enough on reflex. Now, they have a new-ish technology called OpenSearch. It defines requirements for exposing a site's searches as XML--thus turning queries into aggregatable plug-ins. They also point out that existing search engines can be wrapped so that HTML search results are translated into OpenSearch RSS results, although I think that you would just be screen-scraping and rewriting the content.

Continue reading "OpenSearch"
posted by sstrader at 12:26 PM in Programming | permalink

March 14, 2005

Knuth on Morning Edition

Caught a little of Donald Knuth [Wikipedia] on Morning Edition this morning (so there is some benefit to getting up early). They have the audio here. Hey! He looks a little like Larry David. With the story, I was once again reminded that I need to purchase The Art of Computer Programming [Wikipedia]. Amazon has volumes 1 through 3 new for $164.99 or used for ~$100. When's that first paycheck come in?

posted by sstrader at 1:00 PM in Programming | permalink

March 12, 2005

Computer types seem fascinated by Postmodernism

In an essay by the always-wonderfully expressive Paul Ford, he says that [m]any computer types seem fascinated by Postmodernism. Guilty. He includes an unusually inexpressive (ok, almost always) few paragraphs on the subject of geeks and Postmodernism [Wikipedia]. I have my own idea on the subject based on the work I had done with natural language processing. I hadn't considered that many other geeks were so inclined, but there you have it.

Continue reading "Computer types seem fascinated by Postmodernism"
posted by sstrader at 8:28 PM in Programming | permalink

February 16, 2005

February 11, 2005

Map roundup

Quick collection of links relevant to the recent release of Google! Maps! BETA!!

The maps:

The commentary and analysis:

Needless to say, Google's solution is elegant and standards compliant. Beautiful. I'm angry at Opera for not supporting the XSLT technology required by the site. I'm getting (slightly) tempted to switch to Firefox.

Complaints about Google's use of JavaScript:

Some hacks via SourceForge.

posted by sstrader at 3:22 PM in Programming | permalink

February 8, 2005

RadioWave up and hobbling

Tomcat's a go, but there are many little problems with the RadioWave code itself that got ignored when I became Network Administrator. Yay: back to being coder...

posted by sstrader at 5:03 PM in Programming | permalink

February 3, 2005

RadioWave offline for upgrade

Working on the Web server now.

Continue reading "RadioWave offline for upgrade"
posted by sstrader at 2:14 PM in Programming | permalink

Tomcat: 1, Scott: 0

Here's what not to do when trying to upgrade your server software: get distracted with another programming project and exacerbate the original problem that required the upgrade. Sometimes, I'm an undisciplined fool.

Continue reading "Tomcat: 1, Scott: 0"
posted by sstrader at 1:03 AM in Programming | permalink

January 31, 2005

Book: Mastering Tomcat Development

A few weeks back I got fed up with hacking through my Tomcat [Wikipedia] installation and its various configuration files--with only online flotsom to guide me--and went on the hunt for a book. Yes, a book made of paper and not bits. I went to B&N to use one of those new-fangled gift cards. A book bought from a physical store? Now I've seen everything. Mastering Tomcat Development [Amazon] looked like the very thing, but at $45 I was dubious. So I browsed Amazon with my phone and found it for ~$9.

Online purchasing: 1. Brick and mortar: 0.

So I'm now digging in to update my Tomcat installation to 4.x and fix the hacked configurations that grew from necessity and convenience. The book has very clear explanations going from square zero of where to download the files through configuration, Java servlet programming, JDBC, JSP, Tags, Strust, etc. I bought it for an explanation of the finer points of Tomcat configuration, but it will be a nice addition to my Core Java [Amazon] programming books. Expect some downtime as I move from Tomcat 3.x.

Continue reading "Book: Mastering Tomcat Development"
posted by sstrader at 12:43 PM in Programming | permalink

January 26, 2005

RadioWave on the fritz!

I got some mysterious failed and half-recorded recordings last night from RadioWave, and the logs only go back a few hours. Apologies to anybody who actually wanted it to work correctly.

(Debug debug debug ...)

Fixed. A recent update to allow begin and end time adjustments broke recordings for stations in different time zones. The 3rd party stream ripper still occationally locks up, but I haven't pinned that down yet ...
Continue reading "RadioWave on the fritz!"
posted by sstrader at 10:53 AM in Programming | permalink

January 19, 2005

My brain hurts

I just finished my final phone interview for a day that began at 9:00 AM and went non-stop until now. If anyone else asks me what a template is I'm going to crap a pair of angled brackets. I need ... (footsteps going away) ... (and back) ... have a drink. Ah. Thank goodness for left-over party beer.

The prospects are good for < a week searching. I did better technically than I expected (performance anxiety) ... although I think I pulled a Larry David with two of them: make a good initial impression then do something uncomfortable like compliment their son's penis. Gotta work on my social skills.

To The Vortex! Forthwith!!

posted by sstrader at 7:19 PM in Programming | permalink

December 23, 2004


Ed Felten and Alex Halderman over at Freedom to Tinker wrote the world's smallest P2P application in 15 lines of Python. Fifteen lines of anything can be pretty obfuscated, so Richard Jones clarified the intent of the code. The code can be run as a server (serving its own files and connecting to other servers to also server their files) or as a client (able to connect to and download from a network of servers). Connections are password-protected.


posted by sstrader at 3:21 PM in Programming | permalink

December 4, 2004

Code search

I'm sorry I have not really tested this, but this was too cool not to pass on. A source code search engine. It may-or-may-not contain cool stuff, but I'm sure it's worth the effort to find out. I was just praising the breadth and depth of SourceForge as a resource for the hapless programmer, while bemoaning it's lack of organization ("I need a compression algorithm..."). Koders may answer that.

It's similar-but-different than the code library index I've been slowly building from the C/C++ Users Journal.

Continue reading "Code search"
posted by sstrader at 11:48 PM in Programming | permalink

November 22, 2004

Code libraries from C/C++ Users Journal

This entry is a repository for useful code libraries that have been presented in C/C++ Users Journal. The article name links to the zipped file, on CUJ's site, of that issue's source code. The issue date links to the CUJ page for that issue. This will be regularly updated.

Continue reading "Code libraries from C/C++ Users Journal"
posted by sstrader at 3:13 PM in Programming | permalink

November 17, 2004

Natural programming

In the current issue of Queue, the magazine of the Association for Computing Machinery (ACM), there's an article titled "Natural programming languages and environments." The article is written by a group working to create programming languages and environments that are ... closer to the way people think about their tasks.

Continue reading "Natural programming"
posted by sstrader at 1:39 PM in Programming | permalink

November 15, 2004

CSS Reference

This page contains an organized list of Web layout references and tools based on HTML and CSS. An earlier version of the source is available in a previous entry.

Continue reading "CSS Reference"
posted by sstrader at 6:28 PM in Programming | permalink

November 14, 2004

November 10, 2004

Prime geek

Steve Litt at has this page where he presents an algorithm for calculating prime numbers and then steps through optimizations. The algorithm is in C (very well written) with explanations for each step.

The /. article has some further comments on Litt's code along with some useful links.

[ via /. -> Fun With Prime Numbers ]

Continue reading "Prime geek"
posted by sstrader at 1:14 AM in Programming | permalink

October 27, 2004

I got mad skilz

An aquaintance needed some email addresses that were listed on a Web site (no, no spamming involved, just business v. business) and asked me to extract them. They were hidden behind an interesting bit of encoding that had to be worked around. What to do?

I guess the skilz weren't all that mad. And maybe the 'z' is unwarranted, too, but the process was interesting. I have, however, left out most of the specific names to avoid any unlikely-but-unwanted recognition.

Continue reading "I got mad skilz"
posted by sstrader at 6:35 PM in Programming | permalink

October 11, 2004

October 1, 2004

Removing "Compress old files"

This is a simple search, and a simple fix, but I just had to re-learn it so I'll post it here.

When performing a disk cleanup on any machine older than two days, you'll probably be forced to wait for several minutes for the process to compress old files. If this is important to you, enjoy a free coffee break. If, however, the gain is not worth the wait, you can eliminate this step from the process.

Go into the Registry and navigate to this key:


And then delete the subkey "Compress old files". The Google search for "compress old files" registry contains more detailed articles on this.

posted by sstrader at 9:48 AM in Programming | permalink

September 18, 2004

Why do the facts hate IE? part 2

I finally sat down after work Friday to fix the IE problem. The right column boxes (currently etc.) were resizing irregularly and left justified instead of right. It might have been caused by a template change I made when I added the Comic Page of the Week, it might have been by a CSS change when I applied styles to all of the images, or it might have been just some crap IE problem that surfaced to waste my time. It could have been a lot of things and could have taken up my night (of which I value).

However, in less than 30 minutes I had it fixed and republished (what's the emoticon for patting yourself on the back?) and am here to impart wisdom. And, of course, to write this down so that I might retain some of the wisdom.

Continue reading "Why do the facts hate IE? part 2"
posted by sstrader at 2:24 PM in Programming | permalink

September 4, 2004

Semantic government

Paul Ford has begun a series of articles chronicling his conversion of Congress' Web site into semantic Web content. It's a quick read with clean, complete examples detailing his process and with clear insights into a Web guru's approach to this difficult task. It's a labor of interest more than usefulness: he wants to prove to himself and others the benefits of the semantic Web, and he knows that his solution (a hack based on screen-scraping) can easily go out-of-date. Nevertheless, the process is facinating.

Continue reading "Semantic government"
posted by sstrader at 6:00 PM in Programming | permalink

August 22, 2004

No, but there's an I in idiot

At this hypothetical company, we're one week away from having the clients in-house and testing the new software for all major features. They'll be here for two weeks and will expect to see everything working at around 90% compete. All the features should be there, but they can still be a little rough around the edges.

This'd be OK, except for the fact that the project's understaffed and still very (very) far behind. That's always a problem anywhere you go, so I guess you do what you can with who you have. Until, of course, one of those-that-you-have comes up with this little gem as I'm emphasizing how much we're behind, and how we gotta do some non-goofing-off for the next week:

But I'm on schedule, aren't I?


Continue reading "No, but there's an I in idiot"
posted by sstrader at 11:41 PM in Programming | permalink

August 19, 2004

Pointer arithmetic

One rule: avoid it.

Continue reading "Pointer arithmetic"
posted by sstrader at 1:31 AM in Programming | permalink

August 17, 2004

That's not my beautiful code

The general consensus in development seems to be: leave crap the way it is. Everyone eventually has to work within existing, often flimsy code, and the etiquette of what to change must be defined. We should not only consider issues of style but also those of refactoring. And just where does style stop and implementation begin? If we don't have a strong grasp of these issues, the scheduling pressures will cloud our good sense, and the political pressures will promote inaction.

There's no excuse for allowing bad code to continue to be bad.

Continue reading "That's not my beautiful code"
posted by sstrader at 8:50 PM in Programming | permalink

August 16, 2004

Limitations and caution on CE

The standard library implementation that comes with eVC 4.0 does not include the IOStream library. That means no [i|o]stringstream and no [i|o]fstream. The biggest loss with stringstream is the type-safe number conversion. fstream offers similar benefits wrapped in a, generally, clear-cut interface.

I had mentioned before about the delicate nature of CE with regard to memory corruption--the OS will allow the overruns and such until your code eventually locks. Walking through can be very slow and tedious. Another instance where silent memory corruption can occur is when you reference COM objects in your code. I had a code path the bypassed ::CoInitialize(), checked all returns on CreateInstance(), and still ended up with corrupted memory.

All of these memory problems were bugs in my code. However, they would have failed immediately and at the point of the error in a desktop application. There's just less room for error on CE.

Continue reading "Limitations and caution on CE"
posted by sstrader at 3:22 PM in Programming | tagged mobile development | permalink

August 12, 2004

Web components and distributed programming

Kottke has an interesting post on binding all of these Web tools together to make a platform of sorts.

[S]mall pieces loosely joined. Each specific service handles what it's good at. Gmail for mail, iCal for calendars, TypePad for short bits of text, etc. Web client, desktop client, it doesn't much matter...whatever the user is most comfortable with. Then you pipe all these together however you want...
Continue reading "Web components and distributed programming"
posted by sstrader at 11:56 PM in Programming | permalink

August 11, 2004

String algorithms library from Boost

While I was looking to see if Boost had updated their site to include documentation for the multi-index containers, I saw that the next version will have a string algorithm library. Their site seems to be a mess now, but I found the documentation here.

Damn if it isn't everything that I had already written, but of course done so much more elegantly.

Continue reading "String algorithms library from Boost"
posted by sstrader at 11:56 PM in Programming | permalink

August 9, 2004

Binary content links

The O'Reilly Network site has an article on the failure of the Web to provide authors a means to quote from media files as easily as they can quote from text files. If a Web page is laid out correctly (using name attributes), I can easily link to specific sections on a page. There is no easy way to link to sections in an audio or video file.

Continue reading "Binary content links"
posted by sstrader at 12:28 AM in Programming | permalink

August 7, 2004

Indexed containers from Boost

This month's C/C++ Users Journal came in, and it has an article describing the Boost Multi-index Containers Library. This library provides a container template that can be defined with zero or more unique and non-unique indexes. This is genius. Imagine having immediate access to separate, ordered views for your data without having to resort or, worse, provide multiple containers.

Continue reading "Indexed containers from Boost"
posted by sstrader at 1:43 PM in Programming | permalink

August 6, 2004

The policy (trait) pattern

Policies allow you to affect the internal workings of an otherwise opaque class by providing that class with secondary classes. The secondary classes are used by the primary class to define how it should implement its algorithms, or to provide those algorithms themselves.

Continue reading "The policy (trait) pattern"
posted by sstrader at 12:28 PM in Programming | permalink

August 2, 2004

"Invalid column number" error with CRecordset

I recently was performing the simplest of database queries with CRecordset and ran into a snag. Snags are OK, mind you, as long as the answers out there somewhere.

They weren't, but they are now:

Continue reading ""Invalid column number" error with CRecordset"
posted by sstrader at 4:20 PM in Programming | permalink

July 29, 2004

<noun> <verb> <adj>

Ftrain (Paul Ford) has written a fictional article on Google. It explains, in 2009, how Google became King of the World by promoting and harnessing the semantic Web--a universal medium for information exchange by giving meaning, in a manner understandable by machines, to the content of documents on the Web. A concept near and dear to any linguist's or amateur linguist's heart.

Continue reading "<noun> <verb> <adj>"
posted by sstrader at 8:54 PM in Programming | permalink

July 28, 2004

Reasons for using CSS

I tend to trust the pundits who say that CSS is the correct technology to use when designing Web pages. Specifically, their approach is to push all style and layout information into the CSS file(s) and leave only structural information in the HTML. Even fancy menuing systems can be created using CSS + UL elements. The results give you light-weight, configurable, searchable, and simple Web pages.

Here is a review of some sites of interest.

Continue reading "Reasons for using CSS"
posted by sstrader at 8:45 AM in Programming | permalink

July 20, 2004

Fun error of the day

Always fun debugging CE:

'Test.exe' has exited with code -1159943394 (0xBADCAB1E)

I've had 0xBADDF00D before, but never 0xBADCAB1E.

posted by sstrader at 3:05 PM in Programming | permalink

July 19, 2004

HTML integration in CE applications

In two previous entries, I had discussed tips on developing on Windows CE and trapping events from the Web Browser control. I had been researching integration of an HTML UI in a CE application for a hypothetical company I work for. Here are some details on what I've found.

Continue reading "HTML integration in CE applications"
posted by sstrader at 7:10 PM in Programming | tagged mobile development | permalink

July 15, 2004

Asserts, error codes, and exceptions

Herb Sutter has a poorly written, but well-intentioned and informative, article on error reporting in the August 2004 C/C++ Users Journal. In it, he summarizes the difference between asserts, error codes, and exceptions. He also defines the three (and only three) types of errors that occur.

Continue reading "Asserts, error codes, and exceptions"
posted by sstrader at 11:29 AM in Programming | permalink

July 10, 2004

Windows CE development

This entry is a repository for tips and resources on writing C++ code for Windows CE. I'll be continually updating it and reorganizing it as I find new information.

Continue reading "Windows CE development"
posted by sstrader at 1:23 PM in Programming | tagged mobile development | permalink

June 25, 2004

RIP Bob Bemer

/. cracks me up. Here're some threads from a discussion on Bob Bemer's death.

(He helped create ASCII, coined the word COBOL, and warned of Y2K problems back in 1971. His Web site has lots of fun, geeky stuff. Hey, he looks Max von Sydow!)

Continue reading "RIP Bob Bemer"
posted by sstrader at 4:03 PM in Programming | permalink

Shipping software

Here's an excellent blog entry I found via a /. thread entitled "21 Rules of Thumb – How Microsoft develops its Software." David Gristwood posted it on his current blog (not much content there or on his previous one), but it was originally written by Jim McCarthy. Both work at Microsoft and are apparently project managers. Jim wrote the book Dynamics of Software Development from which the rules were summarized.

The /. discussion gets testy at times (not surprising considering that the article is written by Microsoft employees and purports to tell developers how to develop, we're a testy bunch), but here are some points that resonated with me (both positively and negatively):

Continue reading "Shipping software"
posted by sstrader at 2:06 PM in Programming | permalink

June 17, 2004

Programming languages


O'Reilly has a poster in PDF format showing the geaneology of programming langages. There are only ~50 of the ~2500 total, but it's still pretty cool.

Thanks to /. where you can watch the geeks argue about it.

posted by sstrader at 4:57 PM in Programming | permalink

June 16, 2004

Memory management

Trudging through the recent Joel post and read this little gem:

The biggest advantage of .NET is the fact that it has automatic memory management.
If your programming language allows you to grab a chunk of memory without thinking about how it's going to be released when you're done with it, you're using a managed-memory language, and you are going to be much more efficient than someone using a language in which you have to explicitly manage memory.

People often complain about memory management in C++. Although it's true that you have to consider memory management, a couple of simple, well-known techniques push it in the background. They are sometimes even better than the garbage collection in managed languages.

Continue reading "Memory management"
posted by sstrader at 1:34 PM in Programming | permalink

June 8, 2004

Amazon hacks

Everybody loves Amazon, and with the Search Inside feature it's become the Library of Alexandria.

I've begun using it to provide links to relevant quotes and have been a little lazy. The links ended up being session dependent and have expired. Here's a quick hack to do it correctly.

Continue reading "Amazon hacks"
posted by sstrader at 3:00 PM in Programming | permalink

May 27, 2004

Warnings and errors

MovableType doesn't produce valid HTML.

I suspected it as I was slowly modifying my templates, but I finally ran it through the validator and was attacked by tiny, unpaired, angle-bracketed fists of fury. Sure, they're probably cascaded from one or two errors early on, but how can you tell by looking at a page with 100s of errors?

But with even Google failing validation, is it hopeless? Should we just accept the chaos?

Continue reading "Warnings and errors"
posted by sstrader at 10:32 AM in Programming | permalink

May 24, 2004

HTML design issue with links

One of the eminently respectable HTML design gurus declared links that open new browser windows as UI-unfriendly. This is obviously something I use consciously and consistently, and now I have to rethink that decision.

My main argument was based on personal habit. When articles reference an external source, I always open that external source in a new window. I don't like having to use the back and next buttons to refer to both texts.

Nielsen's argument is that opening new windows is a hostile way to try to keep users on your site. He also points out that the user can choose to open a new window if they want to.

The second argument, although Nielsen glosses over it very quickly, is complelling. A _blank target eliminates a choice they would otherwise have from the context menu.

I am undecided.

posted by sstrader at 10:14 PM in Programming | permalink

Trapping element events from a Web Browser control

This entry explains how to trap HTML element events in MFC using the Microsoft Web Control. This will allow you to respond to events such as button clicks and selection changes as they are fired by any element within a Web page.

Setting this up is mostly straightforward. The only tricks are making sure you get the Internet Development SDK from Microsoft's Platform SDK and that you use the correct element type in your HTML.

This was all learned recently, so there are some as yet un-explained caveats.

Continue reading "Trapping element events from a Web Browser control"
posted by sstrader at 11:30 AM in Programming | tagged mobile development | permalink

May 21, 2004


The June 2004 C/C++ Users Journal has an article by Herb Sutter on the recent C++ Standards committee meeting. He talks about some of the new extensions to the C++ Standard Library that will be included in the Library Extensions Technical Report 1 (Library TR1) due out later in the year. Vendors should be releasing implementations soon after.

Continue reading "C++0x"
posted by sstrader at 1:36 PM in Programming | permalink

May 20, 2004

Branch causes

At this hypothetical company, we have a shared code base linked across several branches in source control to accommodate customizations for each client. Customizations include not only configuration file changes but also source code changes that cause the code to be branched from the "base" code. The base code is simply that subset (perhaps 80%) which is linked across all client branches and has no breaks. It's interesting for the fact that it exists only in concept.

This branching is an obvious source of distress. Linked code causes long-distance (cross-client) bugs; branched code isolates features and fixes. What to do?

Continue reading "Branch causes"
posted by sstrader at 9:31 AM in Programming | permalink

May 19, 2004

Corporate chaos

There's this hypothetical company, see? And they give developers' phone numbers out to clients so that they can be contacted at any time of the day. Forget the egregious mistake (see Fact 4) made by allowing developers to be interrupted at any time for any length of time while they're focused on writing code. Just know that this is considered standard.

Well, a funny thing happened this morning at said hypothetical company...

Continue reading "Corporate chaos"
posted by sstrader at 2:05 PM in Programming | permalink

May 14, 2004

Voting irregularities

So, we've all read news articles at sites that let you vote on how good the article was, right? Well the one I read today had the following statistics:

  • You can rate the article on a scale of 1 to 5,
  • Seven people have voted so far,
  • The average of the votes was 2.85

OK? Now, how can we calculate the possible combinations of votes that would satisfy these values? I quickly realized that this was some math that was beyond a Fine Arts degree programmer such as myself (and also beyond a couple of CS degree programmers in the office).

We came up with a few clumsy stabs at describing it, but were woefully underequipped in solving it or even explaining what form the solution might take.

We can state the equation like this:

S(i = 1..7) V[i] = 2.85 | V = {1..5} (the sum of the 7 votes = 2.85, where the votes are between 1 and 5)

[add more later]

Continue reading "Voting irregularities"
posted by sstrader at 7:17 PM in Programming | permalink