Live data from Hacker News

"My current theory is that programming is quite literally writing."

ask.slashdot.org

51–60 of 199 posts

Re: "My current theory is that programming is quite literally writing."

#51

Programming isn't about writing. It's about logic. It's a series of instructions for a computer to follow. The old 'write down how to tie shoes' or 'write down how to make a peanut butter and jelly sandwich' projects show just how hard it can be to pin down exactly what needs to be done to do seemingly simple tasks. The writing is merely how to you transmit the logic.

Unless you're designing your own ICs and then programming them in machine code, there's some amount of logic and knowledge built-in already. I don't have to explain to the computer how to add two numbers together, or how to take a square root, or sort a list. It is necessary to understand the vocabulary that the computer already has. That's what OP meant by learning idioms: I can either painstakingly describe how to make a sandwich, or I can just say "make a PB&J" and you know what I mean.

Re: "My current theory is that programming is quite literally writing."

#52
post #44

Earlier quoted context omitted.

Uniformity in code is bad - it tells you that there's a common concern or pattern which should be factored out. Uniformity in code style is essential, the same way it is for prose.

Is it? In prose you say "first he rushed to the exit door, then he leaped down the stairs, finally he ran to get the train" while in programming it is better to write socket.close(); window.close(); file.close()

Better prose is:

"He rushed to the exit, leaped down the stairs, and ran for the train."

Better programming is to factor out the action:

    [socket, window, file]*.close()

Re: "My current theory is that programming is quite literally writing."

#53
I actually subscribe to the theory put forth in Structure and Interpretation of Computer Programs by Abelson and Sussman

http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-9.html#...

Essentially, "computer science" is a myopic name for what is really "process studies." It just so happens that defining processes to run on computers is forwarding the field more than any other. But in the distant future we will all understand the field to be about abstractly defining processes i.e. a series of repeatable steps to accomplish a task. Which would be independent of the mechanism used to execute the process.

Therefore programming is the act of defining a process. And programming languages are what we use to define them.

It is covered fairly intuitively in the first few minutes of the SICP video lectures as well:

http://video.google.com/videoplay?docid=5546836985338782440

Re: "My current theory is that programming is quite literally writing."

#54
post #44

Earlier quoted context omitted.

Uniformity in code is bad - it tells you that there's a common concern or pattern which should be factored out. Uniformity in code style is essential, the same way it is for prose.

Is it? In prose you say "first he rushed to the exit door, then he leaped down the stairs, finally he ran to get the train" while in programming it is better to write socket.close(); window.close(); file.close()

Analogies are like shopping carts: if you push them too far they don't work well and you have to lubricate them.

Re: "My current theory is that programming is quite literally writing."

#55
post #44

Earlier quoted context omitted.

Uniformity in code is bad - it tells you that there's a common concern or pattern which should be factored out. Uniformity in code style is essential, the same way it is for prose.

Is it? In prose you say "first he rushed to the exit door, then he leaped down the stairs, finally he ran to get the train" while in programming it is better to write socket.close(); window.close(); file.close()

[deleted]

Re: "My current theory is that programming is quite literally writing."

#56
post #16

Most code sucks because we have the fluency equivalent of 3 year olds trying to write a novel. Let's get a little more specific... Most code sucks because the programmer: - didn't name his variables what the really were - didn't understand variable state - didn't understand variable scope - didn't understand the basic concepts of iteration - didn't understand any of the algorithms he needed - wrote the same lines of…

The worst code I've seen is from programmers who had no mental model of what they were doing, just changed things at random until tests passed.

The worst writing I've seen:

* is ungrammatical to the point of incoherency

* loses its train of thought mid-sentence and talks about something unrelated

* is full of irrelevant details

* simply ignores everything above the sentence level, producing mere text, no argument, story or whatever it was supposed to be

Not really the same failure modes.

Re: "My current theory is that programming is quite literally writing."

#57
He is exactly right.

As a beginning-programming instructor, my students have little difficulty understanding language syntax and operation - much like the "language lawyers" mentioned. Their recurring problem is not correct syntax, it's internalizing the process of expressing a solution to a problem using that syntax. They have few unto no examples of what a program - a real, functioning, well written program - looks like.

Indeed, programming is writing: it's expressing the solution to a problem using a formalized language. Understanding how the program works is one thing (and yes, all too often this is a problem); a good program also expresses why.

A 3 year old writing a novel won't succeed because, despite the ability to speak, he does not comprehend the process of concocting and presenting the story; all he knows is the minimum needed to just read one. He's not going to write good novels until he reads lots of good novels, and groks the literary structure and process of having and expressing an idea. Ditto programming: students may know the syntax, but they don't grasp the notion of "writing" because they haven't seen any decent examples.

Rosettacode.org may be a good starting place.

Thanks for the article, I may finally have identified the gap in my teaching. Now to find concise examples to fill it with, as the curriculum does not allocate copious time for reading lots of coding examples. Anyone have links to good examples for beginners regarding fundamental concepts? I don't mean syntax (I teach that well enough), I mean elegant uses akin to poetry or short stories. IOCCC (a moment of reverent silence for greatness ended) has wonderful examples of cool things in minimal code, but commands obfuscation. Anything akin to IOCCC for good readable nifty code?

Re: "My current theory is that programming is quite literally writing."

#58
post #8
post #3

I think he's right. In college, my CS 2 class was taught by a professor very different than the rest of the teachers there. He wanted all of your programming assignments on paper[1]. Then, you'd get it back with every possible bug marked in your program, and he very rarely missed any[2]. That was the first time in college I thought "I really need to learn how to do that!" I went to a state school, so maybe all you gu…

From what I've heard, professors in prestigious schools aren't any better at teaching. They're hired for their prestige and research ability.

Generally true, although the Engineering department at my university (Waterloo) had a focus on making sure the teachers met a high "you must be this good at teaching bar" so the professors I had were routinely good.

Re: "My current theory is that programming is quite literally writing."

#59
post #16

Most code sucks because we have the fluency equivalent of 3 year olds trying to write a novel. Let's get a little more specific... Most code sucks because the programmer: - didn't name his variables what the really were - didn't understand variable state - didn't understand variable scope - didn't understand the basic concepts of iteration - didn't understand any of the algorithms he needed - wrote the same lines of…

meh. i work at a small shop. most of the code i see that sucks was written by competent programmers under high schedule pressure. the code is clearly not well understood anymore, but if you trace the history you can see it's due to a few years of tacking on features as quickly as possible. the technical debt surely slows us down sometimes, but hey that was a business decision, maybe even a correct one! core business…

I get tired of the "blame the shitty programmers" line of thought. We're all shitty programmers. Yet we all "understand variable scope" and "what the code was supposed to do." Some of us have such a large ego that we think it's others. No, Sancho. It's you.

Code gets complex as hell very quickly. If it was building a house, it would be built in a week and architected on the fly. The person mixing the concrete, who has to know the concrete grade and drying time, also has to know that the upstairs has just shifted and now the load is too much on the center beam.

The reality is that, unless your dealing with tiny apps, that "bad programmer"? It's you.

Re: "My current theory is that programming is quite literally writing."

#60
post #53

I actually subscribe to the theory put forth in Structure and Interpretation of Computer Programs by Abelson and Sussman http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-9.html#... Essentially, "computer science" is a myopic name for what is really "process studies." It just so happens that defining processes to run on computers is forwarding the field more than any other. But in the distant future we will all un…

Essentially, "computer science" is a myopic name for what is really "process studies."

Actually the name isn't myopic at all. Computers are basically entities that follow instructions. There was a time when the definition for the word computer was a person who did computation processes.

Post reply on HN