Summer vacation

I’m back in Italy after a wonderful vacation in Oregon. I had a nice time in Portland at OSCON, and got to meet a bunch of people I most likely won’t see for a while, which is always fun. In particular, David Jones of OFBiz was impressive in his determination to do anything and everything to make that project a success. It would have been nice to spend a bit more time at OSCON, but vacation called. On the negative side, I’d kind of forgotten how these things at time break down into cliques, but c’est la vie. It reminds me that I prefer the inclusiveness that is at times more present in Italy.

Going a bit off topic from the topic of this journal, “computer stuff”, we went all over Oregon… Portland, the Gorge, Mount Hood and Timberline Lodge, the central coast, Eugene of course, including a wine tasting trip along the applegate trail, Waldo Lake, Paulina Lakes, and over as far as Fort Rock and the high desert, which was quite a spectacle for us city dwellers acustomed to being surrounded by people.

One of the great things about Oregon, and being on vacation there, is the bookstores. Powell’s is probably the world’s largest physical bookstore, and the separate technical shop is larger than all but the largest bookstores in Italy. I couldn’t resist buying a bunch of books there, and at the Smith Family Bookstore in Eugene, which has loads of used books at good prices. I bumped into Russ Nelson, of the Free Software Business mailing list, in the Economics section of Powell’s, which was an interesting chance encounter.

Amongst the books I picked up:

The Paradox of Choice: Why More Is Less

A good read, but it could have been condensed significantly and still got its point across. I think there is a lot to be learned in this book for us programmer types, who tend to be very much ‘maximizers’ in what we do. I’ve written about this some here:

Maximizers, Satisficers and Programming Languages

Why Globalization Works

The book explains what the title promises. It’s a long read, because the author is very thorough and provides lots of supporting facts and figures.

Growing a Business

Good read on creating and growing a business, even if it’s a bit dated, and related to the individual in question and his experiences. Now, if only I had the business…

How to Bring a Product to Market for Less than $5000

Haven’t read it yet, but I have some ideas for products completely unrelated to high tech (it’s stuff from Italy, actually) that I think would do quite well in the US. Contact me if you’re interested…

The Design of Everyday Things

Haven’t got around to reading this one either (also, I have a backlog of The Economist to read here at home, which is usually time consuming). It comes high recommended though.

The Third Chimpanzee: The Evolution and Future of the Human Animal

I enjoyed Collapse as well as Guns, Germs and Steel by Jarod Diamond, and this one looks interesting too. In light of the aforementioned backlog, I left this one with my parents to read, and I’ll check it out later this fall.

Why Most Things Fail

Doesn’t seem to be rated very well on Amazon, but Ormerod’s thesis that economics-as-a-machine isn’t tenable is interesting, and I’m curious to see the details of that idea. Perhaps one of his earlier books would be good reading as well.

I’ll try and write up the books as I read them, if they prove worthwhile.

New laptop?

I’m looking forward to meeting people at OSCON tomorrow (Thursday) we decided to skip Wednesday, because we’re still a bit tired from the trip over, and… we’re on vacation.

One thing I’m considering while I’m in the states is getting a new laptop because 1) Oregon has no sales tax, and 2) I can get one with a US keyboard (I can’t stand Italian keyboards for programming).

The OS would be Ubuntu.

Any recommendations?

Oregon – OSCON

After more than three years away from home, we’re going on vacation to Oregon this summer. Luckily, that will coincide with OSCON in Portland, so hopefully it will be possible to meet some people there that I ordinarly wouldn’t get to see. Write me email if you’d like to get together for a beer or something! The rest of the time, we’ll be in Eugene, or travelling around the state.

.rhtml minor mode

[ Update – new version is here: https://journal.dedasys.com/articles/2008/09/25/rhtml-minor-mode-update ]

Emacs has been my favorite editor for a long time, due to its incredible flexibility to meet new challenges, and extreme programmability. Things like tramp are just too cool to do without.

In any case, I’ve been doing more Ruby on Rails lately, and as part of that, have run into a few irritations with existing emacs tools. For instance, editing .rhtml files is not quite as nice as it could be. One reason is that psgml-mode, which I use to edit HTML files wants to have access to the DTD declaration in use. Since Rails usually puts fragments in one directory (app/views/foobar/show.rhtml), and the “parent” template in another (app/views/layouts/foobar.rhtml), it means that the “child” template doesn’t have access to the DTD in use, and so autocompletion of tags is not as accurate as it should be. Luckily, psgml mode provides a way to tell it that the parent is elsewhere. Utilizing this, I wrote a bit of elisp that automatically goes looking for the parent .rhtml file when you load up a fragment. It’s just an initial cut, and could use some improvement, but it seems to work for me:

http://www.dedasys.com/freesoftware/files/rhtml-minor-mode.el

On the TODO list:

  • Actually examine the layout file, to look for the top level tag that contains @content_for_layout.

  • Make _partials.rhtml type files work, or at least ignore them. The problem being that it’s hard to find out what tag they are contained within.

Patches, comments and suggestions are welcome!

Good thing that he doesn’t speak Italian

The Java Conference in Milan was a pretty good experience on the whole. Took a train there in the morning, and managed to arrive just in time for James Gosling’s talk. It wasn’t a bad talk, but he’s not a great speaker – you can tell he’s more of a technical guy who’s interested in the details, and perhaps would do a better job of transmitting some of what he’s interested in/working on in a small group or individually. He did talk some about utilizing Java in real time embedded environments, which I found interesting, because those guys tend to be very careful, ‘no bullshit’ sorts of engineers, who have people’s lives riding on their work. It’s not an environment where enterprisey fad things go over very well.

In general, the technical level was reasonably high – I was pleasantly surprised, expecting a bit more in the way of marketing driven presentations.

Indeed, the association of Java with Big Business sorts of applications has long been something that has turned me off on the language. As an individual, or part of a small team, I’m much more interested in systems like Tcl and Tk or Ruby on Rails that let me do more with less code. I’ve felt that it made more sense to avoid competing on terrain where the differentiating factor is the ability to crank out massive amounts of code (getThis, setThat, etc…), because alone, I can’t take on a larger group.

As I was explaining some of this as part of ‘Why I wrote Hecl’ to one of the other guys slated to talk about J2ME in the speakers’ lunch room, I was talking about how “non e` che Java mi piaccia in modo particolare” (I’m not particularly wild about Java), the person I’m talking with starts gesticulating at me, and I turn around and look, and who should be there, talking with someone else, but James Gosling. Hope no one provided a translation for him!

To tell the truth, I think Java has its place. It seems to be an appropriate technology for something like OFBiz, or other apps that genuinely do need to be reasonably large and complex. Just that I have more fun with other languages like Ruby and Tcl.

Concurrency

We’ve been having some interesting discussions on the Hecl mailing list about how to do concurrency:

http://sourceforge.net/mailarchive/message.php?msg_id=19566676

(although it seems SF has managed to lose a portion of the conversation!)

When all things are said and done, we have a couple of options:

  • Try and immitate Tcl’s select-based event loop. Not really concurrency, but it does a good job of “faking it” for things like GUI’s, if done correctly. For the right kind of code, it makes life very easy for the programmer, as you don’t have to think too much about concurrency issues, and you don’t have to deal with threads. The downside for J2ME is that we don’t have the equivalent of select, so we’d have to do the system with threads, which would probably be costly in terms of the resources required to set it up.

  • Tcl style threads, where each thread gets its own interpreter, and data is mostly shared by message passing between the threads. Conceptually, I think this is a cleaner way of doing threads, compared with ‘sharing everything and using mutexes’, and it’s a little closer to how Erlang handles concurrency, which is very nice indeed. For J2ME, I’m a little bit worried that this might be too resource intensive, and potentially slow to launch new threads.

  • A low-level interface to threads that just exposes the Java API. This would be nice, and lightweight, but potentially quite complex to program if we attempt to make the interpreter reentrant. There are a lot of issues with things like stack frames – for instance, say one subroutine (proc) adds a stack frame, then a second thread kicks in and exits a proc, tearing down the stack frame again. If you put a big lock around procs, that just leads to blockage if a proc is doing some sort of long running calculation, defeating the whole point of the exersize.

  • Deal with concurrency on a case-by-case basis, building it into each command that needs it. Not very elegant, and probably requires just as much work, if not more, than other options.

At this point, I’m tending towards each thread having an interp, because option three seems very prone to extremely difficult bugs. Not sharing the interpreter has worked well for Tcl both from the implementation and end user perspectives. It is, however, not an easy subject and I’m still thinking about it.

Note comments are broken, so email me with questions or comments.

Java Conference Milano

Ciao everyone…

My talk on Hecl has been accepted for the Italian Java Conference in Milan!

http://it.sun.com/eventi/jc06/programma/milano_more.html

If you’re going to be there, let me know… it’s always fun to see people I haven’t had the occasion to see in person for a while.

Unfortunately, I won’t be going to ApacheCon Europe in Dublin, which seems like it will be a fun event.

Note comments broken due to Typo being…abandoned?

Climbing the – dare I say it? – stack

Si Chen has a nice write up of a talk he gave discussing OFBiz, and more general, open source in the business world:

http://opensourcestrategies.blogspot.com/2006/06/why-enterprises-are-adopting-open.html

When I started getting involved in the free software world, open source was very squarely aimed at tools, and applications for our fellow geeks. It’s interesting to watch it march off in new directions, such as Ubuntu on the desktop (my wife requested that I put Ubuntu on her new laptop!) and systems like OFBiz, which are very much aimed at higher level business processes.

Streaming programmatically generated content from Rails

Today, I needed to do something that I didn’t find a handy method for in Rails. The API has both a send_data and send_file method, but they are both ‘one shot’ in that you have to send all your data at once.

def generate_file
  @headers["Content-Type"] = "text/comma-separated-values;"
  @headers["Content-Disposition"] = "filename="some.file.txt";"

  i = 0

  render :text => Proc.new { |response, output|
    ...
    output.write("some generated text...")
    ...
  }, :layout => false
end

I more or less copied that from the send_file method, and indeed, I’ll even admit that I’m not entirely sure why it works. What I don’t get is what “connects” the output variable in the Proc to an actual file descriptor somewhere. render_text doesn’t really clear things up (well, for me, at least!).

  def render_text(text = nil, status = nil) #:nodoc:
    @performed_render = true
    @response.headers['Status'] = (status || DEFAULT_RENDER_STATUS_CODE).to_s
    @response.body = text
  end

In any case, the code does do what I want – perhaps someone else will find it useful.

NOTE

Comments are broken, as the typo journal system seems to have been somewhat abbandoned… argh!