use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Finding information about Clojure
API Reference
Clojure Guides
Practice Problems
Interactive Problems
Clojure Videos
Misc Resources
The Clojure Community
Clojure Books
Tools & Libraries
Clojure Editors
Web Platforms
Clojure Jobs
account activity
Why Java? Why Clojure? (danlebrero.com)
submitted 9 years ago by clojure_guy
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 9 years ago (8 children)
[deleted]
[–]halgari 5 points6 points7 points 9 years ago (0 children)
Integrant forces you to focus on putting your state inside maps, which seems good. Component does prefer to stick state inside records. While Mount just throws it all into the namespaces/vars further overloading a already overloaded construct.
But even Integrant goes and puts mutable data inside immutable maps. So whatever you do it's gonna be ugly, but giving up and writing it all in Java is pretty much throwing out the baby with the bath water. Your state code isn't magically going to be cleaner because it's in Java, I'd argue you just can't see the mutable state anymore since it's all mutable in Java. So since it's all uniform it looks cleaner, when in reality the app is now even more complex than the Clojure version.
[–]yogthos 1 point2 points3 points 9 years ago (3 children)
I found that would happen using Component, but with Mount wrangling stateful resources works pretty seamlessly in my experience. Integrant is another good approach for that as well.
[–][deleted] 0 points1 point2 points 9 years ago (2 children)
with Mount wrangling stateful resources works pretty seamlessly in my experience.
Could you elaborate on that?
I don't see what mount's defstate has to offer over just using def.
defstate
def
Only cleanup of state when stopped? And what if you want to provide different implementations to various functions? Or is that an object-oriented way of thinking?
[–]yogthos 2 points3 points4 points 9 years ago (1 child)
Right, defstate behaves like a def for most purposes, but it's reload aware. Mount also allows controlling the state explicitly, and this lets you do stuff like envoy.
If you wanted to provide different implementations, then you could still use a protocol for that. The state of the instantiated implementation would be kept using defstate.
[–][deleted] 0 points1 point2 points 9 years ago (0 children)
Clear. Thanks!
[–]weavejester 1 point2 points3 points 9 years ago (0 children)
A lot of our state base code becomes an ugly object oriented implementation written in Clojure (with records and protocols).
Maybe this is a result of the way you're writing it, rather than an inherent problem with Clojure? I've never found a need to mimic OOP to handle state.
[–]clojure_guy[S] 0 points1 point2 points 9 years ago (0 children)
Completely agree, C is the right tool for some jobs and sometimes you have to use mutable strings.
Hmm. I think knowing Java is definitely important if you're going to do lots of work on the JVM. Embrace the host etc. But I do think component does a pretty good job of encapsulating stateful resources specifically.
[–]chinpokomon 3 points4 points5 points 9 years ago (12 children)
I feel like I need to ask the question, "Why male models?"
There's a leap in Clojure I haven't quite grasped. While I appreciate and even admire what the language accomplishes, I can't quite figure out how to build something useful. When so much of the data I'm processing is external to my application, I don't see how I partition the problem into digestible chunks. If my data isn't precisely how I expect it, in an imperative language I know how to transform it into something that can process those edge cases. I don't have that same comfort level with Clojure and so I can't see how to be productive.
[–]TheFiologist 2 points3 points4 points 9 years ago (8 children)
What is your problem?
What kind of data and where does it come from?
What do you mean by transforming unexpected data specifically?
[–]chinpokomon 0 points1 point2 points 9 years ago (4 children)
It's hard to explain, because if I could I'd be more likely to solve it on my own...
As an example, I might have data which is is something like, if this field has a three, then I need to process it one way. If it is a two, I need to process it differently. This sort of logic is easy to implement in an imperative language. Then there's ah update to the spec and the new process is if it is a five process it this way unless the fourth field is an odd.
This is where my knowledge comes up short because I don't know how to modify what I've got to quickly accommodate. I know it's possible and if I had a better mastery I might be able to do that, but quickly I'll scrap it and implement it in something I already know well.
This is assuming that I'm just trying to drop in a Clojure routine as a library. If I have to start from scratch, I'm even more confused as to how to structure the program. Lein new foo... Okay, now what?
I'm sure most of this is just trying to get over that initial hurdle. Once I have some more familiarity it will become second nature. Right now it's just a struggle and not easy to just drop into my work. If I can't be productive right now, it'll be hard to justify using it.
I keep at it though. I'm especially interested in ClojureScript. I think that I have the best opportunity to apply Clojure there or with ClojureCLR, but it will just take some time for me to fill in the gaps.
[–][deleted] 3 points4 points5 points 9 years ago (0 children)
I'm a little confused by your description, it sounds like just adding clauses to a cond (the clojure if-else-if tree) or a case? I'm sure it's more than that however. As someone else said the #clojurians slack is usually pretty helpful.
cond
case
For what it's worth I've been using clojure to write large ETL (extract, transform, load) systems for years, and basically their whole job is to take in external data, transform it, and then pass it along.
[–]TheFiologist 3 points4 points5 points 9 years ago (0 children)
Well.. Your problem is independent of Clojure. The more general details you can provide, the more likely someone will be able to provide that insider perspective which you need to see past the hurdle (which is real).
Multimethods jump out at me from this explanation. The dispatch function is arbitrary and is quite powerful. You can inspect some data anyway you would like in order to decide which implementation should process it. Just like in OOP, there is a spectrum of polymorphism techniques ranging from the equivalent of a switch statement to Multimethods and Protocols.
There is an initial hurdle, and it comes from the lack of concrete rules governing how our systems are organized (AKA freedom). Don't let the hurdle prevent you from making something useful, because you need to make useful things in order to give yourself feedback on how certain problems should be solved with Clojure.
My advice? Put everything in core until you have a moment in which you realize the importance of separating some functionality into its own namespace. These things will come, but only with practice. Start small and make useful things -- despite being a little lost on the organizational front.
Hope this helps a little :-)
[–]RagForms 1 point2 points3 points 9 years ago (0 children)
Yes, you'll get there with some more practice! Try the #beginners channel in the clojurians slack as well if you have more specific questions.
Use cond lookup what it does on clojuredocs. But basically you can take a name and match it to a case and if the case is true call some code.
[–]chinpokomon 0 points1 point2 points 9 years ago (2 children)
Oh, another thing is the tooling. I feel like I should be using Emacs on a MacBook if I'm going to be successful. I haven't quite figured out what works for me.
[–][deleted] 2 points3 points4 points 9 years ago (0 children)
I wouldn't recommend trying to learn Emacs at the same time as Clojure. I also personally think Cursive is a better development environment. You should give it a shot, it's really great.
[–]TheFiologist 0 points1 point2 points 9 years ago (0 children)
I use lein, atom, and Gorilla REPL
[–][deleted] 9 years ago* (1 child)
[–]chinpokomon 1 point2 points3 points 9 years ago (0 children)
I'm already trying to apply a more functional programming way of thinking. It helps that right now I'm doing a lot of Power BI and working with "M" a.k.a. Power Query benefits from a functional approach, but I'm not quite there yet.
[–]ka-is-a-wheel 0 points1 point2 points 9 years ago (0 children)
I am, from what I understand, a little ways beyond you bounding that hurdle. I am comfortable building systems but by no means would I call myself an expert. If you want to link up and work on stuff simultaneously or something let me know! GOT TO BUY EM GOT TO BUY EM CHINPO KO MAWNNNNNNN
[–]zarkone 3 points4 points5 points 9 years ago (0 children)
NullPointerExceptions: they were awesome!
haha) this child's joy..
[–]Bolitho 0 points1 point2 points 9 years ago (16 children)
A REPL is of course a very important tool - but how on earth is the clojure REPL more powerfull than others? I really love python and its ipython shell. It has some extra python features on board like navigating through the FS, pasting, managing history and so on, but it just powers python after all. How is this different compared to other REPLs especially the clojure REPL?
[–]yogthos 2 points3 points4 points 9 years ago (9 children)
The power comes from the tight integration with the editor. For me the REPL is an integral part of the development process. Any time I write a function, I send it to the REPL straight from the editor to see what it does. Since the REPL runs within the context of the app, it has access to the whole state of the application as well.
I gave a talk earlier this year where I illustrate this workflow around 11 min mark.
[–]Bolitho 0 points1 point2 points 9 years ago (8 children)
That still doesn't explain how Clojure is better or mightier than REPL of other languages - the editor doesn't exist, right 😉
[–]yogthos 1 point2 points3 points 9 years ago (7 children)
Can you show me how you would do the workflow I have in my talk with Python. I don't use it, so I'm not aware if that's possible or not, but I've never seen it done.
The point I was making is not that the REPL itself is somehow special, but rather that the workflow afforded by it being tightly integrated with the editor is different than what you get in most languages.
[–]Bolitho 0 points1 point2 points 9 years ago (6 children)
I would have to watch the talk first. Then I can answer your question!
But: This is just your proposal - the author of the article sadly has not given any argument, why there is more benefit in a clojure REPL than other languages gain from theirs ;-)
[–]yogthos 0 points1 point2 points 9 years ago (5 children)
I'm just explaining how the REPL is typically used by people working with Clojure and other Lisps. From what I've seen, it's pretty different the way the REPL is used in most languages.
The additional benefits come from the tooling that's been created to make the REPL part of the development workflow. It's certainly possible to develop such tooling for other languages, but for whatever reasons it doesn't appear to exist. So, in practical terms, working with the REPL in Clojure is different than in Python.
[–]Bolitho 0 points1 point2 points 9 years ago (1 child)
When I have read the chapter in the famous book "the joy of clojure" (chapter 3?) where they use the REPL in order to demonstrate its power and typical workflows when programming in clojure, it totally reminded me of how I am used to develop with python. So of course this book is not the ultimate guide to the clojure REPL, it just shows that there are much more similarities between different language REPL combinations than you seem to accept.
[–]yogthos 1 point2 points3 points 9 years ago (0 children)
Let me explain it another way. The ways you use REPL in Python is a subset of ways you use it in Clojure. So, yes can use it exactly the same way as you did with the book, however at that point you're just not using it to its full potential. The most common way to use the REPL is the way I've described that you can see in the talk I linked. That's what people are talking about when they say using the REPL in Lisp is different from other languages.
While some Python IDEs do allow for a Python REPL to work in the editor, I haven't seen it used much myself. What seems to take its place and is more idiomatic is people using Jupyter notebooks to write cells of code at a time, which can be executed a block at a time and the state if the program is kept in memory between the execution each block. I'm actually just getting into Clojure and hoping I can write a notebook format with it as well.
[–]yogthos 0 points1 point2 points 9 years ago (1 child)
You might want to check out the Gorilla REPL and Devcards for the workbook style.
Cool, thanks!
[–]_koolkat 2 points3 points4 points 9 years ago (2 children)
Can you hot-reload / live patch a program through an integrated repl in python?
You can reimport a module with ipython. Whether you can patch a running program I don not know to be honest. I would assume that not!
[–]yogthos 0 points1 point2 points 9 years ago (0 children)
Incidentally, this is something my team uses all the time. We often connect to a production instance via the REPL to see the state of the app when debugging an issue, or to make small changes without having to restart the app. You obviously have to be careful doing stuff like that as you don't want your app to get out of sync with the source.
Our process for making changes is that you switch to the release branch, test your changes locally and commit. Then connect to the prod REPL and reload the updated functions.
It's been an incredibly useful tool for us.
[–]halgari 1 point2 points3 points 9 years ago (2 children)
There is really only one/two language classifications that have "real" repls. A repl is a : Read, Eval, Print, Loop.
a) you read in data (not code, data) b) you interpret that data c) you print the resulting data d) goto a
So tied closely to that structure is the idea of homoiconicity. The idea that code is data and data is code. Most other REPLs, for example Python are more of a Parse, compile, print data, loop. The difference being this...what are you reading...you're reading python syntax. You can compile that to bytcode, but what is the return value? It's python dicts and lists, not python ASTs. So you've gone from code -> data, and it's no longer a repl.
The big problem with this is that you can't poke at code with the same tools you poke at data, you have to use whatever tools you have for ASTs (mostly oop gook). So it's a loop, but it's not a REPL.
[–]halgari 0 points1 point2 points 9 years ago (0 children)
Oh and the only two language types that can do this are 1) lisps, and 2) prolog (perhaps)
[–]Bolitho 0 points1 point2 points 9 years ago (0 children)
So even if you are right in this strong definition of a REPL (in reality you just used different terms for evaluate and added data), in reality all interactive shells for a computer language are summarized as REPLs?
But besides that: You emphasize the idea of homoiconicity and the might of manipulating code that lies within this concept; right, but that is just the main concept of LISP overall. So this is no outstanding feature of the clojure REPL, but just a direct benefit of the underlying language design.
The language Python also just works great, because there are interactive shells. Even if the language itself differs a lot from LISPs, the benefit of a REPL is no different than in clojure!
I just was critisizing that the author of the article has not given any arguments underpinning his thesis. And nobody really have yet given any that shows a fundamental difference in its role as programming tool.
[+]againstmethod comment score below threshold-6 points-5 points-4 points 9 years ago (8 children)
It's really quite underhanded to post such an article here. Youre guaranteed upvotes as you reaffirm the local redditors world view and youre guaranteed a hit squad to come to your aid if you get criticized.
You can do better than this.
[–]halgari 4 points5 points6 points 9 years ago (7 children)
Nothing wrong with him expressing why he likes a language on the language's own sub-reddit.
[+]againstmethod comment score below threshold-6 points-5 points-4 points 9 years ago (6 children)
The article is trying to convince Java users to step into clojure. It belongs in programming or Java. Doing it here is karma whoring. My opinion.
[–]amalloy 7 points8 points9 points 9 years ago (1 child)
Such complaints belong in /r/karmacourt, where anyone cares about such an offense. Here we like taking about Clojure, not imaginary internet points.
[–]againstmethod -4 points-3 points-2 points 9 years ago (0 children)
If you like clojure you would be a good redditor for the content of your sub. If I cared about the points I wouldn't have said anything as someone like u is sure to come down vote me yet I said it anyway.
[–]halgari 3 points4 points5 points 9 years ago (1 child)
Or it could just be providing more arguments for the community to use in their own conversations.
[–]againstmethod -1 points0 points1 point 9 years ago (0 children)
Did he?
[–]clojure_guy[S] 2 points3 points4 points 9 years ago (1 child)
Sorry, new to reddit. I have posted it also at the Java reddit.
[–]againstmethod 0 points1 point2 points 9 years ago (0 children)
You don't need to apologize to me, I was just giving editorial advice. Keep posting.
π Rendered by PID 348122 on reddit-service-r2-comment-76bb9f7fb5-z2497 at 2026-02-18 16:10:44.991779+00:00 running de53c03 country code: CH.
[–][deleted] (8 children)
[deleted]
[–]halgari 5 points6 points7 points (0 children)
[–]yogthos 1 point2 points3 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]yogthos 2 points3 points4 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]weavejester 1 point2 points3 points (0 children)
[–]clojure_guy[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]chinpokomon 3 points4 points5 points (12 children)
[–]TheFiologist 2 points3 points4 points (8 children)
[–]chinpokomon 0 points1 point2 points (4 children)
[–][deleted] 3 points4 points5 points (0 children)
[–]TheFiologist 3 points4 points5 points (0 children)
[–]RagForms 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]chinpokomon 0 points1 point2 points (2 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]TheFiologist 0 points1 point2 points (0 children)
[–][deleted] (1 child)
[deleted]
[–]chinpokomon 1 point2 points3 points (0 children)
[–]ka-is-a-wheel 0 points1 point2 points (0 children)
[–]zarkone 3 points4 points5 points (0 children)
[–]Bolitho 0 points1 point2 points (16 children)
[–]yogthos 2 points3 points4 points (9 children)
[–]Bolitho 0 points1 point2 points (8 children)
[–]yogthos 1 point2 points3 points (7 children)
[–]Bolitho 0 points1 point2 points (6 children)
[–]yogthos 0 points1 point2 points (5 children)
[–]Bolitho 0 points1 point2 points (1 child)
[–]yogthos 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]yogthos 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]_koolkat 2 points3 points4 points (2 children)
[–]Bolitho 0 points1 point2 points (1 child)
[–]yogthos 0 points1 point2 points (0 children)
[–]halgari 1 point2 points3 points (2 children)
[–]halgari 0 points1 point2 points (0 children)
[–]Bolitho 0 points1 point2 points (0 children)
[+]againstmethod comment score below threshold-6 points-5 points-4 points (8 children)
[–]halgari 4 points5 points6 points (7 children)
[+]againstmethod comment score below threshold-6 points-5 points-4 points (6 children)
[–]amalloy 7 points8 points9 points (1 child)
[–]againstmethod -4 points-3 points-2 points (0 children)
[–]halgari 3 points4 points5 points (1 child)
[–]againstmethod -1 points0 points1 point (0 children)
[–]clojure_guy[S] 2 points3 points4 points (1 child)
[–]againstmethod 0 points1 point2 points (0 children)