11 ms·
Why we are choosing Clojure as our main programming language
- iamelgringo 16y agoI know this is heresy around here, but have you looked at F#? It's functional, has type inferencing, even in the dev environment, straight forward parallel versions of functions (pmap vs map), async IO, amazing dev tools, a REPL inside of Visual Studio, access to all of the .NET libraries. And, chances are, it's going to be around for a while. You're absolutely on the right track. As startups struggle to hire, new startups should be looking to off loading more and more of their work to more productive programming languages.
- fogus 16y agoMay I ask why F# is considered heresy?
- gthank 16y agoBecause it means you're (probably) going to be running Windows on your servers, which isn't cheap.
- true_religion 16y agoThe cost for windows isn't really a pressing concern for business--even startup business. But the thing is if you go with windows, you're eventually going to have to support linux too just to get a the wealth of open-source codebases like say Redis. I mean its certainly possible to run Redis on windows via cygwin but you're 32-bit limited, and its a pain to actually install and get everything working. On Fedora it's "yum install redis", and you're done.
- kenjackson 16y agoCan't Redis run on Windows proper? I thought I've seen actual Windows builds of Redis?
- true_religion 16y agoThe last I heard Redis on windows native as a wontfix: http://code.google.com/p/redis/issues/detail?id=34 http://code.google.com/p/redis/issues/detail?id=34
- gaius 16y agoThat's simply not true, BizSpark makes the cost of Windows into a rounding error.
- dpritchett 16y agoThat may be so, but how readily can you automate server setup? I am getting pretty handy with ubuntu VMs plus apt to get from a fresh install to "entire stack installed and configured" in an afternoon. The fact that nearly all of the software is available freely online speeds things up for me.
- iamelgringo 16y agoSimply because it's Microsoft. That was partly tongue in cheek. :)
- mduerksen 16y agoYou'll have to restrict your servers to run Windows. That's something not everyone wants to do.
- icey 16y agoF# runs on mono, which runs pretty well everywhere Clojure will run. The F# mono implementation is somewhat slower than the .Net implementation though, so there is that caveat.
- Turing_Machine 16y agoF# on Mono seems to be a lot slower than Java 6, at least in the Shootout (2x to 12x). I don't know how that stacks up to Clojure, though I understand that Clojure can be much more performant with tricks like type hinting. On the other hand, F# does use less memory. http://shootout.alioth.debian.org/u32q/benchmark.php?test=all&lang=java&lang2=fsharp http://shootout.alioth.debian.org/u32q/benchmark.php?test=al...
- icey 16y agoI really dislike the shootout, but F# on mono and Clojure (which is slower than plain Java) look pretty similar: http://shootout.alioth.debian.org/u32/benchmark.php?test=all&lang=clojure&lang2=fsharp http://shootout.alioth.debian.org/u32/benchmark.php?test=all... For whatever it's worth, if you like Clojure, use Clojure. If you like F# use that. If you like Perl, Java, PHP, use those. But, if you're going to consider other options hopefully the FUD doesn't get in the way ;).
- igouy 16y agoIf you really dislike the benchmarks game, don't look at the benchmarks game and don't show it to other people :-)
- gtani 16y agoOK, igouy, somebody has to defend the Benchmarks game (!?) Most FP communities (incl clojure) have devote non-negligible blocks of time to code review and benchmarking to make sure that at the very least poorly written code isnt' submitted (and the right hotspot knobs are on). http://groups.google.com/group/clojure/browse_frm/thread/d27630c0fb21dc20/ http://groups.google.com/group/clojure/browse_frm/thread/d27...
- runevault 16y agoNot everyone wants to use the .NET ecosystem for any number of reasons. When doing purely windows development, it is my first choice, but if I want to do cross platform or web development even with Mono out there the appeal just lacks to me. I will agree though that F# is a beautiful language, and am hoping on getting everyone else at work on board so we can start using it more for our development.
- weego 16y agoIs it counter productive in an environment where hiring is difficult to go too niche though? Our entire server codebase, baring a few external libraries, is Scala (working with Lift) which has been an awesome experience but there is a nagging doubt in my mind that if/when we need to start looking to add in developers we will either need to invest in cross-training a java dev or end up paying out probably more than we could/should afford to get a seasoned java dev who trained themselves in Scala already. If over a short period of time your choice gets some major traction then it will work in your favour, but if not then you could be out in the cold or risking employing someone with no real provable history.
- jared314 16y agoYou might not want someone who can't learn a new language.
- gaius 16y agoIf a developer is so much more productive, why shouldn't you pay a premium for their skills? Remember in business there is no "cheap" or "expensive". There's only "worth the money" and "not".
- jshen 16y agoHow do you know if they are productive before hiring them?
- gaius 16y agoSomeone who is "a seasoned java dev who trained themselves in Scala already" will have a track record of Getting Stuff Done of course. Also see http://www.paulgraham.com/pypar.html http://www.paulgraham.com/pypar.html
- jshen 16y agofar easier said than done. Have you hired a lot of people? What form does their track record come in? A list of projects on their resume?
- va_coder 16y agoI'm willing to keep my mind open. How long it takes to set up a dev environment and push to cloud service? With appengine, 1) I sign up in 5 minutes, 2) clone an app in python or Java, 3) use my favorite free ide to edit the code 4) appcfg.py update Also, if I don't have any of the tools like git I just type: sudo apt-get git-core Heroku on AWS is just as easy. Can you provide a link showing how easy it is to get started with F#?
- cschep 16y agoDefinitely check out appharbor.com, I think their goal is to be a "git push" away from deploying any .NET (F#/C#/VB.NET) app. I've not used them though.
- mattmanser 16y agoHang on, I thought the author deliberately ruled out GAE because its performance is too ropey. Also step 2 sounds like magic and a recipe for disaster. Clone an app? What, with all its settings? Random library includes you weren't expecting? Don't confuse well trod paths with new roads, closure and F# are both new roads, you'll need to do a bit of work yourself. Also visual studio has a free edition these days. Anyway, my point is don't compare apples to oranges when the author said he can't use apples.
- va_coder 16y agoYes Github is magic ;)
- va_coder 16y agoLast weekend, with no prior knowledge of JavaScript on the server, I created a full NodeJS, Express, Coffeescript, Jade, NPM stack and had it deployed to my linux VPS in less than a morning. It's my understanding it's not so easy to do that kind of learning and experimentation on Windows.
- Devilboy 16y agoI'll have you know that Windows is every bit as easy to experiment and learn on. Microsoft go out of their way to make developer and sysadmin's jobs as easy as possible. New versions of the .net framework can be installed without restarting any services, all previous versions will keep running in parallel, etc. etc. Don't dis it till you've tried it.
- gislik 16y agoTo be honest I've never given F# much of a chance. Mainly because I do most of my development on Mac OS X or Linux. But I've seen some cool introductions on F# and the integration with Visual Studio (mainly from CUFP http://cufp.org/videos/keyword/59 http://cufp.org/videos/keyword/59). I'll be keeping my I on it. Thanks.
- pmjordan 16y agoThe latest version of Mono apparently ships with F# support: http://www.mono-project.com/Release_Notes_Mono_2.10#Languages http://www.mono-project.com/Release_Notes_Mono_2.10#Language... Now I just need to find the time to try it out...
- gtani 16y agoI think the biggest impediments to F# adoption: to somebody not already a C#'er is the cost of Visual Studio: You really want that concurrency profiler, which I think is only in the Ultimate SKU (for which MS is giving away licenses in Bizspark, dreamSpark). And a fair number of Csharpers I've met recently (admittedly a small sample) will tell you FP and the parallel/concurrent libs in C# are good enough: TPL, the .NET 5 Async lib (Basically they'll tell you about all the C# stuff in Petricek's book, without looking into what F# can do for them.
- cdavid 16y agoHe mentioned python issues such as deployment and the GIL. While python is my language of choise, I agree those are significant pain points. Unfortunately, he did not mention how clojure solves deployment - is it solved through maven and other java solutions ? It did not strike me as a nice solution either.
- true_religion 16y agoIsn't java deployment as simple as distributing a .jar or a .war----one file? Python deployment on the otherhand is a tarball of several files.
- runevault 16y agoyes all deployment options that work for normal java apps can be done with clojure as well, since in the end it's all bytecode, you just require the one extra chunk that's made up of the clojure.jar and probably contrib to get your baseline to make things work.
- runevault 16y agoMaven is not thrilling, but with lein over the top and clojars for clojure specific jar files, it's reasonably painless IME.
- cdavid 16y agoBut what's the difference with python at that point ? Is is because the JVM makes it inherently easier ("one" jvm, one bytecode, no difference between version/build options for C extensions) ?
- runevault 16y agoThat and by default you have the classpath so each setup has exactly which version of the various jars you specify in your project.clj file, without needing external tools like virtualenv.
- 16y ago
- dylanz 16y agoGood read, and I just read this post while attending Erlang Factory in SF, in the middle of a talk about Lists and Strings :) I asked the teacher about your comment on String manipulation. Yes, it is pretty in-efficient. There are libraries to make manipulation easier, and, you can always go down to binary types, which is much more performant. We chose to use Erlang for a variety of reasons, and String manipulation isn't a problem for us (it's definitely a pre-mature optimization point (for us) at the moment).
- gislik 16y agoI resonate well with many of the reasons for why one chooses Erlang in a project. I guess it all depends on the problem domain :)
- nivertech 16y agoErlang strings is just a syntactic sugar over lists. 1> [104,105]. "hi" 2> [$h,$i]. [104,105] 3> "hi". "hi" Which is efficient for some uses (i.e. iterating over UTF32 characters) and inefficient for others (high memory usage). You can always use: * atoms - for interned strings or enums * binaries - for memory efficiency (i.e. UTF8 byte sequences) * IO-lists - for efficient appending and IO. What I would like is a per-module compiler directive/pragma, which will turn every "string" into <<"string">>, while @"string" will remain syntax sugar for list.
- jedsmith 16y agoI won't commit HN suicide by questioning his choice of Clojure (edit: the downvotes and only positive replies are interesting, though), but I will focus on the original impetus: it's interesting to me that a few problems are explained in Python, including solutions of how to fix them, but the author doesn't want to use the solutions. Honestly, it sounds like he wrote off virtualenv without trying it, because he'd have far less complaints about porting and dependencies if he had. As for the GIL, the author didn't even consider multiple processes -- he explained them away as a solution for some workloads. A Web app is one giant workload where this model makes sense: multiprocessing is the approach you should be taking with a Web application. Tie a request to one core, and spawn enough WSGI applications for the number of cores you have (and then some). That's an elegant solution to this problem, since a request doesn't need to fart around with other requests in most cases. If your app can't handle multiple copies of itself running, how do you expect it to scale? This reads a little bit like a waffling, like a person who considers a completely different environment and rewrite of the entire stack a solution to some thorns in Python. I'm all for picking an alternative Web stack, but: > I had written a database loader to import Apple’s Enterprise Partner Feed (EPF) and a web crawler in Python and next up was the web interface. > It all seemed like a smooth sailing but in the back of my head I was beginning to have doubts about my decisions. > Why we are choosing Clojure as our main programming language This being the third blog post for an as-yet-unreleased product, I'd say worry about delivering a product instead of justifying a rewrite of your work thus far on your blog. If I were considering funding your startup, this blog post would be a fairly bad sign to me. At any rate, a computer language is just a tool to implement an idea, and focusing strongly on the language of choice is busywork itself.
- technomancy 16y agoStarting a "Why we choose X" post with weak token "here's why W, Y, and Z are inappropriate" blurbs can't be chalked up to anything but flamebait.
- reinhardt 16y agoOr just fanboyism and shiny-new-silver-bullet-ism.
- SeanDav 16y agoSince the OP enjoys Python, I am quite surprised Stackless Python didn't seem to enter the equation.
- st3fan 16y agoIt is a myth that Java requires massive amounts of XML that make your eyes bleed. It is perfectly possible to configure a servlet environment once with 15 lines of XML and then never look at it again. Look at Google Guice for example, which does awesome Java based configuration and composition of components.
- toisanji 16y agothat already massive amounts :)
- ww520 16y agoI actually found Java + Play! to be very productive and fun to develop. Have done 3 projects in that combo already.
- brown9-2 16y agoI agree with this - it is really weird to me to dismiss an entire language and ecosystem because many of it's popular tools are configured through XML. You don't need to follow along with what everyone else is doing.
- nhoj 16y agoI'm writing a java web app without any xml at all. The servlet 3.0 api has some pretty nifty annotations.
- st3fan 16y agoI agree with the Python packaging hell. Things are getting better but it is really hard to beat a simple WAR file that contains all your dependencies. Deployment is also a breeze. Place WAR file on a server, let operations people grab it and drop it in a servlet container. Done. Python need to reach a point where it is that simple. I see people around me handle this with Python but it takes a lot of effort to get it right.
- nubela 16y agoAnd why is this hard with virtualenv / pip ? I don't get it. Sure its not as simple as a single WAR file, but if you are unable to initialiaze a virtualenv bottle, perform a pip install with a dependency file, ensure that the python version is the same, you should not be a administrating a server.
- otterley 16y agoIt's interesting that the needs of the business don't seem to factor into his analysis at all. I'll concede that sometimes there are specific cases on which you need to use a new or non-mainstream language or environment. (I'm 99% certain that this business is not one of those cases.) I'll concede, too, that being on the cutting edge is pretty cool and gets you lots of hacker cred. But if you want your business to survive the departure of the founding team, you need to consider whether you can solve the problem with a mainstream environment. If you don't, don't expect your invention (at least in its current form) to carry any legacy. Case in point: People may think Paul Graham is a fucking genius for selling Viaweb to Yahoo!, despite being written in Lisp, but I assure you none of his code still lives on there, not even a fork. His brilliance is as a businessman for getting Yahoo! to fork over $<lots> to him, not for the technical merits of Viaweb itself.
- eftpotrm 16y agoYahoo bought Viaweb 13 years ago. The challenges then were completely different to what they are now, as were the underlying technologies at all levels. Frankly Viaweb could've been written in the most widely used, predictable technology ever seen and I'd still expect it to have been rewritten in the last 13 years.
- otterley 16y agoSure, most things are rewritten or replaced in the very long term. But Viaweb's code didn't even last a few years.
- gridspy 16y agoYes, but it seems lately that Yahoo is where good startups go to die. Viaweb was purchased because it was successful. According to PG, it was successful because they could implement major features in a weekend.
- otterley 16y ago... and you missed the whole point of my argument. That the original author can major features quickly does not necessarily imply that an ongoing concern after the departure of the original author will also be able to implement major features quickly. Choosing your environment with your successors in mind usually increases the value of your business (assuming, of course, that your valuation has a rational basis, which tech companies aren't always good at determining).
- there 16y agoWhile there are enough programmers that know PHP (which is clearly a plus) there’s just not enough sex going on here. wat
- nickik 16y agophp sux. Thats what he wants to say in a nice way.
- there 16y agoit sounds more like they chose not to use it just because it's not cool, not because of any technical merits.
- dpritchett 16y agoIf you're into tea leaves you could check Tiobe's Magic Number charts and see that PHP apparently peaked last year: http://www.tiobe.com/index.php/paperinfo/tpci/PHP.html http://www.tiobe.com/index.php/paperinfo/tpci/PHP.html
- biznickman 16y ago"While there are enough programmers that know PHP (which is clearly a plus) there’s just not enough sex going on here. As with Perl, PHP really wasn’t in the loop." How is that a valid argument? "not enough sex going on here" ... if you choose a language because it's sexy and not because of its utility, you are making a poor business decision. Digg spent a long time revamping their system in new languages and on new databases and look how that turned out (not that the languages were the core part of their failure, but still)
- JonnieCache 16y ago>"not enough sex going on here" I actually thought he meant it in a Darwinian/Dawkinsian(?) sense. That would have been a pretty neat turn of phrase. But yes you're right, he clearly means sexy. Stupid word.
- dmoney 16y agoIf it means he just doesn't enjoy working in it, and thus might never get the business off the ground, then it's a good business decision.
- hendler 16y agoIn particular, I appreciate this article as much for "Why not Python". I feel Python could easily be the lingua franca if it could deal better with the version issue. Using Scala for similar reasons (the other being general performance). Probably the author underestimated node.js though. Using the author's language, it has a lot of "sex".
- robbles 16y agoI'm not sure that a "lingua franca" is even possible. Even if one language was so far ahead of the others that discussions like this thread were pointless, there would always be resistance from other developers. People just seem to get too attached to the idea of "There's one language to write everything in, and I pick this one."
- enduser 16y agoNo judgement here, but from reading this it seems possible that the author did what I and many others have done: overlooked Common Lisp after one or more encounters with Scheme.
- pavelludiq 16y agoI did this too, last year i corrected that mistake by learning common lisp and now clojure is my second favorite language :D
- vic_nyc 16y agoI have written web applications in Ruby on Rails, PHP and recently Clojure. While I absolutely love Clojure and what it offers, building web apps with it has proven painful, because the library ecosystem just isn't there yet. There is indeed the foundation, as the author mentioned - Ring, the equivalent of Ruby's Rack, and a few other frameworks such as Compojure. But these are very early stage projects, parts of them are still being rewritten and they are relatively poorly documented as of now. If you run into problems along the way "how do you do this?" you would have a hard time finding adequate info online, whereas the amount of information that exists out there for RoR, for example, is incredible (message boards, tutorials, blog posts). But even if you go through the initial pains of figuring out how things fit together, many tools are still missing. An easy to use templating library, for example. (several exist already but they are still early stages /are being refactored). Also things like the gems and plugins ecosystem in RoR - where you can pretty much find gems for so many things out there. (e.g.: tagging, authentication, etc). There simply isn't a comparison. So, while I really love Clojure and I believe the community around it is growing - in both size and its contributions, I would say that, let's face it, writing full web apps in it right now cannot be compared to the productivity you would get in say RoR, due to the immaturity of the tools. That being said, I still see Clojure being immensely useful in other scenarios (for example: A.I. algorithms, high performance data processing, etc) and as such I would use it mostly in those settings, while integrating it with a more mature 'front-end' framework.
- radu_floricica 16y agoI managed to use Apache Velocity with clojure reasonably easy. Maybe not the sexiest template engine around, but it's what I was used to. Plus I can just plug a clojure bit in the existing java webapp and not have to change anything else. Probably works with JSP too...
- pico303 16y agoI had the exact same experience with a project we started recently. We jumped from Clojure/Compojure to Erlang/WebMachine with much better success so far. I did in Erlang in two days what Clojure took me two weeks with numerous false starts to accomplish, mostly because the libraries were so poorly documented or incomplete. I spent more time digging through code and trying to assemble a framework to build upon than I did writing useful business logic. I found the Erlang infrastructure to be well-structured and strongly documented, mostly because of it's maturity. What I surmise is that Clojure is just too young, and its web framework lacks a strong commercial force driving it. Rails has 37signals, Webmachine has Basho, Lift has sites like Twitter and Foursquare. Clojure needs something similar to push it forward. All arguments and emotions aside, I'd say if you're starting to build a new web site, and you're not considering Rails or Lift, you're doing yourself a major disservice. Like others have said, JRuby nicely avoids some of the issues discussed for scripting languages.
- dkarl 16y agoIf library versioning in Python is bad, how would a JVM language be better? In my experience, there is no widely-used post-build-time system for declaring or checking dependencies except for OSGi, which is not spreading like wildfire as I expected it to. The Java model seems to be to bundle all your dependencies into a single deployable app, performing all dependency checking at build time and carefully isolating your app from other apps in an application container. I.e., don't even try to solve the problem of sharing libraries between applications. Oddly enough, C has superior runtime checks (dynamic library loading using major version numbers) and install-time checks (*nix package dependencies) compared to dynamic languages. It is very, very strange to me that other language communities have neither embraced alternatives such as OSGi nor worked to transfer responsibility to native package managers such as dpkg or RPM. C et al. under Linux have set a standard that other language communities don't seem interested in matching, much less exceeding. As far as I know, the standard answer for deploying a security update to a Java library is to rebuild and redeploy the entire application that depends on it.
- herdrick 16y agoClojure has Leiningen for library versioning / package management / builds. It's excellent.
- dkarl 16y agoIt seems to be a compile time only tool. Does it let you safely deploy application code separately from its dependencies? Does it let different applications share libraries when possible? Does it come with tools that let you query the version and dependencies of a deployed library and see how those dependencies are satisfied? Can you push a security fix for a library to servers in the field without completely rebuilding and redeploying every application that uses the library (if you can figure out which ones they are?)
- technomancy 16y ago> It seems to be a compile time only tool. Out-of-the-box it's a development tool, but it has plugins for certain types of deployment: https://github.com/technomancy/leiningen/wiki/Plugins https://github.com/technomancy/leiningen/wiki/Plugins You can create tar/jar/war files, deploy artifacts to remote mvn repositories, push to the Google App Engine or Elastic Beanstalk, etc. Deployment to generic unix servers is handled by Pallet, which integrates well with Leiningen: https://github.com/pallet/pallet-lein https://github.com/pallet/pallet-lein > Does it let different applications share libraries when possible? This goes strongly against the culture of the JVM for various reasons that are outside the scope of Clojure itself. > Can you push a security fix for a library to servers in the field without completely rebuilding and redeploying every application that uses the library. Sure, this is pretty easy to do with Swank, but the specifics are going to vary widely based on the type of deployment.
- F_J_H 16y agoI wonder if discussions like this will someday be analogous to a mechanic blogging about "Why we are choosing SnapOn instead of Craftsman as our tools for building NASA cars", or a chef posting on "Why I moved from Cookware X to Cookware Y". I guess it is important to discuss the tools of the trade, but I wonder how long it will be before asking someone what technology they used to build an app would be like asking a musician what brand her instrument was. ("Hey, great song - is that a Stratocaster?) At the end of the day, does your app enable your business to make money? Heck, I've built a business with revenues in the millions using MS Access as one of the main tools! (A long story there!) What I have learned, which other commenters have already pointed out, is that issues like maintainability after you are gone, finding resources quickly, the size of the user community, etc. are all equally important and should not be overlooked.