Utterances of a Zimboe

Programming the Internet.

Archive for the ‘Programming’ Category

Farewell, XML!

with one comment

Minor update: I’m a little concerned over the ‘service’ construct; is request-response still such a valid schema that it’s worth promoting to a native concept in the specification? I might rather try to suppress it in favor of asynchronous patterns.

Back to business –>

Welcome to the developer documentation for protocol buffers – a language-neutral, platform-neutral, extensible way of serializing structured data for use in communications protocols, data storage, and more.

Hah, Google did it again! Excellent. God damn, I’ve really waited for something like this.

Protobuf is of course missing tons of features compared to XML (schema), but I’m quite sure there’s nothing fundamental that can’t be built on top of protobuf. And this is the way to go: very small core that’s a good ground to build on.

Missing:

  • namespaces (implement with field numbers)
  • validating data types (use higher abstractions; message types)
  • types, types of types (simple/complex), elements, attributes, groups… all the cruft (just types and extensions; rok)

(Protobuf doesn’t compare to JSON; former is strongly (statically) typed. JSON is good for small-scale browser stuff.)

Oh, I just luuuuuv it! (== positive initial impression)

Advertisements

Written by Janne Savukoski

July 10, 2008 at 2:25 pm

Posted in Programming, Technology

Earth, wind, fire, .. and .. uh, what was it…

leave a comment »

Bwah, I was really spoiled by my readings while I was traveling from Helsinki to Rovaniemi by train last night. At first I finished reading Hackers & Painters by Paul Graham, which was simply the best non-technical book about programming I’ve ever read. (For some of the others, you can check my LibraryThing.) It also got me considering using Lisp in an embedded system project. (Other strong candidate is OCaml—I’m having this hybrid season now—but the selection is a whole other blog post…)

And right after Hackers & Painters I started reading this short story collection Hackers. Oh boy, what a nice combination. I can definitely recommend if you’re really serious about software. (People without experience on functional languages don’t need to bother; trust me, I’ve been there. It’s a whole other realm on the other side.1)

And why was this so spectacular? While reading Painters, I came to realize that the more fundamental aspect of hacking may actually be the current (or becoming) leading edge in natural sciences. For example, there has already been heated discussion if information can escape black holes; scientists are starting to use information to represent physical phenomena. (Just mentioning here so that you can believe the facts instead of me. By the way, as a tip for youngsters, I’d be a little hesitant on choosing physics over compsci just because one has so much experience on computers already.) Furthermore, the more philosophical aspects of information theory may be the “leading” topic in metaphysics as well.

What I’m trying to say is that hacking is not just about programming computers, but it’s actually about the (current) most fundamental aspects of reality. Becoming the most “serious” of the “serious” sciences. (Compsci has traditionally been considered an order of magnitude less serious than math or physics, and universities adopting Java hasn’t really helped in this regard… ;)

This quote by Dijkstra is one of my all time favorites:

Computer science is no more about computers than astronomy is about telescopes.

But we are still in the early days of comprehending and applying information. Do we have any good reason for not considering information (currently just merely 1 and 0) as the current water-fire-earth?

Just for the sake of context, lets remind here that in “ancient greece” the basic elements of nature were water, fire, and earth. At some point along came gravity and ether. In last century the hot topics were related to structure of matter and Theory of everything.

It would be interesting to know what are the “atoms” of information, but I’m not holding my breath here — getting from water et co. to atoms took quite a while, if measured in human lifetimes. (And we still don’t know shit about gravity.) Qubits may shed some light to this in the near future.

In any case, I’m pretty sure it’ll be interesting to try to master information. A purposeful goal for a lifetime or even few, I suppose.

All classes fear this relentless abstraction of the world, on which their fortunes yet depend. All classes but one: the hacker class. We are the hackers of abstraction. We produce new concepts, new perceptions, new sensations, hacked out of raw data.

— in A Hacker Manifesto, second paragraph

I’ve always been intrigued by sharp edges — it’s merely fascinating to get little cuts to your fingers every now and then. And what’s a more fundamental cutting edge than one that’s shared in philosophy as well.

ps. I just found out that in emacs you can duplicate line with shift-up/down. Neat. (And, in addition to the readily provided shift-left/right character transpose, I’ve had line and word transposes for a while as well. Recommend.)

pps. I’m quite confident that there’s a quite straightforward religious aspect in this philosophy as well… haha, the languages, naturally! Where Lisp is the One True God and pg is the head preacher. ;) (But, seriously. Programming languages are the tools for molding information. (And Lisp is the most abstract.))

1) Imperative programming is about abstracting computers, functional about abstracting information. The longer you deny it, the more you’ll regret.
Read the rest of this entry »

Written by Janne Savukoski

July 9, 2008 at 1:19 pm

Posted in Future, Programming

The Stinky Bits

leave a comment »

These are hardly of any inspiration for anyone else, but just to show the code(s) that ‘sparked’ my previous observation:

override def init(ctx: ComponentContext) {
  val descs = descriptions(new File(ctx.getInstallRoot))
  provides.foreach { svcName =>
    debug("Searching description for service %s", svcName)
    descs.map(t => (t._1.getService(svcName), t._2)).find(_ != null) match {
      case Some(t) => services = t :: services
      case None => warn("No description found for service '%s'", svcName)
    }
  }
  info("Found %d services: [%s]", int2Integer(services.size), services.map(_._1.getName).mkString(", "))
}
def descriptions(dir: File): Iterator[(Description, Document)] = {
  val cache = new HashMap[String, Option[(Description, Document)]]
  dir.listFiles(wsdlFilter).elements.map(f =>
    cache.getOrElseUpdate(
      f.getAbsolutePath,
      try {
        wsdlReader.synchronized {
          debug("Reading WSDL '%s'", f.getName)
          val doc = domParser.synchronized(domParser.parse(f))
          Some((wsdlReader.readWSDL(wsdlReader.createWSDLSource | { s => s.setSource(doc) ; s.setBaseURI(f.toURI) },
                new WodenHandler(f.getName)), doc))
        }
      } catch {
        case t: Throwable => error(format("Exception while reading '%s': %s",
                                   f.getName, t.getMessage), t)
                             None
      })
  ).filter(_.isDefined).map(_.get)
}

That’s just a bit of JBI-related framework logic, which lazily parses some WSDL-files and caches the structures until the required descriptions are found.

Works fine. :)

ps. definitely not the best show-case for abstraction, but I just wanted to play around with files a little.

pps. my editor is 100 cols wide, and the parts that don’t fit are irrelevant.

Written by Janne Savukoski

November 7, 2007 at 1:46 am

Posted in Programming

Pattern Matching

with one comment

Hm, I’m kind of starting to notice a repeating pattern in writing Scala code. It’s a very simple pattern: after the size of a source file reaches some notable size (like 100 lines or so, corresponding to some 500 lines of Java — or 5000, while at it…) I’m spending more time admiring the existing code than actually writing more of it. :) (… just being bluntly honest.) (Certainly, this has never happened with Java, in case you were thinking.) But, I’m still living the initial crush, so I must beg your forgiveness for my utter narcissism

Plus, beer & listening to Antony and the Johnsons may have something to do with this. Life’s good at times.

(And hey, despite the slacking, I’m still 250% more productive compared to Java; although, that figure is probably something like 1k due to increased happiness. (Non-leaky) Abstractions rule.)

I am very happy
So please hit me
I am very very happy
So come on hurt me

I’ll grow back like a Starfish
I’ll grow back like a Starfish
I’ll grow back like a Starfish
I’ll grow back like a Starfish

— in “Cripple and the Starfish

Written by Janne Savukoski

October 31, 2007 at 8:01 pm

Posted in Programming

Unstable identifier

leave a comment »

In case you had missed this teeny bit of Scala spec [v2.6, 8.1.4 Stable Identifier Patterns]:

Example 8.1.2 Consider the following function definition:

def f(x: Int, y: Int) = x match {
case y => ...
}

Here, y is a variable pattern, which matches any value. If we wanted to turn the pattern into a stable identifier pattern, this can be achieved as follows:

def f(x: Int, y: Int) = x match {
case ‘y‘ => ...
}

Now, the pattern matches the y parameter of the enclosing function f. That is, the match succeeds only if the x argument and the y argument of f are equal.

And, a little earlier:

A variable pattern x is a simple identifier which starts with a lower case letter.

I was trying to match a type with a lowercase name and it took me a moment to figure out why it didn’t work.. :)

Btw., I don’t like this syntax-by-convention a bit, and it was a major surprise to bump into such here (with Scala, that is). I guess I need to question this at the forum.

Update (a better look): Ok, backquoting an id is an established syntax for denoting a stable identifier. Oh so novice for not knowing. But still, “identifier which starts with a lower case letter”.

Tags:

Written by Janne Savukoski

October 17, 2007 at 12:38 am

Posted in Programming

Java is done

with 5 comments

Russell Beattie:

I like Jonathan Schwartz a lot, but I think that unless some drastic changes are made to Java, the move to JAVA as Sun’s ticker symbol is going to be as relevant as changing it to COBOL.

Couldn’t agree more. Scala ftw. (for my tasks; feel free to use Ruby/whatever for web UI, etc…) An excellent post, btw.

Written by Janne Savukoski

August 26, 2007 at 10:52 pm

Posted in Programming, Technology

Best of luck for Scala with Sails!

leave a comment »

Already the name ‘Scala with Sails’ made me smile. :)

Furthermore, it’d be awesome if we finally had a decent web presentation framework for JVM!  (The UI layer has always been a bit of a problem for Java and it has caused much sour for the whole Java-technology itself.)  I believe Sails would also be great promotion for Scala, as we can see what Rails made for Ruby.

Of course, now there’s also the JRoR (JRuby on Rails), which I guess is in a very similar position compared to SwS.  But both Scala and JRuby are so fresh—especially the former—that any kind of comparison would be just utter speculation.  And even two would still be much less than 44

I wish the best of my luck for this project!

Written by Janne Savukoski

January 4, 2007 at 4:28 pm

Posted in Programming