News for hackers. Stuff that matters.
Re:State of Clojure 2020 by distantaidenn on Thursday February 20, 2020 @10:05PM (#22380638)
Former Ruby guy reporting in. Started using clojure a few years back, but have been serious about it recently. I can't explain how pleasant the language is. Everything just makes sense, and once you get the tooling sorted (which is admittedly a bit convoluted), it such a beautiful environment.

I've always been an emacs user, so clojure was a match. Emacs + cider for repl-based development has been an amazing productivity boost. I wanna shout from the rafters and tell everyone that this is how it should be done! I don't even want to imagine working in another environment anymore.

The Lisp enlightenment is real, in that I started to see code differently -- more in the sense of homoiconicity. I realized I began to lose the distinction between code and data. Everything just merged. The clouds didn't part nor did I ascend to a higher level of being as promised -- but it was definitely a "whoa" moment.

Enough of my blubbering, just wanna say keep up the good work! The language has brought back the fun of programming for me.

Re:State of Clojure 2020 by piokoch on Friday February 21, 2020 @04:19AM (#22381909)
I am wondering how people deal with complicated domain models, I have many objects that have a lot of properties (from 10 to 30), in Clojure I should represent them somehow, probably with maps, the problem is I would have to memorize all the keys... How this is approached in Clojure in a proper "clojurian way", that is without doing something like using Java classes?
Re:State of Clojure 2020 by slifin on Friday February 21, 2020 @07:27AM (#22382587)
Most editors should autocomplete those keys for you if you want somewhere that is a centralised location to find those names you could consider using spec https://clojure.org/about/spec

Spec 2 should separate two concepts, schema: all of the possible keys, and selection: the keys used in this particular function, Spec is also recursive

Because spec is part of the language there is a growing ecosystem for defining specification once in spec then translating them to things like database schema, GraphQL schema, OpenAPI schema etc where they can be more "traditionally" understood

You also get other cool things like you can generate conformant data examples given a spec, and use those to create generative tests, as time goes on I think our static analysis tools will start working partially with specs to further their abilities

Specs also power things like this: https://borkdude.github.io/re-find.web/ and I think we're increasingly using them for validation, error detection etc in the core language too

Re:State of Clojure 2020 by kls on Friday February 21, 2020 @08:01AM (#22382748)
Was going to highlight the same thing. even in OO if you are not using tooling like autocomplete, you have to mentally map all of those attributes. Fortunately autocomplete is fairly ubiquitous and it exists for Clojure as well. Visual Studio Code has pretty good support for Clojure via some contributed plugins.
Re:State of Clojure 2020 by int_19h on Friday February 21, 2020 @07:34PM (#22388483)
In OO, autocomplete can be driven by type information, which makes it that much more reliable and relevant.
Re:State of Clojure 2020 by dgb23 on Friday February 21, 2020 @07:18AM (#22382557)
It is difficult to grasp this from a distance. But generally: you can compose, destructure traverse/query and „update“ (in an fp sense) maps very freely and uniformly. So there is already an opportunity to model your data very differently and to deal with parts of maps in sane isolated ways by querying and destructuring.

Structure in clojure is rather implicit. The benefit is that you can nail down structure where you need it typically with spec.

A helpful hint could be that keywords can be namespaced. This can lead to better uniformity when structuring maps.

Also your dev environment and approach matters here a lot, since you typically run a REPL while you develop, you evaluate forms incrementally and figure out details about your code ad-hoc, which goes way beyond just dealing with names.

Hope that helps a bit.

Re:State of Clojure 2020 by tsmarsh on Friday February 21, 2020 @05:30AM (#22382184)
There isn't one way of doing this.

Quickly figuring out if the model is good, I'd start with a map. If I'm feeling fancy I'll add a schema, if I need to I'll convert to a Record. Because of the way the language works you can probably make those changes without significant logic changes. Its a remarkable language.

Re:State of Clojure 2020 by andykx on Friday February 21, 2020 @01:25AM (#22381311)
I love Clojure, but I felt like 90% of the time it took me to “learn” Clojure was spent actually learning how to use emacs and working with a REPL. Once you get it down, it’s easy to be super productive, though.
Re:State of Clojure 2020 by simongray on Friday February 21, 2020 @03:41AM (#22381760)
I tried learning emacs when learning Clojure, but found IntelliJ with the Cursive plugin to be a much superior experience (the static analysis is awesome). Been writing Clojure for 3 years now (2 years professionally) and I still prefer Cursive to the alternatives, e.g. Atom, Vscode + Calva, emacs. I would say that most of my colleagues with their custom emacs setups still don't have as a good of a development environment as the vanilla experience in Cursive.

I also use parinfer (https://shaunlebron.github.io/parinfer/) rather than paredit, which makes editing Clojure a bit like editing Python. Rather than memorising commands for structural editing, you instead adjust the whitespace using tab/space/delete and the parens reorder themselves accordingly. You can still use paredit commands while having parinfer enabled, but I rarely have a need to.

Re:State of Clojure 2020 by kls on Friday February 21, 2020 @08:06AM (#22382775)
I fells for the same trap and I would caution any readers considering learning Clojure, that do not already know Emacs, to not fall for the same trap. It sets you up for a harder road and increases the chance of failing to achieve your goal. Just use Cursive or Visual Studio Code with the Calva extension and leave Emacs for a later date if that is a goal.
Re:State of Clojure 2020 by bpicolo on Friday February 21, 2020 @09:30AM (#22383339)
Parinfer + Cursive is my strategy too, and I describe it the same way (Pythonish).

This is definitely the least intimidating strategy for ecosystem newcomers.

Re:State of Clojure 2020 by ngcc_hk on Friday February 21, 2020 @05:41PM (#22387700)
Would try this...
Re:State of Clojure 2020 by ilikehurdles on Friday February 21, 2020 @09:08AM (#22383159)
For folks who don't know emacs, I think it's wise to advise most people to focus on learning one thing and learning one thing well. Emacs is huge and learning it can distract from learning clojure. There is Cursive for Intellij IDEA (my personal tool), Atom plugins (the platform I learned clojure on), Visual Studio Code plugins, even vim plugins. But if you're already a vim user, I recommend Spacemacs as it is well documented and works great with clojure with a next to no configuration out of the box.
Re:State of Clojure 2020 by fishmaster on Friday February 21, 2020 @11:33AM (#22384386)
Spacemacs is great, just use the dev branch (I think) instead of master.