5 ms·
Cool stuff. The danger of this, though, is that you risk doing unidiomatic examples a disservice. I thought you were just going for line-for-line parity until
by danneu 14y ago
Cool stuff. The danger of this, though, is that you risk doing unidiomatic examples a disservice.
I thought you were just going for line-for-line parity until I came across the Clojure example. I think you could've written that same `for` loop in Clojure and either yield the original word or yield "nurble" if it intersected a noun. But this is put up or shut up territory and I'll take another look.
Also, could you clarify why you make multiple assertions that Clojure is "too much" for this task?
I'm a fulltime Ruby developer learning Clojure on the side and Clojure's Ring+Compojure feels like Rack+Sinatra to me. In fact, the choice between Ruby and Clojure to me is as trivial as using Python or PHP. Here's ClojureDoc's tutorial on making a DB-backed webapp in Clojure: http://clojure-doc.org/articles/tutorials/basic_web_development.html http://clojure-doc.org/articles/tutorials/basic_web_developm.... It's just Sinatra/Flask in another flavor all over again.
The only downside of Clojure so far for me is that I might already be drunk with that special Lisp koolaid already.
- adambard 14y agoIt's hard to argue that the Clojure code is as easy to read as the Ruby or Python, and if you're working with a team that matters. Not to mention the relative dearth of Clojure-fluent developers. Neither of those hurdles is impossible to overcome, but if you're choosing between Ruby and Clojure, you have to justify that decision somehow. Of course, if I'm the only developer I choose Clojure every time. That's probably the Lisp koolaid doing its thing.
- danneu 14y agoHere's what I meant: (def nouns #{"apple" "book" "house"}) (def text "My apple is red.") (defn noun? "intersect word with nouns and see if we've got anything." [word] (not-empty (intersection (set [word]) nouns))) (defn nurblize [text] (let [words (split text #" ")] (map #(if (noun? %) "nurble" %) words))) (nurblize text) ;=> ("My" "nurble" "is" "red")
- adambard 14y agoYeah, that's much better than mine.
- deleted 14y ago[deleted]
- yogthos 14y agoI think people like to over-exaggerate the difficulty of learning Clojure. If you have one person on the team who is fluent in it, the rest of the team can pick up enough of it to be productive in days. The place I work at used to be exclusively a java shop, we introduced Clojure for a project a year ago and everybody loved it. So, far we had co-ops learn it, contractors, and the whole team. I'm just not sure who these people who can't learn Clojure are exactly. It might be more difficult to read initially if you've only worked with one family of languages, but that doesn't make it more difficult to read inherently. In fact, there are many benefits to readability once you're familiar with the syntax. It's a lot more regular, there's less special cases than in most languages, and you can see the relations in your code visually, since you're seeing the same AST that the compiler sees.
- bloopy 14y agoRich Hickey sums it up best: "I can't read German therefore German is unreadable."