261 points · by fogus · 11y ago · 115 comments
http://iloveponies.github.io/120-hour-epic-sax-marathon/
Teaches you TDD in Clojure and "forces" you to use git / Github / Travis to test your code.
Highly recommended.
edit: style.
I believe the official link is http://mooc.cs.helsinki.fi/clojure
I used it only once at work to develop a stress test for a Java based game server. It was great fun to build, worked like a charm and ended up taking less than a thousand lines of code to implement the communications, bots and their execution scripts.
Furthermore, the company just bought a copy of The Joy of Clojure and there's already a bunch of my coworkers interested in reading it. Good times!
My latest site is now written in it and clojure script, and I see no reason to not continue. Though cljs is definitely a few years behind on the stability curve.
I've had some issues with the Austin REPL however, there is sometimes random disconnections and it was hard to setup the first time, but using it is so much fun it completely shadows these issues.
I've switched to using the Weasel[1] REPL instead and haven't had any disconnect problems since. Its also a little easier to setup (although still not "easy").
https://www.google.com/url?q=http://www.braveclojure.com/&sa...
However, I found it easier to digest than Let Over Lambda which was a real mind bender for me a few years ago. Being a LISP fan before learning about Clojure definitely made learning it much, much easier. It also made me appreciate the language early on for its impressive beauty, elegance and simplicity.
Great work Clojure community.
Not to start a flame war, but it seems that Clojure/Rich's strong anti-OO stance is almost a selling point of the language.
IMHO, OO just put some lipstick on the procedural pig.
However there are times when the OO approach makes sense and you have a full range of tools from multimethods to protocols. In ClojureScript you even have Self-like functionality in the form of `specify`.
[1] http://dev.clojure.org/display/design/specify+i.e.+reify+for...
(I need to update my github link to point to a static version of Om's code!)
OO will continue to be successful for accessibility reasons, and it's demise will continue to be predicted to have arrived.
But i don't think Clojure is just continuing the (equally immortal!) LISP subculture. I think LISP is growing by recruiting people from OO-ish languages like Java, Python, and Ruby, rather than from existing LISPs. This is the first time in a long time that a LISP has done that. It's also the first time in a long time that a LISP has got even this glimmer of mainstream use. pg wrote 'Beating the Averages' in 2001 [1], and even after that, everyone still thought LISPers were freaks. But announce you're using Clojure in production today, and nobody bats an eye.
People were using LISP in production in the 90s as an advantage, but then they were also using Smalltalk or Objective C also (ironically often in the same places...on Wall street). A new generation is discovering LISP while learning other languages first, but the phenomena is the same: OO was just less popular in the past and so they would come from C or Perl instead of Java.
[edit: not sure why you were downvoted, I thought your post was completely reasonable]
As programmer that feels quite at home with OO idioms - Clojure distills it down to the parts I actually like.
What I meant was is there a significant portion of corporate decision makers that don't look at OO as the default programming methodology, than say 10 years ago?
I'm actually pretty surprised at the uptake of Clojure, especially compared to Scala, which would intuitively be the next language for corporate adoption on the JVM.
I think there are many developers and decision makers that are looking for simplicity now.
If on the other hand we restrict the term to languages where values are essentially identity + a record of methods (whether through the indirection of a class v-table or directly stored in the value as in prototype based languages), I do think that model has largely run its course. It will certainly remain popular in the near future, but people are increasingly realizing that modeling everything as a record of methods + identity (+ state?) isn't a good way to do it. There are certain things that lend themselves to that way of modeling, but most things are best modeled in some other way. Records of functions + identity is just one particular data type among many, and it's not any more special than any other data type. Modeling everything as an object is like TCL where you model everything as a string. OOP is nice on the surface because you have some vague analogy to real world objects, but that does more harm than good. It is similar to agile or TDD where people try to sit down at the computer and immediately start typing code without any careful thinking beforehand. Like TDD and agile, OO also facilitates that kind of programming because people can take the concepts in their head and immediately start typing class definitions. It works for easy problems, but even there it does not lead to a pretty end result (one of the symptoms that sticks out most is the question 'on which class does this method belong?'). Rather than designing your program to model the real world, it usually works much better to design your program around the problem you're trying to solve. Rather than starting with the real world and making an analogue to it in your program, you start with the problem you're trying to solve and come up with a data model that facilitates solving that problem. A famous example of the former style gone wrong is Ron Jeffries who tried to write a sudoku solver with an OO + TDD approach in a series of blog posts. He modeled his program with classes that seem natural for the problem, and he wrote tests for those. Unfortunately writing a sudoku solver is not one of those problems where you can just start banging out code without any thought and get it to work, so he got stuck because he did not think about how to actually solve the problem, he only thought about how to model the real world with OO.
But how often do you know the right solution to a problem? Not very often, and many problems are ill defined from the start. Objects are just units of natural language: we can lie about their relationships, include bias and stereotypes, and be wrong, but it doesn't come with the not often realistic requirement that we be right. OO is agile, it allows us to start working on the solution right away, and that gives us experience about the problem.
But it won't always work! Sometimes you really do need to sit down and work out the math, turn off your natural thought biases by not using objects. And there definitely aspects of a problem that are more mathy and not very suitable for object based design and programming.
So if objects are the only tool in your bag, you are gonna get hurt, but if values are the only tool in your bag, well the same.
Personally, I like Clojure (which I am just learning now) in spite of the lack of objects. I think that the ability to write a Point class, encapsulate the coordinates, and expose an API is great. In my opinion, representing a Point as a vector or map, and then having a set of unassociated functions operating on these point-like collections sacrifices some good ideas that came from object-orientation.
Since you mentioned you were learning, I thought I'd share that, although I like functions-on-data as much as the next guy, I often use protocols and records for tasks like this, generally for no reason other than organization and self-documentation:
(defprotocol Pointy
(add-vectors [this other])
; ...
)
(defrecord Point
Pointy
(add-vectors [{this-x :x this-y :y} {other-x :x other-y :y}]
(->Point (+ this-x other-x) (+ this-y other-y)))
;...
)
I think this has more to do with type-safety than object-orientation though. (defalias Point
(HMap :mandatory {:x Num, :y Num}
:complete? true))
(ann add-vectors [Point Point -> Point])
(defn add-vectors [a b]
{:x (+ (:x a) (:x b))
:y (+ (:y a) (:y b))})Have you tried implementing a numeric tower with proper OO in Smalltalk? Would you describe the experience as wonderful and the program as beautiful? Rinse and repeat for any other problem that requires simultaneous pattern matching on several values.
I do think Smalltalk's style of single-receiver message passing is a sweet spot for structuring many kinds of programs.
The number of languages that I've seen with a proper numeric tower that aren't Scheme (or direct descendants of Scheme like Racket) are zero, so "OO makes it hard to do something almost no one ever does"...?
> Rinse and repeat for any other problem that requires simultaneous pattern matching on several values.
No problem requires pattern matching, much less on several values, any more than a problem requires OOP. Pattern matching and OOP are idioms that can be used to solve problems, but they are never the exclusive idiom that can be used to solve a problem (though either might be the only one that a particular language provides.)
Nope. http://www.tiobe.com/index.php/content/paperinfo/tpci/index....
First functional language on that list is F# at 19.
That list's methodology seems somewhat arbitrary, but let's go with it.
If you look at many top languages in use by a lot of companies, many have increasing functional aspects: Java (#2), Python (#8), and R (#12). (I may have left out some, too.) Python has many functional aspects. Java 8 brings lambda expressions. R has first-class functions and lazy evaluation.
I'd say this is less about functional programming "destroying" OO and more about programmers reaching for some aspects of FP when OO brings too much complexity. For example, why create a new class just to write an event handler? Even Java is getting the picture!
I don't know if the trend will continue (my guess is yes), but you shouldn't dismiss it just because C, C++, and Java are still the most widely-used programming languages in the world.
<sarcasm> Not to start a flame war, IMHO functional bigots just like to incite language wars rather than solving real problems. </sarcasm>
http://clojure.com/blog/2013/06/28/clojure-core-async-channe...
All of the operations are expressions (not statements)
This is a library, not syntaxalts! is a function (and supports a runtime-variable number of operations)
Priority is supported in alt--
Quil is a Clojure and ClojureScript library for creating interactive drawings and animations using Processing (https://en.wikipedia.org/wiki/Processing_%28programming_lang...).
--
Om is actually an interface to Facebook's React. Ironically, the terminology, and the feature set of Om has little, if any, resemblance to React. Om specifically transforms Clojure data so that it can be represented in a way that React can uderstand.
In the Clojure world, we build on top of React and stay away from anything that resembles JavaScript and it's behavior. React provides a virtual DOM and we just use Clojure to talk to the rendering engine.
https://gist.github.com/runexec/6efb322f29fc790a98a1
--
Chestnut allows live coding in the browser. This means all changes are visible without having to reload the page.
2 Minute video of Om using Chestnut. https://www.youtube.com/watch?v=gI3fJKmvgq4
https://github.com/om-cookbook/om-cookbook
--
Apache Cordova is the Apache License version of Adobe PhoneGap. ClojureScript compiles to highly optimized JavaScript already, so you can make mobile apps using ClojureScript and Apache Cordova.
I've been interested in this mixture recently. I use PhoneGap quite a bit. Currently my favorite combination is Sencha Touch Framework with CoffeeScript. IMO, this is a really simple way to develop mobile apps. Do you know of any open source examples of ClojureScript + Apache Cordova?
The future looks bright for the language, especially with applications like this.
When I use clojure, it's typically for companies who need to get something done and then I choose clojure to do it, but only once someone specifically asked me for clojure (but it was an American company).
I don't find it as easy to work as clojure guy in Europe.
In comparison, in the US there's much more demand but many companies refrain from remote contracting Europeans (even though I think my background is quite good ML, Data Science, Statistics, ..)
So IMO the TL;DR is: filling clojure positions is only a problem in the US, not in Europe.
Edit: making it clearer.
Most people who I see using clojure are bored ruby programmers and they bought their open source culture with them to clojure.
Clojure is not even in top 50 on TIOBE index http://www.tiobe.com/index.php/content/paperinfo/tpci/index....
The "index" is calculated (http://www.tiobe.com/index.php/content/paperinfo/tpci/progra...) by searching the 25 highest ranked web sites on Alexa which have a search box and meet some basic criteria then magically weighting them as follows:
- Google - 7.7% - YouTube - 7.4% - Baidu - 7.1% - Amazon - 6.8% - Google India - 6.5% - Yahoo Japan - 6.2% - Hao123.com - 5.8% - Google Germany - 5.5% - Microsoft Bing - 5.2% - Google Japan - 4.9% - Google UK - 4.6% - AliExpress - 4.3% - Alibaba - 4.0% - Amazon Japan - 3.7% - Google Brazil - 3.4% - 360.cn - 3.1% - Google Italia - 2.8% - Amazon Germany - 2.5% - Google Spain - 2.2% - Amazon UK - 1.8% - Google Mexico - 1.5% - Google Canada - 1.2% - Google Ad Services - 0.9% - Amazon China - 0.6% - Google Poland - 0.3%
I might buy that a general internet or e-commerce search might tell you one (low-signal, high-noise) piece of data about popularity. Some of these sites seem highly questionable to tell you anything meaningful. Garbage in / garbage out.
I think use of more specific numbers from sites like Stack Overflow or GitHub seems far more likely to give you relevant information.
Even though this is 2 years old it's still the case that the Clojure folks are heavily dominated by users who have already invested in the JVM. The other largest group seems to be split evenly between Python & Ruby as reflected in this survey.
I was at first turned down by the JVM (not knowing any better back then), but it turns out being a hosted language is one of the best aspects of Clojure.
But Clojure has a strong opinion on immutability and functional programming. I'm not sure those Schemes do.
In any case, if you were to introduce a Scheme, I would do Racket for it's significant community within the larger Scheme ecosystem.
Scheme programmers emphasize the very same things.
>I would do Racket for it's significant community within the larger Scheme ecosystem.
Yeah, Racket would make sense, though I'm personally attached to Guile.
the scheme shell maybe? scsh.net
here's some snippets: