Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

A friend of mine asked me to help him with piece of code. I looked at it and it was all over the place, nest of ifs and loops. To understand it would take me hours so I rewrote it from scratch. Nothing really fancy or overly clever just simple, minimal, straightforward code that followed the assignment. When I showed it to him I discovered that mine had exactly 10x fewer LOC (250 his vs. 25 mine). That wasn't my intention it just happened so. And I know programmers who are 10x more productive than me.


How do they write half a line of code?


maybe

if (x < 10) {

becomes

if (

   x < 10 ) 

  {
I mean yes, in many languages you can write all your code in one line or split it up in all sorts of ways if you prefer, but there is sort of a natural line and an unnatural line for any particular language that is an attribute of its commonly preferred formatting.

on edit: reformatted


That's still not half a line of code. Your first example is 1 line and your second example is 3 lines.

If a 10x developer can solve the problem in 1/10 of 25 lines that means they need to write 2.5 lines. How do you write .5 of a line?

It was meant to be a joke but now it's making me annoyed that 3 people's replies have failed to grasp that you can't write half a line of code given that even a single character counts as a line. Surely that's obvious. Do people on HN not understand what the LoC metric is?


well I've certainly experienced my fair share of people on HN not understanding things, case in point you me now.

I thought it would be obvious what I said was a joke since it is absurd, but now I'm getting annoyed at the person who didn't understood my sense of humor.

However there are obviously also different ways you can write half a line of code, for example I can write half of any specific line of code you give me (allowing of course for rounding up or down when that line is an odd number of characters in length)

Finally there are actually different ways you can count lines of code, generally it is considered best to use logical lines of code http://codebetter.com/patricksmacchia/2007/10/03/how-do-you-... which it seems is not your definition, at any rate it is not necessarily the case that a single character counts as a line depending on what way you are counting lines.

Otherwise thank you for the education, I consider the hours I have spent on HN golden hours, and the lines

of com

ment

time well

spent.


Maybe on Windows if you omit half of the CRLF ;-)

Oh wait, then it’s a Unix komme or a Mac line. Bummer...


A library call? )


shell script to do the same thing?




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

Search: