Posts tagged “software”.

the stack!

img_0386

When I was teaching data structures, one of the things that commonly came up was the whole issue of “pass by value” versus “pass by reference.” This was a very difficult thing to teach;  somehow I’ve internalized the common C/Java style memory model, and these things are fairly second nature.  While lecturing, I was definitely guilty of resorting to mind-numbing aphorisms like “integers are passed by value while objects are passed by reference”.  These rules of thumb just don’t work (and make it incredibly difficult to get your head around the idea that object _references_ are passed by value). This (fabulous) article over at MSDN has a really nice description of the stack as an implementation detail.  Perhaps the key to solving this problem is really to just make the first course in computer science programs a course in programing language implementation.  Then you can move on to harder things like control flow and datastructures (I’m kind of kidding here).

But in reality, the vagaries of “value types” versus heap-allocated objects are too pointy for a data structures course.  Their guts are easily exposed in something like C while being appropriately hidden in an everything-is-an-object language like Python.  The Java/C# mix of these memory allocation strategies is confusing for the beginner.  Expose the details or don’t.  Exceptions to the rules breed bugs and confusion.

earthquake!

I spent a significant portion of my undergraduate career fooling around with the outdated seismology lab in the Loyola Physics department. Though I did eventually connect the seismometers to a computer and was able to record activity, they usually are not running as there is currently no student interested in checking in daily. However, we do turn them on every now and then for a lab that the physics students do. So, we hooked everything up yesterday, and BAM, the biggest earthquake in many years hit Chicago this morning. We captured the quake, and I am positively thrilled. Two traces are below. The times are way off (clock drift), but you can clearly see the quake on the 14:00 line. Also, apparently the after shock was centered in “Bone Gap, IL”! Ha! Amazing.


pipe test

We’ve created an ETL Yahoo pipe that aggregates the content of members’ blogs tagged with ‘etl.luc.edu’. What I’m wondering is how quickly the pipe gets updated, and where things get cached along the line…

s-expression/xml isomorphism

After some discussions with Dr. George recently, I was interested in exploring the relationship between xml and s-expressions. This has certainly been done before, but I thought I would try my hand at it. In the end result, I’m able to convert an s-expression such as:

(a :a1 "test" :a2 "test2" "mycdata" (b :a3 "c"))

to xml:

<a a1="test" a2="test2">mycdata<b a3="c"></b></a>

I do so with a somewhat strange but more explicit intermediate format:

(:element-name "a" :attributes (("a1" . "test") ("a2" . "test2")) :cdata nil                   :children (:element-name "b" :attributes (("a3" . "c"))                                :cdata "My CDATA" :children nil))

This shows pretty clearly how a single namespace xml document can be represented with an s-expression. What I’m wondering now is if I can go from the intermediate representation to something like YAML or JSON. George and I have been calling these ‘tree languages’; I wonder if some sort of overarching equivalence for these ‘tree languages’ can be shown?

I don’t think this has much practical use, but the code is here.

darcs is perfect for university

(I’m guessing that a lot of what I say here applies to all distributed version control systems, but since I’ve only used darcs, that is what I’ll focus on.)

One of the neatest things about darcs is the fact that every checked out copy is itself a repository. This is perfect for university courses! Students can check out the professor’s code, make their own changes to the code (i.e. if the code is the starting point for some assignment…quite common), and commit their changes to their own repository without ‘disconnecting’ it from the professor’s version. All the student needs to do is pull changes from the professors server periodically and deal with any conflicts that may arise. The student can even push their copy to a university server for backup. It’s perfect!

If only Google code had darcs support, then I could force my 271 students to do this. As it stands, I’m not so sure a data structures course is the ideal place to introduce version control, but I may end up doing this anyway.

GNU & Lisp

I’m reading the GNU manifesto, and Stallman talks about adding:

“We plan to have…perhaps eventually a Lisp-based window system through which several Lisp programs and ordinary Unix programs can share a screen. Both C and Lisp will be available as system programming languages.” –RMS


What happened? Where did the Lisp programmers go?

meeting Richard Stallman


I had the chance to meet Richard Stallman on Friday.  He was speaking at the NA-CAP conference at which I volunteered.  All in all, very interesting, and last night I ended up joining the FSF. 

Call Stallman what you will: ideological, dogmatic, unwavering, stubborn, whatever.  You have to give it to him that he is completely and totally dedicated to his cause.  I think this is admirable.

your word documents are ugly and useless

It seems I’ve been in a LaTeX-chatter-whirlwind this past week: someone emailed me about TeX today, I discovered jsmath, this article was on reddit a few days back, and my boss and I were chatting about TeX on Friday. Since I haven’t actually been writing anything lately, I have no need for TeX at the moment, so I’ll just rant.

MS-Word is useless. When writing in word, you’re forced to think about ‘look and feel,’ but when it’s all done, your document will still look like crap (see the aforementioned article for something of intellectual merit on this). Take some time, learn how to use LaTeX (or something as simple as LyX or TeXmacs), and thank yourself later. You’ll write better when you aren’t constantly fretting over the appearance of your document, and it’ll look better when typeset by the brainy TeX algorithms.

Also, if you must collaborate on a document, use a wiki or Google docs, and then paste your nearly complete product into your TeX editor. Emailing a word doc to your colleagues or posting to a website is not collaboration. No one is going to read it, and if they do, they aren’t going to comment. It is too painful.

smalltalk browser too much at first

It’s called bottom up programming, the foundation of which is small composeable methods.

Ramon Leon
This is of course the most important lesson to take from Lisp and its Lispy friend Smalltalk, and in this recent posting, Ramon Leon discusses the relationship between the Smalltalk code/method browsers and bottom up programming. I have no doubt, as Leon suggests, that this type of code browsing IDE encourages and perhaps even demands bottom up programming. However, just as I’ve wondered about this same topic with regards to Lisp and slime, I still maintain that bottom up programming has less to do with the tools than the language itself. Though I’ll assume this to be true and the discussion of why this is the case is beyond me and would take many reams of paper, I’ll state without proof that bottom up programming only emerges from languages with super consistent syntax and semantics.

Now on to the “0piniated” nature of the Smalltalk browser. Leon, I think, shows how the browser really does facilitate better code, but I do not think that this type of environment is a precondition for bottom up programming. On the contrary, the Smalltalk code browser is best appreciated and used after one understands the benefits of bottom up programming. So I think that presenting new users accustomed to more ‘traditional’ IDEs with the Smalltalk browser is a mistake. Instead, provide them with a very simple text editor (something slightly more sophisticated than the workbench), while encouraging them to check out the class browser at a later date. If we were writing a tutorial, maybe we’d do a simple example in the text editor first, and rework this example in the later chapter on the code browser. Ultimately, they’ll appreciate the code-reading-browsing IDE and bottom up programming all the more, and this may reduce some of the initial ‘what the hell is this?’ experience when starting in with Squeak.

(finally) working with Lisp

Several months ago I assigned my data structures students a little recursive puzzle as part of a somewhat longterm assignment. The assignment is due soon, and I thought I’d take some time to write up a solution in Lisp for my own enjoyment.

Now, I’ve been putzing around with Lisp for some time, but this is really the largest thing I’ve written outside of the Practical Common Lisp examples. To be fair, at 56 lines it’s not ‘large’ by any stretch of the imagination. Still, it’s been fun, and I’ve noticed some things.

Programming in SLIME is a pure joy. I find myself writing very short functions and testing them at the REPL repeatedly; Lisp really does facilitate bottom-up programming. Originally I thought this approach was more of a convention, but it turns out to be an emergent property of the language and programming environment. Functions without side-effects are quite easy to test, and SLIME lets you recompile and test at will. Though I think the mutable-state-objects so prevalent in Python really keep us from leveraging the power of the Python REPL, it might be worthwhile to encourage a Lispy-bottom-up approach in Python, too. Maybe some additional tools and a bit more dedication to this style are needed (it’s not the same emergent property as seen in Lisp itself), but the benefits would be worth it. Syntax and macros aside, the ability to tinker with the code I’m writing while I’m writing it is a huge win. Lisp makes this much simpler.

I’m going to think about this some more…I believe the ease of the REPL has pedagogical implications, too (I mean, where’s the Java REPL?).