Hacker Timesnew | past | comments | ask | show | jobs | submitlogin
Want to see how efficient your code is? Have it refactored. (refactormycode.com)
37 points by auston on May 23, 2008 | hide | past | favorite | 13 comments


A lot of the refactors I see being voted most popular are optimizing only for LOC not speed or clarity.

I would recommend putting a higher focus on the last two to the users of the site than the first one.


Many of the submissions seem to have code with lines a mile long. Maybe it's less of an issue nowadays with high-res, widescreen monitors, but I find code that stays within around 80-100 columns to be most readable. Plus it's easier to peruse when you end up seeing the code in other, non-editor environments (terminal, source control, browser).

Does anyone actually prefer longer (100+) lines over LOC? Maybe it's a Windows thing. I know I started to become stricter about line length when I moved to OS X (and started using the command-line more often).


Indeed. Creativity can thrive within boundaries: look at what Shakespeare did with the sonnet, or Beethoven with the sonata. Limiting yourself to 80 characters enforces discipline and serves as a valuable constraint on code: always readable, never verbose.


Maybe it's an IDE thing. I like a skinny column of code next to something else -- either another skinny column of code (maximized gvim, one vertical split) or Firefox with some documentation/reference in it. Firefox and most IDEs seem to want the whole screen, especially on a 1280-px-wide or smaller display.

I can strip the stylesheets off of gratuitously spread-out web pages with Greasemonkey, but most IDEs seem to require enough screen real estate for, um, stuff, that a window with 80 columns of text still takes up more than half the screen.


Newspapers have known for ages that shorter lines are easier for the eyes to follow. I try to stay under 80 lines, with 100 being my max. It helps me to read and comprehend better.

Protip: `less -S` unwraps lines so you can read a file in its original format. The arrow keys let you pan left and right.


I usually write Lisp in 120 columns. I don't actually put very much on each line, but my code tends to be very deeply nested so it finds its way to the right margin rather quickly. Twenty consecutive close-parens is not unusual for me.


I have the opposite experience. Lisp puts the operator on the far left, and has no penalty for a newline, so I find it much easier to keep lines shorter.

In Algol-based languages, I end up with "something_something [op] something_something" and then if I need to do something else, my next line starts 20 chars from the left edge, to line up with the op. So I have to choose between really long lines, or really short identifiers, or breaking one expression into several using temporary variables -- all of these make me feel dirty.


I would agree, but I think there's a common goal among programmers to come up with the most "clever" solution to a problem. It shouldn't be the focus, but it seems a lot of the time when I see a 100-line function distilled down into 5 lines I have this overriding assumption that it's just... better. I've always known this is a faulty assumption and if I know the code will actually be used and needs to be fast I will test it, but there's this sort of sense of accomplishment that comes along with coming up with really elegant, albeit perhaps unreadable and less performant, solution to a problem.


Very cool idea, and nice, clean implementation. I have wished for something like this before without knowing this was what I was wishing for. Looks like a better solution than pasting into IRC chats.


For pasting code to IRC you probably want a pastebin.

http://www.pastebin.org/


true...

i wish it were a bit more structured and let you view subsequent submissions as diffs of previous ones...

very cool concept though, i agree..

perhaps as someone mentioned above it should have three rating possibilities, clarity, performance, loc.


I like the idea, i think its a wonderful way for programmers to come together and collaborate. I do wonder how different this would be from any other programming forum except being better looking?


Perhaps, because it is focused on a single problem?




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: