News for hackers. Stuff that matters.
Re:The Future of Clojure by jakebasile on Thursday December 10, 2020 @04:56PM (#25379284)
I've said it before, and I'll say it again. I will continue to write Clojure for a living as long as I am able to find a job willing to pay me to do so. I have never encountered a more pleasant environment to do my work. I think Clojure isn't going to "go away" any time soon as long as there are other people like me still around.

I do think that Clojure shops (like all software shops) need to dial back the torture interviews / homework / tests, but that's really a bigger thing that just Clojure. I think more could be done to market Clojure to the non-believers, but I don't have specific ideas on how that could be done.

You can take my parentheses from my cold, unemployed hands.

Re:The Future of Clojure by jb1991 on Thursday December 10, 2020 @11:38PM (#25382372)
> I do think that Clojure shops (like all software shops) need to dial back the torture interviews / homework / tests

I work in three main language, including several years of Clojure work. When I applied to a new Clojure shop in Germany, the first step was a lengthy take-home assignment that was time-consuming and vague. After spending a couple days on it, I never got a reply.

A second Clojure startup in Italy did the same to me.

In both cases, there was zero guidance and it felt more like a guessing game about what they were looking for than an actual coding evaluation.

I have never experienced this in any of the other langauges I've used professionally. I've had to do simple, short technical screens, but only Clojure companies seem to expect that you give up big amounts of your time for no pay for the honor of applying to them.

That really needs to change.

Re:The Future of Clojure by simongray on Friday December 11, 2020 @02:19AM (#25383251)
> That really needs to change.

Here's a different anecdote:

I've had two Clojure-only jobs here in Denmark and neither of them had any homework assignments. I got hired at the first and only interview in both cases. One was my first job after finishing uni and the other one was the job after that.

Now I work at Copenhagen University, also writing Clojure and ClojureScript (so the third Clojure job, although it was never advertised as such) along with a little bit of Java for projects inherited from my predecessor. I didn't have any programming assignment while interviewing here either.

It's not that we don't get interview assignments in Denmark, but I've only had to do them in Python, PHP, Java, and Javascript - i.e. mainstream languages.

Re:The Future of Clojure by bit_logic on Thursday December 10, 2020 @05:25PM (#25379625)
I'm a bit surprised to hear this, I thought Clojure shops would be better than this. It was must hard to find any candidates and they're still doing the stupid leetcode interview style? Are these companies putting any thought into their hiring process?

That process was created by FANG because they can abuse their candidates and still get a lot of applicants (although I think this is less true than it used to be)

But to use that same hazing ritual at a smaller company with the hiring funnel further reduced by a niche language? Really stupid.

Re:The Future of Clojure by smarx007 on Thursday December 10, 2020 @07:56PM (#25380976)
Alternative perspective: we were thinking to hire an M.Sc. thesis worker to do some work in Prolog and we definitely contemplated how to make the interview harder. The point was not to be monsters. Instead, Prolog is harder than JS and thesis is shorter than a few-year contract and there is less help on SO. If we hire someone who can barely write Prolog or understand what RDFS inteference is, the output will be nearly zero. Also, if the person struggles to complete something in 6 months, they will get anxious too and nobody wins. But obviously not a regular "hard" algorithms interview. Also, a senior engineer was essentially suggesting ways to completely rewrite my Prolog code in PRs for quite a while. So I hope you can appreciate why Clojure and other niche shops are a bit more selective.
Re:The Future of Clojure by johnnycerberus on Saturday December 12, 2020 @12:08PM (#25399694)
Prolog is not harder than JavaScript, it is just different. I would hire somebody that is interested in Prolog and good with data structures and algorithms in general, and by good I mean knowing the nitty-gritty behind them. In my experience, exotic languages are not enough, they are not good indicators that you have a prospect in front of you.
Re:The Future of Clojure by mto on Friday December 11, 2020 @07:08AM (#25384865)
Recently seen some statistics (if I could just find them) where clojure was one of those languages with more people wanting to work with it than jobs. Compared to something like Go where it was the other way round
Re:The Future of Clojure by jakebasile on Thursday December 10, 2020 @07:45PM (#25380904)
I agree, but it's definitely still common enough even among Clojure shops. I think it's an insight wide plague but despite so many of us hating it, it persists.
Re:The Future of Clojure by bIAW7hAhDO on Thursday December 10, 2020 @05:52PM (#25379891)
Honest question: Why is clojure so much better than the rest?
Re:The Future of Clojure by sankyo on Thursday December 10, 2020 @07:09PM (#25380596)
Everything is a function, functions are first class.

REPL based development gives you instant feedback. lets you write a function in your editor and then run it, change it, run it again. If your idea of REPL is python or ruby, then you are not getting the entire picture. https://stackoverflow.com/questions/5671214/is-lisp-the-only...

Immutable by default. This helps with debugging and solves thread safety. Feel free to pass around references without worry.

Java interop - you can use all the jars

"isomorphic" - write clojurescript for the browser, Clojure for the server

Re:The Future of Clojure by rtpg on Thursday December 10, 2020 @09:05PM (#25381396)
I think the libraries/standard collections having the functions they have is a _huge deal_.

Some other example, Python and JS are both similar languages in many respects. But even something as simple as not having list comprehensions makes JS more fidgety when you're writing simple code.

Python not having great utils for stuff like "give me this dictionary, but without these three keys, but keep the original dictionary intact" (Clojure has dissoc for this) also makes it a bit fidgety compared to Clojure.

"You can write all of this" maybe, but at one point you're really going upstream from the base language.

Re:The Future of Clojure by techdragon on Thursday December 10, 2020 @09:12PM (#25381437)
What do you mean python doesn’t have good tools to select what you need from a dictionary and keep the original intact, you just use a dictionary comprehension and boom you’re done...

  new_dictionary = {__k: __v for __k, __v in original_dictionary.items() if __k not in {‘key1’, ‘key2’, ‘key3’}}
(written on my phone without a repl to double check but the technique is sound and i use it all the time)
Re:The Future of Clojure by rtpg on Thursday December 10, 2020 @09:18PM (#25381480)
I disagree about this being good. I think this is ugly as sin. This is an aesthetics point but isn't most of this aesthetics anyways?

I want `select` and `dissoc`. I also would like for those to be performant (instead of requiring a bunch of copies). I don't want to have to choose between expressiveness and performance.

I don't write Clojure in the day-to-day but I think it hits those beats very well.

Re:The Future of Clojure by adamkl on Thursday December 10, 2020 @07:07PM (#25380582)
Rich Hickey has a bunch of good talks about simplicity, functional programming, and immutability which sort of lays out the ethos behind Clojure, and how it differs from other (primarily object oriented languages), but for me, one of the main appeals is the interactive nature of developing with Clojure.

That, combined with the fact that everything is generally made up of simple data structures (lists, vectors, maps, and sets) just makes working with Clojure fun (for me at least).

Here’s a great example of what I’m talking about:

https://vimeo.com/230220635

Re:The Future of Clojure by kazinator on Thursday December 10, 2020 @08:02PM (#25381022)
> how it differs from other (primarily object oriented languages

That includes every major Lisp dialect.

Re:The Future of Clojure by simongray on Friday December 11, 2020 @04:53AM (#25384015)
The interactive development is definitely Lisp heritage, but not "simplicity, functional programming, and immutability".
Re:The Future of Clojure by kazinator on Friday December 11, 2020 @06:50PM (#25393349)
Functional programming and programming with immutable objects (by choice) is definitely Lisp heritage.

What's not Lisp heritage is to have a vector or hash table to which you can add an item to get a new container, such that the original remains the same.

It's a generalization of consing an item onto a list, though.

Re:The Future of Clojure by mbil on Thursday December 10, 2020 @06:55PM (#25380454)
Compared to other languages, I've found Clojure makes it much easier to iteratively turn an idea into code.

Say you're writing a pure function...

You start with just data and a sense of how the output might look. Let's say I have APIs providing me with a user record and a list of transactions, and I want to get that person's balance...

Maybe you start with some canned data

        (let [person {:name            "Matt"
                      :id              12345
                      :current_balance 100.10}
              txns   [{:person_id 12345 :amt 10}
                      {:person_id 44444 :amt 0.5}
                      {:person_id 55555 :amt 10}
                      {:person_id 12345 :amt 11}
                      {:person_id 12345 :amt -5}
                      {:person_id 66666 :amt 3}]]
          (->> txns
              count)
          )
        => 6
and maybe you want to filter the transactions to just that user

        (let [person {:name            "Matt"
                      :id              12345
                      :current_balance 100.10}
              txns   [{:person_id 12345 :amt 10}
                      {:person_id 44444 :amt 0.5}
                      {:person_id 55555 :amt 10}
                      {:person_id 12345 :amt 11}
                      {:person_id 12345 :amt -5}
                      {:person_id 66666 :amt 3}]]

          (->> txns
              (filter #(= (:id person)
                          (:person_id %)))
              count)
          )
        => 3
then you want to extract the amount for each of those

        (let [person {:name            "Matt"
                      :id              12345
                      :current_balance 100.10}
              txns   [{:person_id 12345 :amt 10}
                      {:person_id 44444 :amt 0.5}
                      {:person_id 55555 :amt 10}
                      {:person_id 12345 :amt 11}
                      {:person_id 12345 :amt -5}
                      {:person_id 66666 :amt 3}]]

          (->> txns
              (filter #(= (:id person)
                          (:person_id %)))
              (map :amt))
          )
        => (10 11 -5)
and sum those amounts

        (let [person {:name            "Matt"
                      :id              12345
                      :current_balance 100.10}
              txns   [{:person_id 12345 :amt 10}
                      {:person_id 44444 :amt 0.5}
                      {:person_id 55555 :amt 10}
                      {:person_id 12345 :amt 11}
                      {:person_id 12345 :amt -5}
                      {:person_id 66666 :amt 3}]]
          (->> txns
              (filter #(= (:id person)
                          (:person_id %)))
              (map :amt)
              (apply +))
          )
        => 16
and add that to the existing balance

        (let [person     {:name            "Matt"
                          :id              12345
                          :current_balance 100.10}
              txns       [{:person_id 12345 :amt 10}
                          {:person_id 44444 :amt 0.5}
                          {:person_id 55555 :amt 10}
                          {:person_id 12345 :amt 11}
                          {:person_id 12345 :amt -5}
                          {:person_id 66666 :amt 3}]
              bal-change (->> txns
                              (filter #(= (:id person)
                                          (:person_id %)))
                              (map :amt)
                              (apply +))]
          (+ bal-change (:current_balance person))
          )
        => 116.1
the function is done!

        (defn update-person-balance [{:keys [id current_balance]} txns]
          (let [bal-change (->> txns
                                (filter #(= id
                                            (:person_id %)))
                                (map :amt)
                                (apply +))]
            (+ bal-change current_balance)))
I posted here as a series of snippets, but this would have been a single block of code, refined and evaluated and refined and evaluated, over and over, in a REPL-integrated editor. It feels like sketching a portrait or sculpting clay.

"But I can do that in any ol' REPL!" you might say. Try Clojure -- really try it, with an nREPL connected to your running application and to your editor, capturing inputs, playing them back, writing evaluation output as comments -- and then tell me you want to go back to your old REPL. A notebook environment is similar, though clumsier IMO.

Come for the REPL-driven-development, stay for the immutability, the Java library ecosystem, the lisp syntax, the concurrency support, etc. I know going on and on about how great Clojure development is is basically a meme at this point, but that's because it's really great!

Re:The Future of Clojure by fhsm on Thursday December 10, 2020 @08:06PM (#25381057)
How do I know if I’m really trying the repl/editor cycle?

I mess with Clojure with some regularity and each time ultimately back away in a combination of frustration and nerd sniping self awareness as the ratio of editor setup blog reading meta work to actual work hits infinity.

Either I am terrible at finding good setup guides or it’s pearls before swine and I just don’t get the aha moment. I’m starting to think it’s the latter.

Re:The Future of Clojure by Folcon on Thursday December 10, 2020 @11:38PM (#25382374)
I'm in agreement with silly-silly, but I must say I spent an embarrassingly long time coding before I worked out how the REPL editor workflow worked, and nowadays I feel a bit spoiled because I really do miss it when I'm programming in another language like python. Jupyter notebooks come close, but not quite there.

The thing that really helped was watching videos of talks / tutorials of people on youtube coding something up, for example [0]. I'm not calling that one out specifically as a great tutorial, that's just an example of what I mean =)... I personally would start with an example of a form and then build it up in stages, basically tinkering with the form as I work out how I want it to function.

Another thing is that you don't have to use a particular editor etc. I'm not sure for example if you think you have to use emacs. Don't get me wrong it's a great environment, but if you're a beginner to it and clojure, that's not a good combination. Pick something you like which hopefully has a good repl plugin. There are a fair few options these days. Intellij, vscode, atom, vim among others.

Worst case if you'd like me to sit down and have a short call to go over stuff I'd be happy to set aside a little time =)... I've done tutorial stuff before and it's always nice to help someone else get comfortable in the ecosystem.

Hope that helps.

- [0]: [Clojure, REPL & TDD: Feedback at Ludicrous Speed - Avishai Ish-Shalom](https://www.youtube.com/watch?v=Ngt29DyNDRM)

Re:The Future of Clojure by silly-silly on Thursday December 10, 2020 @09:19PM (#25381483)
Nah mate, Stay positive.

You're not the 'swine' here, you shouldn't feel that way. I've learned that sometimes paradigms require the programmer to be in the correct 'frame of mind' before it even begins to make sense, its not you.

In my limited experience, keeping an open mind to tools will get you much further and have more enjoyment in your career and life. Trying to force that square peg into the round hole will just make you hate new things. If the time comes and your mindset is right, the tech will still be there.

Re:The Future of Clojure by mbil on Thursday December 10, 2020 @11:43PM (#25382399)
Sorry if my above comment sounded like gate-keeping, that was not my intention! One of Clojure's biggest downsides IMO is the barrier to entry, with the relatively complex tooling setup being one barrier. I wrote Clojure for a long time before I finally had a powerful tooling environment, and I wish I'd discovered it sooner.

Your specific setup will depend on your primary editor. For emacs, the go-to is https://cider.mx/. E.g., with my cursor beside an s-expression, I can hit a couple keys to evaluate and view the output. Don't give up!

Re:The Future of Clojure by kimi on Friday December 11, 2020 @05:30AM (#25384239)
Just ignore them all. Use IntelliJ with Cursive; has sane defaults and just works. Then you can go the way of Emacs or whatever else you may fancy.
Re:The Future of Clojure by ieugen on Friday December 11, 2020 @01:37PM (#25389029)
Cursive is awesome.

You could also try Calva if you use Visual Studio Code. It works great for me.

Re:The Future of Clojure by Scarbutt on Thursday December 10, 2020 @10:16PM (#25381866)

  let updatePersonBalance = ({id, currentBalance}, txns) => {
      let balChange = txns
          .filter(i => id === i.personID)
          .map(i => i.amt)
          .reduce((i,j) => i + j);
      return (balChange + currentBalance);
  }
Defaulting to immutability it's not as useful in single-threaded environments like nodejs or the browser. The above function is pure though and it's an exact copy of yours but could make it smaller and still be readable.

Picking Clojure over JS today is a very hard sell. Both are dynamic and use the same information model, objects/arrays vs maps/vectors but with the difference that JS has a big enabling ecosystem of libraries. And there's Typescript when you need it.

Re:The Future of Clojure by mbil on Thursday December 10, 2020 @11:35PM (#25382355)
My point wasn't to show that Clojure can produce a concise final function -- it was to show that each step in the process of developing that function can be evaluated within the editor (sorry, I tried to communicate this by including each form's output; not an easy process to show in a static comment), without copying and pasting to/from a REPL, without even leaving your current buffer. If you can do that with JS I would genuinely love to know (since I write JS frequently).

> Picking Clojure over JS today is a very hard sell.

I'm not sure I would choose ClojureScript over JS on the frontend. I haven't worked with ClojureScript much nor thought much about the trade-offs.

> Defaulting to immutability it's not as useful in single-threaded environments like nodejs or the browser.

It might not be as useful, but I think it's still useful. With immutability, you know that inside a scope you can do whatever you want with any data (ignoring atoms for a moment) and you're not going to step on somebody else's state.

> with the difference that JS has a big enabling ecosystem of libraries

ClojureScript has interoperability with all the JS libraries, no?

And if you need strong typing, then I'd agree Clojure is not a good fit.

Re:The Future of Clojure by beders on Friday December 11, 2020 @03:07PM (#25390285)
This might be pure if you can guarantee no one is changing txns - for example - while updatePersonBalance runs. Throw in a async fn in there and all bets are off.

Looking at state mgmt solutions for JS today, many will require or recommend immutable data - for very good reasons.

Re:The Future of Clojure by vikiomega9 on Friday December 11, 2020 @05:53PM (#25392657)
Do you have code snippet examples for handling effectful code and testing it (kinda like a monad where you read from a DB). Would love to see snippets around that.
Re:The Future of Clojure by sova on Thursday December 10, 2020 @07:30PM (#25380780)
Collections are primary. [Sequences], {:key value} pairs called maps, and other collections are the fundamental building blocks. Makes a huge difference when you start with sensible datatypes what sort of power you have.
Re:The Future of Clojure by Scarbutt on Thursday December 10, 2020 @05:03PM (#25379375)
Did Clojure made you unemployed?
Re:The Future of Clojure by jakebasile on Thursday December 10, 2020 @05:05PM (#25379400)
No, I am currently employed. It's a play on the "from my cold, dead hands" phrase.

https://en.wikipedia.org/wiki/From_my_cold,_dead_hands