Pro tip of the day
April 15, 2011
Just saw on Twitter: “C++ Tip: Avoid the blame for bugs by placing all your code in namespaces named after other programmers on your team.”
It’s not only the privilege of C++ coders: you can use it in any language which supports multiple namespaces.
Time to amaze your colleagues!
blog revived in 3D
April 13, 2011
Woa! It was quite a long time ago since I posted anything. I even forgot I had a blog. Well, time to start…
I got my hands dirty with Python & OpenGL (PyOpenGL) and started reading The Red Book. It’s now much easier to write fancy programs. What took days, now takes minutes. Back in the days you actually had to roll your own graphics library. It went something like this:
- Write a routine to display a point (pixel). It’s not difficult at all, but first you have to map 3D coordinates onto the 2D display. Then you can display it on the screen (preferably by directly addressing the video memory).
- by using your awesome point routine, you can draw a line pixel-by-pixel
- Ok, triangles next. All objects are made up of triangles, you know that, right? Even spheres.
- Still there? Good. Now we can create rectangles, cubes, spheres and so on. You have to build them up by using triangles. Sometimes it can be rather tedious.
We used to write it in Assembly, which further complicated things (especially x86 Assembly, which was a pain at that time (memory segmentation, too few registers, to name a few annoyances)). But anyway after writing these pretty basic things we have our shiny new library. It’s time to start working on funny stuff like animation, texture mapping, hidden surface elimination, transformations (scaling, translation etc.), lighting, shading… The list goes on. It’s a lot of work and maths (vectors, matrices, linear algebra etc.). And we’re still not cross-platform.
Well, that’s it for a start.
Monty Python on YouTube
January 26, 2009
In case you didn’t know: the Monty Python team put some of their sketches online. See their YouTube page. Quote from the page:
For 3 years you YouTubers have been ripping us off, taking tens of thousands of our videos and putting them on YouTube. Now the tables are turned. It’s time for us to take matters into our own hands.
We know who you are, we know where you live and we could come after you in ways too horrible to tell. But being the extraordinarily nice chaps we are, we’ve figured a better way to get our own back: We’ve launched our own Monty Python channel on YouTube.
No more of those crap quality videos you’ve been posting. We’re giving you the real thing – HQ videos delivered straight from our vault.
What’s more, we’re taking our most viewed clips and uploading brand new HQ versions. And what’s even more, we’re letting you see absolutely everything for free. So there!
But we want something in return.
None of your driveling, mindless comments. Instead, we want you to click on the links, buy our movies & TV shows and soften our pain and disgust at being ripped off all these years.
I wish them good luck! It’s time to order `The Complete Monty Pythons Flying Circus – Collectors Edition Megaset’.
Some of my favorites include:
CLOS hint #1
January 26, 2009
Keene’s `Object-oriented programming in Common Lisp’ is the book generally recommended for starting with CLOS. While it’s a very good book and I too recommend it, it was written before the Common Lisp standardization process was finished. Therefore it has some inconsistencies (but so few that you don’t actually have to worry about them). One of them is specializing
describe on page 40 (and 41, 49, 56 and 241):
(defmethod describe ((l lock))
(format t "~&~S is a lock of type ~S named ~A."
l (type-of l)
(if (slot-boundp l 'name)
(lock-name l)
"(no name)"))
(values))
This won’t work, since describe is an ordinary function, so you can’t specialize it. You have to specialize describe-object instead, which takes a stream as its 2nd argument. Apart from that it’s the same:
(defmethod describe-object ((l lock) stream)
(format stream "~&~S is a lock of type ~S named ~A."
l (type-of l)
(if (slot-boundp l 'name)
(lock-name l)
"(no name)"))
(values))
See the documentation of describe and describe-object.
Again, this is a good book on CLOS and the code examples are clean. Also, I recommend Practical Common Lisp by Peter Seibel, though it’s not a book on object-oriented Common Lisp, but a general introductory book to the world of Common Lisp.