4 ms·
According to Paul Graham (http://www.paulgraham.com/arcchallenge.html http://www.paulgraham.com/arcchallenge.html): The most meaningful test of the length of
by rntz 17y ago
According to Paul Graham (http://www.paulgraham.com/arcchallenge.html http://www.paulgraham.com/arcchallenge.html):
The most meaningful test of the length of a program is not lines or
characters but the size of the codetree-- the tree you'd need to represent
the source. The Arc example has a codetree of 23 nodes: 15 leaves/tokens
+ 8 interior nodes. How long is it in your favorite language?
So instead of measuring lines of code, you measure the size of the AST. Works well for Lisp, at least; not sure how well it generalizes to other languages.
- gdp 17y agoThat's probably a better metric, but I still think it's making a statement about some causal relationship between size and quality, which I think is complete bunk. I can solve a problem in 1 line of buggy code. You have to write 1000 lines, but it is mathematically certain that yours works. Whose is the better implementation? Mine might be O(n^n) in the worst case, while yours is O(1). See, I'm talking about specific programs, but these sorts of comparisons extend fairly naturally to programming languages too.
- scott_s 17y agoClearly, the 1000 lines of mathematically proved correct code that is also faster is better. But that's a contrived example. In general, less lines means less bugs. That you can contrive counter-examples does not invalidate the metric for use in the normal cases.
- tetha 17y agoThis does not generalize to other languages, imo. Pythons ASTs tend to be pretty involved, but the language is very simple and clean.