Live data from Hacker News

500 Lines or Less

github.com

11–20 of 70 posts

Re: 500 Lines or Less

#11
> canonical problem in software engineering in at most 500 source lines of code

I'll reserve judgement of the book for when its in a form I can easily read, but this seems to come up on the wrong side of the "less isn't always more" line.

I can implement a lot of logic in 500 lines of code, but I won't be able to go back a month later and understand any of it, at least not without rebuilding the logic from scratch. And I certainly can't also implement the safety checks, corner cases, and tests in that line quota.

I would personally think there is more value in showcasing a single complete and well commented solution instead of a slew of partial solutions with "the error checking left as an exercise to the reader" (I'm not sure if this phrase is in the book, I plucked it from any number of poor college textbooks).

Re: 500 Lines or Less

#12
Looks like there's code in different languages, so the arbitrary 500 line count gets even more hazy. As an extreme case, consider 500 lines of APL vs. Java.

Re: 500 Lines or Less

#13
500 lines of what? 500 lines of APL / J / Q is enormous; 500 lines of Haskell / Scala / Ruby is quite a mouthful, 500 lines of Java or C is rather moderate, and 500 lines of assembly is precious little.

Also, since a line of code can contain zero or more statements, something like cyclomatic complexity, or just statement count, could give a better measure.

(Edited: fought autocorrect.)

Re: 500 Lines or Less

#14
post #13

500 lines of what? 500 lines of APL / J / Q is enormous; 500 lines of Haskell / Scala / Ruby is quite a mouthful, 500 lines of Java or C is rather moderate, and 500 lines of assembly is precious little. Also, since a line of code can contain zero or more statements, something like cyclomatic complexity, or just statement count, could give a better measure. (Edited: fought autocorrect.)

Good point. Tangentially, assembly language is extremely modal. Logic can be coded in almost exactly the same number of lines as any high-level language. Compare-and-branch is a single line as in any language.

But compositing data (building argument lists or structured data) can be exhaustingly wordy. A single call with 2 or 3 arguments can take a hundred lines of assembler.

So it all depends.

Re: 500 Lines or Less

#15

Is there a compiled version somewhere? I don't think I will be able to build this on my phone.

I couldn't build it on my laptop. I'd have to install 3.5Gb of Tex dependencies to do it so I'll pass.

Me, either. Tried on OSX. Thought I'd get away with installing ~ 0.5 Gb when I read up about everything, but still run into problems.

This is a book people. I shouldn't really need to compile it; even if I absolutely must, it should be at least possible, if not fairly straightforward. Disappointing.

Re: 500 Lines or Less

#16

Earlier quoted context omitted.

I couldn't build it on my laptop. I'd have to install 3.5Gb of Tex dependencies to do it so I'll pass.

Me, either. Tried on OSX. Thought I'd get away with installing ~ 0.5 Gb when I read up about everything, but still run into problems. This is a book people. I shouldn't really need to compile it; even if I absolutely must , it should be at least possible, if not fairly straightforward. Disappointing.

It is not finished, so they haven't released a complete version yet, but previews of the individual chapters are on their website: http://aosabook.org/blog/

Re: 500 Lines or Less

#17
Hi, I'm the editor of 500Lines. Thanks for posting this! A few notes:

- Code golf was strictly discouraged throughout the review process. When authors were faced with implementing functionality poorly to fit more in, we generally cut scope instead.

- 500 lines was selected as a limiting criteria because it is easy to specify and understand. You will see that the chapters written e.g. with Clojure do "more" (for some definition of more), but that does not make the lessons learned in the other chapters less interesting.

- The "or less" moniker is grammatically a bit offensive but sounds cute on paper, so we kept it.

- If you'd like to learn more about the philosophy or story behind this volume, Ruby Rogues hosted us a little while ago: https://devchat.tv/ruby-rogues/256-rr-reading-code-and-the-a...

- The print version of this book (and the official launch on aosabook.org) should happen sometime in the next 4-6 weeks. You can follow this issue if you'd like to know when that happens: https://github.com/aosabook/500lines/issues/212

Re: 500 Lines or Less

#19
post #13

500 lines of what? 500 lines of APL / J / Q is enormous; 500 lines of Haskell / Scala / Ruby is quite a mouthful, 500 lines of Java or C is rather moderate, and 500 lines of assembly is precious little. Also, since a line of code can contain zero or more statements, something like cyclomatic complexity, or just statement count, could give a better measure. (Edited: fought autocorrect.)

Good point. Tangentially, assembly language is extremely modal. Logic can be coded in almost exactly the same number of lines as any high-level language. Compare-and-branch is a single line as in any language. But compositing data (building argument lists or structured data) can be exhaustingly wordy. A single call with 2 or 3 arguments can take a hundred lines of assembler. So it all depends.

And even Asm, while traditionally one-instruction-per-line, can have macros and some syntaxes like RosAsm's allow more than one instruction per line:

https://upload.wikimedia.org/wikipedia/commons/5/50/RosAsmTr...

Re: 500 Lines or Less

#20
post #17

Hi, I'm the editor of 500Lines. Thanks for posting this! A few notes: - Code golf was strictly discouraged throughout the review process. When authors were faced with implementing functionality poorly to fit more in, we generally cut scope instead. - 500 lines was selected as a limiting criteria because it is easy to specify and understand. You will see that the chapters written e.g. with Clojure do "more" (for some…

Skipping over the semantics of the title, and the war over the languages (btw, all programs can be written in one APL line), I thank you and the other authors for your work.

If you are looking for other things to write, I'd like to suggest a simple editor and a text translator to go from one markup to another, which at the end could be combined to be a WYSIWYG editor.

Post reply on HN