Sigcse2018 - Malloc Lab

I wasn't going to go to this session. I started out in a panel on integrating social good into CS Ed. With the panel not meeting my expectations I moved over to my second choice - the system programming sessions where I saw Implementing Malloc: Students and Systems Programming, a paper presented by Brian Railing of CMU.

I really liked both the paper and the talk.

CMU computer science students all take a systems course that uses Computer Systems: A Programmer's Perspective. It's a great book. I read through the first edition years ago and felt it was great resource not only in a systems course but also for self study. One of the labs has the students implement their own memory allocation calls, or malloc for us old time C wonks.

There were a number of self perceived deficiencies with the assignment such as encouraging bad programming style by modeling less than ideal practices but the biggest deficiency as that students could game the assignment. Students could do very well on the assignment by exploiting knowledge of the assignment rather than by writing a full and correct malloc implementation. One example is that students were able to figure out that no allocation would be more than 100MB so they really didn't have to deal with 64 bit pointers. They could use smaller offsets thus simplifying the assignment. The assignment became more about figuring out how to get it through the grader and less about learning memory management. I'm sure I'm overstating it but that's the idea.

Railing explained all of the deficiencies and then how they changed the assignment to address them.

At the end of the day, the assignment had fewer loopholes to game so students had to really write the malloc library and presumably learn about memory management.

They also added an intermediate deliverable so students couldn't leave everything for the last minute.

Near the end of the talk, Railing discussed results where he pointed out that students final exam scores didn't change but they did better on the malloc questions. It wasn't clear if the overall scores didn't change, meaning that the students did better on the malloc questions but worse somewhere else or if they did similarly to past students on the other sections and in addition they scored better on the malloc questions. I'm not sold on the final exam questions being the best way to evaluate learning but it is an easy data point.

I loved the presentation and paper and I love what Railing is doing but my big takeaway was…

Well, Duh…

  • students aren't doing as they should
  • teacher realizes students are gaming assignment
  • teacher reworks assignment
  • students do better

Teachers do this all the time. Of course when we do it, it's not "research." This was a recurring theme for me at SIGCSE2018 and I tweeted it. While it's true that K12 teachers can learn a lot about CS content from higher ed, people in higher ed can learn a lot about teaching from teachers.

What Railing presented was terrific and important as changing assignments like this will now be considered by people who haven't thought about this before but this is second nature to a teacher. Of course I'm talking about a good teacher, not one who blindly follows scripted lessons.

I don't mean this as a slight to professors. They're hired and promoted based on research so much of their job involves another skill set. I know many professors who care very much about teaching but they might only teach one or two classes a semester that meets once or twice a week while a typical high school teacher meets 150 students a day five days a week over five different classes a day. Much more of an opportunity for deliberate practice.

This presents a huge challenge. How can professors who are hired and promoted as researchers be given the time and ability to develop as teachers? What about adjuncts or Teaching Assistants? I'd imagine it's even harder for them. I know that colleges have lines for teaching faculty but from what I can see, those instructors are usually super overloaded with classes and students so that doesn't solve the problem. Even if you do have teaching faculty that have the time to develop their craft, how do you get those teaching chops over to the research faculty?

After the session, I was talking about this with Mark Stehlik, Assistant Dean at CMU's School of Computer Science. Mark was telling me about CMU's efforts to develop teaching faculty across the disciplines. I was happy to hear about the efforts CMU was taking but it sounds like they have the same challenges with respect to pedagogy as everyone else. If it's a challenge for CMU with all their resources, what does that mean for the rest of us?

Still, it was encouraging to go to a number of sessions where it was clear that professors - both teaching and research faculty are serious about the craft of teaching and conferences like SIGCSE can bring them together with those of us who don't have the chops as researchers but do so as teachers.

SIGCSE 2018

I just got back from SIGCSE2018 - the big annual conference on computer science education. Although I've been in this racket for decades, this was only my second SIGCSE and once again I had a blast.

As with most conferences, a highlight was the "hallway track" where I got to spend time with friends and colleagues from all over the country. I also got to check off a few names from the "people I've been following online and want to meet in person" list. There are a few more on the list but it's getting smaller.

The theme was CS For All but the range of topics covered was both wide and deep.

For me, I left thinking about a few themes:

  • College faculty can learn a lot from K12 teachers in terms of pedagogy and teaching.
  • So can "thought leaders," policy makers, and big companies.
  • Colleges face a huge challenge in both developing pedagogues and transfering pedagogical knowledge over to researchers.
  • Can you do both CS4All and have quality CS teachers in the short term (I doubt it)?
  • Researchers vs Practitioners and the value of listening to one or the other.
  • Nifty assignments are frequently regular assignments reskinned with graphics.

There were a few sessions that dissapointed me but most of the ones I attende were terrific. I thought I'd blog about some of them in detail over the next few weeks.

Here are the sessions I'm planning on writing about:

I might talk about a few other sessions as well.

Overall it was a great conference. I look forward to sharing my experiences with all of you in the coming posts.

Using Emacs 43 - Music with MPD

I like to listen to music at work. Sometimes I just stream from YouTube, Soundcloud, Spotify or some other online source but if you're a person of a certain age, like me, you probably have quite an mp3 collection. All those CDs that have been ripped not to mention some converted vinyl.

I used to use the Music Player Daemon or MPD back in the day. It would run in the background and you could connect to it using lots of clients.

When I was running Ubuntu and Mint Linux, I had some trouble setting up MPD but the process is much smoother using Manjaro which is Arch based and I'm currently enjoying.

Here's a video on how I set up MPD and also use Emacs to control it.

Coincidentally, on the same day I recorded this, Uncle Dave put up a similar video. Dave also sets up MPD on an Arch based linux but he uses EMMS for his player. I ultimately end up with Simple-MPC with briefs stops at the built in MPC mode and Mingus along the way.

Enjoy.

Testing, Testing

With CS4All being the buzzword of the day we're paying a lot of attention to the fact that when we teach a CS class for all students, most of them won't end up studying CS or going directly into a tech heavy field.

Among those that do study CS though, there is another division. Those studying CS as an academic exercise or to go on to graduate studies and those who are going in to the tech sector. For those going into the tech field, it's important that they're prepared in terms of software development, design, and all those goodies not covered in CS classes.

I'm not advocating removing the good stuff currently in most colleg CS curricua, although I will say that most CS programs I've reveiwed could benefit by trimming some requriements and adding some electives. I am advocating doing more than telling your students "comment your code," - a refrain many undergrads have heard frequently with little guidance.

I'm advocating to begin by bringing in tools and practices that either don't detract from current CS classes or in fact can add to or streamline them.

Last year I wrote about using Git and GitHub in my classes. Students have to submit projects anyway and frequently have to work in teams so using Git and a Git hosting service can actually make both student's and instructor's class experiences better while introducing them to an industry best practice.

Today I want to talk about testing.

Students are always told to test their code but frequently not given tremendous guidance. The results can be:

  • projects that don't compile
  • projects that compile and run but not the way they're supposed to.
  • wonky input or interfaces
  • projects that don't work for all cases

On the instructor side, we have to evaluate the student's submissions and deal with all of this. Some teachers use auto graders to help. I have mixed feelings on them. On the one hand they can speed up grading but on the other hand it's important for me as the teacher to actually dive into the student's code. In any case, using an auto grader is actually somewhat similar to running a test suite.

Why not have the students create their own test suites? If done right, this should encourage students to evaluate their own code more carefully and also cut down on the time it takes the intructor to evaluate a given submission.

This means that we have to use a testing framework with a very low cost of entry.

I ended up finding doctest for C++. It's really simple and just a single include file. This means that students don't have to actually install anything on their machines. Here's the example from the project page:

using_doctest_888px_wide.gif

Basically, the students can just start writing tests.

Python also has a couple of low friction testing options. One is to use the built in doctest facility. Basically you put sample runs in the doc string at the top of a function with the expected output:

def factorial(n):
    """Return the factorial of n, an exact integer >= 0.

    If the result is small enough to fit in an int, return an int.
    Else return a long.

    >>> [factorial(n) for n in range(6)]
    [1, 1, 2, 6, 24, 120]
    >>> factorial(30)
    265252859812191058636308480000000
     """

    import math
    if not n >= 0:
	raise ValueError("n must be >= 0")
    if math.floor(n) != n:
	raise ValueError("n must be exact integer")
    if n+1 == n:  # catch a value like 1e300
	raise OverflowError("n too large")
    result = 1
    factor = 2
    while factor <= n:
	result *= factor
	factor += 1
    return result


if __name__ == "__main__":
    import doctest
    doctest.testmod()

This might seem a little cumbersome, particularly if you look at the example at the link. It also requires the tests go on top of each function and that the tests will print out as part of the docstring.

The other easy Python option is the built in unittest module.

Here's an example of testing strings from the link above:

import unittest

class TestStringMethods(unittest.TestCase):

    def test_upper(self):
	self.assertEqual('foo'.upper(), 'FOO')

    def test_isupper(self):
	self.assertTrue('FOO'.isupper())
	self.assertFalse('Foo'.isupper())

    def test_split(self):
	s = 'hello world'
	self.assertEqual(s.split(), ['hello', 'world'])
	# check that s.split fails when the separator is not a string
	with self.assertRaises(TypeError):
	    s.split(2)

if __name__ == '__main__':
    unittest.main()

I havn't played with Java testing in years but I'd guess there's something similarly light weight.

Tomorrow I'm hoping to finish the groundwork on using C++ doctest with my class and I'll write another post afterwards. Probably after SIGCSE since I'll be attending that from Wednesday on.

We'll see how this goes but I'm guessing it will work well. If it does, it should make my life as a grader easier and also get the kids on track to using test frameworks - something they'll need wherever they end up.

Using Emacs 42 - Git Gutter and Time Machine

One day I'll do a Magit video but since there are already some good ones out there I thought I'd share a couple of other great git related packages.

The first is Git Gutter which adds markers on the side gutter of your buffer so you know what's changed since you're last commit. I pretty much use it exclusively for that visual but it can also be used to cmmit and revert individual chunks of your changes.

The second is Git Timemachine which lets you move forward and back between commits.

The video demos both.

Enjoy

Using Emacs 41 Pandoc

Another Emacs quick hit today. Actually, not really Emacs. Today's video is a quick, really quick, look at Pandoc. Pandoc is a document converter.

Here are the formats that Pandoc can covert read from:

Markdown, CommonMark, PHP Markdown Extra, GitHub-Flavored Markdown, MultiMarkdown, and (subsets of) Textile, reStructuredText, HTML, LaTeX, MediaWiki markup, TWiki markup, TikiWiki markup, Creole 1.0, Haddock markup, OPML, Emacs Org mode, DocBook, JATS, Muse, txt2tags, Vimwiki, EPUB, ODT, and Word docx.

And here are the ones it can write to:

plain text, Markdown, CommonMark, PHP Markdown Extra, GitHub-Flavored Markdown, MultiMarkdown, reStructuredText, XHTML, HTML5, LaTeX (including beamer slide shows), ConTeXt, RTF, OPML, DocBook, JATS, OpenDocument, ODT, Word docx, GNU Texinfo, MediaWiki markup, DokuWiki markup, ZimWiki markup, Haddock markup, EPUB (v2 or v3), FictionBook2, Textile, groff man, groff ms, Emacs Org mode, AsciiDoc, InDesign ICML, TEI Simple, Muse, PowerPoint slide shows and Slidy, Slideous, DZSlides, reveal.js, PDF

That's pretty impressive

I was faced with an html file describing a lab for all the CSCI13500 students at Hunter. I wanted to modify it for my class and that was going to be a bear. I also wanted an easy way to have it render up on GitHub. With pandoc, it was trivial. I just typed:

pandoc -f html -t org -o lab3.org lab3.html

which converted the file to org-mode. This was trivial to edit and then I uploaded it to GitHub as the lab's Readme.org file which GitHub automatically renders on the project page.

Pandoc for the win.

I've also used pandoc to move between org-mode and word files.

If you haven't checked out pandoc, you should.

Google Sheets

I make regular use of Google's office suite. I use Google forms all the time to collect data, Google docs when I have to leave Emacs for document preparation - usually when I have to collaborate with others online and I use Google Sheets as my greadebook.

I don't do a lot of data processing using Google sheets. For that I download the data and write small scripts. On the other hand it turns out that you can do some pretty nifty things by scripting right in Google sheets.

Google sheets can be scripted using Javascript and Google's APIs. For example, adding "hello" and "world" to the two bottom leftmost cells in your active spreadsheet can be done by running a function like this:

function addHello() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  ss.appendRow(['hello','world']);
  }

In general, it's pretty easy to grab, modify, or otherwise manipulate cells from a spreadsheet with simple javascript.

You can also send email from a Google app script. For me this was a big win. I use it for emailing grades to students and also as a poor man's mailmerge. The key call is:

GmailApp.sendEmail(email , subject,msg);

Here's a video walking through sending emails to a list of people from a spreadsheet. The code is underneath.

function sendEmail(to,subject,msg){

  GmailApp.sendEmail(to,subject,msg)
}


function getSheetByName(name){
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheets = ss.getSheets();
  for( var n in sheets){
    if (name==sheets[n].getName()){
     return sheets[n]; 
    }
  }
    return sheets[0];
}

function prepareMessage(name){
  var sheet = getSheetByName("Msg");
  var oldSheet = SpreadsheetApp.getActiveSheet()
  SpreadsheetApp.setActiveSheet(sheet)

  var dataRange = sheet.getRange(1,1,1,1)
  data = dataRange.getValues()
  var msg = data[0][0]
  msg = msg.replace("%FIRST%",name)
  SpreadsheetApp.setActiveSheet(oldSheet)
  return msg
}

function sendGrades(){
  var sheet = getSheetByName("grades")
  var rows = sheet.getLastRow()
  var cols = sheet.getLastColumn()
  var dataRange = sheet.getRange(2,1,rows-1,cols)
  var data = dataRange.getValues();
  for (i in data){
    var name = data[i][0]
    var to = data[i][1]
    var msg = prepareMessage(name)
    sendEmail(to,"Important Grade Info",msg)
  }

}

Using Emacs 40 - Atomic Chrome

Thanks to everyone who voted for topics or commented with suggestions for videos. I'll try to get to them in the coming months.

Today is just a quick hit on Atomic Chrome - an Emacs package and browser extension that allows you to edit web form inputs with Emacs.

UPDATE

I forgot to mention that you can set a shortcut key, at least in chrome rather than clicking on the icon. This makes things much smoother.

All you have to do is:

  1. Go to chrome://extensions
  2. On the bottom of the page you'll see a button to set keyboard shortcuts
  3. Set the shortcut for Atomic Chrome

Enjoy:

On Textbooks

I thought I'd answer Alfred Thompson's recent post on using textbooks. Like Alfred, I've never used textbooks particularly effectively. Even when I taught math I mostly used them as a resource for problems.

I also agree with Alfred in questioning the "flipped class" model or as I like to call it "homework" for reasons similar to Alfred's.

Even back in the Pascal days of APCS getting textbooks was an ordeal in NYC. First, the book had to cover both the A and AB parts of the class since I rarely had budget to buy two books for a class, then they had to be sold by the high school division of the publishing house eliminating many college texts and finally we had to get the books on the "NYSTL list" so we could buy and pay for them.

I finally found a book I liked that covered the full year by Nance and Naps. By then I knew that I wouldn't really work it into the class but I felt that it explained things, the data structures and algorithms in particular very well.

That's one thing I always look for in a text book. If I'm not tightly integrating the text then I want the text to be a worthwhile resource for the student. If a kid doesn't get it in class I want the text book to be a second chance.

When we moved to C++ we moved to Nance and Naps for the language and Nance and Lambert for the Data Structures. Somehow I got the school to fund both books.

Everything changed when the AP class went to Java. I never found a Java based book that covered the data structures in a way I liked but finding a text was a problem even beyond that hurdle.

All of the Java based texts tightly integrated with some project or library provide by the author. It was just like the AP case study. If the case study worked well into your course and the way you taught it was great, otherwise it was a bear to deal with. I settled on Lewis and Loftus which integrated their own graphics library but always as an add on to each chapter rather than tightly integrated.

For my homebrew classes, I've never found a single textbook. The nice thing today is that there are so many resources already available. Tutorials, videos, online practice sites like codingbat and more. There are also a number of authors who make their books available online for free. I use one - Automate the Boring Stuff with Python in one of my classes but I purchased a copy for myself and encourage my students to do so as well if/when they're able to based on economic situation. Usually I can cobble together a good set of resources for the students that are both free and probably superior to any single text book out there.

All of this said, it's important that students have resources independent of the teacher. If you can get a good textbook, that can be it but fortunately, in this day and age we have many great alternatives.

Is Teaching CS Hard?

Last week, Mark Guzdial asked What does it mean for Computer Science to be harder to learn than other STEM subjects? as a follow up to his ACM Blog post this month and the ensuing discussion.

You should read both posts but here's how Mark started off the follow up:

I made an argument in my Blog@CACM Post for this month that “Learning Computer Science is Different than Learning Other STEM Disciplines,” and on Twitter, I explicitly added “It’s harder.”

When you talk about how hard or easy it is to teach a subject you can do so at many levels. college, high school, middle etc.. Since most of my career has been as a High School guy, let's focus there.

I do in fact believe that it is hard to teach CS, at least to do it well but is it harder to teach then other STEM subjects?

Let's see how we're doing in those other subjects. I took a look at the New York State Regents Exam results from 2015/2016. I'm certainly not a believer or supporter of standardized tests but they're a convenient measure for the sake of this post.

Only 58% of test takers scored 65 or higher on Integrated Algebra and only 41% scored 3 (proficient) or higher on the Common Core version with far more students taking the Common Core exam.

Higher performing schools frequently offer Algebra in 8th grade but in the lower performing districts, students frequently take it over the course of two years.

The Geometry regents boasts a passing rate of about 40%. Trig does a little better.

The science regents exams look a little better but overall, these are not terrific results, particularly on the classes that are required for graduation.

It seems that those other STEM fields aren't so easy to teach after all.

On the other hand we have CS. If you listen to all the press releases and media attention on APCS-P from this past year it would seem that CS is easy to teach and learn. We have all these high school students mastering a "college level" course and we can prepare teachers to be master CS instructions with just a bit of in-service professional development.

The truth is, of course that CS isn't easy to teach. When you're a summer or after school program or even an elective it's easy to create a fun experience using shiny tools to self selecting students but when you have to take everyone and prepare many of them to succeed in more advanced classes we have a real challenge. We really should be looking at retention in more advanced CS classes rather than just passing the intro ones. Most students won't go beyond the intro class in any given subject but the ones that do must be well prepared. Unfortunately, I fear that the people who will get the blame when kids drop CS later on will be the teachers of the more advanced classes regardless of who, if anyone, is at fault.

Teaching CS is hard. It's brand new and very open ended. When programming a solution to a problem kids start with a blank slate. They don't have the library of patterns, vocabulary or idioms needed to build solitions. There are many ways a teacher can scaffold the learning. Code tracing, analogies, Parsons problems and more but the truth is teachers strong in both content and pedagogical knowledge are still in rather short supply and as Mark wrote on his blog the body of knowledge on teaching CS is just not that mature.

On the other hand, Algebra students usually had a first look at some of the topics prior to the class and much of the class can be "learned" through memorizing relatively short procedures and patterns. This might not lead to a depth of understanding but it does get you past standardized tests. On the science side, the Living Environment exam is really just a reading test. On the other hand, we're supposed to start teaching proof to students in Geometry and that's really hard to do.

So, teaching in general is hard and teaching CS is no exception. At least it is if you're doing it right.




Enter your email address:

Delivered by FeedBurner

Google Analytics Alternative