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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Why use Clojure?

132 点作者 iamtechaddict超过 11 年前

15 条评论

DigitalJack超过 11 年前
The big lie wrt lines of code vs bugs is the kind if bugs.<p>What good is a single line of clojure vs 25 of golang if it takes 45 minutes to get that line of clojure working. I might have more bugs in my golang but the are trivial.<p>I&#x27;ve busted my ass on clojure for two years with various projects (systemverilog parser&#x2F;manipulator, CPAP data decoder interpreter visualizer). I want to use clojure but I find myself dealing with awful error messages, constantly breaking tooling (cider), and dealing with asinine constructions all in the name of functional and programming directly in an AST.<p>I tried. I&#x27;ve read the awe inspiring posts about lisp from Graham and Fogus and Raymond and of course R Hickey and Granger and Hagelberg and Stokke . I think all these people are amazing!<p>After two years I have not gotten there. I can write reasonably sophisticated applications, but the productivity is so low I feel like in programming in Russian.<p>I got fed up with tree traversal the other day and said screw it. I turned around and rewrote versions of my CPAP app in golang, and then CPP in d a day. It took me weeks to get this done in clojure.<p>I couldn&#x27;t get a binary parser framework to work except for the most trivial case, so I wrote my own generic binary parser. I couldn&#x27;t tell if seesaw made swing better or worse. Actually I decides worse because at aleast with Java interop I can tell what the hell is going on.<p>In CPP writing a binary parser was nearly as simple as defining a struct and memcpy. God I live memcpy. You know how many years it&#x27;s been since I wrote CPP? Never. I&#x27;ve never written a line of CPP before and the rewrite was almost pain free. The Makefile and understanding data alignment in struct a was the hard part.
评论 #6960417 未加载
评论 #6960642 未加载
评论 #6960545 未加载
评论 #6960650 未加载
lkrubner超过 11 年前
I feel like the &quot;Why Use Clojure?&quot; essay is a bit flawed. I feel like it focuses too much on details so minor that I would regard them as trivial. I would suggest that a much better answer to the question &quot;Why use Clojure?&quot; could be found by reading Colin Steele&#x27;s essays. When he became CTO at Hotelicopter&#x2F;RoomKey he was inheriting a vast system of PHP and Ruby. When they re-wrote the system in Clojure, he had a very small team: only 4 programmers. That they were able to accomplish so much in a short amount of time says a lot about the power of Clojure. These are 2 essays he wrote:<p>60,000% growth in 7 months using Clojure and AWS<p><a href="http://www.colinsteele.org/post/27929539434/60-000-growth-in-7-months-using-clojure-and-aws" rel="nofollow">http:&#x2F;&#x2F;www.colinsteele.org&#x2F;post&#x2F;27929539434&#x2F;60-000-growth-in...</a><p>Against the Grain: How We Built the Next Generation Online Travel Agency using Amazon, Clojure, and a Comically Small Team<p><a href="http://www.colinsteele.org/post/23103789647/against-the-grain-aws-clojure-startup" rel="nofollow">http:&#x2F;&#x2F;www.colinsteele.org&#x2F;post&#x2F;23103789647&#x2F;against-the-grai...</a><p>At this point RoomKey is a lot bigger than Hipmunk.
评论 #6961063 未加载
评论 #6961085 未加载
kohanz超过 11 年前
The introduction has a reasonable premise, but I thought <i>Business Case No. 1</i> doesn&#x27;t do much to further the point. In fact, it reinforces the academic&#x2F;industry divide that is belabored in the intro.<p>Ask people who are working on &quot;commercial&quot; development how often they have to implement a Fibonacci sequence or something similar. The example comes across more like a neat party trick then something that would make itself useful on a daily basis.
mpweiher超过 11 年前
Not very convincing when the very first example is apples vs. oranges: the java fib() code includes a main() driver with command line parsing and printing of the result to stdout, which I don&#x27;t see in the clojure version.
评论 #6959866 未加载
评论 #6959852 未加载
评论 #6960067 未加载
评论 #6960442 未加载
评论 #6960266 未加载
kvtrew76557超过 11 年前
Good question. Unlike most languages with which I am not yet familiar, Clojure looks like Greek. Most languages are at least somewhat readable. Perhaps I need to know Lisp to appreciate Clojure. Coming from a Java&#x2F;Scala&#x2F;Ruby&#x2F;Python&#x2F;Haskell&#x2F;Pascal&#x2F;C# background. I can&#x27;t make head or tail of Clojure examples. It might as well be encrypted. To those who are using Clojure, which previous languages enabled you to make sense of Clojure more easily? Or was it something you learned from scratch?
评论 #6959931 未加载
评论 #6959962 未加载
评论 #6960127 未加载
评论 #6959862 未加载
评论 #6960467 未加载
评论 #6960480 未加载
评论 #6960546 未加载
评论 #6960298 未加载
评论 #6959901 未加载
评论 #6959883 未加载
评论 #6960507 未加载
评论 #6960934 未加载
评论 #6959882 未加载
评论 #6959965 未加载
lpolovets超过 11 年前
I wrote an answer to this question on Quora a while ago: <a href="https://www.quora.com/Clojure/Why-would-someone-learn-Clojure/answer/Leo-Polovets?share=1" rel="nofollow">https:&#x2F;&#x2F;www.quora.com&#x2F;Clojure&#x2F;Why-would-someone-learn-Clojur...</a><p>I think the answer is interesting because it&#x27;s not purely mine, but instead summarizes a poll of ~5 strong engineers at my previous company. Two years later, I still think most of these bullet points hold, though I could also add a few more advantages and a few disadvantages of using Clojure.
virtualwhys超过 11 年前
Could substitute Clojure for Scala and the arguments made in the post would be at least equally valid.<p>2014 is going to be a big year for the JVM as the Java 8 gorilla cometh. Will be interesting to see what impact that event has on Scala&#x2F;Clojure&#x2F;Ceylon, etc. alternate JVM language adoption.
评论 #6961009 未加载
评论 #6960236 未加载
评论 #6960555 未加载
elwell超过 11 年前
&quot;going on other&quot; =&gt; &quot;going on in other&quot; (actually that sentence doesn&#x27;t make sense anyways; somewhere around &quot;were&quot; it&#x27;s gets confusing)<p>&quot;perseption&quot; =&gt; &quot;perception&quot;<p>&quot;Fewer lines of code is a great thing&quot; =&gt; [the opposite argument could easily be made as well; more lines of code (within reason) = less obfuscation]
评论 #6960483 未加载
评论 #6961037 未加载
ChristianMarks超过 11 年前
The Java Button Demo translated (or transliterated) into Clojure. If this doesn&#x27;t lead to instant employment, I&#x27;ll switch to OCaml.<p><pre><code> (ns buttondemo.core (:gen-class) (:import [javax.swing AbstractButton JButton JPanel JFrame ImageIcon] [java.awt.event ActionEvent KeyEvent ActionListener]) (:use [clojure.contrib.swing-utils])) (defn create-image-icon [path] (if-let [img-url (clojure.java.io&#x2F;resource path)] (ImageIcon. img-url) (.println System&#x2F;err (str &quot;File not found:&quot; path)))) (defn enable-buttons [button-flags] (doseq [[button flag] button-flags] (.setEnabled button flag))) (defn initialize-buttons [b1 b2 b3] (doto b1 (add-action-listener (fn [_] (enable-buttons [[b1 false][b2 false][b3 true]]))) (.setVerticalTextPosition AbstractButton&#x2F;CENTER) (.setHorizontalTextPosition AbstractButton&#x2F;LEADING) (.setToolTipText &quot;I can disable the middle button.&quot;) (.setMnemonic KeyEvent&#x2F;VK_D)) (doto b2 (add-action-listener (fn [_] (prn &quot;I told you not to click me.&quot;))) (.setVerticalTextPosition AbstractButton&#x2F;BOTTOM) (.setHorizontalTextPosition AbstractButton&#x2F;CENTER) (.setToolTipText &quot;Don&#x27;t click me.&quot;) (.setMnemonic KeyEvent&#x2F;VK_M)) (doto b3 (add-action-listener (fn [_] (enable-buttons [[b1 true][b2 true][b3 false]]))) (.setMnemonic KeyEvent&#x2F;VK_E) (.setToolTipText &quot;I can enable the middle button.&quot;) (.setEnabled false))</code></pre> )<p><pre><code> (defn -main [] (let [[b1 b2 b3 :as buttons] (for [[title file] ; [[&quot;&lt;html&gt;&lt;center&gt;&lt;b&gt;&lt;u&gt;D&lt;&#x2F;u&gt;isable&lt;&#x2F;b&gt;&lt;br&gt;&lt;font color=#ffffdd&gt;middle button&lt;&#x2F;font&gt;&quot; &quot;right.gif&quot;] [[&quot;Disable middle button&quot; &quot;right.gif&quot;] [&quot;Middle button&quot; &quot;middle.gif&quot;] [&quot;Enable middle button&quot; &quot;left.gif&quot;]]] (JButton. title (create-image-icon file))) panel (doto (JPanel.) (.setOpaque true))] (doseq [b buttons] (doto panel (.add b))) (initialize-buttons b1 b2 b3) (do-swing-and-wait (doto (JFrame. &quot;Button Demo&quot;) (.setDefaultCloseOperation JFrame&#x2F;EXIT_ON_CLOSE) (.setContentPane panel) (.pack) (.setVisible true)))) )</code></pre>
JackMorgan超过 11 年前
I wish this didn&#x27;t use the 590 core functions vs 30 Java keywords argument. Clojure only has a handful of &quot;special forms&quot;, whereas Java has dozens. A better count would be all the methods in String, Int, List, Array, etc.
评论 #6962767 未加载
creese超过 11 年前
Can your validation example handle checking at the map level (i.e. the case where a required field is missing)? It seems like this is something you would want to do.
评论 #6960511 未加载
robin2超过 11 年前
[Lightweight comment] The main thing that puts me off from learning Clojure is the name. I mean, why not go the whole hog and call it funargs4j?
bonemachine超过 11 年前
Oh, cmon.<p>Comparing any functional language to Java is just silly. As illustrated by the Fibanocci example.
dkhenry超过 11 年前
So if thats the best list I am happy I went with Scala. Especially the Leiningen example. Is that seriously what needs to be written for a project to build ? Its as bad as maven.
评论 #6959973 未加载
评论 #6959915 未加载
评论 #6959946 未加载
评论 #6960122 未加载
michaelochurch超过 11 年前
<i>Functional languages, as personal experience above leads me to believe, are inherently more difficult to comprehend</i><p>I don&#x27;t agree with this. They seem &quot;weirder&quot; and harder, but they&#x27;re not intrinsically difficult. They&#x27;re just less familiar.<p>Also, there are a huge number of people out there who think they &quot;know Java&quot; but really don&#x27;t. If you don&#x27;t know what volatile and synchronized are and how they work, for one example, you don&#x27;t really know Java. I would say that, unless everything in <i>Java Concurrency in Practice</i> is familiar to you, you don&#x27;t really know Java.<p>Java and C++ are actually complex, difficult languages. The difference is that, with &quot;design patterns&quot; and explicit managerial attention to differences in ability (i.e. don&#x27;t give mediocre programmers hard problems) it&#x27;s more possible to half-ass that knowledge.
评论 #6960906 未加载
评论 #6960501 未加载