Search Results: "willi"

27 February 2006

Anthony Towns: #debian-tech, Redux

Back in September last year I blogged on #debian-tech, a new IRC channel for discussing Debian, but with a charter and some ops with a mandate to enforce it. At the time I wrote:
It’ll probably be quite a bit different from #debian-devel on either OFTC or FreeNode; hopefully that’ll turn out to be in a good way. We’ve got (I think) a pretty good variety of ops, who have (I think) some pretty good ideas on encouraging good productive activities on Debian. We’ll see what happens!
Since then, we’ve had a couple of significant discussions on it, reflected on the wiki page; the multiarch discussion was interesting and spontaneous, and the release and archive qualification discussions were both potentially highly contentious discussions that seemed to end up being conducted really well, and have both had some pretty significant results. That’s pretty pleasing – this time last year, there wasn’t anywhere I’d’ve been comfortable having those sorts of discussions in public, now there’s somewhere that’s been demonstrated to work fairly well. A more surprising outcome is that we’ve never actually banned anyone from the channel. To some extent, this is to be expected since people who don’t like the concept just won’t join in the first place, and to the extent that’s true, it’s a good thing. And at least Wouter, who’d also objected in the past, was willing to join briefly for one of the discussions important to him and get along fine. Unfortunately that’s not the only reason for the total lack of bans. The other aspect is that people have turned out to be far more ready to ban themselves than the ops have been. To anonymise an example from November last year: Read the rest ...

22 February 2006

Clint Adams: The Judgment Game

Sometimes, when there are what one might term charged discussions , I like to play a little game. I sample a few of the people who are shooting their mouths off and check to see how they're contributing to a certain project about which I might have some opinions. In some cases, I find that they are not worthless blowhards as one might conclude from the inanity of their speech and actions, but actual contributors who just happen to be terribly, terribly incorrect. In other cases, I discover that they have shown a grave lack of judgment in prioritization. Let's stereotype some of the charming winners. The worthless blowhard: This person has a contribution-to-noise ratio that is infinitesimal small. Perhaps he believes that by expressing himself, he is making the world a better place. Perhaps he thinks that his opinions matter. He is mistaken. The arrogant egoist: This person also does very little. She believes herself to be supremely qualified to dictate the way in which others make their contributions, or at least moreso than the people who are actually doing the work. She is quite often mistaken, and should be ashamed of being such a control freak. The catamite trainer: This is a version of the arrogant egoist who betters the world by taking on an apprentice. The Master supervises the Apprentice's contributions, and continues to dictate how things should be done despite being unwilling to actually contribute himself. One notable difference between this and a respectable mentorship relationship is that the Apprentice is aware that he is more qualified to make these decisions than the Master, but feels that it would be socially inappropriate to shake off the yoke of oppression. He is mistaken. The possessive stoner: This is someone who is lax in her responsibilities but means to correct these deficiencies as soon as humanly possible. If anyone offers to help her, she says, No! I'll do it myself this weekend. Then she does something else. The offer is repeated a month later, and she replies, No! This weekend for sure, Rocky! Two years later, people are still fuming that the work hasn't been done. She is a flake. On a completely different subject, let's talk about Debian. I recommend the expulsion of anyone who posts more than 5 mailing-list emails or newsgroup articles in a 24-hour period. I recommend the expulsion of anyone who finds out about Debian votes by reading Slashdot. I recommend the expulsion of anyone who reads Slashdot. I recommend the expulsion of anyone with subpar personal hygiene. I recommend the expulsion of anyone in Project Scud. I recommend the expulsion of anyone who employs statistics in a dishonest manner. I recommend the expulsion of anyone who tries to impose the values of a particular subculture that is not Debian on an international project. I recommend the expulsion of anyone who uses cdbs. I recommend the expulsion of anyone who likes tarball-in-tarball. I recommend the expulsion of anyone who makes lists. I recommend the expulsion of anyone who contributes more to Gentoo, Mandriva, Red Hat, SuSE, Ubuntu, or Xandros than to Debian. I recommend the expulsion of anyone who ever wrote an autobiography. I recommend the expulsion of Mos Def and Talib Kweli: best expulsion in hip-hop. Y-O.

21 February 2006

Uwe Hermann: Apple Safari executes arbitrary shell scripts without asking you for permission

It seems Apple is having more and more severe problems lately, MacOS viruses and worms start popping up and spreading on a larger scale... Michael Lehn has now discovered that Apple Safari can be tricked into automatically downloading and executing arbitrary shell scripts. No need to mention what harm this can cause, especially if you are stupid enough to browse the web as root (or whatever Apple calls their superuser). The behaviour to automatically open downloaded "trusted" files in a respective application is the default in Safari, which is obviously not the brightest idea Apple ever had. This is not an Apple-only problem, though. I really wonder why so many people, be it developers or users, are willing to sacrifice security for some crappy "feature"... (via Digg)

18 February 2006

Jeff Bailey: For your own good!

I've often wondered why people still run Windows? When I ask folks, sometimes I get comments of "I tried Linux 4 or 5 years ago, and it seemed too hard.", or "I just couldn't do without the latest features in application FOO.". These comments have always struct me as odd - As far as I can tell, GNU/Linux with Gnome is at about the state that Windows was, say, 1997 or 1998. While it's probably a step back in terms of raw functionality, it's incredibly usable. I think today, I've figured out the real reason why people run windows; The problem is, I think, reflective of a real problem with our thinking in general:
Is it possible that people are simply unwilling to give up the idea that the world around them should protect them from themselves? It would explain recent trends in North American and Western European government elections, magazines that talk about how our cancer rates, death rates and such are all other people's problems. Maybe it's time for us all to buck up and take some responsibility for our lives. If I'm out of shape, perhaps I haven't gotten off my ass and worked out in the past week. Maybe if this winter weather is unusual, I should stop driving the car and find a gym closer to me. Maybe if the world out there feels a bit dangerous, it's because I'm not willing to go out and meet my neighbours and become friends and build real local community. Maybe I can remember to make a difference.

David Welton: Maximizers, Satisficers and Programming Languages

Whilst ambling around on the web after seeing a post on reddit.com that piqued my curiousity, I happened on some work discussing "maximizers and satisficers", which, put crudely, says that there are two kinds of people. Those who, out of a group of options want the best one - maximizers - and those who just want something that will work - satisficers. Anyone who has been around programming languages more than, say, a week, will instantly recognize the above theme in the endless discussions of "which programming language is best?", or more generally, which "X" is best? I'd be willing to bet that programmers, and especially open source programmers, tend towards the 'maximizers' end of the spectrum - I don't want just any old X, I want the best one, dammit! Sometimes, this can be a good thing, as it leads us to continuously seek to improve things we come into contact with, or try new approaches, it can also be detrimental if your goal is simply to accomplish some task, rather than spending too much time fretting about finding the perfect tools to accomplish the task with. This also has ramifications for people designing or dealing with programming languages. One of the papers (the original?) on the subject (here), actually deals with the fact that maximizers, in their search for perfection tend to be less happy. Where satisficers are happy because they've got something that works, and they can go on to something else, maximizers have lots of room for "fear, uncertainty, and doubt" about their choices. In some instances, actually reducing people's choices makes them happier. Python's "one good way to do it" makes everyone happy, because both maximizers and satisficers know that they're doing things right, and don't have room to worry. Another example that I know well from my involvement in the Tcl community is "object systems for Tcl". For those who don't know Tcl well, it's an extremely flexible, extensible language, both in the language itself and in terms of its C API. So flexible, in fact, that you can write an OO system in Tcl itself, which has been done, or in C, which has also been done several times, leading to a proliferation of OO systems, and a never-ending stream of questions on the newsgroup about which is the best one? Perl's "there's more than one way to do it", despite apparently providing and pushing choice, may actually work well because it encourages people to be satisficers and use whatever works. I'm sure everyone can think of examples where too much choice causes doubts and hesitation. I think the lesson to be learned is that while it's important to encourage experimentation in order to explore possible solutions to problems, at a certain point it makes sense to consolidate and provide one or two recommended ways of doing something. That's not always possible (Linux distributions, for instance), and squashing competing ideas too early might cause friction with people generating innovation, so it can be difficult to accomplish, but I believe it's an important social aspect of software creation to keep in mind.

17 February 2006

Michael Janssen: Debt "consolidation": scam, scum or sweet?

Throughout the last couple of years, I've had some bad decisions. I decided to start using my credit to work for me, and to buy things which I couldn't afford. Partly this was because I had a horrible ex, who I thought I should do things for, and partly because of just living outside of my means for a certain period of time. The long and short of it is, I've gotten myself into a bit of credit card debt. I'm not in any big trouble, just needing to pay it down so that I can get on with using that money for other things. There is a couple of web applications that I have in the works which will help me remind myself, but that's neither here nor there at this point. So, I have all of this credit at high interest rates, surely there is someone out there that will look at my credit and finance it at a lower rate, make some money off of me, right? I'm thinking that what I need is a consolidation loan - something to lump together my credit card debt and give me one monthly payment. What I call this, is debt consolidation. Thinking we are in the age of the internet, I type "debt consolidation" into google and give it a try. This is my first mistake. Apparently "debt consolidation" doesn't mean that you are consolidating your debt, it instead means that you are going into what I would call debt negotiation. This means you decide of your own volition that you are going to stop paying your bills, and try to negotiate with the credit card companies to pay off your debt at a fraction of your actual debt. But I don't know this, so I nievely fill out a couple of forms at "debt consolidation" sites. This gets pretty long, so I put in a break. Read on, MacDuff. The Scam The first people who got in contact with me were some people from Credit Solutions. Let me be clear on this: I'm not making broad generalizations about the company here - I can only speak of my own experiences. The person who I got on the phone went through a whole spiel, "explaining" how it works. He was very high-pressure and very fast talking, just from the start I didn't want to buy anything from him because he seemed like a used car salesman who decided that it was better to make money from nothing than from goods. Here's the explanation he gave me: You've probably been paying your cards down already, so you've paid 70-100% of the cost of your original loan. You stopped paying your cards, wait 3 months, and then they start negotiating with their "powerhouse lawyers". Then they negotiate you to pay your debt at 40-60% of the current balance, and the credit card companies get to take the remaining 40% as a tax loss. Now is when the math gets strange. The man on the phone attempted to say that this meant that the credit card company got 140% of the current balance. This doesn't make sense to me, especially because I'm a smart credit card consumer, and most of my debt is on 0% APR promotional rate cards. This means that they have made at most 3% of the balance from me, based on balance transfer fees. The man on the phone tried to dance around the issue, saying that they actually will get the 40% tax loss and that means they'll still get 140%. 140%? This doesn't make sense - 60% plus 40% is 100%, not 140%. Lets add to this that a tax loss is not the same as profit: a tax loss only gets you like, 30% of your loss. At this point, I've decided that I'm being taken for a ride already, but I ask how it works anyway. Here's how this particular company is setup: I pay into a savings account (of my own), automatically deposit around $200 a month, and they take money out. For the first three months, they take the WHOLE amount. After that, they take half the amount, and leave the other half. They then start negotiating with your creditors, and when they make a deal, they tell you "pay them now". In the end, they take 15% of the settled cost of your debt. On $6k settled debt, this is another $900. I really didn't want to do it now, mostly because of the high cost. The man kept coming back to my objections with "you can't borrow your way out of debt". Of course you can't borrow your way out of debt. That's stupid. I wasn't planning on borrowing money and then ending up with less debt. I was planning on borrowing money so that I'm not paying so much in order to have the debt. Apparently he thought I was an idiot, because he kept repeating it to me. He sent me a little packet of stuff, which laid out the whole plan. After that, he gave me a call back. This is when I got really defensive. I asked him point blank: "What is the worst thing that can happen to me if I go with this plan?" His answer: "You stop paying your bills." On the surface, this is true. The worst thing that can happen is that I stop paying my credit card bills. He neglected to mention the fact that ceasing payment on my credit cards would ruin my credit, cause insane fees for lateness, and possibly send me to forced arbitration with the creditors. Every creditor that I have ever had since 2002 has had an arbitration agreement, which basically would end up in garnishment of wages. The Scum About a week after my first bad experience with a debt "consolidation" company, I got a second call from a completely separate company. They introduced themselves on the phone as "Christian Financial Services" or some such. Basically the same deal, but this was a low-pressure sell instead of a high-pressure sell. He was much more reasonable, and talked me through the whole thing at my own pace, taking his time to lay everything out that I could understand it. It was basically the same deal, 15% and they negotiate for you, but they set up an escrow account instead of you doing it yourself. When I asked the same "worst situation" question, he gave me a realistic outlook, and this company is in a much better standing. If the creditors don't like their negotiation and take you to arbitration, you actually get representation from their company to help you out. I was almost willing to do it. Then I went and looked at their actual company online, and discovered that they are a chamelon of some sorts. They were originally called something similar to "USA Debt Consolidation" or something otherwise patriotic. Apparently they decided that God could be on their side, at least it's good advertising. What good company has to change their name to get religion on their side? A good company would not need to change it's name. The Sweet Some people have gone with these companies, and they have actually negotiated with the creditors in order to pay off your debt at a fraction of the price. If it happens, that's the sweet part of this. Just given an example of $10,000 credit card debt, it is possible to pay around $6,000 and have all of your debt paid off. It's basically saying that you can spend money that you won't have to pay back, ever. There is some hit to your credit rating in the short term, but in the long term, it starts going the other direction. The hard part is finding a company who will do this and who you like. I had an even harder hurdle to surmount - I don't really believe that it is ethical to do this. I spent the money, I should pay it back - that's the deal I made with the company when I signed up for the card. To me, I need to go through with paying them back. Luckily, I came into this with a decent credit rating, and will probably go out with a similarly decent one. Right now, I am a prime target for anyone who wants to give me a large loan at a decent rate - if I can pay less for the money I spent, I'm savvy enough to do it. The Alternative There is one other option which I looked into, and will represent the only company that I will link through this diatribe: Consumer Credit Counseling Services or Money Management International are truly non-profit and have good word-of-mouth from anyone I have talked to. They will not negotiate to settle your debt, but they will work with the creditors to get lower percentage, and help you through your budget. The couple of talks on the phone that I had with these people were very productive, and I got some stuff in the mail to help me out. You pay down the entirety of your debt. The downside is that you get a good size hit on your credit rating. My Choice In my position, I decided that I was on a good track myself already - I'm paying off my cards smartly, taking the highest APR out as quickly as possible. On my current plan, I will be completely debt-free in 3 years, less if I get some windfall of any sort. One of the bonuses of having a good credit rating is that people are willing to loan me money at promotional rates for some amounts of time. When my promos run out, I play financial musical chairs and get the lowest rate on all of my money. That's just for me though, to each his own. The most important part in all of this is that I got control of my budget, and started living within my means. My punishment for living outside of my means for so much time is that now I have to live well within my means. I have to live within the means set upon by having to pay a large chunk of each paycheck to the creditors. Once I'm outside this, it will be much easier for me to have lots of happiness and savings.

6 February 2006

Martin F. Krafft: Counting peas in Switzerland

Switzerland is bloody expensive, you surely don't want to be shopping here. For instance, I wanted to get myself the Lonely Planet Guide for Laos and Myanmar, both of which have had new editions released in 2005. Their price is a little more than 20 each, including the German VAT of 7%. If you buy the book in Switzerland, it's between 40 and 50 CHF (incl. 7.6% VAT), which is almost 10 more than the German price. Despite the fact that I cannot find the 2005 editions neither in Swiss stores nor on amazon.de, I'd be looking at a slight problem. Either, I can pay the higher price in Switzerland (in addition to shipping), or I can order with amazon.de (or the like) in Germany, who will subtract the VAT and ship it to Switzerland for free. Sounds great, huh? Well, it isn't really, because in Switzerland, receiving packages might mean you have to pay VAT, and not only that, they also make it unnecessarily complicated: If the goods you receive are valued less than 75 CHF, you do not have to pay VAT. However, if you do have to pay VAT, the VAT and a nominal service charge of 10 CHF count towards those 75 CHF, which means you effectively have to stay below (75 - 10 - VAT) CHF, which is 60 CHF or thereabout. Translate that to Euros, we're talking about 38 . Thus, if you want free shipping and no VAT, you have to place orders between 20 and 38 -- 20 is the minimum price to get free delivery if your order is not entirely made of books, in which case delivery would be free even below 20 . You do not want to place orders higher than 38 ever, because VAT in Switzerland is higher than the VAT for books in Germany, and the additional 10 CHF charge is not going to make up for it. So the only way for me to obtain the two books is either through the overpriced Swiss bookstores, or via two separate orders to amazon.de so as to not exceed the 38 limit. The maths gets more fun when you get away from books. For normal goods, VAT in Switzerland is still 7.6%, but 16% (and maybe soon 19%) in Germany. Thus, you will want to stay below 38 , unless the total value of the goods exceeds an amount where the cheaper 7.6% VAT + 10CHF service fee is lower than 16% VAT. This drives the limit up to 121 CHF, or about 77 . Now, if you think this is complicated, stay put. I am looking to buy myself the DrayTek Vigor 2900VG router, for which is around 265 in Germany including the 16% VAT, and 421 CHF including the 7.6% VAT in Switzerland. These prices square, but they're not including shipping, and if I would order the German product for delivery to Switzerland (which they are not willing to do, but anyway), I'd have to add the 10 CHF service charge and the 7.6% VAT. I also would not be able to claim the 16% VAT paid in Germany with EU customs because I am not a full resident of Switzerland. Man, no wonder taxes have had a long history of violence. Now I also received a 35% rebate offer from the Swiss distributor, driving the price down to 274 CHF, which is clearly a hell of a lot cheaper than the German product. So what am I waiting for? Well, Germany being an EU state and all, the German shop has to give you a 30 day return warranty and a 2 year product warranty. In Switzerland, you get no return warranty and only 1 year of product warranty. My dilemma thus becomes: are 30 days return warranty and an addition year of product warranty worth the difference of roughly 150 CHF? Seems like the answer must be "no". But I know that if I order it in Switzerland, it will break after 366 days, by the laws of Murphy. I have now asked the German distributor to match the 35% rebate. If they will, I'll order the device to my parents house in Germany. If they don't, I'll take it up with Mr. Murphy. PS: If you think the DrayTek Vigor 2900VG is not a good choice, speak up now!

5 February 2006

Erich Schubert: On window placement

John Williams, of GNOME fame, recently blogged on window placement as part of his "things about gnome that suck" series. Well, I basically agree with him - but he doesn't propose a solution. Devil's Pie isn't a solution, because it's not configurable by the average user. Or even by me, I failed to have it tell apart my terminal windows and use a sane placement for them. Just remembering the last window position doesn't work either - I'm annoyed by this "feature" by nautilus, for example. I tend to have a default position for my windows, by I occasionally have to move them away, and I do not want to have them reappear at this different position ever. My personal approach basically is to run all windows (except my terminals and popups such as IM windows) fullscreened, on dedicated desktops. Even the IM windows are usually on my "IM & Chat" desktop. This works really well, especially since I keep my terminal windows open all the time, and the default placement to minimize overlap works fairly well. Still I couldn't specify a general rule how any window manager could learn where to place my windows... so just complaining that Gnome doesn't do this good isn't all - we need to find a way to make this work just fine without the user noticing... I don't know about OSX - how does this work there? In windows it definitely is horrible. When you watch windows users, you'll often see them stating their Internet Explorer, then clicking on the maximize button. All the time.

1 February 2006

Jos Parrella: auto-eject-cdrom 0.3

Today my boss asked me for a method to clearly umount and afterwards eject a CDROM media on the event of trying to eject the tray using the drive button. I googled around a bit and found auto-eject-cdrom, in the public domain, and originally written by Jens Axboe, from SuSe, and Peter Willis, in 2001 and 2005 respectively. The problem with this little application is that it was unable to eject both my boss drive and mine. It did umount the filesystem but did not eject the tray. So I dig into the code and found that it used plain, old cdrom events, handled by the cdrom kernel module. The event was, in fact, defined in <linux/cdrom.h> as:
#define CDROMEJECT 0×5309 /* Ejects the cdrom media */ I found out that using system (”eject”); as my quick and dirty solution after the umount was working ok, but I was losing performance because eject is used for ejecting floppy disks, tapes and several other media. In fact, eject can figure out which media is he working with so he selects the proper method of ejecting, but I was bitten by the curiosity. So I implemented both the cdrom commands and the SCSI commands for ejecting the tray, in two functions, copypasted from the eject.c, previously apt-get source‘ed and I’m putting this interesting piece of code to the public domain (most likely it should go with a GPL license, since I used GPL’ed code on it) here: auto-eject-cdrom v0.3. A relevant and important piece of code goes now:
        /* Here I use two different methods for ejecting the CDROM. This is for fun only,
           since I could use system(\"eject\"); but this is the dirty hack. Here I use the only
           two CDROM-related eject functions from the eject.c file of the eject program
           by Jeff Tranter (tranter@pobox.com) - Note by Jose Parrella  */
Installing is just a matter of compiling and copying to /usr/local/sbin and running it as auto-eject-cdrom &. I hope it’s useful for those of you who can not afford to use one of the keys of your keyboard to assign the eject command to it. Enjoy!

30 January 2006

Antti-Juhani Kaijanaho: Counting lines

Insipired by Daniel Burrows’ tests, I decided to do mine. The object is to come up with a Haskell program that performs the job of wc -l as efficiently as possible. My test material is a randomly generated file with all lines less than 80 characters long. Summary: my final idiomatic version is twice as slow as wc -l, and my final nonidiomatic version is as fast as wc -l, or at least within the margin of error. First, the baseline:
$ time wc -l testfile
7798137 testfile
real    0m12.127s
user    0m0.765s
sys     0m0.399s
Then the most idiomatic program. Honestly, I expect it to suck performance-wise:
main = getContents >>= print . length . lines
And it does:
$ time ./wcl1.hs < testfile
7798137
real    1m14.993s
user    0m54.182s
sys     0m0.573s
But only by a factor of six. My first hypothesis is that garbage collection is the culprit. And, indeed:
$ time ./wcl1.hs +RTS -sstderr -RTS < testfile
./wcl1.hs +RTS -sstderr
7798137
25,236,174,340 bytes allocated in the heap
5,070,193,924 bytes copied during GC
117,484 bytes maximum residency (3750 sample(s))
96274 collections in generation 0 ( 26.36s)
3750 collections in generation 1 (  0.74s)
2 Mb total memory in use
INIT  time    0.00s  (  0.00s elapsed)
MUT   time   27.17s  ( 42.72s elapsed)
GC    time   27.10s  ( 33.72s elapsed)
EXIT  time    0.00s  (  0.00s elapsed)
Total time   54.27s  ( 76.44s elapsed)
%GC time      49.9%  (44.1% elapsed)
Alloc rate    928,824,966 bytes per MUT second
Productivity  50.1% of total user, 35.5% of total elapsed
real    1m16.616s
user    0m54.278s
sys     0m0.700s
As you can see, GC takes half of the processing time. Unfortunately, minimizing GC time does not have as big an effect as I hoped:
$ time ./wcl1.hs +RTS -H100M  -RTS  < testfile
7798137
real    1m1.354s
user    0m44.371s
sys     0m1.171s
Here, I’m effectively telling it to use a 100-megabyte heap. A separate GC profiling run tells me that GC time has dropped from 50 % to 1 %. The memory problem seems to be a red herring. What we’re doing here is creating four separately allocated memory cells for each character in the input. Of course, the cells are generated lazily, that is, a cell pair is allocated when the lines function demands another character; it then creates another cell pair to denote the same character in a list of lines. As soon as each line has been counted, the four cells become garbage. This sounds like a lot of work! But apparently it isn’t; I tried a few variations that did away with the stream of input altogether, not much unlike what Daniel did in his tests. Surprisingly, the performance worsened a lot. The lesson: functional programming language implementations, unlike typical imperative ones, are built on the assumption that you’ll be doing a lot of allocation. What I suspect is taking a lot of the time is arithmetic. Haskell’s Int is boxed, and lazy by default, adding a lot of overhead. I hand-fused length and line, yielding a tail-recursive countLines function, and I added the command-line switch -funbox-strict-fields, which enables a few significant optimizations of the laziness of Int. The results were nice:
ajk@kukkamaljakko:~/scratch$ cat wcl4.hs
module Main (main) where
main :: IO ()
main = getContents >>= print . countLines 0
countLines :: Int -> String -> Int
countLines n ('n':r) = countLines (n + 1) r
countLines n (_:r) = countLines n r
countLines n [] = n
ajk@kukkamaljakko:~/scratch$ ghc -O -Wall -funbox-strict-fields --make wcl4.hs -o wcl4
Chasing modules from: wcl4.hs
Compiling Main             ( wcl4.hs, wcl4.o )
Linking ...
ajk@kukkamaljakko:~/scratch$ time ./wcl4 < testfile
7798137
real    0m37.961s
user    0m29.853s
sys     0m0.495s
ajk@kukkamaljakko:~/scratch$ time ./wcl4 +RTS -H100M < testfile
7798137
real    0m25.153s
user    0m13.497s
sys     0m0.803s
ajk@kukkamaljakko:~/scratch$
With a large heap, the program is only twice as slow as the baseline. This is pretty good, considering that the code is still idiomatically functional. The following rather ugly, imperative program does away with the lazy stream and carefully avoids any laziness without doing any too dirty tricks:
ajk@kukkamaljakko:~/scratch$ cat wcl7.hs
module Main (main) where
import Data.Word
import Data.Array.IO
import IO (stdin)
count :: Int -> (Int, Int) -> IOUArray Int Word8 -> IO Int
count 0 _ _   False = undefined -- force ac evaluation
count ac (l,u) _   l > u = return ac
count ac (l,u) ar
    = do a < - readArray ar l
         let ac' = case a of 10 -> ac + 1
                             _  -> ac
         count ac’ (l+1, u) ar
maxn :: Int
maxn = 4096
main :: IO ()
main = do
  arr < - newArray (0,maxn) 0
  let loop :: Int -> IO Int
      loop acc = do n < - hGetArray stdin arr maxn
                    if n == 0
                       then return acc
                       else do acc' <- count acc (0,n) arr
                               loop acc'
  res <- loop 0
  print res
ajk@kukkamaljakko:~/scratch$ ghc -O  -Wall -funbox-strict-fields --make wcl7.hs -o wcl7
Chasing modules from: wcl7.hs
Compiling Main             ( wcl7.hs, wcl7.o )
Linking ...
ajk@kukkamaljakko:~/scratch$ time ./wcl7 < testfile
7798137
real    0m13.431s
user    0m10.342s
sys     0m0.467s
Of course, this program is not Haskell 98, but the nonstandard things it uses are fairly common. As can be seen, this version’s performance is, considering the margin of error, equal to the baseline. The compiler used in this test is The Glorious Glasgow Haskell Compilation System, version 6.4.1, as packaged in Debian sid.

Daniel Burrows: How much speed are you willing to give up for pretty code?

After experimenting a bit with Haskell and using it for some toy projects, I decided to see if there was any chance it could be used for a non-toy task; i.e., one where it might one day be necessary to actually have fast code. As a proxy for this, I decided to try a very simple task: counting the number of lines in a file. As input, I generated a file with a million lines of random data and an average of 40 bytes per line; all the Haskell programs were compiled with the current GHC in Debian unstable and with optimizations enabled.

The baseline is, of course, our friend "wc":

real    0m0.084s
user 0m0.043s
sys 0m0.040s


(this and all other timing data was taken after "cat /tmp/testwc.txt > /dev/null" to ensure that the file was cached) Now, it's probably too much to hope that a Haskell program will run as fast as a C program does, since the C program can run in a tight loop. But it seems reasonable that it should be possible for Haskell to be competitive with the trivial Python implementation of this program -- after all, Python is interpreted and Haskell is compiled.

import sys
n = 0
for line in sys.stdin:
n += 1
print n


Running this simple Python program under "time" produces the following statistics, a bit less than 10 times slower than the C version:

real    0m0.698s
user 0m0.643s
sys 0m0.050s


The trivial Haskell program to count the lines of its input is:

main = do c <- getContents ; print $ length $ lines c


Note that this is basically identical to the Python program, but expressed in a functional style. Pretty, but how does it stack up?

real    0m6.744s
user 0m6.426s
sys 0m0.213s


OW! Ten times slower than the Python code, and a good 80 times faster than "wc"! The gap can be lowered to "only" 50 times with the following program --

do c <- getContents; print $ length $ elemIndices '\n' c


-- but surely it's possible to do better. I'd expect that the expense here is in the use of lazy streams for IO; eliminating them gives us the following code:

wc :: Handle -> IO Int
wc h = do a <- mallocArray bufSize :: IO (Ptr Word8)
loop a 0
where loop a n = do amt <- hGetBuf h a bufSize
elts <- peekArray amt a
(if amt == 0
then return n
else loop a $! n + nlCount elts)


At this point, we're basically using Haskell as a (bad) imperative language. This function allocates a buffer, repeatedly reads into it, and counts the number of newlines in the buffer (I dropped some auxillary code to keep the post short). The $! is important; without it, even though this routine is tail-recursive, Haskell will still allocate an unbounded amount of memory to store the return value. (because, of course, it's terribly important to remember that you're actually returning "1+2+3", not "6")

So, how does this unreadable, hand-optimized version of the code perform?

real    0m1.980s
user 0m1.757s
sys 0m0.094s


That's right -- I've eliminated most uses of higher-level functional techniques, and the Haskell version is still two times slower than an ultra-high-level interpreted language, while also being uglier and harder to read! Ouch. It appears the old performance albatross of functional languages is not quite dead yet.

25 January 2006

Benjamin Mako Hill: For Everything A Name

I've recently been speaking quite a bit about people who are principled, and sometimes not so principled, about free software. Now, I'm not convinced that name calling has ever done any movement much good but I won't let that stop me when I want a few concise way to describe different groups of unprincipled, hypocritical, struggling, or just plain confused free software users -- at least not when it's all in good fun. I do not, as I've mentioned before, consider myself immune from either my criticism or my epithets. To appreciate either term, you merely must recognize that the term FLOSS is often used to mean Free, Libre and Open Source Software. The first great term is the brilliant neologism flip-flosser, a creation of Dafydd Harries. It is perfect for describing the on-again off-again free software user. My own addition is the more edgy flosstitute: an solid poke at anyone willing to sell out their principles and their movement for a little political good will or a slicker desktop.

22 January 2006

Eric Dorland: contrary to popular opinion, we do actually fix bugs

A recent post by Ingo Juergensmann lamenting m68k not making the cut in this round of architecture qualifications. While it is a shame I think, I don't think it's necessarily the end of the world and his complaint that developers will now stop fixing bugs is crazy. Just because they're suddenly not release critical doesn't mean (good) maintainers will be unwilling to fix them. Most architecture bugs are toolchain bugs (ie not the package maintainer's fault), general types of architecture bugs (eg endianess, int size) that affect more than one architecture and tend to get fixed quickly and easily and really freaking hard problems that most package maintainers don't have the skill to fix on their own (eg #343687, help!). But if someone submits a bug that's trivial to fix, or gives me a patch, that bug will get fixed. I don't like bugs in my packages and probably most other developers don't either.

20 January 2006

Eric Dorland: contrary to popular opinion, we do actually fix bugs

A recent post by Ingo Juergensmann lamenting m68k not making the cut in this round of architecture qualifications. While it is a shame I think, I don't think it's necessarily the end of the world and his complaint that developers will now stop fixing bugs is crazy. Just because they're suddenly not release critical doesn't mean (good) maintainers will be unwilling to fix them. Most architecture bugs are toolchain bugs (ie not the package maintainer's fault), general types of architecture bugs (eg endianess, int size) that affect more than one architecture and tend to get fixed quickly and easily and really freaking hard problems that most package maintainers don't have the skill to fix on their own (eg #343687, help!). But if someone submits a bug that's trivial to fix, or gives me a patch, that bug will get fixed. I don't like bugs in my packages and probably most other developers don't either.

19 January 2006

Meike Reichle: On laundromats

Not owning a washing machine of your own does funny things to you. When I moved here, I knew that being without one I would have to cycle to the laundromat every time, carrying a huge backpack, wash my stuff, cycle back home with the wet cloths and hang them in the drying room in the basement. Compared to the hassle that it would be to get a washing machine, and considering I am only going to live here for half a year this seemed sensible. There are however a few things I did not know/consider:

18 January 2006

Eric Warmenhoven: You can use a coupon!

For a while now I’ve been thinking that I’d like to get my private pilot’s license, so I’ve decided that once daylight saving time begins, I’ll start taking lessons. Does anyone have a recommendation for a good instructor? I’d prefer one based out of Reid-Hillview, since I live just off Capitol. Also, how long should it take, and how much should it cost? (I know those answers are dependent on how much flight time I need before I feel comfortable taking the exams, but I’m just looking for an average.) Lisa’s dad has his license so he was able to give me a bit of an idea, but he got his out of Hollister so I’m not sure if there’s a difference. Also, I’d like to get my IFR and probably also multi-engine; but I’ve heard some people say that it’s a good idea to wait a while after getting VFR before getting IFR. Is there any merit to that? Lisa and I are also getting serious about buying a new home, and this time we’ve even got a realtor helping us find houses that we might be interested in. It’s sort of off to a slow start, since the market is kind of slow right now anyway, but I’m hoping it will pick up soon. Also I don’t think we’ve adequately explained to the realtor quite what we’re looking for, and how little work we’re actually willing to do to the house. We’re hoping to move sometime this year, but I’m not sure whether that’s realistic. Fortunately we don’t have any urgent need, so we don’t have to settle for something; but I’d still like to get it over with as quickly as possible.

15 January 2006

Edd Dumbill: The Web as it was meant to be used

Since giving XTech 2006 the tagline "Building Web 2.0", I've received a few questions as to how wise this was. The Web 2.0 label has been accused in some quarters of being a vague, marketing-oriented, term. Perhaps an attempt to kickstart a new bubble. I was going to write further, defending my choice: that, practically speaking, Web 2.0 encapsulates a combination of technologies and practices driving the web forward. Yes, it's a label of convenience, but the implementation trends are real. The maturation of XML, a revival in browser technology, a willingness to share data openly and new web development frameworks. Just as I embarked on distilling these thoughts into a fuller form, Paul Graham published an excellent essay on Web 2.0. In it he analyses the Web 2.0 term:
Does "Web 2.0" mean anything? Till recently I thought it didn't, but the truth turns out to be more complicated. Originally, yes, it was meaningless. Now it seems to have acquired a meaning. And yet those who dislike the term are probably right, because if it means what I think it does, we don't need it.
So what's the reasoning that means we don't need the term? Graham writes: "Web 2.0 means using the web the way it's meant to be used." There's nothing fundamentally new, but there is a groundswell of understanding of what's been there all along. For me, that's a wonderful encapsulation of both current web trends and my aspirations for XTech. "Web 2.0" is a just a handy label for this. "The Web as it was meant to be used" will strike a chord with many web practitioners today--whether it's sensible use of web services with REST, improving user interaction in web design, or open semantics and data interchange. If you're involved in using the web as it's meant to be used, consider submitting an XTech proposal.

Edd Dumbill: The Web as it was meant to be used

Since giving XTech 2006 the tagline "Building Web 2.0", I've received a few questions as to how wise this was. The Web 2.0 label has been accused in some quarters of being a vague, marketing-oriented, term. Perhaps an attempt to kickstart a new bubble. I was going to write further, defending my choice: that, practically speaking, Web 2.0 encapsulates a combination of technologies and practices driving the web forward. Yes, it's a label of convenience, but the implementation trends are real. The maturation of XML, a revival in browser technology, a willingness to share data openly and new web development frameworks. Just as I embarked on distilling these thoughts into a fuller form, Paul Graham published an excellent essay on Web 2.0. In it he analyses the Web 2.0 term:
Does "Web 2.0" mean anything? Till recently I thought it didn't, but the truth turns out to be more complicated. Originally, yes, it was meaningless. Now it seems to have acquired a meaning. And yet those who dislike the term are probably right, because if it means what I think it does, we don't need it.
So what's the reasoning that means we don't need the term? Graham writes: "Web 2.0 means using the web the way it's meant to be used." There's nothing fundamentally new, but there is a groundswell of understanding of what's been there all along. For me, that's a wonderful encapsulation of both current web trends and my aspirations for XTech. "Web 2.0" is a just a handy label for this. "The Web as it was meant to be used" will strike a chord with many web practitioners today--whether it's sensible use of web services with REST, improving user interaction in web design, or open semantics and data interchange. If you're involved in using the web as it's meant to be used, consider submitting an XTech proposal.

Edd Dumbill: The Web as it was meant to be used

Since giving XTech 2006 the tagline "Building Web 2.0", I've received a few questions as to how wise this was. The Web 2.0 label has been accused in some quarters of being a vague, marketing-oriented, term. Perhaps an attempt to kickstart a new bubble. I was going to write further, defending my choice: that, practically speaking, Web 2.0 encapsulates a combination of technologies and practices driving the web forward. Yes, it's a label of convenience, but the implementation trends are real. The maturation of XML, a revival in browser technology, a willingness to share data openly and new web development frameworks. Just as I embarked on distilling these thoughts into a fuller form, Paul Graham published an excellent essay on Web 2.0. In it he analyses the Web 2.0 term:
Does "Web 2.0" mean anything? Till recently I thought it didn't, but the truth turns out to be more complicated. Originally, yes, it was meaningless. Now it seems to have acquired a meaning. And yet those who dislike the term are probably right, because if it means what I think it does, we don't need it.
So what's the reasoning that means we don't need the term? Graham writes: "Web 2.0 means using the web the way it's meant to be used." There's nothing fundamentally new, but there is a groundswell of understanding of what's been there all along. For me, that's a wonderful encapsulation of both current web trends and my aspirations for XTech. "Web 2.0" is a just a handy label for this. "The Web as it was meant to be used" will strike a chord with many web practitioners today--whether it's sensible use of web services with REST, improving user interaction in web design, or open semantics and data interchange. If you're involved in using the web as it's meant to be used, consider submitting an XTech proposal.

8 January 2006

Moray Allan

Some of the books I read in 2005:

Bruce Feiler, Walking the Bible: A Journey by Land Through the Five Books of Moses
Georges Perec, Species of Spaces and other pieces
Bob McCulloch, My Fare City: A Taxi Driver's Guide to Edinburgh
Origen, On First Principles (translated by G. W. Butterworth)
Sin-leqi-unninni, Gilgamesh: a new English version by Stephen Mitchell
Vladimir Nabokov, Pale Fire
Richard Fletcher, The Conversion of Europe: from paganism to Christianity 371–1386 AD
M. A. Screech, Laughter at the Foot of the Cross
Oliver Sacks, The Man Who Mistook His Wife for a Hat
Otto Friedrich, The Kingdom of Auschwitz
Nicholas Barton, The Lost Rivers of London: a study of their effects upon London and Londoners, and the effects of London and Londoners upon them
Anton Chekhov, The Steppe and Other Stories (translated by Ronald Hingley)
George Orwell, Down and Out in Paris and London
Otto F. A. Meinardus, Coptic Saints and Pilgrimages
Aleksandr Solzhenitsyn, One Day in the Life of Ivan Denisovich
R.W.B. Lewis, Dante: a life
Miles Glendinning and Aonghus MacKechnie, Scottish Architecture
Arturo P rez-Reverte, The Flanders Panel
John Chadwick, The Decipherment of Linear B (second edition)
Bart D. Ehrman, Lost Christianities: the battles for Scripture and the faiths we never knew
Plato, Timaeus and Critias (translated by Desmond Lee)
Albert Camus, The Outsider
Tim Wallace-Murphy and Marilyn Hopkins, Rosslyn: guardian of the secrets of the Holy Grail
Ginevra Lovatelli, Secret Rome
Dauvit Brown and Thomas Owen Clancy (editors), Spes Scotorum: Hope of Scots: Saint Columba, Iona and Scotland
Plato, Phaedrus and Letters VII and VIII (translated by Walter Hamilton)
William Chester Jordan, Europe in the High Middle Ages (The Penguin History of Europe)
J. M. Coetzee, Disgrace
Giovanni Boccaccio, Famous Women (translated by Virginia Brown)
Kazuo Ishiguro, An Artist of the Floating World
Georges Perec, A Void (translated by Gilbert Adair)
Saul Bellow, The Victim
Franz Kafka, The Trial
George Orwell, Nineteen Eighty-Four
J. K. Rowling, Harry Potter and the Half-Blood Prince
Francesco Colonna, Hypnerotomachia Poliphili: The Strife of Love in a Dream (translated by Joscelyn Godwin)
Italo Calvino, Our Ancestors (The Cloven Viscount; Baron in the Trees; The Non-Existent Knight) (translated by Archibald Colquhoun)
Eusebius, The History of the Church (translated by G. A. Williamson)
Flynt Leverett, Inheriting Syria: Bashar's trial by fire
Paul Auster, The New York Trilogy (City of Glass; Ghosts; The Locked Room)

Next.

Previous.