Do you believe "good types" in a 1000 line program is easier to reason about than a 20 line program?
Do you believe "good types" in a 1000 line program is easier to reason about than a 20 line program?
I certainly believe that there are 20 line programs which are harder to reason about than some 1000 line programs with types. That's a big silly, though, I'd believe the same even without the "with types" caveat.
So, here's what I believe:
* Types impose logical structure on programs which is continuously
checked, high-level, and very human interpretable
* All things being equal, shorter programs are easier to comprehend
than longer programs
* If I were to list the things which aid program comprehensibility
then types + most of the things on the list in this blog post
actually go *far* higher on that list than "short length"
(Edit: I should add, given what came after this point, that "all things being equal" above is, in my eyes, a very difficult hypothesis to satisfy.)I think most professional programmers could write a relational database in under 1000 lines. Arthur did SQL92 in 20:
http://web.archive.org/web/20060505221834/http://kx.com/q/e/...
I think this example is perfectly illustrated: I find it more valuable than anything else I have found to have the entire program all on one screen.
> If I were to list the things which aid program comprehensibility then types + most of the things on the list in this blog post actually go far higher on that list than "short length"
I think there are so many useful and successful applications that "use types" and so many useful and successful applications that do not "use types" that types are probably irrelevant for success.
That many of those useful and successful programs are very large suggests that size has very little (or nothing at all) to do with success.
But comprehensibility?
I cannot imagine what universe would have a large program as being "easier to comprehend" than a short program.
Then we'll merely have to agree to disagree. I personally think this example is remarkable levels of incomprehensible. I'm not going to claim that my personal opinion has any level of generality, though. More power to you if that page of code is easy to comprehend.
> I think there are so many useful and successful applications that "use types" and so many useful and successful applications that do not "use types" that types are probably irrelevant for success.
The existence of examples both positive and negative is insufficient to demonstrate that some cause has no effect. You might strengthen that to say that in your experience the use of types has zero correlation with "useful and successful". I think with a little qualification there we could again get to a point where we'd merely have to agree to disagree.
It's also vital to point out the selection bias incurred by either of our experiences.
> I cannot imagine what universe would have a large program as being "easier to comprehend" than a short program.
I could try to demonstrate examples of both, but it'd just be my opinion as to that selection. So, instead of trying to be comprehensible, I'll just state for posterity:
Offhand, I believe it would be very easy to write a 1000 line (or even larger) implementation of SQL92 which I would find to be far more comprehensible than the example you've linked.
In particular, I believe in this case that attempting to make that code fit on one page is a significant detriment to its comprehensibility.
And again, I'm not going to try to convince you but merely state that as the fact of my opinion.
I can make any program only 1 line long if I remove all the newlines. I don't care if a program fits on one screen if it is unreadable. The example you cite is a poor example of a valuable program as it is on purpose made to be difficult to reason about.
On the other hand, i'm the kind of guy that has read 20 lines of code and missed possible null value bugs. Sucks when you have to tell customers to wait for the next point release before they can use this new feature.
I wonder if you thought I meant "a bug in 20 lines" when I meant a "20 line program".
EDIT: e.g. 20 lines is enough for SQL http://web.archive.org/web/20060505221834/http://kx.com/q/e/...
What is this blasphemy?!
Here's an excellent introduction to K: http://archive.vector.org.uk/art10010830
Most kdb users use Q though, which is something else.
The typical '1000 line program' could be compacted like your program is and all fit onscreen at the same time, if you really wanted. It's not anywhere close to 50 times as much code.
Most of the functions are independent, with the exception of the parse utilities, so it's easier to list the exceptions: cre depends on col, w depends on w0 and w1; v and w are used in e (for tokenising); where (wh) is reused by select (sel) and update (upd). c and a are used for the pull parser.
I'm not proposing "dropping the typing requirement".
I think having the program small and fit on the page is more important than types or no types.
To that end: I don't even want to have the argument about types because I think they're so irrelevant.
I'm sure most professional programmers could write an SQL92 implementation in around 1000 lines; Again, types or no types.
Here's Arthur's SQL written in 20 lines (including lexing and parsing):
http://web.archive.org/web/20060505221834/http://kx.com/q/e/...
Here's Steve Apter's relational (not SQL) database in 16:
But that is exactly what you chose to do in your original post.
I'm happy to see an argument that (having or not having types) is more important than a short program.
but I'm not happy having an argument whether to have a language with types versus one without.
That's what "I think types are irrelevant" means.
It seems like at least some people realise this e.g. https://news.ycombinator.com/item?id=8999077 but if after re-reading my post you disagree, let me know how I could better articulate what I mean.
With regard to your larger issue, almost all programs other than exercises are vastly larger than a screenful, so either the way all software is written is completely wrong, or your preference for screen-sized programs is irrelevant to the real problems of writing real-world software. Just as professional mathematicians need to be able to follow proofs that occupy more than one page, professional programmers need to be able to reason about code that occupies more than one page.
Agreed.
Arthur wrote an SQL in 20 lines of K, and a dynamic window manager in around 60 of C. His programmers editor with syntax highlighting easily fits on a page.
kOS's kernel is under 60 lines of C as well (including annotations; paging, filesystem, syscalls, etc).
Where I work, I wrote an RTB service for digital advertising demand-side platforms- implements HTTP, application protocol decoding, maps and bidding in under 100 lines of C. I fit a video player with VAST+VPAID support in 42 lines of Javascript.
So it follows how programmers write software is completely wrong.
However the inertia will be hard to overcome.
I'm writing this way; I'm finding value writing this way, and at the moment I'm making no other claims other than the shortness of a program is the single best indicator of correctness, performance, and "reasonableness". It's certainly more important than a "types" argument.
While your best counterargument against short programs is inertia, suggesting we shouldn't leave the trees isn't helpful. You should try it. You might like it.
If you had not strayed from that position, I would not have joined the discussion. I happen to agree that there is an inordinate amount of unnecessary complexity in the present code base, but I think it is an orthogonal issue to that being raised by the original article. That is because it seems to me that the main causes of this introduced complexity is developers' poor understanding of the requirements they are trying to satisfy, together with a trial-and-error approach to programming, rather than the language features covered by the original article.