TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Counting Clojure Code

119 点作者 aaroniba将近 8 年前

4 条评论

hacker_9将近 8 年前
When I first started learning Clojure I was surprised at how concise it actually is. I was so used to scanning imperative code in huge jumps, that the conciseness caught me completely off guard and I would scan functions without even taking it in. Every.Single.Word matters in Clojure, there is literally zero boilerplate. So I agree that counting nodes is actually not a bad way to measure how much the code base grows over time.
wellpast将近 8 年前
&gt; I also count lines when choosing libraries. When you depend on a library, the library code becomes your code in a way. [...] If two libraries do roughly the same thing, but one has far fewer lines, I will usually prefer the smaller library.<p>This is a little odd imo. Far more important when choosing a library are other aspects like its maturity, activity, interface width...<p>In fact, the goal in choosing a library should be to <i>minimize</i> the probability that the &quot;code becomes yours.&quot; You should be looking for a strong and <i>stable</i> abstraction, first and foremost.
评论 #14448509 未加载
christophilus将近 8 年前
TL;DR; He wrote a tool that accurately counts the number of lines in a Clojure project (e.g. ignores comments, etc) and <i>also</i> counts the number of nodes in said project&#x27;s AST.<p>I think an interesting metric would be number of AST nodes per line, maybe even providing the top N most complex lines, where complexity is number of nodes per line.<p>I find that some languages (Scala and Perl come to mind) tend to encourage extremely dense one-liners that have <i>way</i> too much going on with many tiny little temporary variables and symbols all crammed into a short amount of space.<p>A tool like this, if added to a linter could help discourage that sort of programming.
评论 #14449780 未加载
draw_down将近 8 年前
&gt;Obviously<p>``` (f a b c) ```<p>&gt; is the same &quot;amount&quot; of code as<p>&gt; `(f a b c)`<p>Yes, obviously! But they do not take the same number of lines - one is three lines and the other is one line.<p>It&#x27;s sort of funny to me- number of lines doesn&#x27;t paint the picture we want it to... so let&#x27;s change the metric! Our code is special, anyway.