14 ms·
Clojure: The JFDI language
- coolsunglasses 13y agoIt's not really accurate to think of core.async as mutable state at all, because by default channels are only queues in the sense of implicit waiting go blocks forming a queue. Unless you use a buffer implementation, channels have no "placeness", you're not mutating/adding to a queue by parking a go block. I liked everything else.
- michaelochurch 13y agoYeah, a couple of other people pointed that out. core.async has state (when buffers are used, in particular) but state is not exactly the same thing as mutability. Producers and consumers don't have unconstrained access to channels, in the way that users of a mutable cell (a Clojure atom, a ref cell, or just a variable in many languages) can clobber it at will. Likewise (although I didn't get into this) state doesn't necessarily violate referential transparency. Memoization uses state as an optimization, but doesn't interfere with RT.
- coolsunglasses 13y ago>Likewise (although I didn't get into this) state doesn't necessarily violate referential transparency. Boy do Haskell users ride that one hard.
- ninetax 13y agoAre there really more Clojure jobs than programmers? As a clojure programmer looking for a job I haven't seen many... Wish there were more though!
- michaelochurch 13y agoI said the opposite: more programmers than jobs. That might change. Clojure's been making some pretty impressive in-roads into the enterprise. At this year's Conj, there were a fair number of companies hiring. Staples Innovation Labs is apparently hiring a lot of Clojure people. What part of the world are you in?
- ninetax 13y agoedit: well after actually reading your comment, I see now what you said :). Yes that seems like a good reason for companies to adopt Clojure, I hope they do. Ah, yeah, I really wanted to go to Conj, but only found out about it last minute. I'm in San Francisco. It's not that there are no companies using Clojure, it's more that the companies where I do want to work, don't want to use it. When I mention it in an interview or something they kind of give me a funny look like they hope I am not one of those LISP people. I mean I can see where they're coming from. It's a big risk to let someone write in a language you don't know much about, and that you don't know if you'll be able to hire for in the future. And at the places where they are feeling a bit adventurous, everyone seems to be leaning towards Go :( Oh well, I can still use it for all my side projects until it gains more popularity I suppose. It really is such fun to use. I only started 2 months ago and I have been having the best time of it.
- puredanger 13y agoWe are planning Clojure/West to take place in San Francisco in the spring (April-ish timeframe).
- _xczx 13y agoThe misconception list basically summarizes the interactions I have with people who know I use Clojure. It's really interesting that these are still around, especially considering that lisp hasn't been new for a long time. As an aside, I loved the chrono trigger reference! I was actually listening to some of its music as I viewed the slides. I know this is old hat for the FP community, but it's worth mentioning that the dot product would be normally be written as (reduce + (map * xs ys)) (or something similar) for the sake of readers scared by the loop acc pattern.
- michaelochurch 13y agoIt's really interesting that these are still around, especially considering that lisp hasn't been new for a long time. People want to believe the world is simple, and that learning one PL is enough. Once you know Java, why learn another one? Either they're all the same, or they're so radically different they must be weak in some critical way. When you grok Lisp, and realize that it is actually practical, you realize that you've only scratched the surface of the PL problem... and that's scary for a lot of people, especially as there's a tendency to overestimate the barriers between languages. (The Internet runs on components written on all sorts of different languages.) it's worth mentioning that the dot product would be normally be written as (reduce + (map xs ys))* Yes, I had that thought, too. In fact, that formulation is too slow for, say, large-scale ML. I've been getting a lot of mileage out of Prismatic's hiphip library... and I really look forward to, about 5 years from now, when Clojure is as mature for numeric programming and ML as Python is with Numpy, Scipy, Numba et al.
- danenania 13y agoThanks for this. It's a great overview that manages to be both detailed and easily accessible. Your visual approach to explaining macros with arrows to demonstrate the substitutions also really helped me to grok them in a way I haven't been able to previously. They are actually quite simple aren't they? It's basically the same idea as html templating, but outputs code instead of markup. I'd love to see you get more in depth on some of the headier topics--core.logic, monads, storm/hadoop interop, etc. You seem to have a gift for making difficult concepts approachable.
- billsix 13y agoyou may enjoy On Lisp. http://www.paulgraham.com/onlisp.html http://www.paulgraham.com/onlisp.html
- coolsunglasses 13y agoStructure-aware, fully programmable (you use your full programming language at macro-expansion time) HTML templates, sure.
- JackMorgan 13y agoI wrote a post about macros in Clojure going into some more detail if you're interested in learning a bit more. http://deliberate-software.com/intro-to-macros/ http://deliberate-software.com/intro-to-macros/
- brandonbloom 13y agoTo be clear, that ` character is called "syntax-quote" (in Clojure; "quasi-quote" elsewhere) and it's the "templating" part. It's both possible and common to use macros without syntax-quote and vice versa. In fact, common practice in Clojure is to define a your macros in terms of a backing function: (defn foo-fn [body] (fancy stuff here that probably uses syntax-quote somewhere)) (defmacro foo [& body] (foo-fn body)) Clojure's style of macro system is known as a "procedural" macro system because the macros can be any arbitrary procedures which returns code as data. There are other types of macro systems, like Scheme's syntax-rules, which are more directly embrace the fact that most macros are tree rewrites.
- joelgrus 13y agoThis is a really nice overview of Clojure, thanks.
- saosebastiao 13y agoInteresting to see you mention Supply Chain Optimization. Other than myself, I know of only one other person that actively uses it for the task. Is there some hidden community that I'm not aware of?
- dm3 13y agoCuriosity took the best of me. Could you elaborate, please? Where are you actively using SCO?
- saosebastiao 13y agoI use Clojure for a lot of analysis, modeling, protoyping and optimization for supply chains (I work in Amazon's Supply Chain). The presentation mentioned that Clojure was used for SCO, and I was curious jf there was some community of supply chain users of Clojure somewhere because AFAIK I'm one of two people that use it for SCO.
- speek 13y agoWe use it at my company, Weft -- we're building Waze for Cargo. Shoot me an email (marc@weft.io) and we'll try to get a Clojure for SCO group going! There are at least a few of us hacking away on that kind of stuff.
- EdwardDiego 13y agoCheers for a great synopsis that I intend to inflict upon my coworkers at the first available opportunity. :D
- vorg 13y ago> Functional programming has two simple, elegant design pattern that don't suck: noun and verb. I'd add adjectives (including adverbs), which is the metadata on the nouns and verbs.
- dscrd 13y agoInteresting point. I wonder if it would have an effect on how non-programmers view coding if programming language constructs were renamed like that.
- michaelochurch 13y agoAdjectives, to me, are more unresolved but I think Clojure's protocols appear to be close to the right answer. Adjectives are properties or classes of things, like Numeric or Closeable (with-open pattern) or Monad. The Haskell solution is type classes. The Java solution is OOP. The Erlang solution (fairly similar) is the actor model, which is the inspiration for OOP's principle of locally interpreted functions/methods (as opposed to global function definitions). OCaml's is functors, which are extremely powerful but hard for most people to use.
- vorg 13y agoPerhaps protocols/interfaces are like restrictive adjectival phrases, and metadata like non-restrictive. Just in case you don't know: Restrictive clauses limit the possible meaning of a preceding subject, whereas non-restrictive clauses tell something about a preceding subject, but do not limit its meaning. Example of restrictive use: The suspect in the lineup who has red hair committed the crime. Example of non-restrictive use: The suspect in the lineup, who owns a red car, committed the crime.
- sandGorgon 13y agoQuestion - there was a recent post about how the dailymail group moved 140k lines of java code to 4k lines in clojure. Since I have never programmed much in Java (I went from c++ to ruby!), could someone tell me where the gains are coming from ? I know that eliminating the setters and getters (and the private/protected/etc system) would eliminate a lot of code, but I dont understand if it would be that much. Possibly, I'm also trying to understand if they would have gotten similar improvements in kloc if they had switched to.. ruby/python for instance.
- deleted 13y ago[deleted]
- PurplePanda 13y agoSome reduction in lines of code may have come if they had rewritten it in Java too, due to better understanding the problem space after having written the first version. Java has a fair amount of boilerplate type code other than getters and setters. For example forcing you to use "classes" for everything, even when you really want a procedural or functional API. Some people try to write semi functional style programs anyway using object oriented "patterns", which can sometimes lead to really just a lof more lines of code too. Also explicit type annotations take up space. And the Java style of using exceptions can be quite verbose. There may also be better designed libraries to do a lot of things for you automatically in clojure. Macros are very helpful too. But I'm just making all of this up, haven't actually seen the codebases to compare them.
- cliftonc 13y agoHi, I'm the CTO at the MailOnline so can comment. The biggest reduction in loc was due to the move from a relational DB to elastic search containing flatter representations of our content. This basically meant that we could delete thousands of lines of boilerplate and create a very simple processing pipeline to render content, and for this clojure really shines of course. The REPL made the first week of exploring the problem and solution space really effective, and even as a node guy I was impressed with what could be done. I can say that there is definitely a big productivity boost, but as others have said it isn't purely the language, but rather thinking about the problem in a completely new way that really did it. I do credit clojure though with giving our engineers the ability to think differently, as that is often the hardest part. There was a comment I made in a speech recently about functional programming being frictionless for content management system design, this is what I was alluding to. I don't want to start a flame war, but we built an earlier version in ruby (with one of the best OO guys I know leading it), and it was much more complex through attempting to model our home page as a set of inter related objects, using visitor patterns to traverse etc., than the clojure version.
- eklavya 13y agoI don't get it. Scala has all the features, it's fast AND it's easier to read (no matter how much the presentation tries to play down the () issue, it's there.) Why not use Scala insead?
- mullr 13y agoClojure is dynamically typed, homoiconic, and places a lot of emphasis on immutability and managing state. Scala has different design goals. Idiomatic Clojure code is quite different, structurally, from idiomatic Scala. You should try it, and believe it when everyone says that the parentheses fade after about a week.
- eklavya 13y agoWell I just might, for now Scala seems to be doing a pretty good job though :P Is learning clojure enough if I would like to write lisp in future?
- josteink 13y ago> Is learning clojure enough if I would like to write lisp in future? Since clojure is lisp (although not common lisp or any other non-clojure variation like Scheme), I would have to answer yes.
- krat0sprakhar 13y agoCan't agree with this more. All the plus pointed touts for FP are available in Scala without the necessary mental context-switch that is required to grok the parenthesis extravaganza. Why Clojure instead of Scala?
- s_kilk 13y agoWell, first of all Clojure is a substantially simpler language than Scala, which counts for something. Secondly, I believe that Clojure does a better job of presenting the developer with a new way of thinking about problems, which (as alluded to further up the thread) can be a big source of productivity gain and inspiration.
- davidp 13y agoI enjoyed the presentation very much, until "Engineers 3-10x more productive" Citation needed. If this were generally true (of any technology X) the dollars would be flowing that way in an unstoppable torrent, and anyone using anything else would be the subject of ridicule and/or pity. It would be like writing custom websites in C. Since that isn't happening, I have to take assertions like that with a sizable chunk of salt. The alternative would mean that there's a gigantic arbitrage opportunity that's being missed by a bunch of highly motivated people. So yeah, citation(s) please.
- terranstyler 13y agoIMO the problem with the unstoppable torrent is that the people who decide where company dollars flow to can hardly tell C from Clojure so they rely on the opinion of those whose job would then be to say "ah yeah right, me and my team have been using the wrong tools all the way" which doesn't happen for obvious reasons. I started up with clj and I am trying kinda heavy arbitrage here :)
- danenania 13y agoThe reason is simply that more powerful tools require more skill and experience to use effectively. It's not just a question of switching from imperative language X to clojure and seeing a huge productivity boost. You must also understand why clojure is designed the way it is and how to use it effectively. For awhile, you'll likely be less productive as you learn how to approach problems functionally and wrap your head around the capabilities of lisp, but you'll also be building stronger, more reliable systems, and at the end of the learning process, you will indeed be significantly more productive. Managing a transition like this is far from trivial for a company facing a variety of immediate demands and constraints, even if it promises to pay dividends in the long run.
- kazagistar 13y agoRight, but just about every language makes this claim. Very few support it. As far as I am concerned, they are all being deeply deceitful. If you make some "fact" up, and pawn it off as the truth, you are being dishonest.
- wuschel 13y ago(Disclaimer: I am a python that found a new home in the scheme world) Clojure is a Lisp. Lisp based languages are great. However: One of the problems with clojure - or rather with its home or ecosystem - is the fact that it requires a very high activation energy to get going. Grasp the concept of functionial programming, cc/call, macros, totally different syntax than your previous imperative language of choice, and last but not the giant blob that is called Java platform with all the traps regarding project management, IDEs, building, compiling, deploying etc. I know that there are great tools such an Leiningen or LightTable, but they only make the whole process of transition more manageable. Now, I know that Java is a huge benefit for all that want to make use of its gazillion tools. But if You are not into Java, then Clojure might give you some hickups. In comparison to Clojure, Python also allows for some functional programming, gives the eager disciple an easy going start. Most of libraries are written in Python (or exist in a fast, a C-esque implementation) and are very easy to grasp. I can not say that for the Java enviroment Clojure has been born into. I frown at java lingo error tracebacks in the REPL, and to bring a external Java library into play is even more problematic. Any thoughts on this how to remedy this problem without getting involved into Java? I wish there would be some kind of Index of how to use certain Java libraries from Clojure, or an index of Clojure wrapping packages. It might make life a bit easier. Finally, I claim that for now, I am quite happy with my choice to migrate from Clojure to Chicken Scheme/picolisp. You can get quite a bunch of Clojure data types from the good package repository. It compiles without setting your hair on fire. And it is really simple, as the language basics are small. I will keep an eye on Clojure. but I must say that Julia is as appealing to me when it comes to the choice of future language.
- jamesjporter 13y agoJulia is a really cool language; I came to it from a python background and in a lot if ways it feels like "python done right"
- minikomi 13y agoPlease drop by the racket world sometime. The documentation is fantastic :) Can you recommend a good picolisp resource?
- 13y ago
- yresnob 13y agoGreat overview.. from direct work experience in building complex systems in clojure....I agree with all the statements made in this document... I am a better developer because of it and will look at things differently if I need to pick up java or scala again.. and I will also make sure to always "get in the hammock" before writing a line of code..
- yresnob 13y agoGreat overview.. from direct work experience in building complex systems in clojure....I agree with all the statements made in this document... I am a better developer because of it and will look at things differently if I need to pick up java or scala again.. and I will also make sure to always "get in the hammock" before writing a line of code..
- turar 13y agoIs there a web framework for Clojure similar to Play for Scala?
- yogthos 13y agoCloser to Sinatra or Flask, but you can always check out http://www.luminusweb.net/ http://www.luminusweb.net/
- turar 13y agoThanks! I found an interesting discussion on the topic here as well: http://grokbase.com/t/gg/clojure/131bp962q1/full-stack-clojure-web-rest-framework-is-there-any-mileage-in-it http://grokbase.com/t/gg/clojure/131bp962q1/full-stack-cloju...
- deleted 13y ago[deleted]
- swah 13y agoRelated to this is the Erann Gat "How I lost my faith in Lisp" story[1]. He was also a googler but going the other way. Of course, this is quite old (before Clojure). But the points remains... [1] https://groups.google.com/forum/#!msg/comp.lang.lisp/L5dZ-j6Id-s/9tOJorXPdW8J https://groups.google.com/forum/#!msg/comp.lang.lisp/L5dZ-j6...