Wednesday, February 20, 2008

factoring the time

$ watch -n 60 factor \`date +%H%M\`

http://xkcd.com/247/

Wednesday, February 13, 2008

lambda * delta = crap

I was wandering aimlessly through the murky waters of the interwebs having forgotten my surfboard at home. After hours and hours of swimming around in the dark I stumbled upon this dude. From what I understood by skimming through the website, the guy is doing artsy spirity things using electromagnetism instead of classical stuff. Kind of cool because very few people do art and electronics and programming. So his scrying boards are programmable in Scheme which is supposed to be (his words): novel, highly expressive, dynamic, introspective, elegant, extensible, a {lightweight, mobile, active} means of describing worlds and processes, thus perfect for such stuff as scry-programming. Wow. So if you followed the Wikipedia link you might have seen that ugly lambda starring at you. After a quick skim through the article, I most sincerely can't find the elegance, expressiveness, beauty, simplicity or whatever this language is supposed to have. Before going to Wikipedia I first looked here, where else but the famous MIT. There's that damned lambda again. Why do people have to hail lambda calculus and build virtual statues and monuments to lambda calculus and kiss it in the ass like it's somekind of hyper-meta-rational godly piece of abstract shit? So I go to the big famous MIT and what do I see? A crappy black and white logo that's the most noisy logo I've seen in the last 6 months. (shiver!) Why can't people antialias their pictures? Is it so hard? Or is 1-pixel wide monochrome the new fad? There are tons of image editing packages out there that can do a proper picture resize, and many of them are free. But people still put out bad graphics because a)they're lazy or b)they don't care for proper sampling and quantization. Well of course they don't, they care for lambdity (lambdaness? lambdacity?). I took a quick look over the Scheme doxumentation on the MIT site and damn, I really can't call it simple, expressive, elegant, let alone introspective. But of course I can't argue about it not being statically scoped and properly tail-recursive, as its homepage states. So let's take the first decent example of Scheme code (is it called "code"? maybe it has some esoteric, intellectually pretentious name? am I perpetrating a terrible insult by calling it code and not self-referencing internally-reflexive external character-stringy description or something?) - so let's take this piece of code that's found on both Wikipedia and the MIT doxumentation and just post it here:
;;; The FACT procedure computes the factorial
;;; of a non-negative integer.
(define fact
(lambda (n)
(if (= n 0)
1 ;Base case: return 1
(* n (fact (- n 1))))))

Man, now that's introspective!
The same code written in a proven, widely used, respectable, expressive language like C would sound a little bit like this:

/* If you do not know what a factorial is
you should search it on Wikipedia or Google. */
int fact (int n)
{
assert(n >= 0); //jackass!
return n > 1 ? n * fact(n-1) : 1;
}
Much cleaner eh? Compare that to 1-2-3-4-5-SIX parenthesis. And their code screws up bigtime for negative numbers assuming n is a signed integer (I don't know, I hate lambda-anything, I suck), while mine doesn't. (Who would want to be using unsigned numbers by default anyway??) Mine also warns the careless programmer who feeds negative numbers to the factorial function. So not only is their canonical "hello world plus a little bit more" example ugly, it's also an infinite loop if my perfectly reasonable assumption of n being allowed to be negative as well as positive holds. Well, it might not be infinite because the hardware might not let it, but that's fucking bad practice. And after 5 more minutes of searching it seems that my assumption indeed holds, because according to the MIT documentation (- 3 4) gives -1. After another 5 minutes I opened up a GIMP script console and entered the code, then called the function with -1. It froze.

This more complicated example does the same shit but without (rather idiotically) wasting stack space with recursive function calls:
(define (fact n)
(define (fact2 n m)
(if (= n 0)
m
(fact2 (- n 1) (* m n))))
(fact2 n 1))
Of course it has a pretentious name called proper tail-recursivity and Scheme is such a great, wonderful, revolutionary, INTROSPECTIVE =)) language for supporting it.
Here's the same shit in C, which also does not choke on negatives, unlike the code above.
int fact (int n)
{
int f;
for (f = 1; n > 1; f *= n--);
return f;
}
Fuck lambda calculus and fuck computational linguistics.

Saturday, January 26, 2008

darkness

God damn it, they've made black paint. Finally. But it's still not black enough.

Monday, January 14, 2008

computational linguistics

I have a course on something that I guess resembles computational linguistics, for which I have to take an exam in 2 hours.
So what is text mining and data mining useful for? Building "a more intelligent Google" of course.
And what about an example of a malformed sentence? "The green, colourless ideas are sleeping furiously."

My New Hobby:
Confusing text mining web bots with ambiguous sentences.

"Would fine times be forever flawlessly falling through the fallacies of faceless fires!"

"John, come here!" "What now?" "I think the text bot got high on semantic tree cycles again!"

Tuesday, January 1, 2008

happiness

I just realized upon opening the blog dashboard that the previous post had been the 100th.
Well, I was under the impression that this includes updates to previous posts to fix typos and shit, but no. It does however include one or two drafts whose content I'm not very sure about yet. So whatever, let's celebrate the new year with post number 101. Or number 100 if you think the new millenium came in 2000, which it did not.* By the way, there's a bank called "Millenium" here whose offices look more like beauty salons or something (which is not necessarily a bad thing, it's actually rather original). They kind of built "Europe's tallest Christmas tree" here in Bucharest. Well, it's not actually a tree, it's more like a regular steel structure that vaguely looks like a tree, and I find it very ugly, distasteful and ... well... not too tall actually. Nevertheless, when they lit it up for the first time on December 1st (which is also the National Day), 'bout 100 kilopeople rushed to see the kitsch. 'bout 50 kids got lost, people stepped on each other, it was mayhem, hell, chaos, whatever you like to call it. The square and its incident streets were flooded with people, traffic ground to a standstill, busses carrying people couldn't move anywhere, and of course people started ranting about busses being severely overcrowded and arriving way too late. So basically the whole city was fucked. "The tallest Xmas tree in Europe" they say. Some even doubt that assertion, but I couldn't care less actually: it's ugly, it's pointless and it's small. So big wow.
So happy new year, happy 100 posts and whatever.
If happiness were a piece of shit, would it smell like fresh forest soil?
---
*) You'd also number this post 100 if you were a reasonable computerist who liked their addresses to start with 0, but in this case you'd be celebrating the "binary millenium" in 2048.

Saturday, December 22, 2007

black magic

If you measure an optocoupler's output while driving its input directly from a 9-volt battery, you get a 2-leg transistor.



laugh! ha ha ha!*



You can still use it as a temperature sensor or maybe even as a radiation sensor.

"Merry fucking Christmas!"**

---
*) I HATE those movies where they insert laughter in the background whenever some idiotic underpaid actor recites some funny line. It's an insult to my sense of humor. Is it like, am I too stupid to figure out for myself when to laugh and when to go take a shit? Good comedies never insert that stupid laughter. Only mediocre ones that target mediocre people need to.
**) a famous quote by Mr. Garrison.

Thursday, December 20, 2007

environment2

As I said before in posts such as this, fuck environmental fanatism. People are part of the environment, they're part of nature, they're not above it. They can't objectively protect it or destroy it, they evolve with it, they go with it, they live and die within it. All toxic materials created by human industry come from the Earth (where the hell can they come from, outer space?), so they're part of the environment. Everything on this planet is part of the environment: stones, critters, humans and all the tools and crap and toxins they produce. We're not hurting the environment with anything, but we might be putting ourselves in a position of being evolved out of it a as species, I mean killed and re-integrated into it as dead molecules. Species go extinct all the time and that's a natural thing. So quit worrying about stupid panda bears that don't like to reproduce and small furry mice whose 20-head population count doesn't really influence anything, and start worrying about yourselves. This guy says it perfectly and I totally agree with him, with absolutely every word and sentence. And he's funny too.