Live data from Hacker News

Lessons from teaching CS 1: Code fast

imprompt.us

11–20 of 40 posts

Re: Lessons from teaching CS 1: Code fast

#11
I've been thinking some about the idea of coding fast, or coming up to speed on new languages quickly.

From that viewpoint, I'm wondering about what the minimal set of language features you need to have committed to memory to enable you to code fast. These are the pieces of code that without which you can't make even a passing claim of competency in a language. I'm thinking about the crib sheet of functions/definitions/language features you have to have ready to go in your toolbox so you can code fast. It's the stuff you'd want candidates to demonstrate knowledge of in an interview as well and be able to apply at least in conversation to a new problem.

I'm interested in figuring this out for a multitude of reasons, not least of which is retention of knowledge related. Years ago, I hacked in C for performance reasons in the domain I was working in Lots of pointer junk, tiling of data (interleaving of row and column data to blow up memory bottlenecks), and a healthy dose of bit twiddling to make it all work nicely. I realized not too long ago that most of these skills had faded due to lack of use.

I'm playing some with spaced repetition software for memory training (think SuperMemo and Mnemosyne) and thinking about plugging in those pieces of programming languages that you have to be ready to throw out to code fast in a language. I'm just testing for now, but I think I might even try throwing something like the question/answer pieces from The Little Lisper in there for fun. Kind of a daily brain teaser.

Since I spend most of my time at work hacking SQL, it's pretty easy for me to stay fresh and also identify the minimum set of concepts and ideas you need to even think you can write halfway decent SQL: SELECT,INSERT,UPDATE,DELETE,JOINS - all types, ansi sql functions - including analytic functions, nulls, subqueries, boolean logic,etc. It's a non-trivial set of stuff to have in your head so you can think correctly about problems.

To make it even more fun, you need to have a meta-sense of when to apply what tools and languages? When do you want a RDBMS versus rolling out hadoop? What data do you want to send to your web app so your users can muck around with it - which means understanding enough Javascript to be able to provide them with some intuitive tools to munge data there.

I'm pushing towards the idea of internalizing not only the specifics of a language, but the idea of what programming language and tool fits a problem best at any given time.

Software folks get all the best toys to think about . . .

Re: Lessons from teaching CS 1: Code fast

#12

I agree... personally I think you should not be allowed to code unless you can type somewhere around 60-70 wpm. It is only with extreme mental effort that I can watch someone hunt-and-peck out 5 lines of code fiddling with their mouse and looking for the "n" key or the ";". There should be a minimal period of time between when the code appears in your head and you see it expressed on a screen. If you can't type that…

He's not talking about fast typing. He is saying that is a big effort for his students to try out an idea because they have to struggle to find the correct syntax and keywords to express it.

Re: Lessons from teaching CS 1: Code fast

#13

I agree... personally I think you should not be allowed to code unless you can type somewhere around 60-70 wpm. It is only with extreme mental effort that I can watch someone hunt-and-peck out 5 lines of code fiddling with their mouse and looking for the "n" key or the ";". There should be a minimal period of time between when the code appears in your head and you see it expressed on a screen. If you can't type that…

He's not talking about fast typing. He is saying that is a big effort for his students to try out an idea because they have to struggle to find the correct syntax and keywords to express it.

I have to disagree. I would say that anything that helps get to a testable solution faster helps make one a better coder. This could be by saving time having to look up syntax, but it could also literally be just typing twice as fast as somebody and being able to iterate through solutions twice as fast as the next guy.

Re: Lessons from teaching CS 1: Code fast

#14
post #2

It's not just prom teaching CS1, it's also from teaching algorithms and OS and every other course I've taught. A willingness and ability to code fast and fail fast is universally applicable and useful.

Hi, Peter! I'd fix my Hacker News headline but the edit link has expired. (Changing the title it to emphasize exploration rather than speed would have been nice too, since it seems like a lot of people are arguing against points you didn't make.)

Re: Lessons from teaching CS 1: Code fast

#15
post #7

I find myself disagreeing on two fronts here: First, in the context of CS1, in my experience, the assignments just aren't long enough that speed writing code matters. 20-50 lines of C just isn't that much typing. Second, in the world of real work, the hard problems rarely boil down to how fast you can get the thoughts out of your head, through the keyboard, and into the computer. I often spend hours or even days pour…

Reading the post again, it seems to me it isn't about raw speed in producing a finished product; it's about the ability to explore a problem space by writing small throw-away trials, before you know how the result should look. Physical speed is just one part of this; I'd say it's really about fluency. Do you use code as a medium for thought and expression, or do you have a separate step where you translate your ideas into code from some other form?

This is a real distinction I see even in experienced developers, and in that case I think it's more a matter of habit and practice, rather than skill. Some of my co-workers have an ingrained habit of sitting down at a REPL and trying out several ways of doing things, whenever they're thinking about a problem. Others have apparently never tried this way of working, even though they are probably quite capable of it.

Re: Lessons from teaching CS 1: Code fast

#16
post #7

I find myself disagreeing on two fronts here: First, in the context of CS1, in my experience, the assignments just aren't long enough that speed writing code matters. 20-50 lines of C just isn't that much typing. Second, in the world of real work, the hard problems rarely boil down to how fast you can get the thoughts out of your head, through the keyboard, and into the computer. I often spend hours or even days pour…

You're right this type of coding doesn't work well in maintenance. However, when exploring a problem, fast coding is phenomenal. Once I discovered I could write code quick enough to do experiments, and that the whole iteration took less time than reasoning out, planning, doing back of the napkin style calculations, and still maybe getting it wrong, I moved to exploratory programming. This is where fast coding shines. Further, a lot of infrastructure can be built up this way, helper functions, I/O frameworks, etc can get massaged into a good solution.

At the end, there is still refactoring, and maintenance (particularly by people not intimately familiar w/ the codebae) may need some more thought, but the initial build... fast is good.

Re: Lessons from teaching CS 1: Code fast

#17
post #7

I find myself disagreeing on two fronts here: First, in the context of CS1, in my experience, the assignments just aren't long enough that speed writing code matters. 20-50 lines of C just isn't that much typing. Second, in the world of real work, the hard problems rarely boil down to how fast you can get the thoughts out of your head, through the keyboard, and into the computer. I often spend hours or even days pour…

Reading the post again, it seems to me it isn't about raw speed in producing a finished product; it's about the ability to explore a problem space by writing small throw-away trials, before you know how the result should look. Physical speed is just one part of this; I'd say it's really about fluency. Do you use code as a medium for thought and expression, or do you have a separate step where you translate your ideas…

Yes! That is the kind of speed and skill to which I was referring. The ability to use code as a medium for thought and exploration rather than just viewing it as a final product.

Re: Lessons from teaching CS 1: Code fast

#18

I agree... personally I think you should not be allowed to code unless you can type somewhere around 60-70 wpm. It is only with extreme mental effort that I can watch someone hunt-and-peck out 5 lines of code fiddling with their mouse and looking for the "n" key or the ";". There should be a minimal period of time between when the code appears in your head and you see it expressed on a screen. If you can't type that…

He's not talking about fast typing. He is saying that is a big effort for his students to try out an idea because they have to struggle to find the correct syntax and keywords to express it.

Also that they refuse to experiment by trying out ideas which may or may not work. Instead, they bang their heads and don't type a lick until they have found what they regard as "the" solution. Which is often not even "a" solution, but because they haven't been coding their ideas as they go, they have no way of finding that out until they slowly and painfully implement their idea and it doesn't work.

Re: Lessons from teaching CS 1: Code fast

#19
This is like asking an un-experienced driver to drive fast. Or an un-exprerience scuba diver to go deeper.

I remember that I didn't code fast in my CS1 classes. The reason was because it was scary. The compiler and all syntax errors seemed cryptic.

Now one of the goals of the class should be to make students not afraid of trying things out. To get there they have to understand the tools and the basics.

Having a good langauge + compiler/interpreter definetly helps. For example, Python's REPL is a way to try things fast. Especially when used with something like ipython, where you can explore an object's methods as you type.

C/C++ and gcc is not so great in this respect. You get a segementation fault, and the next thing you do is pepper code with print statements or fire up gdb. Now they have another problem to solve -- how to use gdb. Very useful, but perhaps not for someone in CS1, unless CS1 as a filter and its purpose is to scare everyone away.

Re: Lessons from teaching CS 1: Code fast

#20
post #2

It's not just prom teaching CS1, it's also from teaching algorithms and OS and every other course I've taught. A willingness and ability to code fast and fail fast is universally applicable and useful.

Hi, Peter! I'd fix my Hacker News headline but the edit link has expired. (Changing the title it to emphasize exploration rather than speed would have been nice too, since it seems like a lot of people are arguing against points you didn't make.)

Hi Matt! No worries. Thanks for posting this to HN! It's always nice to feel like I am not just shouting into the void, but it feels too self-promoting and vaguely spammy to post my own stuff. So I've been very glad that people (both here and on Facebook - I must figure out how to unify comments) have found this interesting.
Post reply on HN