News for hackers. Stuff that matters.
Re:C++ vs. Lisp by jacquesm on Tuesday May 04, 2010 @12:40PM (#1318539)
Why the extreme focus on lines of code?

That's not the best metric to begin with (I used to think so too, but someone here pointed out that gzipped source is already much better), and besides that, there are other ways of looking at it besides 'size', such as readability.

Re:C++ vs. Lisp by silentbicycle on Tuesday May 04, 2010 @12:57PM (#1318600)
Lines of code and readability are both surrogate measurements for codebase complexity. People focus on lines of code both because it's easy to measure and because readability doesn't go down linearly as codebases increases - there are discontinuity spikes.

Once it grows past a certain size, you need the right kind of IDE, etc. to cope with the conceptual sprawl. People start duplicating functionality because they aren't aware things already exist, minor details that handle historically recurring bugs get overlooked in the noise, it takes much longer for new people to understand the codebase, etc. A 100k codebase is not just ten times harder to maintain than a 10k codebase.

Re:C++ vs. Lisp by gruseom on Tuesday May 04, 2010 @01:08PM (#1318640)
Hold on there. Gzipped source is a terrible metric. It would undercount duplicate code, the worst kind of program bloat.

Not that I'm defending LOC. If one has to count something, counting tokens seems less susceptible to noise.

Re:C++ vs. Lisp by jacquesm on Tuesday May 04, 2010 @01:15PM (#1318667)
That's the whole point. Even if you program in a 'sloppy' way the gzip algorithm will see that and reduce accordingly so you are comparing the languages, not the programmers stylistic elements.

Besides, the article talks about implementing the same algorithm twice in different languages, if you went about that in a completely different way then that would of course be problematic. But when comparing the expressiveness between two languages you'd assume the same major structures would be present.

Re:C++ vs. Lisp by nostrademons on Tuesday May 04, 2010 @02:08PM (#1318835)
Except that some languages encourage sloppy programming. Haven't you ever looked at some Java code where two (or more!) functions do exactly the same thing except that the types are different? GZip would compress that down to almost nothing, but you still have to deal with the complexity, maintenance burden, and API bloat of having multiple versions.

It also doesn't account for language misfeatures that introduce significant additional cognitive burden for the programmer but don't appear much in source code. For example, manual memory management in C++ results in a bunch of "delete x" calls in code, which would get GZipped down to very little, but impose a very high cognitive cost on the programmer. PHP's inconsistency in argument order doesn't show up at all in code length, but also presents a big cognitive tax that sends you back to the reference manual all the time.

Personally, I think that the best metric of language productivity is "The amount of information you have to keep in your head in order to write code as fast as you can type." Unfortunately, that's nearly impossible to measure.

Re:C++ vs. Lisp by jacquesm on Tuesday May 04, 2010 @04:31PM (#1319216)
Doesn't that suggest that such code 'bloat' is actually less important than people make it seem ?

After all, there is not much to remembering that two functions exist for the same type, it's not like you have to remember that there is something 'completely' new, just a routing that is almost the same as another.

Re:C++ vs. Lisp by gruseom on Tuesday May 04, 2010 @06:48PM (#1319691)
If you're right, then there isn't much value in abstracting over repetitive patterns. I'd say that is pretty decisively contradicted by the history of software. Why have functions at all then?
Re:C++ vs. Lisp by jacquesm on Tuesday May 04, 2010 @07:21PM (#1319781)
Because it saves space and because it makes maintenance easier, and it allows you to label a block of code with a meaningful name.

Caching also means that if you execute less code you will have better performance.

The actual instructions can be interpreted serially, in fact when you're 'desk checking' that is exactly what you do, to unwind the way the code is written to the serial stream that the processor is executing.

Re:C++ vs. Lisp by loup-vaillant on Tuesday May 04, 2010 @12:59PM (#1318605)
Why do Gzipped source size is better? I mean, if with the same number of LOC, Gzipped size is different, that means one program is more repetitive than the other, right? I suppose experiments were done to show that Gzipped size was "better" in some sense?

I don't think you can objectively measure readability. It is tightly coupled with concrete syntax, which is highly subjective.

Re:C++ vs. Lisp by jacquesm on Tuesday May 04, 2010 @01:07PM (#1318638)
Because gzip (or any other text compression protocol) tends to reduce the size of the file without reducing the information content. So for instance, if you used longer variable names but the same overall structure or if you split single lines up in to multiple lines (or vv) the gzipped bytecounts would be relatively close in spite of huge differences in source size.
Re:C++ vs. Lisp by eru on Tuesday May 04, 2010 @01:35PM (#1318727)
Yes. Although Gzip still punishes longer variable names, but more or less only once, instead of every time you use them.
Re:C++ vs. Lisp by SapphireSun on Tuesday May 04, 2010 @12:52PM (#1318580)
Would the minimal # of lines of readable code be a useful metric? It's not an easy to evaluate one as you have to actually read the program, but a smaller program should be more understandable than a larger one if they both have approximately the same information density.