insertion sort in clojure
Here is my first cut, non-lazy implementation of insertion sort.
insertion sort in clojure
Here is my first cut, non-lazy implementation of insertion sort.
The so called “social networking” websites seem to be the new craze (or is it already too old?). I used to have an account in facebook and orkut for more than 2 years and it was mainly used to connect back to classmates and the likes. But it turned out to be a distraction, atleast for a while. One just connects to a friend and almost never talks to him or her again thru these websites. Instead we post what we ate for breakfast, what new year resolutions we took etc etc - those phrases which carry zero information. And some people use it to show off their new materialistic possessions like their new Honda Cities and their newly built houses and their latest trip across atlantic etc.One can easily sink an hour a day browsing from a link to another without leaving facebook.com.
In the end, I decided that my time is more precious and enough is enough. So I am facebook/orkut free from today. Facebook incidentally only de-activates the account.
I didn’t tell my friends in facebook or orkut that I am leaving. But I guess in the true spirit of social networking, they don’t care, so it doesn’t matter.
Tale of autocomplete
To give a short summary for those like me, what really happens is that the JS script running on your browser (which gets downloaded from the webpage/site you are viewing) issues various HTTP requests to the server “asynchronously” while you are plugging in some values into a form. There is a standard way of issueing this request - XMLHttpRequest. Once we get the data, we can modify the structure of the HTML Page. I was sort of lying. HTML page is not modified. The HTML page is read by the browser, parsed and arranged as a Tree structure and is made accessible to the JS Script. This structure is called DOM - Document Object Model. Think of DOM as a parsed HTML page re-arranged as a Tree, because HTML Document is indeed a heirarchical data structure and can be represented as a tree. The attributes of any HTML tag is now an attribute of a node in the tree and is accessible to the JS. JS script can now add/delete/change any node or its properties in the tree. When a change in DOM is made, it reflects immediately in the rendered page and one need not do a “refresh”.
This is the essense of what happens in the so called “Web 2.0” style websites. Unfortunately, web has too many jargons which creates an impression that it is highly complex. It is complex but with a bit of effort, it is not difficult to understand.
I found the IBM DeveloperWorks series on AJAX very useful in understanding the above concepts.
cell phone battery charger
I misplaced my cell phone charger about 2 months ago and ever since, had been charging my cell phone with the micro USB cable connected to the laptop. So far, I have managed to charge the phone before it completely exhausted the power. Until yesterday. I thought it is just a matter of plugging in, the cable into the phone and connect the other end of the cable to the computer. The phone did start charging. But at some point, it got enough power to bootup and decided to automatically bootup. Once booted up, it shows up as a USB Mass Storage device. But before it enumerates, the phone powers off again. The issue is that, before enumeration, the host controller gives out only 100 mA of current. It can give out 500 mA, only after enumeration. The current was just not enough to keep it going and it kept on booting up and powering down again and again.
Finally I found a way to break the dead lock by rebooting the computer and stop the boot at GRUB prompt. Turned out that the BIOS configured the USB Host Controller to give out 500 mA and it quickly charged up, enough to enumerate, so that I could turn on the computer again.
debian and other off-work projects
I met another debian package maintainer today for gpg key signing and general chat. I understood how horribly outdated I am, with the happenings in the debian world though I still manage to read some of the debian emails. It provided enough motivation for me to work on some of my packages.But that would mean taking time off from my Lisp study.
I have not been able to keep up with SICP videos though I managed to see (multiple times) up to 4b. I need to catch up with the book though. Currently I am working through Seibel’s Programming Common Lisp. I have also set my eyes on Clojure and had been going through its features. I also worked some small programs with it and found it to be incredibly powerful. It has immutable data structures which is better suited for creating pure functional programs, unlike CL where data is mutable.
I have zero Java knowledge though and often find myself struggling to use java classes from clojure.
coders at workPeter Seibel
The book is a collection of conversations with some very well known figures in the computing world. These people have done significant contributions to the body of knowledge and are “inventors/practitioners” of Unix/C, Lisp, Java, Erlang, TeX etc.
Peter has done a great contribution to the computing world by bring out this book (not to mention his other great book “Practical Common Lisp”). The subjects seem to have been very carefully chosen and are experts in their respective fields. But did I miss anyone? Yes, Richard Stallman. He has done some really great deal of programming, all by himself. Nevertheless, this book is a great contribution into the field of Computing folklore and biographies and is very very inspirational. Hats off to Peter for painstakingly undertaking this massive activity of researching the backgrounds and also for researching various topics. It is not easy to talk to these great people in the same language.
The questions are spontaneous and encourages the people to open up the story gradually. Mix of context specific ones and generic ones. Peter also seem to have been careful about not getting into a duel on various usual flamewars. For instance, Peter never asked the question “Vi or Emacs?”.
These are some of the questions, Peter seem to have asked everyone.
It is also amazing to see that these folks are still tinkering with the machine and programming, pretty much every day. In contrast, my job is trying to keep me away fron hands on programming. I am instead trying to work with what others have done and bending it to work with other things and in the process, not writing much code at all.
The discussions are very casual and not formal. It will be very interesting to hear the audio recordings of these conversations, which will obviously have much more interesting anecdotes and stories which Peter couldn’t have been able to incorporate into the book. Most subjects are older programmers. There are few younger ones.
Ken Thomson’s interview had quite a lot of surprises. I just loved this interview. Ken just opens up his mind on various very interesting things.
Peter, though an author of a successful Lisp book, never gets into an argument with Ken Thomson, when he kind of, thrash the Lisp machine concept and the mentality of MIT hackers at that time to compete with the Unix. I was also surprised when Ken said he had not heard of the “Worse is better” paper of Richard Gabriel which compares the Boston style vs New Jersey Style of computing. I also couldn’t justify the vague answer Ken gave regarding Buffer overflowscaused by slppy coding of C/C++ programs. Also Ken said, at Google he has no check-in rights. He also said he despise C++ (like many others in the book and elsewhere) developed by his ex co-worker. C++ has too many features and everyone use a subset of it. Ken clearly says that it is a badly designed language.
Ken also says about the well known story of his wife and kid who went away for a month when Ken was happily programming pieces of Unix at a fast pace. Ken says that when your wife and kid are away, you no longer have to sync with the Sun’s cycle of 24 hours and that he never experienced any stress during that time. Ken also feels (like his friend Rob Pike) that nothing new is happening in the computing world. According to him, the last significant change was the Internet. Ken also shares the same thought, which many others also expressed, that the modern day programming is all about layers on top of layers on top of layers and that a program depends on 40 different libraries which in turn depends on more libraries and at some point, one just can’t keep all that in one’s head. On top of it, things are now distributed with messages being passes from one place to another. Modern day free software projects like GNOME and Mono and gtk are good examples of this phenomenon. Personally, I find it extremely hard and intimidating to even figure out where to start looking if I see a problem and the very thought of it scares me away from such an undertaking. One instance is that on my laptop, the speaker volume control always resets to mute every time I bootup, no matter what the volume level was during the previous bootup. I had been trying to track the problem down for quite a while and finally the layers scared me away and I gave up.
There are some good discussions and contrasting opinions on Unit Testing and how and when to do it. Some of these have hit the headlines recently.
Overall, it is a very inspirational book for programmers and everyone interested in the craft or art or religion or whatever you call it, should read it.
groklaw's PJ on RMS
This post ought to be read by the so called "open source" pragmatists.
Paul Graham's On Lisp
C Programming Language
Just thinking aloud. I used to think that C is a “general purpose” programming language and languages like lisp are “application specific” high level languages. Obviously, this was because of my ignorance and lack of thinking.
I now feel the exact opposite. C being a glorified assembly language with poor support for higher level data structures, is a language intended for low level programming and languages like Lisp with its rich support for data structures and extensibility with macros is the real general purpose language. For proof, see the kind of things Common Lisp allows you to do with the ”numbers” for instance. The C library itself does not seem to have all those facilities, though it has some of those facilities. One can argue that C allows one to implement all those features, but that is not the point.
SICP and wishful thinking
One of the most powerful ideas conveyed by SICP is the idea of designing programs by “wishful thinking”. It is a simple but powerful concept. The idea is that if you want to design a large program, then we think in terms of some building blocks and use them in our program as if they are primitives. We assume that it is someone else’s problem to write those and give it to us, for a moment. We then write our program in the clearest terms using the newly given building blocks. Once that’s done, we worry about how to implement those building blocks. The idea itself is a recursive one.
For a while I thought that this is a sort of top-down approach of programming. But I now feel that, it is not so. It is instead, bottom-up programming strategy. It is as if we grow the language to create the primitives we need and solve the problem at hand. The order in which we implement them is not important and that’s what we often confuse with the top-down vs bottom-up approach. Atleast that’s how I thought.
New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.
Keep up with the latest Advogato features by reading the Advogato status blog.
If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!