/var/spool/weblog | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Geek News del.icio.us bookmarks RSS |
Thu, Jul 13, 2006
Learn to Program
Honestly, it failed to grab me. It looked like a nice enough language, but its syntax is sort of a hybrid of Perl and Python. Given that I already know both Perl and Python, I couldn't see the point of spending much time on Yet Another Language, especially one that was more of the same. Still, buzz continued to grow. I picked up a copy of Hal Fulton's book The Ruby Way. This one included Appendices explicitly for Perl and Python programmers, as well as several "real-world" examples, so I gave it another shot. Actually, I started to give it another shot. But since the Appendices were squarely aimed at me, I started there. Big mistake -- I fell asleep. Several times. I put the book aside and figured I was done. Three years later, in 2004, along came Ruby on Rails. Wow. Do I really need to tell you how impressive Rails is? But at the time I wasn't working on any web applications, I still wasn't thrilled with Ruby as a language, and I certainly wasn't thrilled at the prospect of learning a whole new language just to write web apps. More recently I've been looking at the cavalcade of Rails clones. I think I've settled on CakePHP as the best documented, most mature, and easiest to learn. But just as I was getting started, it occured to me.... As I tell students, the best way to learn is by going straight to the source, not by reading the nth re-hash by someone else. I'm still planning to learn Cake, but really, why not start with the best? (Or at least with the original.) Ok, back to Ruby. In the years since Programming Ruby was published by Addison-Wesley, the Pragmatic Programmers have started their own publishing company, The Pragmatic Bookshelf. Which brings me (finally) to the ostensible subject of this review, Learn to Program by Chris Pine. The purpose of Learn to Program is, well, to learn to program. The language just happens to be Ruby. Honestly, I don't even remember when I first learned to program -- I must have been 7 or 8 years old. (BASIC, on a Timex-Sinclair 1000, if you must know). I can't really comment on how well the book succeeds in that goal, because I'm clearly not the target audience. I read through the book fairly quickly, since I already understand the concepts. A couple of things concerned me, though. The explanation of "variables" seemed overly complicated. I think the author was trying to explain references, without actually using the word "reference". Ditto his explanation of recursion -- I admire the attempt to suggest that recursion is a perfectly natural concept (the title of Chapter 10, on recursion, is "There's Nothing New to Learn in Chapter 10"), especially since most CS1 textbooks for imperative languages make it far too complicated. But c'mon. If it's so easy, why does "nothing new" take 17 pages to explain? So I can't tell you whether it's a good book for a beginner, but it was a good book for me. The truth is, the only way to learn a new programming language is to write code. You can't just sit and read a book about programming; you need to do it yourself. In this, the author succeeds wonderfully. The exercises he suggests (under the heading "A Few Things to Try") are geared toward putting the concepts you've just read about directly into practice. And they're straightforward enough that, instead of thinking "oh great, another programming exercise," you'll be thinking "hey, that sounds easy enough," and you'll dive right in. Even better, they're fun. No lame "Hello, world" or farenheit-to-celsius converters here. (Oops, I think I just insulted K & R.) Instead you'll find such gems as
Oh, and my impressions of Ruby now that I've written a few short programs? It's kind of a nice language. You can slurp the contents of a file in a single line. It switches seamlessly between fixed-sized integer types and "big" integers. (As it turns out, so does Python, but I'd never seen it before). YAML is nicer than Perl's Data::Dumper. I like that you can add easily add methods to built-in classes, even if it's probably a bad idea -- being able to type 3.factorial is coool. Ruby strikes me as being sort of like Python, if Python had been written by someone who liked Perl. I don't think, though, that it goes the other way: Ruby is not sorta like Perl. It just has enough Perl-ish bits to make the transition less painful. I'm having trouble deciding on my next Ruby book. I'm leaning toward the Pickaxe Book, but Ruby for Rails looks good, too. After all, that's why I was planning to learn Ruby in the first place. By the way, click here for some bits of Ruby code. Nothing spectacular, but they're sitting here on my hard drive -- no point in not sharing them. Wed, Jun 14, 2006
Compiling Fl-Inventor on Windows
Open Inventor on Windows
If you want to do Open Inventor programming on Windows, the options seem to be:
Alternatively, the Win32 port of Open Inventor does incldue pre-compiled DLLs of Inventor, but not of the SoQt library or command-line tools. I'm honestly not sure what the best solution is. I'll post some instructions when I come up with something. Fri, May 19, 2006
Minimal Ray Tracer
I've updated the code to do the following:
ppmtojpeg ,
If you want to experiment with changing the scene defined in /var/spool/courses/csuf/2006/spring/cpsc465 # Sat, May 13, 2006
Assignment 10
/var/spool/courses/csuf/2006/spring/cpsc465 # Fri, May 12, 2006
Demos for tonight's lecture
/var/spool/courses/csuf/2006/spring/cpsc465 #
Pixar's On-line Library
/var/spool/courses/csuf/2006/spring/cpsc465 # Wed, May 10, 2006
Is this
I wonder which part of the illumination equation isn't being evaluated /var/spool/courses/csuf/2006/spring/cpsc465 #
Material Colors
void color(double r, double g, double b) { float color[4] = { r, g, b, 1.0 }; if (glIsEnabled(GL_LIGHTING)) { glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color); } else { glColor3f(r, g, b); } }Note that although the color can be set for GL_AMBIENT and GL_DIFFUSE separately, you'll usually want them to be the same.
Alternatively, you could try reading about /var/spool/courses/csuf/2006/spring/cpsc465 # Fri, May 05, 2006
Chapter mismatch between HTML and PDF versions of the Red Book
/var/spool/courses/csuf/2006/spring/cpsc465 # Fri, Apr 28, 2006
Assignment 9
/var/spool/courses/csuf/2006/spring/cpsc465 # Fri, Apr 14, 2006
Slides for tonight's lecture
/var/spool/courses/csuf/2006/spring/cpsc465 #
A note on doing the work yourself
Note, however, the following:
Hint: pick a partner who's smarter than you are. /var/spool/courses/csuf/2006/spring/cpsc465 # Fri, Apr 07, 2006
Announcements
Note the updated office hours shown to the left: I've been able to rearrange my work schedule in order to be available before class. Be sure to drop by and visit. /var/spool/courses/csuf/2006/spring/cpsc465 # Fri, Mar 31, 2006
GLIntercept
Here's a 30-second walkthrough:
glClearColor(0.000000,0.000000,0.000000,0.000000) wglGetCurrentContext()=0x10000 wglGetCurrentDC()=0xb70114f8 wglGetCurrentContext()=0x10000 wglGetCurrentDC()=0xb70114f8 glViewport(0,0,600,300) glMatrixMode(GL_PROJECTION) glLoadIdentity() glOrtho(0.000000,2.000000,0.000000,1.000000,-1.000000,1.000000) glMatrixMode(GL_MODELVIEW) glLoadIdentity() glClear(GL_COLOR_BUFFER_BIT) glColor3f(1.000000,1.000000,0.000000) glBegin(GL_LINES) glVertex3f(1.000000,0.000000,0.000000) glVertex3f(1.000000,1.000000,0.000000) glEnd() glViewport(300,0,300,300) glMatrixMode(GL_PROJECTION) glLoadIdentity() glFrustum(-1.500000,1.500000,-1.500000,1.500000,2.000000,8.000000) glMatrixMode(GL_MODELVIEW) glLoadIdentity() glMultMatrixf([1.000000,0.000000,0.000000,0.000000, 0.000000,1.000000,0.000000,0.000000, 0.000000,0.000000,1.000000,0.000000, 0.000000,0.000000,0.000000,1.000000]) glTranslated(0.000000,0.000000,-6.500000) glPushMatrix() glPushMatrix() glColor3f(1.000000,0.000000,0.000000) glBegin(GL_LINE_LOOP) glNormal3fv([0.000000,0.000000,-1.000000]) glVertex3fv([0.500000,0.500000,-0.500000]) glVertex3fv([0.500000,-0.500000,-0.500000]) glVertex3fv([-0.500000,-0.500000,-0.500000]) glVertex3fv([-0.500000,0.500000,-0.500000]) glEnd()Running with gliConfig_FullDebug.ini also makes sure that every call to an OpenGL function is checked with glGetError(), which will catch things like passing bad values to functions or trying to pop the matrix stack more times that it's been pushed. To make the best use of a tool like this, you'll probably want a utility to tail the log as your program is running. (I'm told there are also GUI versions). Note that you don't need access to the source code -- if you have a game at home that uses OpenGL, you can watch what it's doing, too. (Just don't steal their code, and don't tell them I'm the one who told you how.) GLIntercept has a few more tricks up its sleeve, but I'll leave it up to you to read about them. For Linux people, there's a similar program called BuGLe, but I haven't tried it. And, of course, we smug OS X weenies have the OpenGL Profiler. For those of you using Igloo, I've put together a new debug package that includes GLIntercept and Windows port of GNU tail. I'm not entirely sure about the legality of all this -- GLIntercept and GNU tail are available under the GNU General Public license, but EiC is still MIA. /var/spool/courses/csuf/2006/spring/cpsc465 # Sat, Mar 18, 2006
Why Microsoft is not my favorite software company
The HTML file was generated by setting a print area and choosing Save As Web Page from the File menu in Excel 2004 for Mac. I understand cross-browser differences. I even understand cross-platform differences. But if I can't save a web page from the latest version of one Microsoft product and have it readable from the latest version of another Microsoft product, well... You should all be using Mozilla Firefox anyway. It looks fine there. /var/spool/courses/csuf/2006/spring/cpsc465/misc #
Homework Grades
If you turned in an assignment that isn't recorded, or if you didn't get as high a score on an assignment as you think you should have, please e-mail me. /var/spool/courses/csuf/2006/spring/cpsc465 # Fri, Mar 10, 2006
Assignment 5
/var/spool/courses/csuf/2006/spring/cpsc465 # Tue, Mar 07, 2006
Pop-quizzes and pedagogy
quizzes -- given early and often -- may be a student's best friend when it comes to understanding and retaining information for the long haulSay, that gives me an idea... /var/spool/science/psychology # Mon, Mar 06, 2006
Another schedule update
For those of you wondering why I've been making changes to the schedule, I've taught the course two different ways in the past:
I'd originally planned to teach this semester as a lecture course, but when it was scheduled for a single class meeting on Friday nights a couple of things became clear:
/var/spool/courses/csuf/2006/spring/cpsc465 #
Vector Math Tutorial for 3D Computer Graphics
/var/spool/courses/csuf/2006/spring/cpsc465 #
A correction
If you compare it with the original screenshot, you'll notice that the original wasn't really a parallel projection.
The problem is that (as you should recall from your reading) OpenGL is a state machine. When you make a function call like
My mistake was to draw the parallel projections (calling To avoid making silly mistakes like me, do the following whenever you go to render a model (e.g., in your display callback):
/var/spool/courses/csuf/2006/spring/cpsc465 # Thu, Mar 02, 2006
Don't cross the streams
By the way, Assignment 4 is available. /var/spool/courses/csuf/2006/spring/cpsc465 # Fri, Feb 24, 2006
Assignment 3
/var/spool/courses/csuf/2006/spring/cpsc465 # Mon, Feb 20, 2006
Best science headline ever
So don't complain when I do it in class: it's a pedagogical technique. On a more serious note, blame computers for this one: Mathematical proofs getting harder to verify: "Twenty-five years later we're still not sure if it's correct or not. We sort of think it is, but no one's ever written down the complete proof" |
Topics
Archives
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||