Home
The Memoirs of a technophile
Recent Entries 
10th-Apr-2006 09:54 pm - Wow! Python never ceases to amaze me!
What do you do, when you have to write an assembler and a code generator from scratch and in 2 days, espescially when your right hand is out?

Answer: Use python.

Thats something that still never ceases to amaze me. This is one language that really adheres to the old maxim of less is more. Espescially the fact that there are no cruft charecters which help if you are typing with a few fingers in your left arm.. and (you can't reach shit and ] the same time to do { when all you have is your left pinky to hold down shift!
30th-Mar-2006 08:49 pm - cvm stuff
Hmm.. seems thinking in the meta is a lot tougher than I thought, I am still hopeless about how to go about writing a proper generational garbage collector. Maybe I should stick to something more simpler like a stop-and-copy or good old reference counter styles!

Anyway got a type system and a basic system stack working. Though both the system stack and the type system (considered part of the VM) are not on the garbage collected heap that the vm's programs reside in, I see no reason in not putting them there (likewise I see no reason in putting them there either. what a sad conondrum! ).

So, for now, untill I come up with a better garbage collector, I am stull going to keep all the VM's internal stuff strictly sepereate from the garbage collected heap. (that brings the question of where would the gc store its book-keeping vairables?).

Signing Off
Vishnu Vyas.
25th-Dec-2005 09:49 am - Zen Moment 1
(09:40:52) vishnu: hey
(09:40:59) vishnu: i had a zen moment now


---


(09:42:47) adarsh_ram85: whats that
(09:43:17) vishnu: how many people do you think who are like us in the city?
(09:43:26) vishnu: people who are internet and computer savy,
(09:43:31) vishnu: people who like to go out..
(09:43:47) vishnu: don't mind spending more than 250k on rare occasions..
(09:43:55) vishnu: very similar to us?
(09:43:59) adarsh_ram85: 250 k !!!
(09:44:04) vishnu: not k
(09:44:08) vishnu: make it rs
(09:44:16) vishnu: 250rs
(09:44:21) adarsh_ram85: ok..
(09:44:28) vishnu: how many?
(09:44:45) vishnu: in chennai?
(09:44:54) vishnu: i suppose atleast 1000 people
(09:45:05) vishnu: what do you say?
(09:45:07) adarsh_ram85: yeah
(09:45:08) adarsh_ram85: i guess
(09:45:17) adarsh_ram85: y say that ?
(09:45:19) vishnu: what if we have a website that we could log-in..
(09:45:24) vishnu: and find out..
(09:45:32) vishnu: more like Chen.Food.Guide
(09:45:36) adarsh_ram85: ok ok
(09:45:37) adarsh_ram85: i get it
(09:45:38) vishnu: but much more organised...
(09:45:41) vishnu: but self organised..
(09:45:42) adarsh_ram85: basically a forum
(09:45:49) adarsh_ram85: for the like minded
(09:45:50) adarsh_ram85: rite ?
(09:45:54) vishnu: yeah.. its a forum, with self organised information
(09:45:58) vishnu: orkut + self organisation.
(09:46:07) vishnu: it ain't such a big deal if we get a data model.
(09:46:08) adarsh_ram85: ok ..
(09:46:19) adarsh_ram85: ok..
(09:46:28) vishnu: once we have a data model.. i guess it will take us approximately less than a week to build it..
(09:46:46) adarsh_ram85: yeah i guess
(09:46:49) vishnu: it will sparkle on our resume's
(09:46:58) vishnu: will work great in getting RA/TA
(09:47:00) adarsh_ram85: yep
(09:47:03) adarsh_ram85: ok ..
(09:47:08) vishnu: why don't we do that
(09:47:15) adarsh_ram85: ok cool
(09:47:17) adarsh_ram85: we will
(09:47:40) vishnu: when i get some time off in feb or something ok
(09:47:49) adarsh_ram85: ok da
(09:47:54) adarsh_ram85: jot it down
(09:47:56) vishnu: that was my zen moment..
(09:47:57) adarsh_ram85: so that we dont forget
(09:48:32) vishnu: yeah.. you do that too
(09:48:48) adarsh_ram85: wogay
(09:48:54) adarsh_ram85: i will put a reminder on my phone
(09:48:56) adarsh_ram85: brb
(09:48:57) adarsh_ram85: .
(09:49:17) vishnu: me going to watch 3rd episode of boondocks
(09:49:18) vishnu: bye
7th-Dec-2005 06:58 am - cactus vm design notes.
Cactus VM is currently a Stack based Virtual Machine (it might move to CPS). These are design notes to document it for postertiy.

  • As I said, its a stack based virtual machine

  • Inside the virtual machine, everything is an TObject.

  • There are special TObjects, namely method TObjects

  • The method TObjects are stored in a method dispatch tables for the sake of method dispatch

  • The dispatch table is another special TObject which is a special case of a dict TObject

  • Other special TObjects include sequences and numerics

  • They special in the sense that opcodes are present for manipulating them

  • Opcodes are actually either 32bits or 64bits in length.
    Bit Positions values
    0 1 2 Identifier bits
    001 : intrinsic opcodes
    010 : special opcodes
    100 : extended opcodes
    3 - 15 Opcode
    16 - 23 Opcode descriptor (depends on opcode)
    24 - 31 Opcode Hints (depends on opcode)
    32 - 63 (optional) Operand




So thats all for now,
Signing off,
Vishnu Vyas.
26th-Nov-2005 06:48 pm - Reading Simon Singh..
My recent trip to blore, and the book addict I am, made me buy this book by Simon Singh called "The Code Book". Its a pop-sci type book into the world of codemakers, codebreakers and cryptography! Should be an interesting read.

That gives me lots of interesting ideas about some code I would want to, probably something to break mono alphabetic ciphers! probably will post something more eloquent at http://vishnuvyas.wordpress.com

signing off,
Vishnu Vyas
22nd-Nov-2005 01:51 pm - Funny Lisp Snippet.
CL-USER> (format t "Shakespeare has given us the age-old question, \"To be or not to be?\"
Computer science has given us the answer:~%
~x | ~~~x == ~x" #x2B #x2B (ldb (byte 8 0) (logior #x2B (lognot #x2B)))) 
Shakespeare has given us the age-old question, "To be or not to be?"
Computer science has given us the answer:

2B | ~2B == FF
22nd-Nov-2005 11:33 am - Across the Line of Magic

Programmingis something thats an inherently fun affair. It lets you be the masterof your creative energies. It lets you become god for some time, Itlets you create. And that gives a programmer immense pleasure andsatisfaction. Just like sex. And then there is debugging. The darkerand uglier side of programming. Where you have to deal with themistakes that you so blissfully overlooked when you were busy creating.The pleasure comes back as a pain to haunt you. Again, just like sex.

Ihave been busy hacking on a feed reader in lisp these days and tryingto fix an XML parser into accepting something as brain dead as 'CDATA 'and the XML parser was actively fighting back. Just like a wounded dogyou are sotrying to help but still bites you back. It was more of a debugging(pains) session than a pure programming (pleasure) session. I was at mywits ends, unable to fix the damn thing. My code to my eyes lookedright and my compiler was conking out. It was like trying to fight aninvisible enemy. The worst bugs to fight are those that are not in yourcode, but in someone else's code. But this was not even that. It waswhat happens when induvidually correct programs are coupled and theirinteractions create a semantic monstrocity that its hard for even thecreator to understand, let alone anyone else. This particular problemis what happens when you take an untested XML parser, SLIME, Emacs and SBCLand put them into a mixer and then try to figure out whats wrong withyour parser. It turned out that SLIME uses a limited form of encodingcalled iso-8859-1 whereas most web transfers and the CDATA in RSS feeds are in UTF-8type encoding. You think thats hard to figure out? - You bet it is! Theproblem is the other characters apart from your original ascii aremostly invisible. And hence vrey hard to even insert your timely printdebug statements to observe what actually is going on.

Onething that definitely helps when you are debugging is taking a break.In fact, from my experience taking a well deserved break definitelyspeeds up your following debugging session. But in spite of this, likemost other programmers I was caught in 'fixing' the bug that I waslosing concentration and was basically getting frustrated. I knew I hadto take the break, but I used each and every excuse to convince myselfnot to. But fortunately the bell rang and it was the TV repairman. Thiswas when I started my journey across the line of magic.Now let me explain what the magic line actually is - every programmerhas to learn one of the most important concepts in programming and isoften exposed to it at the earliest stages in any good computer sciencecourse and thats abstraction . Abstraction is just a formal way oftelling that you should stop bothering about the nitty gritty detailsand get to work on your problem. The level of abstraction depends onthe nature of the problem and the programmer. In fact abstractions areevery where and people use it all the time. Files are abstractions overthe various device dependent process for storing bits onto storagedevices. Your operating system is an abstraction over the raw hardwareand your processor and so on. One characteristic of a good abstractionis that its as 'not' leakyas possible. Infact most good abstractions totally make invisible theunderlying implementation. Files are good examples of those types ofabstraction. And in general, us programmers should not bother aboutwhat lies beneath our abstractions otherwise we are doomed to the samefate as the web surfers of the pre-google era - information overload.But since most abstractions inevitabily turn out to be leaky there isno way but to break the law of abstractions. The question is all aboutwhere to draw the line. The line beyond which you trust yourabstractions unqestionably that you don't even bother to know how itsworking. And this particular line is what I call the magic line.

Programming in Lisp had recently raised my line from what it was when Iwas writing C code, and sometimes its just nice to find your roots.Comming back to the TV repairman, our TV had been busted recently dueto the monsoonal rains and erratic electricity and no TV was somethingthat was totally unacceptable to my 'tv-serial' addicted parents. Sothey called in a funny looking guy to fix it. Usually I hate doinghouse work, and espescially helping out TV repairmen and all that andto be honest I din't take this guy too seriously in the begining, butthere was something that just din't fit in about this guy. So hestarted to work on our TV and then I saw this lookon his face. I have rarely seen this except on a few close friends ofmine. The last time I saw it on a guy's face the guy was working onimplementing minimax trees and alpha-beta search. Did I say implement?Let me make a small correction. He was trying to debugit. This look, which I had considered the secret trade-mark of uselitist geeks, was exactly what I saw on the repairman's face. This wasobviously an expert at work. And the best way to learn anything is tolearn by watching the experts do it, and this time I had to cross mymagic line to the realm of bits and piecies and all your fancyelectronics - the resistors, the capacitors, the transistors and whatnot. And very soon it dawned on me that he was in a similar predicamentas I was just before he had rung the bell. Fixing a system where thebug is in the connections rather than the components themselves.

Andhe debugged the system beautifully. My words don't do justice to theskill of this expert, but anyhow here is my feeble attempt to describeit. As usual he started with a problematic system. There was no outputon the CRT, no sound from the speakers nothing. For all practicalpurposes the system was dead. He started out by pulling out all plugs,and all the other things that hold the tv together, he was taking apartthe system into its individual pieces and took a good look at the wholesystem. the main PCB, the CRT connectivity boards and the audiosubsystem. I guess he took a moment to understand the complexity in itswhole. Then he went about looking at all the usual sources of problemsin TV system, and incredibly his first guess was right. It was thepower subsystem that had been totally busted. He took out the old powersystem and replaced it with a new one. And walah ! - the system stilldidn't work (got you there didn't I?). Now this is where the wholeprocess gets close to what real debugging is like. He was poking aroundwith a multimeter and various points and once he found something wassuspicious he tried to unsolder and try the system again. He did thisfor various components, unsoldering and soldering them back. At somepoint he even inserted new components (a resistor to be precise) tocircumvent a diode that he was sure of being broken. And with the diodehe added a couple of buffers and a weird three legged device which Iwon't name as I won't risk my knowledge (or lack thereof) ofelectronics being exposed here. Seems so close to all those gartituousprint statements that I litter in my code when debugging. And once hegot a reading on the multimeter I saw the "Aha!" look on his face.Seems like he had finally nailed the bug and in fact he did. Hereplaced the faulty component (which I presume is a diode), with a newcomponent and the system sprang to life albeit with a grainy pictureand almost indecipherable sound. Now, there is a difference betweenreal debugging and his method. We programmers might have let it go andleft it for version 2.0, but this guy didn't stop. He twiddled withvarious controls, some resistors changing one component for anotheruntil the picture was clear. Next he worked on the sound system and hegot it working in no time. It took him one painstaking hour to fix ourbroken TV form dilapidated old hag to "good as new"condition and he was working for minimum wage. Now thats India for you.I paid the equivalent of what a boy would get for one hour's work ofdelivering pizza in the US to watch an obvious expert at work andwithout the complaining too!!.

Signing Off,
Vishnu Vyas.

21st-Nov-2005 07:34 pm - more feed rendering code.
(defun handle-post (post-param)
  (let ((input-stream (caddr (thttp:http-get post-param))))
    (with-output-to-string (s)
      (render-atom-feed input-stream :output-stream s))))
  

(defun atom-page ()
  (let ((source-string nil))
    (when (post-parameter "feedurl")
      (setq source-string (handle-post (post-parameter "feedurl"))))
    (no-cache)
    (recompute-request-parameters :external-format +latin-1+)
    (setf (content-type)
          (format nil "text/html; charset=~A" :iso-8859-1))
    (with-html
      (:html
        (:head
          (:title "Vishnu's Atom Feed Reader Beta!")
          (:style
           ".div-1{float:center;border:1px dashed black;background:#53d2f1;width:75%;padding:5px;}
            body {background:#f3efc0;font:0.9em Arial;}"))
           
        (:body
          (:center (:h1 (:i "Vishnu's Atom Feed Reader!")))
          (:div :align "center"
          (:p (:form :method "post"
                "Enter Feed URL: "
                (:input :type :text   
                         :name "feedurl")
                (:input :type :submit :value "Load"))))
          (:p :class "div-class1" :align "center"
              (:center
               (:div :align "left" :class "div-1"
                     (if source-string (write-string source-string))))))))))
21st-Nov-2005 07:16 pm - some feed rendering code.
(defun render-atom-feed (in-s &key (output-stream *standard-output*))
  (let ((atom-feed (s-xml:parse-xml in-s :output-type :sxml)))
    (loop for element in (s-xml:sxml-element-children atom-feed)
          when (string= (symbol-name (s-xml:sxml-element-name element)) "entry")
          do (loop for node in (s-xml:sxml-element-children element)
                   when (string= (symbol-name (s-xml:sxml-element-name node)) "title")

                   do   (lml2:html-stream 
                         output-stream
                         (:h1 (print (car (s-xml:sxml-element-children node)) 
                                     output-stream)))

                   when (string= (symbol-name (s-xml:sxml-element-name node)) "content")
                   do (if (stringp (car (s-xml:sxml-element-children node)))
                          (write-string (car (s-xml:sxml-element-children node)) output-stream)
                          (s-xml:print-xml (car (s-xml:sxml-element-children node))
                                           :stream output-stream 
                                           :input-type :sxml
                                           :header nil))))))
4th-Nov-2005 06:41 am - my document
Lets say this is a document.

This page was loaded Dec 16th 2009, 5:57 am GMT.