Log in

entries friends calendar profile Programming blog Previous Previous
Journal of Complexicism
Searching for car keys far from the streetlight
It's fun recording your predictions, so that you can have a laugh reading them in the future. I still remember the space conquest predictions of the 20th century culminating in the movie 2001 Space Odyssey.

Unfortunately, we still only have one space station in orbit and no colonies on the Moon, not to mention Mars or the moons of Jupiter. Hal, the on-board computer in 2001, despite tremendous progress in computing, is still beyond the reach of our technology.

At this point I should take a shot at Singularitarians, but it would be like dynamiting fish in the barrel.

The big thing that is lurking just around the corner are new display technologies. Remember the CRT's? I still have one or two in my basement. Some of the technologies that came later are already on the way out--rear-projection TVs and plasma displays. But there are new kids on the block that will compete against the currently dominating LCDs.

OLED, or Organic Light-Emitting Diode. It works similar to LCD, except that the semiconductive organic polymer emits light (as opposed to transmitting light) when voltage is applied to it. That means there's no need for back-lighting. OLED consumes less energy and produces higher contrast image than the LCD. If it can become competitive in price, it will definitely replace the LCD. I've seen a demo of an 11'' OLED TV in the Sony store (U-Village in Seattle) and I'm impressed.

E-Ink, or electronic ink display. The amazing property of the e-ink display is that it looks like paper. It doesn't emit or transmit light--it reflects it. So, unlike other types of displays, it's hard to read in the dark but easy to read in full sun. E-ink consumes very little power and only when the image changes. The image persists evan if you switch off the power.

I played with the Amazon Kindle, which has e-ink display (my "$100" laptop hasn't arrived yet). It's a developing technology, so in some aspects it's still a bit clunky. It's black and white and it takes more than a second to rewrite the screen (and you can see a blink between images). But other than that it's pretty amazing. I love working outdoors, and no other display stands up to the sun's rays.

I don't think e-ink will replace other display technologies, because there will always be a need for light-emitting displays. But for laptops (and electronic books, like the Kindle) it's the best.

Speaking of the Kindle, it still looks and works like a prototype, but its future incarnations will revolutionize the way we interact with (formerly) printed matter. Two technologies contributed to this breakthrough: e-ink display and high-bandwidth internet access.

The Kindle accesses the internet not through Wi-Fi, which is limited to hot spots, but by the cellular phone network, which has much wider coverage. And, incredibly, lifetime internet access is included in the price of the Kindle! Not that, with limited display capabilities, you'll be able to have a full internet-browsing experience on a Kindle. Net access is still mostly limited to downloading purchased books. But you can glimpse what the future has the store.

Maybe not in 2008, but soon enough, I imagine myself owning a laptop with wide-band, always on, cellular internet access; and a fast, color, e-ink display. I can't wait!

Glossary for future readers:

CRT stands for cathode-ray tube. It's a large bulbous vacuum glass jar. It has a little electric heater in the back that emits free electrons that are accelerated by high-voltage electric field towards the front of the tube, which is coated with phosphorescent chemical--a substance that glows when bombarded by electrons.

Rear Projection TV has a projector on a chip in the back, and the image is projected using lenses and mirrors on the semi-transparent screen in the front. The projector on a chip is a clever combination of electronics and micromechanics. It is covered by an array of miniature mirrors--one mirror per pixel--which are toggled by electric fields.

Plasma Display is essentially an array of miniature fluorescent bulbs.

LCD stands for Liquid Cristal Display. Special semi-crystalline liquid is poured between two sheets of glass covered with semi-transparent electrodes. When electric potential is applied to one vertical and one horizontal electrode, liquid crystal becomes transparent at the crossing of the two. A fluorescent bulb is used to back-lit the display and it shines through the transparent openings in the liquid crystal.
Leave a comment
I finally had some time to rewrite a little Java applet that I wrote some time ago when computers were slower. You can see it here. The original version was just throwing animation frames as fast as possible, which was slow enough back then. However, on modern computer, it become just one big blur.

So I downloaded Eclipse and started working. Eclipse is pretty good considering that it's free. The amazing thing about Java is that it's so easily parseable. Eclipse runs a parser in the background, while you're editing, so you see your errors almost in real time. It's also easy to do various kinds of bulk code modifications and refactoring. This will never happen with C++. I hope, however, that such things will be possible with D.

Another funny thing is that threads are not as alien to Java as they are to C++. My little applet now uses a thread to drive frame refreshing.

Debugging is also easy in Eclipse. My main problem was in gluing the applet to an HTML page. Java runtime just couldn't find the class files. It turned out that I mistakenly created a "package" and that screwed up the naming of classes. Oh, well. Shows you how little Java I know.

I wrote this applet after reading one of the Feynman lectures on physics. There is this incredible relativistic effect that blows your mind when you understand what's going on. Unfortunately, when you just look at the equations, all you see is that they are pretty complicated. Feynman had the unique ability to see through equations. Plus, he was able to communicate what he saw in relatively simple terms.

Nowadays, thanks to computers, we have powerful visualization techniques. I decided to use them to expose the weird reality behind the equations, the reality Feynman was able to see with his "naked brain."

The effect is all encoded in Maxwell's equations. It so happens that even though Maxwell couldn't have anticipated general relativity, his equations have. In fact, the first glimpse of relativity was the discovery of Lorenz transformation as a symmetry group of Maxwell's equations. Lorenz himself didn't fully understand the deeper meaning of his equations, because they were telling something really weird about space and time. It was Einstein who decoded them and came up with his theory of relativity.

So here's the setup--a charged particle generates an electric field. When the particle moves, the field moves with it. When the particle accelerates, the field ripples--electromagnetic waves are generated. Shake the particle hard enough and it will emit light, which is a particular kind of electromagnetic radiation. As I said, all this is encoded in Maxwell's equations. They are just not so easy to solve. For the case of a charged particle, the equations were solved by Lienard and Wiechert (the Lienard-Wiechert potential).

So if you want to see what kind of field is generated by a charged particle moving along an arbitrary trajectory, you just plug the trajectory into the L-W potential and get the result. With a computer, we can calculate the field numerically at any point and moment of time.

That's what I did in my applet. I simulated a charged particle moving along a straight line, back and forth; with a period of uniform movement in the middle, and two bouts of deceleration near the ends. I calculated the electric field generated by this particle at one point in space, at regular time intervals. The result is an animation, which shows how the vector of the electric field tracks the position of the particle, gives the insight into what's happening--something that Feynman described in words only. The mind-blowing part is that the field at the observer's location anticipates the position of the particle as well as the available information permits. Notice that the information cannot travel faster than light, so the observer can only use obsolete information. Based on this information he can calculate where the particle should be "right now." And that's the direction the field vector is pointing at!
Leave a comment
So far I have audited two Computer Science grad courses at the UW. The first one was about Distributed Systems. It turned out to be very useful in my work at Reliable Software, since we have implemented a distributed peer-to-peer version control system.

I was able to position our system among other distributed systems. I saw how other people solved similar problems in various context, and how unique our solution was. Essentially, one could try to build a distributed VCS on top of a distributed database, and it would work, but progress would be hard to make, since distributed transactions could wait for a very long time until they fully commit or abort. We have to be able to make progress based on transactions that haven't committed yet. Very interesting problem, as it turns out. And our solution seems to be very close to optimal.

The second course was completely different. The title, Concepts of Programming Languages , sounds deceptively vague, but it was hard-core CS. One of the side effects of the course was that I learned functional programming in OCaml. There is something very elegant and, at the same time, very unnatural about functional programming. No matter what some people say, recursive thinking is not built into our reptilian brains. You can learn it and even get used to it, but it doesn't just flow naturally from your brain.

But functional programming is not only about recursion. It's also about using functions as first-class objects. Constructing them on the fly, passing them back and forth, storing them in containers, etc.

This course turned out to be very useful in my work on D. I started implementing a thread library in D. The cool thing about the D programming language is that it makes generic programming easy. I would not have been able to implement such a library in C++.

For instance, how do you create a thread? Thread creation has to be parametrized by a thread function--each thread must execute its own function. When the function returns, the thread dies. But the realm of all possible functions is huge! Functions are parametrized by the set of arguments they take and by the return value (possibly void). And you are supposed to write a generic function, newThread, to which you can pass any thread function and the values with which it should be called.

Imagine a C++ implementation. You'd have to write separate templates for newThread0 (thread function taking zero arguments), newThread1, newThread2, and so on, up to some magic maximum number of arguments. Then you would have to parametrize these function by passing the return type of the function. Finally, you'd want it to work not only with function pointers, but also with functors (objects that have operator() defined). It's a monumental task.

In D it took me a few hours to write one generic function, newThread, that works with an arbitrary thread function, functor, delegate, or closure. Ta dah! Here it is:
ThreadHandle newThread (F, A...) (F f, A a)
    alias ReturnType!(F) RetType;
    alias Thunk!(F, A) ThreadThunk;

    auto thunk = new ThreadThunk;
    thunk.Init (f, a);

    uint tid;
    auto h = _beginthreadex (
        null, // security attribute
        0, // stack size (default)
        &ThreadFunction !(ThreadThunk),
        & tid);

    if (IsNull (h))
        throw new Errno ("Thread creation failed");

    auto handle = ThreadHandle (h, tid);
    return handle;

Here F is the type of the function (or function-like object), and A... is the (possibly empty) list of parameter types. Not only is this code simple, but it's very easy to use. Here's how you can call it:
    // execute a closure returning void
    int shared;
    void fvoid ()
       shared = 13;
    auto h = newThread (&fvoid);
    h.WaitForDeath ();
    assert (shared == 13);

In this case the thread runs a closure that takes zero arguments and returns nothing. You can tell it's a closure, because it grabs the caller's environment with it, in this case the variable "shared". Once the function is executed in a separate thread, this variable has a new value. Doesn't it just blow your mind?

And I'm still not totally happy with the language. There are some rough corners in the definition of Thunk.
struct Thunk (F, A...)
    F _f;
    A _a;
    static if (is (ReturnType!(F): void))
        void Exec () { _f (_a); }
        ReturnType!(F) _r;
        void Exec () { _r = _f (_a); }
        ReturnType!(F) Result () { return _r; }

    // Revisit: turn into constructor
    void Init (F f, A a)
        _f = f;
        //_a = a;
        foreach (i, T; A)
            _a [i] = a [i];

static extern (Windows) uint ThreadFunction (ThunkType) (void * p)
    auto thunk = cast(ThunkType *) p;
    thunk.Exec ();
    return 0;

I don't like the "static if" (compile-time if). Here it is used to special-case the void return type. I have already submitted the proposal that would eliminate the special case and treat void just like any other type (and it was already accepted in our meeting last night). The Init function is used in place of a constructor, since structs in D don't yet have constructors or destructors (coming up soon, though). Consequently, I couldn't implement reference counting for thread handles, but that is also coming soon in D (I could have used classes rather than structs, since they are garbage collected, but for thread handles you really need better deallocation control).

I'm having a lot of fun with D!


Leave a comment
I never thought I would be pining for Microsoft software, but that's because I underestimate the inaptness of other software companies.

Case in point: Comcast in our area was using Microsoft software as the UI for their cable boxes and DVRs. Suddenly, with total disregard for the consumer, they switched to the LAMEST piece of software ever made for TV, GuideWorks, which they wrote jointly with Gemstar TV Guide International.

I really tried using it, blaming my old habits for not getting along with it, but it's not me--it's them! Every amateur thinks that designing user interface is a piece of cake. It's not! The difference is between a usable and unusable system. GuideWorks is unusable.

To begin with, I'm going to ask Comcast to replace my current DVR box with the standard cable box. DVR programming became practically impossible, so I'm not sacrificing much. I'm also thinking of getting a cheaper channel lineup.

Current Mood: angry angry

1 comment or Leave a comment
Could you believe that?! I am cited in conservapedia, the religious right's response to wikipedia! See for yourself. I am born again! Hallelujah!

So how am I helping the defenders of intelligent design? I wrote this article in which I explained that, in view of modern science, in particular Einstein's general relativity, it is possible to describe the universe from the geocentric point of view. It would require the change of the coordinate system to the non-inertial frame that moves with the Earth. Of course, such a description would be immensely complicated and impractical, but the principle is correct. Of course, from this statement there is only one tiny step to the claim that "Heliocentric and geocentric theories are both used today, depending on which allows more convenient calculations." Frankly, I had no idea anybody still used epicycles to calculate the movement of planets, but what do I know about science curricula at religious universities.

There is a tiny problem though: Conservapedia is not very fond of the relativity theory either. Here's en interesting excerpt:
There is a correlation between enthusiasm for the theory of relativity and political views, and there is an unmistakable effort to censor or ostracize criticism of relativity. Physicist Robert Dicke of Princeton University was a prominent critic of the theory of relativity and that may have hurt him professionally, even though his theory "has enjoyed a renaissance in connection with theories of higher dimensional space-time." Despite being one of the most accomplished physicists in the 20th century, Dicke was never awarded a Nobel Prize just as other outspoken critics of scientific theories were passed over in granting the Nobel Prize to less-accompished colleagues.

Darn it! I had no idea that any time you criticize a scientific theory, you face terrible persecution (burning at a stake, being passed over by the Nobel committee?). Einstein was lucky--he destroyed the well established theory of ether and still got away with a Nobel price.
2 comments or Leave a comment
Things are not as bad as I though. Yesterday I attended a seminar at the UW about the state of the war between the "cease and desist" people and the rest of us. We are winning the war!

As far as copying music, the industry has pretty much given up the futile efforts at copy protection. After EMI decided to start selling unprotected soundtracks, the rest will follow in short order.

The low definition DVDs use a brain-dead protection scheme, CSS (Content Scrambling System), that has been broken long time ago--witness DeCSS. CSS contained in its design the possibility of revoking broken cryptographic keys, but the industry never used it, so all past and present DVDs are easily copyable.

The new breed, HD-DVD and BlueRay, both use a new system, AACS (Advanced Access Control System). This is actually pretty strong system, with strong encryption and the ability to revoke broken keys at will. So it was a bit of a surprise to find out how quickly it has been broken by dedicated hackers. The cryptographic key was extracted from WinDVD in a very clever way. This key is now available on the Internet, on T-shirts, coffee mugs, etc. All the "cease and desist" notices mady it only more popular. With this key, you can decrypt (and copy) all HD-DVDs and BlueRay DVDs that have been published so far.

However, this key is now being revoked. This doesn't change the ability to decrypt existing DVDs, but all new DVDs will now contain the revocation of the broken key, so they won't be copyable. At least that was the idea. The revocation of the key takes 90 days, and for the last three months there have been no new releases of high-def media. The new wave will be released next Tuesday.

Now guess what. A DVD from a new batch was somehow leaked prematurely. To everybody's surprise, a software player called AnyDVD from SlySoft can play the new disks. Either they have broken more keys, or they found a way to circumvent the system.

Why is it so important to break the DVD encryption system? After all, people who have the means to play high def DVDs have already invested thousands in their hardware, so they can afford to buy DVDs. Except that there is one more annoying copy-protection mechanism, HDCP, the one between your computer or player and your monitor. If your expensive hi-def monitor doesn't have HDCP input, you're out of luck. Your legally bought player will not play your legally purchased HD-DVDs on your legally acquired plasma display! Caveat Emptor!

Fortunately, HDCP system has been long broken, and anyway it's not required if you use a player like AnyDVD. So even if you plan on purchasing all your HD-DVDs or BlueRays, you still might need an illegal player. They are just asking you to circumvent their system.

Anyway, this is not the biggest headache of the DVD industry. In fact, from the business point of view, they would be better off dropping copy protection (including the annoying region codes, and blocked user operations). The biggest problem is the format war between HD-DVD and BlueRay.

The prediction is that both systems will die and a new system will be adopted that has no DRM.
2 comments or Leave a comment
I've been using Jasc Paint Shop Pro for ages. Unfortunately they were bought by Corel and the Corel marketing scum started working on it. They added the InstallShield update manager, an obnoxious piece of software that works like a Trojan horse. It regularly pops up a window telling me that there is a new version of Paint Shop Pro which I should buy for 55% less.

I would gladly buy it, if it weren't for the Corel's way of pushing it. The message pops up regularly and there is no obvious way of turning it off. There is a tiny help link, which tells me that I should click on some non-existing button or link called "Settings". I've found a Corel bulletin board post that addresses this problem (so the bastards are aware of it!). It tells me that I have to download the uninstaller from InstallShield web site.

Corel is officially the Enemy of the User!


3 comments or Leave a comment
I'm in the middle of big changes in my life.

For one, I bought an iMac--yes, I caved in. I'm a sucker for shiny toys. It's a beautiful machine.

I'm also reading about QT, learning D, and working on a book about Windows programming in D.

And, before I forget, I'm now a non-matriculated grad student of CS at UW.
I'm one of these "early adopter" types, at least as far as Microsoft operating systems go. I even installed a beta of Vista on one of my computers. But this time I'm going to stop at that. I think it's time for a consumer revolt. Read a very thorough analysis of Vista DRM (digital rights management) system by Peter Gutman from the CS department of the University of Auckland and cry. The short story is that Microsoft has joined forces with digital content providers in screwing up customers. I don't think computer pirates will have any problem bypassing Vista DRM--it's the honest consumer who will be paying for the idiotic system. Don't expect HD DVD's to be playing on your Vista computer withing the next few years.

For now I'm going to stay with Windows XP and probably diversify towards Linux, which I shunned for the longest time. Since I'll be buying new computers, I will demand no pre-installed Vista.

I wonder why it had to be somebody from New Zealand to write such a paper. Are our domestic academicians too scared of the Digital Millennium act to criticize any DRM system, even the most harebrained one?
5 comments or Leave a comment
I am stupid! There's no doubt about it. I am the leader of the microcephalic. I am the top moron, the emperor of dumbness. In other words I used Microsoft media player.

I mean, it kind of did its job--it played my CDs and DVDs. But that wasn't enough for me! When the media player announced that there was an upgrade ready to be installed, I jumped on it like a three-legged wardrobe. Slick new UI, oh my, I can't resist it!

And then, ha ha, I wanted to play a DVD. A DVD for which I paid actual money (stupid me!). It turned out that, unbeknownst to me, the new media player installed DRM (Digital Rights Management). Mind you, I am not a pirate, I haven't even ripped my DVD. I bought it, I put it in my DVD drive, and I wanted to play it. I shouldn't care whether DRM was installed on my computer or not, right? Right?!

Guess what, the new media player refused to play my DVD. It hijacked my computer and demanded a ransom. I am not kidding you! It told me that if I want to play my precious Fellowship of the Ring I had to pay twenty bucks. Did I mention that I'm not kidding you? Microsoft decreed that, if I wanted to watch my DVDs, I had to buy a third party decoder. It even informed me, in case I was a cheap bastard, that there are NO FREE DECODERS!

I hear there is this other operating system, Linux or some such, that DOESN'T HIJACK YOUR COMPUTER AND THEN ASK FOR RANSOM! I think I'm gonna give it a try.


5 comments or Leave a comment