Fork me on GitHub
#clojure
<
2021-02-27
>
evocatus02:02:32

can you point some (not very long) examples of Clojure expressivity? Something to show to a person only introduced to mainstream languages to show the difference of LISP approach?

evocatus02:02:44

there are people who claim that "homoiconicity is overrated" and other languages have achieved certain level of power on par with LISP

evocatus02:02:03

when I advocate Clojure I usually follow Rich Hickey talks and speak about values, time, state, immutability

evocatus02:02:57

but immutability is default in languages like Rust and Kotlin

lassemaatta07:02:26

(Disclaimer: I don't have experience with kotlin.) One thing to consider is that immutability is more than just having a language construct like the Java final keyword: how idiomatic it is to handle immutable (and persistent) objects and collections(!) in the language (e.g. does the standard library expect you to use them). Clojure and its APIs embrace immutability and make it very pleasant to work with them. I don't know if the immutability in Kotlin is closer to just final or the way clojure operates, but my understanding is that at the moment it does not offer persistent collections (`kotlinx-collections-immutable` is still experimental).

lassemaatta07:02:58

I mostly do java projects and in order to actually get even close to the immutable concepts like clojure I need to a) use final everywhere, b) use libraries like org.immutables to construct objects and c) use libraries like to construct collections.

phronmophobic02:02:53

If you're trying to "sell" clojure, I think https://www.youtube.com/watch?v=VSdnJDO-xdg [https://github.com/matthiasn/talk-transcripts/blob/master/Hickey_Rich/ClojureMadeSimple.md] covers that well. The slide on how Clojure does what it does is:

slide title: How?

+ Data orientation

+ Simplicity

What matters is not just what a programming
language makes possible, but what it makes
         _practical_ and _idiomatic_.
With regard to expressivity, he talks about the different flavors of "small" when it comes to programming > So program size matters. Smaller is better. This is one of the few areas where we have research. People have done research and said: smaller programs have fewer bugs. It is just that simple. It does not matter what programming language it is. Smaller programs have fewer bugs. > > Bigger programs have more bugs, longer time to market. They are harder to maintain, and they are more brittle. > But what I think is interesting is that there are two flavors of small. A lot of languages focus on concision, which is size in the small. How small is your if statement? How small is a function call? How tiny are your constructs? How much overhead, how much syntactic stuff is there? And there are a lot of languages that focus on that: Ruby, and Python, and a lot of languages are actually very good at concision. > > But the bigger impact on a program overall is not moving from 42 characters to 20 characters. That only gets you 2x. The biggest thing is moving from more specificity, which bloats your program, to more generality, which shrinks it. That is the big payoff. That is the area where you are going to get a payoff much higher than 2x.

👍 3
evocatus02:02:44

another good talk is "Narcissistic design" by Stewart Halloway

raspasov12:02:16

Just watching that talk 😂

evocatus02:02:10

I face it every day writing in Go - things change under your feet all the time

seancorfield02:02:11

@gr.evocatus Even after a decade of Clojure in production, I still don't find it easy to persuade people who only know mainstream languages. So much of what Clojure brings to the table is very alien to them. It's hard to get people past that at times.

raspasov06:02:03

For me, back in 2013 this was the talk that convinced me to to try Clojure https://www.infoq.com/presentations/Are-We-There-Yet-Rich-Hickey/ I was very much into OOP pattern fetish, and kinda loved it. I think the key phrase for me was “just take a step back and imagine you don’t love it (OOP)” 🙂.

seancorfield06:02:29

Yeah, I think you've really got to go through the cycle of loving OOP but then running into all the problems it causes and recognizing them -- and there's a lot of Stockholm Syndrome around OOP unfortunately...

😂 3
raspasov10:02:25

You’re probably right, unfortunately… Esp. since most people are taught OOP-centric, place-oriented languages as a first language… It’s the “industry standard” in 90% of cases

evocatus10:02:45

even children at schools hear "variable is like a box"

raspasov11:02:47

They should hear it, and should also hear “that is NOT a good thing in 98% of cases” 🙂

raspasov11:02:14

Unfortunately, most people don’t realize/know the second part

evocatus13:02:54

I'm a part time school teacher. And when I explain Python I never use this "box" example. I use "tag" and "name"

raspasov08:03:19

@gr.evocatus that’s a better one but unfortunately the real problem with Python and all other languages without value semantics is that there’s no way to know (without walking the whole data structure) if the world has changed underneath that tag/name;

seancorfield02:02:19

It's interesting reading @viebel’s new book because it's focused on data-oriented programming -- Clojure's style -- but teaching it for "other languages".

👍 3
JoshLemer05:02:01

I wonder if there will be any changes to core.async (for clojure-jvm at least) once Project Loom is completed. In particular, maybe we would no longer need to have two different apis for >!/`>!!` , <!/`<!!`

Alex Miller (Clojure team)13:02:41

No plans to look at this until Loom is done and in an LTS release

❤️ 3
hiredman05:02:33

https://clojure.org/dev/contrib_libs lists core.async as being under active regular development, so maybe rich is thinking about it right now

hiredman05:02:37

(I was going to say it was "stable" and not under active development but thought I'd check first)

Alex Miller (Clojure team)13:02:50

Still actively (but sporadically) working on it

raspasov12:02:25

Btw, not sure if this is the correct place to post this, but https://www.4clojure.com seems to be down (and has been down for the last days I’ve checked) I loved showing it to people who might want to try Clojure (and also doing some of the examples myself once in a while). Does anybody know who is in charge of 4clojure?

raspasov13:02:07

Very nice 🙂

Max Deineko13:02:08

Might it be worth reporting via <mailto:[email protected]|[email protected]> or github repo issue with location info? Fwiw it seems to be available & working from Austria..

raspasov14:02:12

Woah, it actually works from Chrome! (I normally use Safari)

👍 3
raspasov14:02:20

That is quite strange.

raspasov14:02:41

@U9TGHG3LP thanks for pointing this out

Max Deineko14:02:43

A quick test revealed that while wget, firefox & chromium all load 4clojure site fine on my machine, curl does report empty reply from server. So it looks to me like an older nginx version might be causing this: https://stackoverflow.com/a/55067301/4386035 . There's already an open ticket with safari issue at 4clojure github repo, so I guess whoever's hosting the site will be made aware of the problem eventually..

👍 3
borkdude13:02:11

Why is this not in clojure.core on the JVM?

cljs.user=> (source dispatch-fn)
(defn dispatch-fn
  "Given a multimethod, return it's dispatch-fn."
  [multifn] (-dispatch-fn multifn))
/cc @wilkerlucio

☝️ 3
Alex Miller (Clojure team)13:02:38

Add an ask question, seems like a reasonable thing to want

aratare13:02:23

Hi there. So I'm getting some weird behaviour from Clojure tools CLI and not sure if this is a bug or not. I have something like this in my options:

["-v" nil "Verbosity level; may be specified up to 2 times. Levels: INFO (Default) -> DEBUG -> TRACE"
    ;; If no long-option is specified, an option :id must be given
    :id :min-level
    :default 0
    :update-fn inc
    :validate [(fn [a]
                 (println a)
                 (<= a 2)) "Verbosity level cannot exceed 2."]]
and a is printed as true instead of either the level before or after applying update-fn. Is there a way to work around this so I can validate after update-fn has been called? Thanks in advance.

seancorfield17:02:27

@rextruong :validate operates on the initial option value as part of the option parsing process; there's no subsequent validation step. It might be a useful enhancement so feel free to post it as a question on http://ask.clojure.org tagged in the tools.cli category and when I'm next making a pass over the Contrib libs I maintain, I'll create Jira tickets from things there.

Alex Miller (Clojure team)18:02:40

Not tagged - should be in the contrib libs / tools.cli category

seancorfield18:02:01

Ah, right, ask has "tags" and "categories". Message updated.