Thursday, December 27, 2012

GitHub and Open Source in the Classroom

I started using source control in high school, and I believe every computer science student should be comfortable with at least one source control package. Last semester in my GPU Programming and Architecture course at the University of Pennsylvania, we had students use GitHub for their code. This semester, we took it a step further.

Last semester, we used a GitHub educational account so each student could access a free private repo. To release a project, we added a new directory to each student's repo (which was slighly less work than creating a new repo; forking was not an option since each student wasn't required to create an educational account). Students submitted their work by creating a tag. This all worked OK. Students learned basic git features. Rolling out fixes to our starter code was reasonable enough.

But we could do much better.

This semester we said goodbye to private repos, and went completely open source (well, students still had the option to use private repos, but no one did). To release a project, we simply added the new repo to our GitHub organization, and students forked it. Students submitted their work with pull requests. Besides better exposing students to git, this had some major benefits.

Code portfolios

Each student built a code portfolio, which will help them start their careers. This is inspired by an internship posting by Christophe Riccio:

"The profile for the candidates: C++, OpenGL, OpenCL. Applications with a source code and for the principle of it, a resume."

I whole-heartily agree with the spirit of this. Students with public code portfolios are more marketable than students without. Public code portfolios give students more exposure and give employers a lower barrier-to-entry. By diffing repos, employers can also see what exactly the student did vs. what was provided.

Combine a public code portfolio with cool projects (our students implement GPU ray tracers, path tracers, and rasterizers to name a few), and quite frankly, I don't know how students without a code portfolio will compete.

In addition to helping our students, keeping everything public has the potential to help anyone.

Help the larger community

Interested in writing a GPU path tracer? Fork ours. Don't stop there, read our slides and listen to the audio. They're public for everyone's benefit. Ultimately if the course gets attention, it also benefits those who took the course.

Academic integrity

The most common question I get is if everyone's work is public, can't students cheat?

Yes, but students don't need public repos to cheat. They can talk among themselves and there's already lots of code online.

There's also lots of things that discourage cheating:
  • No two projects are alike - we never provide rigid requirements. For example, the image processing project gives a selection of filters to implement, and requires students to come up with new ones. The rasterizer gives a set of required stages, and a selection of extra ones. In practice, projects turned out to be remarkably different.
  • Random presentations follow projects - three or four students present their projects in class without any notice. The main motivation is for students to get use to talking on their feet giving an elevator pitch. Discouraging cheating for fear of not presenting well is perhaps a side-effect.
  • Social pressure - the code trail is public and commits have time stamps.

Cheating is, of course, still possible, especially copying one-liners. However, the benefits of public code repos outweigh the risk. We strive for a course culture where students don't care to cheat. They want to implement the projects - actually, even students outside of our course want to implement them. If a student wants to chase after grades, they need to take another course. In our course, we stay up to 2am coding for fun, not grades.

Saturday, December 1, 2012

Hackathons in the Classroom

I teach a graduate-level GPU Programming and Architecture course at the University of Pennsylvania. I do lots of atypical things like open source projects using github (there is no "homework" - who wants to do homework?) and I've even let the students make their own final - of course, they didn't know they were doing it at the time. This year I got rid of the final altogether to allow us to focus more on building portfilios of projects like, for example, the work of Zakiuddin Shehzan Mohammed.

Inspired by Facebook and PennApps, and based on feedback from last semester, I decided to bring a hackathon into the classroom. The goal being to build a culture of excitement and intensity, and to code for the fun of it. No grades, just bragging rights and prizes: a copy of OpenGL Insights and a few Cesium t-shirts.

Tiju Thomas presents his hack

I canceled class and replaced it with a six-hour hackathon, 6pm-12am, in the graphics lab using the GLSL Sandbox, an online editor for writing GLSL fragment shaders. The theme was two triangles (or even one) ought to be enough for anybody. The GLSL Sandbox renders a full-screen quad providing one fragment per pixel for students to ray trace, ray march, or do anything else they liked. They were allowed to fork any existing example in the gallery as long as they demoed the original along with their work.

I even encouraged students to fork each other's work as a fun way to compete, e.g., a student might focus on soft shadows, procedural textures, and other shading techniques, and then fork another student's work doing CSG to create something really awesome. This arms race didn't pan out in practice, but with more preparation - perhaps a project on ray marching leading up to the hacakthon - it could be really interesting.

Ashima Gupta and Yue Hue present their hack

Once the hackathon got rolling, there was a sense of focus and intensity. By the end, all students got something working, and many surprised themselves. People outside of my course even joined in, like Nop Jiarathanakul's procedural smoke and Gabriel Leung's Conway's Game of Life

We stayed until about 2am doing demos and reflecting on the experience. It was very cool to see students motivated and working hard for the sake of the project; there were no grades involved. A student could have walked out or not even showed up with nothing to lose, but no one did.

Yuanhui Chen presents her hack

Moving forward, we may compete with a class at another university and do a longer event open to all our graphics students. I want to thank our TA, Karl Li, for helping with the event, Nop Jiarathanakul for demoing his work at the kick-off, and Aline Normoyle for letting us use the lab.

Check out the results:

WebGL, Virtual Globes, and Santa

I've been quiet on this blog recently; in addition to teaching GPU Programming and Architecture again, I have been working on a fun project using WebGL and Cesium, our virtual globe, to help NORAD track Santa this Christmas Eve.

NORAD has a long history of tracking Santa. The NORAD Tracks Santa site is very popular, last year it received 19 million unique visitors over the holiday season. NORAD has provided a 3D globe with Santa's real-time location on Christmas Eve before. However, thanks to WebGL, this is the first time the globe does not require a plugin, so I expect 3D will reach even more people.

I wrote a blog post on the Cesium website with many of the tech details: rendering global terrain, imagery, stars, etc. However, some of the biggest challenges weren't strictly technical, for example, how do you design a UI for 5-10 year-olds and their parents?

Of course I am excited about this opportunity for Cesium, but I also see this as a huge opportunity for WebGL. APIs need killer apps to drive adoption. Although there are lots of amazing WebGL demos, there are few WebGL apps that have reached the masses with a compelling better experience. This needs to change, and I hope NORAD Tracks Santa is one step in that direction.

Our globe will be live Christmas Eve at In the meantime, there is the tech preview I wrote and instructions for getting WebGL, but if you're reading this blog, I'm pretty sure you already know how to do that.