173 points · by cryptolect · 12y ago · 73 comments
Who says hard work pays off?
In comparison, a post[2] I was really excited about, that demonstrates how to improve (Korma) SQL abstraction in Clojure with Macros (I created a demo app) didn't seem to get anyone excited. I probably spent 4x as long trying to put it together. Oh well.
Anecdotally, it feels like programming-related posts with a few high level pieces of code resonate better than deeper dive posts. Possibly because they're easier to skim across while having your morning coffee.
[1] https://hackworth.be/2014/02/05/an-expanded-comment/
[2] https://hackworth.be/2014/02/18/spicing-up-korma-with-macros...
I don't think you could have predicted ahead of time which of those would be more popular before writing them.
Having said that, the Stasis post is much longer, so it's less conducive to reading at work and quickly dashing off a comment or two on Hacker News without your boss noticing you goofing off. Hypothetically speaking, of course. :)
Based on my experience, a "worthy" article has about a 50-50 chance of making it off the new page to the home page and taking off. This is basically random. Many people think HN is a meritocracy where the best articles succeed, but its not. There is a huge random factor in the way. This isn't too bad for a short throwaway article but it's frustrating if you put hours and hours into an article and know people would like it but it goes nowhere.
I don't have any problems with the skewed "readers per effort" metrics, it was just a fun observation. If my only goal was internet fame, I would not write huge long-ass posts :)
I think for any big win/viral/hits based endeavour - music, OSS, blogging, games - creating many things quickly and doubling down on whatever works is the best strategy.
HN is pop programming culture and if you're writing Clojure, you can't expect them to appreciate it as much as, say, Node.js.
I've only recently started with Clojure and I feel like a clumsy newb most of the time, but I adore the elegance and simplicity. I like that this article gets into the benefits of hashes, maps, and vectors as first-class objects in Clojure. I'm sure the Lisp purists hate it, but as someone used to 21st century programming languages, I love it. And I like how it shows Clojure's superiority over other languages' access/manipulation of the same structures. I'd love to see a follow-on here about the advantages of immutability too.
As for the popularity of Node.js... fertilizer is a wonderful thing, but it's still made out of manure. I can't quite get around my distaste for Javascript.
What is this philosophically opposite that you mention? Haskell is good at creating domain-specific languages, so I think the differences must be around the superior meta-programming facilities in lisp languages. So, what would you do with Clojure that you couldn't do in Haskell easily?
- static vs. dynamic typing
- pure vs. allowing side effects
- native vs. hosted
- focus on syntax vs. rejection of syntax
Depending on the problem, you may get big benefits out of one side or the other.
One particular thing that is much easier in Clojure is dealing with heterogeneous, hierarchical data. This is just so effortless because of the combination of dynamic typing and the wonderful built-in persistent data structures. This is possible but takes a lot more work to do in Haskell and is much slower to iterate on when your data changes.
Interested? Then take a look at the Shen[1] and enjoy having both the benefit of types and other powerful Lisp constructs in one language.
[1]: https://github.com/downloads/frenchy64/papers/ambrose-honour...
The dynamic-typing means Clojure code is usually built around data-flows of maps/vectors/strings (generic information types that are trivial to integrate from different sources), trivial serialization, code-as-data.
I'd guess Haskell code is more likely to be built around abstractions based on the more powerful type system.
clojure.core.logic - a Prolog-like logic language that you can embed in the middle of a Clojure function - is a good example of something that is possible thanks to Clojure's lisp macros.
import Control.Monad.Logic
And! You don't macros for that. Macros are not used much in Haskell (only for very special cases), there's no need for them.
The type system gets a bit in the way when implementing something like miniKanren in Haskell. I suspect Clojure is a better fit for this kind of highly dynamic problem.
The real beauty of macros is to simplify syntax without taking a runtime performance hit.
How would you implement thread-first or thread-last in Haskell without a runtime performance hit? Template Haskell?
And if you don't like that, it's easy to use "untyped" types as well.
user> (:key nil)
nil
Mmmm, I'm not certain I particularly want this user> (nil :key)
CompilerException java.lang.IllegalArgumentException: Can't call nil
RUN! (:foo (:bar {}))
Without throwing a NPE. Which is what I want 99.9% of the time. As someone who codes in Clojure close to 10 hours a day, I rarely see a problem like you describe. user> (let [e nil] (e :key))
NullPointerExceptionThe link to Clojure points to "http://cjohansen.no/clojure.org" instead of "http://clojure.org".
(map :name people)
evaluates to a lazy sequence, not a vector.
It might be interesting to discuss _why_ keywords or maps or sets can work as functions, by implementing the IFn interface. Perhaps explain why homoiconicity and macros enable things like thread-first and -last, and talk about how we can implement our own reader literals.
That was kinda the whole point of the post.
Maybe the other post I posted the same day would give newcomers a better impression of what using Clojure is like in practice (lots more code, more in-depth): http://cjohansen.no/building-static-sites-in-clojure-with-st...
ps: what is the min* function ? can't find anything on google