Live data from Hacker News

Ask HN: Do you ever go back and admire a piece of code you wrote?

news.ycombinator.com

251–260 of 267 posts

Re: Ask HN: Do you ever go back and admire a piece of code you wrote?

#251
post #122

Earlier quoted context omitted.

I do this with almost everything I make. The act of creating is an act of achieving an aesthetic you developed in your mind's eye, so it seems reasonable to want to spend some time admiring that aesthetic once achieved.

The thing I can't get over, is that I know a lot of successfull, highly paid programmers who don't care about code at all. It's sad (to me) that they get rich, while not caring about their code.

I suspect that for some of these people, the reason they don't care is that they know it is fairly likely that their code won't last long, regardless of how awesome it might be. They will move on to other projects, possibly other jobs, and/or someone will decide it's time for a rewrite in a new language/framework, or whatever. Or the company will decide to flush their work and move to an outside provider, or to a different tool.

Some people's way of dealing with that is to just not get too attached to their code.

I'm not saying that all code is short-lived. Most developers I know deal with at least some code that's been around since dirt. But there is also a fair amount that gets left behind rather quickly, and neither of those scenarios necessarily has anything to do with the quality of the code nor the suitableness of it to the task at hand.

Not to mention that most of us have had projects we put a lot of effort into, that fulfilled the requirements, and was done on time, only to have it rarely ever (and sometimes never) used by the people who asked for it.

I think it's possible to either care too much about your code (in the sense that you often have no control over what's done with it in the long run, and you need to be able to accept that), or to care too little about it (if you're going to bother writing it, at least try to as good a job as you can under the circumstances).

Re: Ask HN: Do you ever go back and admire a piece of code you wrote?

#252
post #20
post #11

The only thing I have ever gone back and admired is when I wrote the following snippet of code: long time; // no see

Hehe, well if we're going here there are various go-to shell commands / filenames / hostnames I inevitably end up using at some point just for the wry smile: $ PONG=1.1.1.1; ping $PONG $ more cowbell $ cat dog | tee hee And my favourite choice of empty file: $ touch me Also I was fairly please years ago when I briefly re-aliased cd to something that could do "the right thing" (TM): $ cd ... $ cd ..../src/ etc..

LOL - thanks for sharing this. Especially "$ more cowbell".

I am SO gonna steal that.

:-D

Re: Ask HN: Do you ever go back and admire a piece of code you wrote?

#253
post #11

The only thing I have ever gone back and admired is when I wrote the following snippet of code: long time; // no see

I once came across some code, written by a coworker, that consisted of deeply nested blocks. I added a comment that simply contained a URL: // http://photos3.meetupstatic.com/photos/event/4/b/c/2/600_436939394.jpeg I don't know if anyone ever noticed this comment and followed the URL, but I hope they did and were amused. (The code was eventually refactored/rewritten, so the comment no longer exists in the codebase.)

Well, I followed the URL and was amused. So it wasn't a complete loss (even if I never did see the code). Thanks for sharing!

Re: Ask HN: Do you ever go back and admire a piece of code you wrote?

#254

Earlier quoted context omitted.

But was this in C?

It was in Java...but I C where you are going with this.

Well, actually, the fact that it wasn't in C kinda makes it work even better, from one point of view. :-D

Re: Ask HN: Do you ever go back and admire a piece of code you wrote?

#255
I've never written a single line of code that I liked. I enjoy programming, but I'm a terrible programmer even after... Jesus, thirteen years. Sometimes I'm not totally unhappy with my solutions, but most people here could do a hell of a lot better. Fortunately, that doesn't keep me from getting paid and delivering acceptable work.

Re: Ask HN: Do you ever go back and admire a piece of code you wrote?

#256

Earlier quoted context omitted.

Are they ‘what?’ or ‘wat?’ comments? Maybe that’s the difference?

what, opposed to ‘why’ or ‘how’

No, I understand that part; but, I think of a "what" comment as "incrementing value of X"

a "wat" comment, like the meme, is more of a "this is a really weird blob of code that might be obvious when you break the whole thing apart; but, what it's doing is _this_ this is the implementation of it because we have a complicated data structure that's connecting all these pieces"

Re: Ask HN: Do you ever go back and admire a piece of code you wrote?

#257

All the time. The old joke is about us looking at code we wrote six months ago, and being horrified at what we see. And I've had more than my share of that. But what's ALSO happened, many times, is I look at old code I wrote... and I'm IMPRESSED. Just blown away by the beautiful elegance and power of the abstractions I came up with, the sheer intelligence of the approach, the insight and lucidity oozing from the code…

"Wow, that just like I would have written it!"

:)

Re: Ask HN: Do you ever go back and admire a piece of code you wrote?

#259

Earlier quoted context omitted.

I'm struggling to understand how this is special... isn't it basically just the normal 2-argument range function, but with date instead of int? def range(start, end): while start Or is it more about the beauty of the algorithm than this specific code?

I think it's just the relative simplicity of code that handles date logic compared to other languages: https://stackoverflow.com/questions/4345045/javascript-loop-... I hate dealing with date math, but I have to admit that Python makes date math much more elegant. I've written the functional equivalent of the OP function several times, and it's just so nice to be able to loop over dates just like they were any other…

Python's date handling is meh. Some languages have dates as first class primitives and are a dream to work with.

Re: Ask HN: Do you ever go back and admire a piece of code you wrote?

#260

Earlier quoted context omitted.

Try go :) it's got the speed and "here's how the machine works" of C plus a) batteries included for all the modern things, and b) excellent multi-core scheduler. On the grandparent, I never much wrote a ton of C and then compiled, did more "skeleton of the app/lower level bits/stich them together" incremental stuff. So lots of compiling and testing along the way. Not quite Lispy but Lispy for C.

I have, and I do use it for projects (and plan on using it for more). But I also need C for things that require certain performance I'm unable to get out of Go.

Use Rust, then. Rust is like Go, except its binaries are small and fast (except string formatting, which is very runtime, horribly bloated and merely "fast-ish"). Anything C can do, Rust can do better (the string formatting excepted).
Post reply on HN