Undergraduate programming languages

I read two quite different articles about programming in academia today.

I don’t know Yossi Kreinin, and when his piece Why bad scientific code beats code following “best practices” appeared on the Hacker News front page, I guessed that I probably wouldn’t agree with it. I’m a programmer working in academia who has spent some time trying to find ways to improve the code that researchers write, and I don’t want to be told I’m wasting my time.

But on the whole I agreed with him. A totally naive programmer is going to produce messy, organic, but basically linear code that will usually be easier to understand and work with than the code of someone who has learned a bit of Java and wants to put everything in a factory class. The part I don’t agree with of course, and that I suspect he put in just for the sake of the headline, is that these really are best practices.

I think that one of the hidden goals of a project like Software Carpentry is to teach that the reason software developers appear to be “too clever”, and somehow unreachable for the scientist outside the software field, is that they are being too clever. Programming gets over-complicated; you can learn to write good code (that is, readable code) more easily than you can learn to write bad code the professional programmers’ way.

I also identified with Yossi’s line that “I claim to have repented, mostly”. Most of the code I’ve written in my career is not very good, by this standard. It’s a long path to enlightenment.

The other article was by my friend Christophe Rhodes: What is a good language to teach at undergraduate level for Computing degrees?

A computing degree is an odd thing. Computer science is the theory of how computers and programs work. Computing, as a subject, is computer science plus some stuff about how we should actually program them in order to get a job done. The two are very different.

Christophe breaks down objectives of a computing degree: Think, experiment, job, career, study, society. I’m not very familiar with the study objective, which refers to postgraduate study in a computing department (something I never did). Think refers to teaching students how to think and solve problems computationally. I think he may be missing a step, and it may be useful to separate thinking about how the computer works (“understand”?) from thinking about how the programmer can work.

There is also, of course, the question of how to avoid making your programmer feel too clever.

As an undergraduate in 1990-94, I was taught, in this order, Prolog, C, ML, 68k assembly language, and C++. I also learned some Lisp, though I can’t remember being formally taught it. Prolog, C, and the assembly language were all good bases for what I referred to as the understand objective, getting something out of the history of computing and learning about how computers work. ML was a wonderful introduction to thinking, and it’s no coincidence that I’ve recently been programming in an ML variant as an engaging alternative to work.

The hard one to evaluate is C++. It was a very poor teaching language for object-oriented programming, which is a pity because at the time we learned it, I didn’t get object-oriented programming at all. And we learned nothing about any other kind of programming from it, having already been taught three different high-level languages. So it contributed very poorly to the think objective and not at all to the understand one. It’s an awful language to learn to write clear, reliable code in, therefore bad from the society perspective, and you can (as I have) spend 20 years learning to write it, which is obviously ridiculous, hence you would think also bad from the job perspective.

But it turns out that C++ has been the most valuable job language there could be, because (a) it is resiliently portable: it turns out that write-once-run-anywhere with a virtual machine comes and goes in waves, depending on the whim of the top operating system provider of the time, but compiling to machine code seems to be eternal; (b) it is just about able to ape a number of programming paradigms, so you can get away with adopting a style without adopting another language; and (c) its complexity means that it looks good on your CV. I honestly wish, as a 20+-year C++ programmer, that we could make it so that nobody ever had to learn C++ again, but even now I don’t think that is the case.

The one goal completely unaddressed by my own degree, and almost every language I’ve learned since, is experiment. I think there are two essentials for this: a responsive interactive interpreter, and visual responsiveness, like a graphical scene environment or plotting tools. Most of the things you want to do here are probably growing up in Javascript and HTML5.

I don’t really know anything about teaching, about the actual on-the-ground business of making people learn stuff. So you shouldn’t listen to me on this next bit, I’m just daydreaming. But if I were planning a 3-year computing degree course in my head now, I think I would aim to teach, in this order:

  • Python, for the basics of procedural computing. It’s the cleanest language for doing satisfying simple loops and input/output transformations, and is a sound general-purpose language.
  • Clojure. I’ve decided now that I don’t so much care for Lisp syntax day-to-day, but a Lisp gives you so much to talk about and investigate without getting lost in the specific requirements of the language. And a Lisp on the JVM gives you more depth: advanced students could learn quite a lot about Java without ever actually being taught Java.
  • Some assembly language, probably ARM and preferably with a nice visible bit of circuit board on hand.
  • Javascript, but not aiming to teach the language so much as using a specific interactive framework and with a specific small game-development project to complete. I would probably also use Typescript rather than untyped Javascript.
  • Haskell. As an ML guy it was always my enemy, but Haskell is the functional language that has endured. It’s a follow-on course from Lisp.
  • C++. Because, as far as I can see at the moment, you pretty much have to. But please, give them modern-style pointer ownership and RAII (i.e. avoiding explicit heap allocation).
  • Python again, in a closing course that taught people how best to do things in an actual working environment. Testing, not being too much of a smartarse, etc.

But the odd thing about that set of languages is that, just as with my own degree, you never get a very good dedicated object-oriented language. Maybe Objective-C could replace C++; it’s probably a clearer pedagogical object language, but C++ is everywhere while Objective-C is effectively platform-specific, even if it is a very popular platform.

And be sure to teach them version control.

Oh, and don’t forget to add a double-entry book-keeping course. It’s probably more useful than the programming stuff.

 

T40p, T60p, T540p, go!

I recently replaced my desktop machine at work with a Thinkpad T540p.

T540pThis laptop has had some bad reviews online: terrible trackpad, keyboard a great disappointment, Windows drivers problems, not the proper colour for a Thinkpad (it’s dark grey instead of black), installing Linux will brick it.

I read a few of these and did hesitate. On the one hand, bad reviews and all that. On the other, a matt-finish retina-resolution 15″ screen.

The screen and keyboard are the most important things about a computer. Some people clearly disliked this keyboard, but it’s still a Thinkpad and their reputation is still pretty good. Worth taking the risk, I thought.

So we ordered one with the 3K (i.e. high-resolution) screen and the upgraded keyboard option. I deleted Windows and installed Arch Linux, and didn’t brick it in the process. And it’s a terrific computer. The screen really is splendid. The keyboard is quite heavy, which I like, and is asymmetrically placed, which others seem to have a problem with but hasn’t bothered me. And it’s fast and quiet, tough, and relatively cheap by the standards of new T-series laptops.

This is the first new computer for years I really look forward to using: finally a good successor to the older T40p and T60p series.

There’s one caveat, where I agree with all the reviews: the trackpad is indeed awful. It looks good, it’s got a nice soft smooth finish and it’s fine for moving the pointer, but it has a whole-button design with a nasty twist: you have to push the whole pad about a millimetre before it registers. It’s impossible to do it without moving the cursor, and click-drag is out of the question. If you prefer using the Trackpoint in the middle of the keyboard, well forget that too: the only buttons are built in to the trackpad and consequently useless.

But this is a big laptop, and you’re probably using it in a space where a mouse is OK anyway. Get one of the Microsoft Arc Touch mice that fold flat, and forget the trackpad ever happened.

Proprietary Unix

From 1992 to 1998, every paid job I did came with a Unix workstation on my desk. Admittedly that only covers three employers, but it covers a lot of different kinds of workstation.

In those days, selling Unix software (unless you could dictate the hardware as well) involved a lot of porting, and companies would build up a library of different workstations to port and test on. A bit like Android development nowadays, but much more expensive.

At some point I used, or had in the rooms around me, machines running

  • Silicon Graphics IRIX on MIPS processors (the SGI Indigo and Indy—the natty coloured boxes)
  • Sun Solaris on SPARC (with my favourite keyboards, the Sun Type 5)
  • SunOS 4 on Motorola 68K (immense single-bit-depth mono screens)
  • DEC Ultrix on MIPS, and OSF/1 on Alpha (everyone wanted the Alpha)
  • SCO Unix on Intel x86 (nobody wanted that)
  • Hewlett-Packard HP-UX on HP Precision Architecture (nice hardware, didn’t enjoy the OS)
  • Data General DG/UX on AViiON (not a very likeable machine)
  • IBM AIX on POWER architecture (fast, though I was never into the rattly keyboards)
  • and a System V implementation from Godrej & Boyce of India running on Intel i860

That was up to 1998.

From 1999 to 2014, every paid job I’ve done—other than excursions into Windows for specific bits of work—has come with an Intel PC running Linux on my desk.

I suppose proprietary Unix workstations made something of a comeback in the shape of Apple’s Mac Pro line with OS/X. I think of the dustbin-shaped Mac Pro as a successor to SGI workstations like the Indy and O2: the sort of thing you would want to have on your desk, even if it wasn’t strictly what you needed to get the job done.

Small phones will rise again!

In 2007 Apple launched the iPhone. It was a fancy phone, but big and heavy by the standards of the time.

For the first few years after that, it seemed to be generally accepted that the iPhone was big. Even by 2010 commentators were writing things like “Apple has to expand its product range [with] a nano model … give it a modestly smaller screen than the iPhone 4, ie 3.2 inches.”

In time, other companies started making Android phones with even bigger screens. Perhaps they were working on the hi-fi shop principle that if you play it a bit louder, listeners will think it sounds better. Commentators supplied compelling arguments why Apple would never follow suit: you wouldn’t be able to reach the edges of the screen while holding it one-handed.

In 2011, the Google and Samsung flagship Android phone was launched with a surely ludicrous 4.65 inch diagonal, and iPhone users mocked it (“That’s no moon. It’s a phone”).

Time passed. In November 2013, The Verge opened a review of a Nokia Windows Phone with: “Three years ago, Nokia shipped over 110 million smartphones worldwide. None had a display larger than 3.5 inches. Today the company moves far fewer smartphones, every single one of them with a display bigger than its largest option in 2010.”

In January 2014, Sony launched its Xperia Z1 Compact, a new device promoted as being pleasingly small. It had a 4.3-inch-diagonal screen.

Mobile

The most distinctive feature of a mobile phone is that it’s mobile. You can carry it anywhere.

No matter how engaging the experience or how captivated you are, you’re never going to spend as much time poking at your phone as you do just carrying it around. The main thing a phone has to do is sit in a pocket and shut the hell up without making you constantly aware that it’s there. Small is good.

I recently retired my Nokia 700, a Symbian-powered phone with a 3.2″ screen. With the Swype keyboard it was nicely usable, but Nokia had started shutting down many of the Symbian services. I would love to have been able to keep using that hardware with a different OS, but that’s impossible with these devices.

I’ve been testing a FirefoxOS device and I’d like to be able to switch to that—but the smaller FirefoxOS phones have pretty ropey hardware (nasty screen, awful camera) and the only other one available now is too big. I’d have been happy with a device no bigger than a Keon but with a better screen and camera.

Apple have stayed pretty sensible: the iPhone did go a 3.5 to a 4″ screen, but it got thinner and lighter at the same time. But I don’t want an iPhone.

(I ended up buying a lightly-used Nokia 620, a nice enough phone with Windows Phone 8 and a 3.8″ screen. It’s a year old and I think it’s technically been discontinued in favour of larger models. It’s still a bit too big, but it’s the best I could do.)

 

SoundSoftware tutorial at AES 53

I’ll be co-presenting the first tutorial session at the Audio Engineering Society 53rd Conference on Semantic Audio, this weekend.

(It’s the society’s 53rd Conference, and it happens to be about semantic audio. It’s not their 53rd conference about semantic audio. In fact it’s their second: that was also the theme of the AES 42nd Conference in 2011.

What is semantic audio? Good question, glad you asked. I believe it refers to extraction or estimation of any semantic material from audio, including speech recognition and music information retrieval.)

My tutorial, for the SoundSoftware project, is about developing better and more reliable software during research work. That’s a very deep subject, so at best we’ll barely hint at a few techniques during one programming exercise:

  • making readable experimental code using the IPython Notebook, and sharing code for review with colleagues and supervisors;
  • using version control software to manage revisions and escape disaster;
  • modularising and testing any code that can be used in more than one experiment;
  • packaging, publishing, and licensing code;
  • and the motivations for doing the above.

We presented a session at the Digital Audio Effects (DAFx) conference in 2012 which covered much of this material in presentation style, and a tutorial at the International Society for Music Information Retrieval (ISMIR) in 2012 which featured a “live” example of test-driven development in research software. You can find videos and slides from those tutorials here. The theme of this one is similar, and I’ll be reusing some code from the ISMIR tutorial, but I hope we can make this one a bit more hands-on.

 

On Vodafone

Vodafone UK still haven’t fixed the problem I grumbled about in my previous post. They’ve left me unable to use my primary mobile number for 7 weeks now.

The phone works and has the right number, but it has become detached from the billing account somehow and can’t be topped up, making it effectively useless.

After talking to the friendly folk on Vodafone’s support lines got me nowhere, I switched to dealing with the people in my local Vodafone store. They’ve also been as helpful as they can possibly be. Unfortunately, all that means is that they, rather than I, have been getting nowhere by trying to talk to the technical team.

I did get to see what my account looks like on Vodafone’s systems though. It’s blank. They can search for my mobile number, and the search succeeds, but the record that comes back has nothing in it—even the phone number field is empty.

I also finally managed to get a ticketing number for the problem with their technical team. The ticket has a “72-hour SLA”, but they haven’t managed to update it in over a fortnight despite several reminders from the store staff.

Vodafone’s customer accounts website has been down for most of this week. They had network outages in several areas, last week and this.

Their systems are looking pretty fragile.

(Other networks have their problems too: EE screwed up billing for many, many pay-as-you-go customers last week. But at least they fixed that one fairly quickly.)

Edit: Vodafone fixed this on the 27th January, just after I posted this and tweeted about it. The combination of social media pressure with an actual ticket number for an open technical ticket seems to have done the trick.

 

Vodafone’s fiction of customer service

A couple of weeks ago I switched my mobile number to Vodafone, because they have better signal coverage in my workplace than T-Mobile.

That was a mistake. Vodafone screwed up my account, and their support systems have only made it worse. And it’s strange, because Vodafone work hard at making their customer service look good. Let me explain.

I use a pay-as-you-go phone. Vodafone, like most UK networks, have a system by which topping up by £10 qualifies you for “free” texts and data for the month, with calls charged separately. I don’t make many calls, so that suits me.

cmJust before my main number was ported in, I topped up £10 expecting one of these text and data packs to appear. I got a weirdly-phrased text message in reply (see picture), but no pack.

There seems to be a problemSince then I’ve dealt with at least 15 Vodafone support staff to try to get this fixed. All they’ve managed to do is confuse their accounts system so that it no longer recognises my phone number. Now when I log in on their online system, I get a different number and an error message.

I can’t top up my phone, and I can’t query its balance. I know it’s about to run out of cash, though, because Vodafone have sucked all the money out of my account for text and data charges. Their charges for texts without an active pack are pretty high.

All in all, this is crappy service from Vodafone.

What is strange is that they obviously work quite hard to supply all the trappings of good customer support:

  • I’ve never had to wait ages for anyone to pick up the phone. Every time I’ve used their online support line or phone support, I’ve been put through to a real human in a minute or two.
  • I’ve never had to convince a rude and surly operator that there was a problem here. Always, the person I’ve spoken to has sounded friendly and helpful and prepared to try to sort it out for me.
  • I’ve been able to contact them easily through social media. I tweeted about this problem and got an immediate reply with a secret-looking contact URL, suggesting that if I got in touch, they’d get it sorted right away.

But every time I communicate with someone—including that super-secret contact URL from Twitter—they react as if this is the first they’ve ever heard of it. And although they promise things, those things never happen.

None of Vodafone’s customer support people has ever been able to do anything.

I’ve been told a lot of things. I’ve been told that my problem couldn’t be escalated, because it had already been escalated and so was already in a queue somewhere. I’ve had a support adviser submit a request to fix something, then put me through to another support adviser who told me the problem was that there were now too many outstanding requests.

I’ve been put through to a “technical team” member who told me she would walk over to the technicians on the other side of the office and try to persuade one of them to look at it. And I’ve been put through to another “technical team” member who told me the technicians were in a different part of the country and they only communicated with them by email.

None of the people who told me these have achieved a single thing.

Not only are the support people powerless to fix anything, they also appear to be powerless to find out anything. Every time I’ve asked for an estimate of how long I’d have to wait, I’ve had the same reply: “usually 24 to 48 hours, sometimes as long as 72.” (We’re over 370 hours so far.) The technicians who make the fixes just don’t seem to be answerable to anyone.

Vodafone have some of the friendliest, most accessible customer service people I’ve dealt with. But they’re maintaining a fiction. They can’t provide any service.

These good people seem to be employed solely to give the customer somebody to talk fruitlessly to. They’re a kind of customer anti-service, a customer placation department.