Thursday, July 20, 2006

LaTex Schmatex?

Diddlbiker doesn't even know what triggered it but he decided recently to get some hands-on experience with LaTeX. Now, to correct the title, I actually [b]do[/b] like it, [i]but...[/i]
It is not as wonderful and perfect as everybody says it is. Clearly, its biggest appeal to most Linux Kiddiez is that it is not 'Micro$oft'. As we all know, each and every Microsoft product sucks beyond belief. Actually, it is all these immature kids that want to differentiate themselves from the big crowd that suck, they usually don't know what they are talking about.

So, what about LaTeX. First of all, I absolutely [b]hate[/b] software with funny names. As if "Latex" isn't bad enough, an apparently even "LaTeX" couldn't do the job for sufficient weirdness (see logo - this is how the software is referred to in the manual on a continuous basis. The horror!). It is like software as Lotus Symphony! or Act!, or that wonderful non-IBM compatible 80186 powered monster that Philips introduced in the 80's, the :Yes! (an exlcamation mark is sooo common, let's throw in a colon for good measure).

Before I continue to rant; Latex is really, really good. I like it. However, saying that 'Word is the worst word-processor ever invented' and 'no match for Latex capabilities' is like making claims that 'Outlook is much better at email than Powerpoint' - you're comparing two different pieces of software. Latex is purely typesetting software. It is language, not a word processor. The result is the same (a printed document), but the software - and the expectations - are different. So, in defence of word, some of the 'Latex myths' about how horrible word is - and what in my view the reality is.

Latex' output is much better than in word.
Could be, but that's probably because you're looking at something that LaTeX excels at (mathematical formulas for instance). I've been looking for the example that I found that was 'honest' proof - two identical documents with just plain text. "Look at how much better LaTeX handles whitespace, especially at the second sentence". The text in case had an indentation at the LaTeX document, forcing the words closer together. Of course did the Word document look bad...

Latex can handle large documents, Word can't
Technically speaking, LaTex doesn't allow editing of any document - you will have to edit your files with a seperate text editor. Stuck with an old-fashioned Notepad in Windows 98? Too bad, only 1 Mbyte...

Microsoft Office is such a memory hog.
Excuse me? I installed LaTeX (the ProText package) on my machine, which took a whopping 800 megabyte. With Microsoft Office, you get Word, Excel, Powerpoint, Outlook, Access and a whole bunch of tools - and there's still room left

Word is so slow, LaTex is muuuuch faster.
True, if you're interested in a 500 page dissertation laced with formulas every other paragraph. If on the other hand, the scenario "Boss: can make something to show sales blah blah blah geographical bla bla costs blah?" is your daily routine, Word can usually help you out in less than 30 minutes (and that includes making the two bar charts in Excel and the map in Mappoint)

WISYWIG is horrible!
I saved the best for last. WISYWIG may not always be the best solution, but it is pretty much convenient. Switch to normal mode, show hidden characters on and there's not a lot left to surprise you in Word. And of course, make documents the way you're supposed to - using templates and styles. But no, reading the manual is only allowed for LaTeX, with Word we expect you to do everything correctly at once. And at the same time you see all those LaTeX editors that do have WISYWIG ability. Oh yeah, soooo horrible...

I could go on for a long time. Again, LaTeX is excellent and fun to play with for Geeks. It is definetely better than Word when it comes to large, complex documents. But fight Word on it's hometurf (30 page documents with lots of integrated charts, pictures, and excel spreadsheets embedded in it) and it won't come out that pretty...

Sunday, July 16, 2006

Places I visited

I stumbled accross www.world66.com today, and one of the things you can do there is make maps of places that you visited.

This is me in the USA:


create your own personalized map of the USA
or check out ourCalifornia travel guide

And this is me in the whole world:



create your own visited country map
or check our Venice travel guide

Rather disappointing :-)

Reminder: reading from disk is expensive

M_01898Diddlbiker is working on a little project at work. What the project consists of is not important, but in one step of the process I have to find transportation links between two locations.
There is all kind of theory written over this, but in this case, the problem was very simple: I have rail links in table 'A', and truck links in table 'B'. What is the best routing option from Houston to New Jersey? Straight over Newark or is railing to Philadelpia so much cheaper that the extra trucking cost doesn't matter.
So, for each route there are about thirty rail links to choose from, and there is only one truck link that connects the rail link to the final destination. So what's the big deal? I have to do it for 200,000 entries, and that takes some time.
The initial approach was a brute-force pure-SQL attempt. Well, that didn't go over that well.
The second approach was a VBA approach. Each link would start with a recordset of all rail links originating from it's starting point, for each rail link I can than look up (another recordset) the truck link, and when I all have them, find the cheapest one. That worked, but it took an amazing amount of time - after 45 minutes of processing, only about 1% of the entries was done!
From here I had three options:

  1. Intelligent approach: go and study and find an optimal way of doing it. I don't think there is a lot to be gained here - I'm only investigation 30 options per link, after all

  2. Reduced data: instead of 30 options per link, I could reduce the rail set by 30% by predeterming what the 10 links are that are closest to the final destination. I wouldn't want to go below 10 - 5 or 6 links might be the closest location, but different stations, and you really want to see if routing over a different location works. It would reduce processing time by 70% - but processing would still take around 20 to 30 hours.

  3. Caching: a lot of time is spent reading the truck rates, and there aren't that many of them (about 110,000 to choose from). Writing a simple cache wasn't that hard, and the result was amazing - total processing time went down to 45 minutes.

One of the nice things about VBA is that you get a pretty good Dictionary for free (it's in the Scripting Runtime Library). A small hashing function was written in minutes.

Total time invested: about one hour
Total time saved: about 80

Yay me!

Wednesday, July 05, 2006

Brilliant!





In really, really rare occasions Diddlbiker feels like he accomplished something brilliant. Today was one of those days. And the best thing is: my artwork is actually something small, elegant and comprehensible.

What happened, was that my clients would need a table in a certain format, but the model it supported would demand a different format:























Client Wishes Model Demands
20060%
2006
1.0000
20075%
2007
1.0500
20084%
2008
1.0920
20093%
2009
1.1248
20102%
2010
1.1473
20111%
2011
1.1587


Clearly, my users want to specify a percentage increase for each year. I on the other hand, want a factor that compounds the increases year after year. The solution I came up with was non-equi self join with a kick:

SELECT tblYear.Year, Exp(Sum(Log([tblRate].[Rate] + 1.0))) AS Factor

FROM tblIncrease AS tblYear

INNER JOIN tblIncrease AS tblRate

ON tblRate.Year <= tblYear.Year

GROUP BY tblYear.Year;

I achieve two things in the query. First of all, by using a JOIN ... ON ... <= ... I'm able to pick up all years up to and including the 'current' year.

Second, SQL doesn't have a PRODUCT aggregate function. By turning the factors into logarithms I can multiply them by adding them together - and SUM is something that you can do in SQL! Once they're all summed, I can reverse the logarithm by using an EXP (exponent) function.

The query basically turns the first table (input-friendly) into the second table (model-friendly) without any scripts, temp tables or other garbage. Brilliant!



Speaking of brilliant: I saw a link on Joel on Software today about Elastic Tabstops - I wished every editor was that smart!

Tuesday, July 04, 2006

Nature in Bergen County

W_02450Diddlbiker's father-in-law got himself a bird feeder. That doesn't mean that you will get birds, though. Those dinosaur-descendants are very, very careful and seem to have a sixth sense when it comes to photography: they will simply not show up.

The good news is that those dang squirells have no problem with biped mammals at all, so while I was sitting outside in the blistering heat, there was at least something that I could take pictures of. An FIY for my European friends: squirells are not looked upon kindly in this country. They are as much enjoyed as pigeons in large European cities. So, in analogy of winged rats one could call them rats with fluffy tails.
So, why the picture of the squirell? This would be a great moment to quote Ansel Adams, or Cartier Bresson, about photographing the ordinary, but the truth is: they are adorable creatures to photograph!

W_02453So what about the birds? Eventually they got used to me and a couple of birds did show up. Thanks to Birds of the Mid-Atlantic I am able to find out what bird this is: a Mourning Dove. Just like in Dutch, American bird names are weird. I mean, you might think "tjiftjaf" and "lepelaar" are weird names, but what about "Grackle" or "Tufted Titmouse"?

W_02454I got even luckier after a few more minutes when another rare bird showed up, in this case a House Sparrow. I even managed to get them into a single frame! Without being sarcastic, there are a lot of interesting birds to be seen - I just never carry my camera with me when I see them (which is rare). So far I have seen:
  • Pelican (in Charleston)
  • Turkey Vultures (lots)
  • Eagles (not bald)
  • Cardinals (without bats)
And of course a whole list of ducks, warblers, sparrows, geese and other common birds.

And one day I will get a picture of that special bird. It will just take a while - I'm not a bird watcher after all.