6 ms·
Essentially, only write a program when you finished it completely in your mind already. Good luck with that beyond some Leetcode-sized problems.
by treprinum 3y ago
Essentially, only write a program when you finished it completely in your mind already. Good luck with that beyond some Leetcode-sized problems.
- Icko 3y agoI feel you should be able to keep the high level idea in your head at once; of course not the details. I don't think I've ever completed a piece of code without having a scheme in my head, and where it should fit in it.
- TrackerFF 3y agoDunno, maybe it's some old-school thing from the days of punch cards? My first programming teacher was back in HS, some 25 years ago. The man was a retired software engineer in his 60s. He really pushed that train of thought - to "finish" the code in your mind, on paper, etc. before actually writing it and hitting compile / run. I never took it literally in the sense that you need to think out the entire program, but rather that when writing functions and more overall logic, it is good practice to have it all worked out - rather than just write as you go, and iterate. The latter part is very easy to do these days, as running code is more or less instant...
- jacquesm 3y agoThe edit-compile-test cycle in 1986 on a large mainframe was approximately 6 hours. A laser printer cut that down to 3.5 hours and that was enough to be able to do twice as much in a day. You can't imagine how surreal the difference was between my productivity at home on my micro computer vs what I got paid for. The only way to get anything done at all was to have the program more or less complete in your head otherwise you'd be busy for months on a simple problem. Exploratory programming? Forget about it...
- vsnf 3y agoMy father, a programmer who got his start in the punch card era, was the same way, but I never had the mental capacity for this. I need to start writing before I can concretely hold anything in my mind. The structure of the program, and the output feedback loop into themselves and emerge more or less simultaneously.
- jacquesm 3y agoI'm pretty sure you have the mental capacity, you just don't have a concrete need for doing it that way. It's like having the capacity to walk from here to Paris (wherever you are, pick a large city a few hundred km away). You can do it. But you never will and so you won't know that you actually have that capacity. But if the real need arose and you had no other alternatives suddenly the impossible would be possible.
- bruce343434 3y agoI liked some of the MIT lisp lectures where they show that you compose a program out of simple functions. Think of the input, the out, and then a made up function which transforms it in 2 to 5 made up steps. Then recurse, and think of steps for the steps. Etc.
- fransje26 3y agoYou wouldn't happen to have a link to that lecture series by an chance?
- bruce343434 3y agohttps://www.youtube.com/watch?v=-J_xL4IGhJA&list=PLE18841CABEA24090 https://www.youtube.com/watch?v=-J_xL4IGhJA&list=PLE18841CAB...
- fransje26 3y agoThanks!
- gregorygoc 3y agoThis is not what he said. > There are very different programming styles. I tend to see them as Mozart versus Beethoven. When Mozart started to write, the composition was finished. He wrote the manuscript in one go. In beautiful handwriting, too. Beethoven was a doubter and a struggler, who started writing before he finished the composition and then glued corrections onto the page.
- pareidolia 3y agoHe did say that having successive revisions is doing it wrong. Literal quote (from the translation) "So then you get these version numbers, even with decimals, version 2.6 or 2.7. That's nonsense. While version 1 should have been the finished product." So I think the nuance you are trying to make is unsupported. He did mean: think it through once, write it out once, version 1. Done.
- gregorygoc 3y agoHaving a final output as a single version of the product does not imply anything about the production process behind it.
- usgroup 3y agoI get this now but certainly didn't 20 years ago, and I suspect it will more easily register with functional/logical programming language users. I've heard it referred to as "wholemeal" programming. Take the first step with the last one already in mind, and be circumspect. In practice you still iterate, but a lot less, and pursuit of this ideal does result in a different aesthetic to the solution. I personally have a fetish for short code with minimal departures from the standard library. I "feel" it when its correct, and this strongly conditions how I code as a result.
- nerdponx 3y agoI've never regretted spending time up-front on architecture and design. Of course you aren't going to write the entire program from scratch in your head. But iterating through stages of written descriptions, diagrams, actual code, and unit tests tends to produce a much higher quality result in the end than just banging out and implementation from start to finish. It takes more time at the beginning, but it takes so much less time to clean things up later that the additional time cost at the beginning is usually worth it. Writing prose is similar. it might seem like you don't want to waste time outlining and sketching out ideas, but it's usually easier to assemble something useful from an outline than it is to try to work with a disjointed stream of consciousness. You might get to a point of familiarity and/or mastery where you can do a lot of that work in your head. But that's very different from not doing that work at all.