10 ms·
Why I'm Productive in Clojure
- dj-wonk 12y ago> What matters to me in a language is whether I can use it without thinking about it. I love this statement. It reminds me of the what it feels to be good at mathematics (not my words): "Your intuitive thinking about a problem is productive and usefully structured, wasting little time on being aimlessly puzzled." from http://www.quora.com/Mathematics/What-is-it-like-to-understand-advanced-mathematics http://www.quora.com/Mathematics/What-is-it-like-to-understa... The author also says more about mathematics: > To make an analogy with math, it's nicer to have a general formula that you can derive others from than having to memorize a whole bunch of formulas for specific problems. > This is where Clojure comes in. With it I can always easily derive a solution to a particular problem from a small set of general patterns. The number of things I have to keep in my head is not overbearing. Any language that lets you spend your brainpower on the essence of the problem is a tremendous advantage and joy. This unlocks creativity and productivity.
- S4M 12y ago> Any language that lets you spend your brainpower on the essence of the problem is a tremendous advantage and joy. This unlocks creativity and productivity. For some reason the only language that let me reach this level is Python. I tried Clojure and Common Lisp, but for some reason I could never be as efficient as I wanted with them, which I think is a shame because in some ways I think the Lisps are superior to Python (due to the "code is data and data is code" of Lisp).
- willismichael 12y agoI really like Python, and use it on a daily basis but I found that after enough experience in Clojure, I prefer it when I have the choice and there isn't a compelling reason to use Python instead. This isn't a criticism by the way, I do understand that people have different preferences of language idioms, and I do occasionally find myself scratching my head about the idiomatic Clojure way to solve a problem that wouldn't have been so hard for me in Python.
- S4M 12y agoWhile I don't think Python is a bad language at all, it has some limitation that I am becoming more and more being aware of them - lack of static typing, limitation of lambdas, speed is an issue sometimes, but on the other hand it's very easy for me to be productive in it. I am pretty sure that its lack of features is making Python easier to "master" (I don't claim to master it, just that I am more productive with it), but this lack can be limiting sometimes, so I am trying to find a solution to have both power and proficiency.
- agumonkey 12y agoCould you tell us more about what you ended up missing from Python ? is it syntax ? concepts ? libraries ?
- S4M 12y agoIt's nothing I miss, it's just that I couldn't keep in my head all the standard way to do things in Clojure/CL. I kept wondering "oh, how do I check if an element is a member of a list in Clojure, again?", or "ok, so I need to put this Sexpr out of this parenthesis, so with paredit I need to do C-right or C-left?", etc. I plan to give Clojure and CL another shot in the future, but for now I am just lack of proficiency with them (I think I wrote about 1k loc in those language, including 4Clojure and project Euler, and some mock projects I tried to do but gave up).
- agumonkey 12y agoOk so only a matter of habits then.
- jcromartie 12y agoI use Clojure a lot, and did more Python in the past. Whenever I come back to Python, I am frustrated by being unable to remember what's a plain old function and what's a method, and the differences defining functions vs classes and methods etc.. In Clojure I know it's always (except for interop) just functions on values. Some functions dispatch to an implementation based on the type of the value, as is the case with multimethods and protocols, but it's still always just function calls from my point of view while writing the code.
- scardine 12y agoObjects in Python little more than glorified namespaces. I always think of methods as a function that gets the namespace where it was declared as the first argument. Yes, there is the inheritance thing, but in Python it is just a mechanism to organize code.
- mimighost 12y agoIn general, Python method is just combination of function object and pointer to "self" namespace.
- agumonkey 12y agoI'd like to know if it's done differently in other languages. In my view, methods are curried function over self with a '.' syntactic shortcut.
- collyw 12y agoThat's pretty much how I view them as well.
- agumonkey 12y agoGreat then.
- kazagistar 12y agoLua does not do the currying bit, but it does a lot less OOP and a lot more "dictionaries with stuff that can do something like prototype OOP if you squint hard enough". Java and whatnot just don't let you really use methods as first class citizens, so it doesn't matter.
- djtriptych 12y ago"code is data and data is code" has a name: homoiconicity.
- S4M 12y agoTrue, somehow I forgot the name of that concept.
- pjmlp 12y agoI was big on Python side back in the early 2000's, on the Perl vs Python for system administration tasks. Maybe because of the experience in using scripting languages on the server side for a late 90's .COM startup in terms of performance, I never could convince myself to use Python other than for shell scripting on steroids. I always looked for other languages in terms of tooling support, IDE support and support for native compilation on their toolchains (JIT or AOT).
- akurilin 12y ago> Any language that lets you spend your brainpower on the essence of the problem is a tremendous advantage and joy. This unlocks creativity and productivity. Isn't that the huge advantage of having a compiler? I can let it worry about whether I connected function input/output correctly and only care about what the function itself is doing.
- mcguire 12y agoAlfred North Whitehead on notation[1]: "By relieving the brain of all unnecessary work, a good notation sets it free to concentrate on more advanced problems, and in effect increases the mental power of the race. "Probably nothing in the modern world would have more astonished a Greek mathematician than to learn that...the whole population of Western Europe...could perform the operation of division for the largest numbers.... "It is a profoundly erroneous truism...that we should cultivate the habit of thinking what we are doing. The precise opposite is the case. Civilization advances by extending the number of important operations which we can perform without thinking about them. Operations of thought are like cavalry charges in a battle---they are strictly limited in number, they require fresh horses, and must only be made at decisive moments." That being said, the proper notation is very problem-dependent. [1] http://introtologic.info/AboutLogicsite/whitehead%20Good%20Notation.html http://introtologic.info/AboutLogicsite/whitehead%20Good%20N...
- deno2 12y agoTo be a language means to be a way of defining thoughts in order to have them delivered to another. With no constraints you could just write random rubbish (a bit like this). With the constraints of Java or C# you write code which does it's job, however a lot of work is in fitting your thoughts within the extensive syntax of the languages' constraints. Clojure, or any other Lisp, helps in that the initial constraints it imposes are simple (). Once you get a feel for the simplicity you get the feel for the power it brings. It's a bit like wingtsun kung fu. Your brain is no way fast enough to react to your opponent fast enough to decide for example is this a hard punch or a soft punch. By that point the punch would have been received, restricting your thinking further. However if your body knows the language of wingtsun there is no thinking involved. Period. Your body knows the language of interacting with another body so leaving your mind the time to make decisions. Your body has embraced the language and can rely on it to keep you alive whilst giving your mind the freedom (time) to make decisions or ultimate kill moves or be creative. Another word for decisions is creativity. The cost of creativity is time. So embrace your language and be creative with your thoughts given the time your language allows. If you feel your language is asking for help unrelated to your problem then either you don't understand your language or the language is not a language at all and maybe another is better for the current context. To sum this range in rubbish clojure: (if (total-time > time-spent-defining-problem) (ask-where-this-time-went total-time time-spent-defining problem) :you-are-at-one-with-your-language-and-in-flow-my-friend) Or think about: (def time (apply + allthetimesyouspentdefiningclasseswhenallyouwantedwasafunction)) End of drunken rant.
- yawn 12y agoI'm curious to see how Clojure fares against the current crop of folks becoming intrigued by statically-typed languages like Haskell, F#, etc.
- gregschlom 12y agoI'm a strong static-typing advocate, and for years this has put me off learning Clojure. (In fact, my very first HN submission, back in 2010, was about Clojure: https://news.ycombinator.com/item?id=1453259 https://news.ycombinator.com/item?id=1453259). I've been coding exclusively in Clojure for the last month however, and I found it extremely enjoyable to use. Much easier to learn than Haskell, for example, because Clojure isn't purely functional. The key of Clojure is that it's pragmatic, as opposed to dogmatic. It's a language designed to solve real-world problems in production environments (hence the focus on concurrency, for example). Also, being a lisp, it's a "programmable programming language", and once you realize the power that that gives you, it's hard not to fall in love with it.
- dominotw 12y ago>'s a language designed to solve real-world problems in production environments (hence the focus on concurrency, for example). It would be nice to see example(s) of clojure solving real world concurrency problems.
- MichaelDickens 12y agoI learned Clojure from the book Clojure Programming (http://smile.amazon.com/Clojure-Programming-Chas-Emerick/dp/1449394701/ http://smile.amazon.com/Clojure-Programming-Chas-Emerick/dp/...). Once the book gets past the basics, it starts giving lots of concrete examples for how to solve real problems idiomatically in Clojure.
- dominotw 12y agoYea but I am looking for actually field reports from people solving hard concurrency problems out in the wild with Clojure. I am yet to see one.
- Touche 12y agoMy biggest problem with Clojure (specifically ClojureScript) is that it's too workflow opinionated. Nearly all Clojure devs use 1 of 2 text editors. Nearly everyone uses Leiningen. Nearly everyone uses some sort of auto-builder. Nearly everyone uses hot-swapping. Clojure wasn't even optimized for this workflow, it's just the only one that works. So as much as I love the language I keep going away from it because I prefer the freedom of my own workflow.
- willismichael 12y agoI'm curious what language and workflow you prefer? In my opinion, there are plenty of other technologies (quite popular ones at that) that have a specific workflow considered "best practice", arguably because "it's just the only one that works".
- Touche 12y agoI prefer any language that requires nothing more than a text editor (any) and possibly a compiler. Where you can use any build system you want and be pretty much just as productive. I agree that there are other languages that suffer the same problem, the .NET languages for example (except kinda F#), but there are plenty that do not (C, JavaScript, etc).
- mjt0229 12y agoC brings in its own problems. Compiler (in)compatibilities, the need to install libraries on a machine to be able to compile and run programs. And besides, in C you still have a build system problem - Make is fine, but it is definitely opinionated about how things happen, and you potentially have to write a lot more boilerplate to get a complex project built with Make than you do for Leiningen, Maven, SBT, etc.
- Touche 12y agoYou don't have to use Make, there are a half a dozen other popular build systems.
- nmac 12y agoI recently migrated to clojure from the php world. I have to say that although I am still learning the language, its actually fun compared to php, which would sometimes feel like pulling teeth to get some basic functionality. Way less boilerplate, and as can be said of anything good, it just works. Also, the idea of thinking in the problem domain versus the subset of problems that arise in languages like php is an acute difference. Just being able to focus on the product as your programming keeps you on task and thinking about new ways to implement features, etc. -- big difference.
- deno2 12y agoI made a career move from dentistry to programming. And I would say that anything I've used pre-clojure is a good approximation of pulling teeth. But even pulling teeth has the benefits of knowing when you're finished and the direct customer feedback is usually good.
- cheez 12y agoWhy did you decide to switch from dentistry?
- deleted 12y ago[deleted]
- deno2 12y agoAn intellectual, emotional disaster. I'd been programming since a child and I think in all honesty I was pushed into dentistry by the people that love me and wanted me to make money. However dentistry in London is medicine in two years then three years specialising in the head and neck. Then two years dentistry training. I found it a LOT of learning facts. I know that knowledge-based systems are better than humans for that application. I had the pleasure of learning human anatomy for two years with Prof Harrold Ellis. Which is what I really took away with me. The guy was a genius. And the other was "If you are not certain then say I don't know, never guess, always seek truth" not that many people appreciate that knowledge in my experience. Robotic surgery yes, lying about the safety of amalgamate fillings no and telling mums of the effects of sugar and carbonic acid drinks was not enough scientific exploration for me. I think I was too young, always the youngest in my year, to really know and show what I wanted to do. I should have studied Physics but was told at the time "I'd end up a Physics teacher" as if this was a bad thing... Pre-uni I wanted to build quantum computers but my Physics teacher at St John Ruskin College school didn't know what direction I should head in (the school at the time was also being ripped off by the head mistress, look it up, bad). After that I got a scholarship to a private school to do A levels which was absolutely brilliant. Dulwich College an excellent school where I was treated like an adult and learnt maths, physics and chemistry. Two of the best years of my life. Nobody noticed really that I wasn't just lazy and so it was very tempting to my parents to be told I could go to the best medical school etc when I pissed the exams. So I went to the best medical school in the UK, Europe not really sure why. After two years depression forced me to take some action and I quit and got a job in a bank as a COBOL programmer. I learnt that COBOL doesn't cure depression but can even make it worse. However I learnt from two old ladies who were probably employed AS computers in their prime. And they were the awesome COBOL dinosaurs. From there on its always been a bit of struggle not having a degree. Although what I've taught myself, and continue to do so, is worth several degrees at least. Probably a PhD or two. I now know a lot of programming languages and have lots of experience in them. Clojure took me to the next level with regards to meta-programming and language design. I still have hopes for genetic programming. My interests now are really into augmented reality and basically augmentation of human perception, memory and "brain power" both in the progression of our species and knowledge itself. If you really want to know where my head is at read The Beginnings of Infinity by David Deutsch http://en.m.wikipedia.org/wiki/David_Deutsch http://en.m.wikipedia.org/wiki/David_Deutsch. He has interesting ideas on quantum computing, knowledge and reality which align most closely with my own. I'm now mostly a "Senior Developer". How about you?
- sternenseemann 12y agoBeing popular on HN is not the best thing for Webservers...
- yogthos 12y agoIt certainly isn't, my poor server went catatonic under the relentless onslaught. :)
- davexunit 12y agoREPL-driven development is wonderful. I'm not a Clojure user (yet), but I write a lot of Scheme. My programs are living creatures that adapt and evolve as they are running. It's refreshing to see that Clojure is seeing real use in the industry. Gives me hope that I can get paid to work with a language I really enjoy some day.
- jptman 12y agoI'm a bit curious about your comment. Do you mean during development you run your code on a REPL and change portions of it , or do you mean you run code in Production in a REPL and change portions of it as it's running? I'm interested to know your setup in either of those cases. The one inconvenience I have about REPL based development is that I need to copy over an expression from my editor into the REPL and if I make any changes in the REPL, like fix a typo, I need to make sure to copy it back to my editor.I guess this may be because I don't use Emacs and have an editor and REPL in one.
- deno2 12y agoREPL Driven development as it's called is really yes having your whole system running at your thingertips (even production for the adventurous). You can execute arbitrary code and get results or see what state has changed. You can also redefine anything (in Clojure at least) that is referred to, such as functions and variables (I use these terms loosely here). Normally you have your IDE configured so that anything executed is executed in the context of the running REPL session. So there should be no need to copy/paste. When done properly with tests running on every change you really can't, as a developer, get any quicker feedback. It's brilliant and empowering! Your issue could be emacs but, for Clojure at least, there is the Cursive Intellij plugin which is now definitely usable. Also there are the brand new IDEs like LightTable. LightTable.com started out with some very different ideas with regards to code organisation and there is still a lot of potential work there. But lighttable instead became open source and a core for plugins. The plugins now range from rainbow parentheses to 'pick your language' evaluation. If you want to discuss any of these ideas or others please do or PM me. I'm always willing to discuss as my girlfriend is hopeless. But then for everything not programming she keeps me sane.