clojure

New to Clojure? Try the #beginners channel. Official docs: https://clojure.org/ Searchable message archives: https://clojurians-log.clojureverse.org/
stathissideris 2020-11-24T10:56:14.121600Z

Two related questions: (1) Do you agree that a lot of ex-Rubyists became clojurians? (2) If true, why do you think it happened?

2020-11-24T11:02:14.121700Z

https://de.surveymonkey.com/results/SM-CDBF7CYT7/ check Q3 looks like only 9% of clojure developers recognize ruby as primary

2020-11-24T11:05:07.122Z

here you can get links to the results of other years https://clojure.org/news/2020/02/20/state-of-clojure-2020

borkdude 2020-11-24T11:43:36.122200Z

That's only the recent questionnaire. You should probably look at the timeframe 2007-2012 to see if Clojure converted Rubyists to it.

borkdude 2020-11-24T11:43:57.122400Z

Because after that time, it wasn't a sudden surprise that there was such an an alternative

borkdude 2020-11-24T11:44:20.122600Z

The company that became Cognitect, Relevant, was a Ruby shop before Clojure came

alexmiller 2020-11-24T14:51:17.125100Z

fyi it was Relevance, not Relevant. there was definitely a surge at one point (around when Rich did the talk at RuPy)

alexmiller 2020-11-24T14:51:53.125300Z

generally people comfortable with dynamic typing but in need of better performance for server apps

lukasz 2020-11-24T14:52:43.125500Z

It definitely was a trend 7-5 years ago (my team moved from Ruby to Clojure around that time) and I remember "Clojure vs Ruby" type talks happening at various meetups and what not. Puppet for example wrote Puppet server in Clojure around that time (IIRC) while puppet core is still a DSL written in Ruby etc etc

borkdude 2020-11-24T14:55:07.125700Z

sorry, Relevant was typo

2020-11-24T16:42:46.126100Z

I've definitely worked full time for multiple companies that did their first draft in ruby but switched to clojure for performance / server resource reasons

2020-11-24T18:36:41.126300Z

Interestingly, I'm not a big fan of Ruby, but love Clojure.

borkdude 2020-11-24T18:37:08.126500Z

You are not alone.

2020-11-24T18:39:00.126700Z

I think that could indicate that Clojure is just all around better than Ruby, and since Ruby has no killer ecosystem like Python, it make sense that Clojure would attract Rubyist. You get access to a larger eco-system (jvm/js), better safety (immutable/functional), better performance (multi-threaded/JIT), better interactivity (REPL), and I'm skipping on the details.

2020-11-24T18:39:58.126900Z

I think if Clojure had have a RAILS competitor, there'd be even more of an exodus. Now I think, since Elixir has created a RAILS competitor (Pheonix), I think Rubyist are now moving to Elixir over Clojure

mjw 2020-11-24T19:39:53.129200Z

For those of you who use spec, how has adopting spec affected your usage of records? Do you find yourselves now preferring maps over records, or has your use of records continued unchanged?

seancorfield 2020-11-24T20:16:17.130200Z

@matt.wistrand I wasn't using records much before and I still don't 🙂

👍 1
mjw 2020-11-24T20:29:39.130600Z

I haven’t used records much either apart from components (and it looks like that’s not necessary anymore), but I recently picked up Clojure Applied and noticed that records are used for data modeling there. ¯\(ツ)

dharrigan 2020-11-24T20:31:30.130900Z

In my applications, I've not used Records yet, it's been maps all the way 🙂 (with a few vectors for good measure)

dgb23 2020-11-24T20:31:49.131100Z

This discussion strikes me as interesting. I never considered Clojure because of runtime performance. My projects are typical custom web based software/tools/sites. The reason I initially got into learning it and now using it for real is that I got increasingly frustrated by other languages. The paradigms, the boilerplate, the weird workarounds… Then I remembered Scheme and Racket and looked for something that is like those but with a stronger focus on production.

2020-11-24T20:32:14.131300Z

I will not put words in @alexmiller's mouth, but I have a dim recollection of him commenting on whether he would emphasize them as much if he wrote the book today.

seancorfield 2020-11-24T20:37:31.131500Z

Yup, Alex has said that if he were writing Clojure Applied today, he would use maps more and records less.

👍 1
mjw 2020-11-24T20:39:01.131800Z

Thanks for the info!

dharrigan 2020-11-24T20:41:52.132Z

This may be useful, it's a bit old, but I feel still quite useful:

borkdude 2020-11-24T21:12:17.132600Z

I've rewritten clojure.spec from a protocol based impl to a map based impl because babashka couldn't handle protocols back then :)

borkdude 2020-11-24T21:12:19.132800Z

https://github.com/borkdude/spartan.spec

denik 2020-11-24T21:42:43.135600Z

What’s the fastest way to logically compare two data-structures containing values of different types?

(compare [:a "a"]
         [:a 1])
Execution error (ClassCastException) at java.lang.String/compareTo (String.java:134).
class java.lang.Long cannot be cast to class java.lang.String (java.lang.Long and java.lang.String are in module java.base of loader 'bootstrap')

alexmiller 2020-11-24T21:43:22.136Z

compare for equality or for ordering?

alexmiller 2020-11-24T21:43:36.136300Z

for equality... = :)

alexmiller 2020-11-24T21:43:59.136800Z

for ordering, you'll need to make a custom comparator that can handle whatever types you want to handle (lots of choices to make there)

denik 2020-11-24T21:46:14.138300Z

equality, thanks!

alexmiller 2020-11-24T21:54:50.138800Z

Clojure's = is a deep operation, checking all nested collection values

denik 2020-11-24T22:13:39.139600Z

does it terminate early upon finding something that is not equal?

2020-11-24T22:16:04.140100Z

user=> (= '(0 1 2) (range))
false

2020-11-24T22:16:14.140400Z

that wouldn't have returned if it didn't exit early :D

😁 1
bronsa 2020-11-24T22:16:35.140700Z

:) I was gonna show

user=> (= [1 (reify Object (equals [_ _] (assert false)))] [2 3])
false

2020-11-24T22:17:35.141600Z

but as @bronsa shows, it's up to each object to define how it implements an equality check - most collections short circuit before checking the full input

🙏 1
jmckitrick 2020-11-24T22:36:50.142100Z

What’s the current ‘best way’ to import a local java jar into a CLJ project?

2020-11-24T22:45:19.143100Z

you can use eg. lein or mvn to install it to the local cache, but usually you'd want to also have that jar propagate to a maven repository somewhere (so other devs, or ci, can use the same artifacts)

2020-11-24T22:46:38.144500Z

I've used a maven store that works over s3, and "artifactory" (a saas artifact repository that works with maven) in the past

seancorfield 2020-11-24T23:59:32.145500Z

@jmckitrick If you're using the Clojure CLI / deps.edn, local JARs are supported directly via :local/root -- no need to install it.