Live data from Hacker News

Programming: Doing it more vs. doing it better

kevinmartinjose.com

201–210 of 223 posts

Re: Programming: Doing it more vs. doing it better

#201

Earlier quoted context omitted.

> People who want to write "beautiful code" are not role models, don't listen to them. They are vain and not productive. People who push "mostly working" code are hell on earth. Sure you spend 5 hours less on it right now, but it's going to cost literal days or weeks down the line. How many times have I seen developers push some "good enough" code that they didn't discuss with anyone because it looks good to have XXX…

> People who push "mostly working" code are hell on earth. Sure you spend 5 hours less on it right now, but it's going to cost literal days or weeks down the line. Wildly exaggerated, but I'll bite: it's still better to save 5 hours while you are bleeding money (before your product works) and spend 1 week to improve the "beauty" of your code while it's already paying your salary. > “Programs are meant to be read by h…

> Emotional and mental cost to the programmer is of less importance.

Only if you want it to be like that.

It's as if an assembly worker from 1930 was telling his mates that working 90 hours a week and wasting his health for a few $ is ok because it's good for their bosses.

Might be ok if you're the #1 in a SV startup, sure, but everywhere else I doubt it'll take you very far.

Re: Programming: Doing it more vs. doing it better

#202
post #153

Earlier quoted context omitted.

I despise this kind of mentality which tries to demonize someone's passion to actually write a beautiful code. This kind of mentality takes away "the human factor" from the working environments turning IT jobs into delivery driven factories. I for one need to enjoy my work to actually be productive. And don't get me wrong - I understand that product people need to deliver products and they enjoy doing their diagrams…

> meaning - correct, performant, maintainable, understandable, clever and so on My favourite part of this is how often these criteria are essentially at odds. - Understandable *and* performant? - Clever *and* maintainable? But, you know, I'm also bad at all this so maybe it's just me :p

IME it's you (but /Pace/, no criticism intended, it may be that my area of databases + business dev allows this more easily than yours).

Part of it is using the tools others aren't aware of, so simple things become simple (counterexample on codinghorror, someone not knowing that XML has libraries to parse it, and started parsing it manually with regeps. From my own experience taking over a web-scraping project, I used XSLT where they previously used regexps). I have plenty of other examples of people doing things the hard way because they didn't read the docs.

Part of understandability is recognising a simple solution exists instead of a tangled ball. The simple SQL solutions are often most efficient, with tweaking, and the most understandable (which does NOT get you out of writing comments, BTW!)

Performant? The easiest code to optimise is that which is well written and nominally 'less than efficient'. This separation of layers allows me to put in new layers easily as I can see what's going on. Example: for an SQL + pascal product I got a minimum 10X speedup on the GUI, which really made a huge difference to the users, by sliding in a 3rd layer between 2 existing layers. It was simple and quick to do (3 days).

Other example: if someone had thought for a moment about creative use of SQL indexes they'd not have written another complex - and slooooooow - feature in the product I just mentioned.

So IME understandable = clever = performant = maintainable surprisingly often.

(disclaimer: I'm no coding god, I make plenty of mistakes too).

Re: Programming: Doing it more vs. doing it better

#203
post #13

Earlier quoted context omitted.

Interesting view. I'm learning, with about 8 months worth of knowledge and experience, and this is useful. Did you notice any skills/traits in those people who were "unbelievable" in those 3 years? For instance, did they do "test driven development"? Also, did they keep good log habits?

No, they didn't do the modern day ceremonies around programming such as TDD. What they did was code a lot. Code a lot of different things, knew where to draw the line and "finish" up their projects. Maybe out of their many projects, they really took one or two all the way and polished, but most were fast, done and the lessons learned. ... They also stayed deep in the language and didn't rely much on frameworks & libr…

I like your notes on varying programming languages yet staying deep in one. I think this is turning into a consensus among the folks here who've been kindly offering advice.

And will consider this: "Maybe out of their many projects, they really took one or two all the way and polished, but most were fast, done and the lessons learned. ... They also stayed deep in the language and didn't rely much on frameworks & libraries."

This is also useful: "Code your own text editor Code your own interpreter". I find these types of things intrinsically motivating, thank you.

Re: Programming: Doing it more vs. doing it better

#204

People who want to write "beautiful code" are not role models, don't listen to them. They are vain and not productive. Listen to the people who finish correct programs on time, or mostly working prototypes in hours or days. How to recognise the former group: they obsess about coding and other standards and processes, plan and discuss too long how to implement something (plan what to implement, do it, then improve it…

This, 1000x times. Experience throwing code does a lot in my experience (~7 years programming, 4 professionally). Learn the best practices, and know when they break. Heck, purposely break them and see if/when/how they bite you back! A very good rule of thumb to recognize the former group is to simply ask "when is this best practice not valid"? This will tell me whether they are consciously proposing it or mindlessly…

Interesting view. In your experience, how did you learn about the best practices - and, then, consider asking when that practice is not valid?

It looks like you add purposeful breaks, experiment, and then see what happens. I wonder if you also talk with your colleagues, self-reflect, think about the big picture rather than just the task at hand when you're doing this?

Re: Programming: Doing it more vs. doing it better

#205
post #153

Earlier quoted context omitted.

I despise this kind of mentality which tries to demonize someone's passion to actually write a beautiful code. This kind of mentality takes away "the human factor" from the working environments turning IT jobs into delivery driven factories. I for one need to enjoy my work to actually be productive. And don't get me wrong - I understand that product people need to deliver products and they enjoy doing their diagrams…

> meaning - correct, performant, maintainable, understandable, clever and so on The only little nit-pick I have here is the use of the word "clever". Maybe you and I define clever differently in a software engineering context, but to me, "clever" is a dirty word in programming. For me, "clever" means undefined behavior, one-off hack, difficult to parse, shortcut, etc. The difference between "clever" code and "bad" co…

For me clever is when someone is facing some problem and comes up with clever solution. Something that for example reduces complexity from O(n^2) to O(n) due to some smart idea. But I agree that elegant is another quality which can be added to the list :)

Re: Programming: Doing it more vs. doing it better

#206
post #8

Someone who's been programming for three years is still a beginner, even though based on what he wrote here, Kevin is almost certainly a lot better than I was when I'd been programming for only three years. I do find that a lot of programming stuff that used to be hard is easier for me now that I've been progrmaming for 38 years. But that doesn't mean I spend all my time doing things I can do without thinking, and it…

> Also, though, what counts as "big" has changed for me. What I can hack together in an afternoon now might have taken me a week ten or fifteen years ago. So I can explore alternatives with less risk, in a way. Could you elaborate on that? Maybe with an example of something that would fall into this "hack together in an afternoon" category? I am still a beginner with less than 5 years of professional experience, but…

Well, one night in 2007 I wrote a 3-D rendering engine in JS http://canonical.org/~kragen/sw/torus and one Friday night in 2013 I wrote a raytracer in C http://canonical.org/~kragen/sw/aspmisc/my-very-first-raytra.... It took me until almost 4 AM, at which point I had reflection, color, and Lambertian shading from a tabular ASCII scene file format; a few days later I added procedural textures, a K-V-pair scene file format, specular highlights, and some more textures.

One night last year I wrote http://canonical.org/~kragen/sw/dev3/usql.py, a toy SQL database supporting queries that join up to two tables. I would have implemented more of SQL, but I had set myself a two-hour time limit, and there isn't a parsing engine in the Python standard library.

Last month I wrote a Mandelbrot set renderer in Python, but it was slow, so I rewrote it in Lua using LuaJIT, which made it extremely fast. That took less than an hour, but I subsequently added some more features to it, so it represents maybe a few hours of work now: https://gitlab.com/kragen/bubbleos/blob/master/yeso/mand.lua

(That one will only run on Linux right now, or MacOS with X11, because it uses my GUI library Yeso, which I haven't ported to Quartz or GDI yet. The others are portable.)

aspmisc, dev3, and bubbleos are Git repos you can clone if you like. You may need to append /.git to the URL.

Those were all purely programming exercises, not drawing on frameworks and libraries and whatnot beyond the very basic stuff that comes with the languages in question (and, in the Mandelbrot case, the Yeso library), but of course I've also learned how to use a bunch of tools; I can spin up a new React project with an Express server and get something working in an hour or two, I can hack together a visualization with D3 in minutes, I can spin up a test server on Bithost in a few minutes, I can import stuff into SQLite or LevelDB in a few minutes, I can write a website scraper using Beautiful Soup and urllib2 in half an hour or so, and so on. So if there's something that's easy to do in SQLite, I don't waste my time doing it the hard way in Python, and vice versa.

I think there's enormous value in investing in tools like Docker to reduce the overhead in spinning up a new environment. There's also a lot to be said for improving low-level skills like typing, text editing, and writing and debugging simple code. It allows you to devote more attention, and more uninterrupted attention, to higher-level tasks like system design. But mostly programming more productively is not about writing code faster, although that sure helps; it's about writing less code.

Re: Programming: Doing it more vs. doing it better

#207
post #8

Someone who's been programming for three years is still a beginner, even though based on what he wrote here, Kevin is almost certainly a lot better than I was when I'd been programming for only three years. I do find that a lot of programming stuff that used to be hard is easier for me now that I've been progrmaming for 38 years. But that doesn't mean I spend all my time doing things I can do without thinking, and it…

While 3 years isn't much from a whole career perspective, I do believe those may be the three most important years, where you learn the most etc; I'm at about 10 years now, and don't feel like my level has significantly improved since then. I mean sure, I'm more experienced now and know more languages etc etc, but it's not like I'm 10x more productive or smart or better than I was 10 years ago.

Being 10× more productive doesn't always feel like being 10× more productive. It can mean spending two days on a project which, seven years ago, you would have spent five days planning out, two days implementing, and eight days debugging; or you would have spent five days planning out, eight days just beginning to implement it the wrong way before someone pointed out that there was a library that already did what you needed, and then two days implementing the actual solution. It can look like half-assing things that need to be half-assed and thoroughly solving things that need to be thoroughly solved, instead of thoroughly solving everything. It can look like writing unit tests for your code that find the stupid bugs right after you write them when it's easy to fix them, instead of spending a bunch of time debugging the whole system when you do an integration test. Conversely, it can look like having less unit tests and therefore less code to change when you need to change something.

In the original "10×" study, some programmers were never able to finish the assignment at all (within the allotted time); probably they either couldn't figure out a workable attack on the problem (like Ron Jeffries on Sudoku: http://ravimohan.blogspot.com/2007/04/learning-from-sudoku-s...) or they wrote their code as cleverly as possible so that debugging it was beyond their ability. The 0.1× programmers in the study were the ones who almost didn't finish in the time that the researchers gave them. Presumably you can think of problems that you know how to solve now that you didn't know how to solve in any finite time seven years ago; presumably also you've learned how to avoid introducing bugs that you would have introduced then, costing you, again, unbounded time to diagnose.

Or maybe not. Maybe I just learn slowly. I've certainly worked with programmers with only a few years of experience who were better than I was; maybe they'd already hit their performance ceilings. But I doubt it.

Re: Programming: Doing it more vs. doing it better

#208
post #8

Someone who's been programming for three years is still a beginner, even though based on what he wrote here, Kevin is almost certainly a lot better than I was when I'd been programming for only three years. I do find that a lot of programming stuff that used to be hard is easier for me now that I've been progrmaming for 38 years. But that doesn't mean I spend all my time doing things I can do without thinking, and it…

Someone programming for 3 yrs is not a beginner, There are people programming at 3 yrs that are experts and will run circles around you and your 38 years. Some people really have the talent and put in the work to get good. In 2019, the mentorship is available via means of books, blogs, MOOC, youtube videos, conferences. What some folks can achieve in 3 yrs these days is really unbelievable. P/S, I have been hacking a…

> There are people programming at 3 yrs that are experts and will run circles around you and your 38 years.

Yeah, there are; I've had the privilege of working with some of them. Probably they're even better now than they were then, though.

Re: Programming: Doing it more vs. doing it better

#209

I think one word would shed light on such anecdotes: deliberate practice. Countless literature and researches have pointed out that simply doing more would not bring much improvement but find out what is missing and practice it to perfection then move to another weaknesses is the best way to achieve top performance, be it in sport, in music or other fields. Like someone who want to learn chess; simply plays a lot eac…

On that note, what do you think deliberate practice looks like for programming and software engineering?

Re: Programming: Doing it more vs. doing it better

#210
I'm surprised the author's takeaway from the Joyce quote was disillusionment. He's actually quite close to the secret sauce. I don't think writing more code and ending up with less code are at odds. In fact, I think you need to write more code to end up with less. You write more code in order to understand the problem space. Once you understand the problem space, you can then refactor everything that you wrote into more concise code that more accurately reflects the problem.

James Joyce wrote Ulysses at the rate of a hundred words per day if you only consider the finished product. However, I doubt every word that Joyce wrote ended up in Ulysses. I'm sure he did quite a lot of cutting and rewriting.

The takeaway from me from the two quoted stories was that quality and quantity are not at odds, but instead are the yin and yang of productivity. They reinforce each other. The more things you produce, the more patterns you are exposed to which in turn leads to higher quality since experience leads to efficiency, giving you more time to get things right.

Post reply on HN