Fork me on GitHub

Hello, if i really like lisp I should be using clojure to write production software right? It has just dawn on me. I started with scheme and right now I am using common lisp for projects. What are the books I should read to get real work done and get a job? thanks. I am trying to have an open mind but i just dont like its link with java. is clojure a real lisp? How so?


It depends who you ask, but clojure is homoiconic and has common lisp style macros


Clojure differs at least as much from common lisp and scheme as those two differ from each other

hiredman03:05:19 is a good read if you haven't seen it yet

👍 2

rhickey gave some talks (over a decade ago now?) at a New York lisp users group called clojure for Lisp programmers


It's also worth mentioning that Java (the programming language) and the JVM (runtime) are not synonymous terms. When I first heard of Clojure in conjunction with Java, my immediate reaction was, “yuck!” Until I learned to differentiate between Java and the JVM. Clojure is a hosted language that targets the JVM and other runtimes like JavaScript, CLR, BEAM (the Erlang VM), and Dart. You don't need to know Java to use Clojure, although it certainly helps to know about Java libraries and understand the JVM when debugging, etc.


@U0282BF0T0W I learned Lisp at university about 40 years ago and liked it a lot but my career path led me, ultimately, to the JVM in 1997 and all my jobs have been on JVM since then, using a variety of languages -- I really haven't had to write much Java in the two and a half decades I've been paid to write software on the JVM. For more than a decade, my job has been writing Clojure. As someone who likes Lisp and also functional programming, I'm very happy that Clojure exists -- it brings me joy every day in my job (and also in my open source projects outside work).

💡 2

I can only think of two downsides to the JVM: 1. It's relatively large and resource-intensive, so it's not a great fit for, say, embedded systems. 2. It lacks support for tail call elimination. I don't do no. 1, so that doesn't matter to me. By choice, I will likely never work on systems where space, memory and energy usage are real concerns. No. 2 is just an minor intellectual annoyance, and we have the loop/`recur` construct as a workaround.


A third non-technical downside might be that the JVM is often lumped in with Java, with a certain stigma. Clojure is thus inextricably linked to Java in people’s minds, even though it's designed to be “platform agnostic.” And many people who are looking for something “other than” or “better than” Java might get the wrong first impression of Clojure.


Perhaps also worth a read is which lists a lot of languages that have implementations that target the JVM (as well as high-profile "JVM languages" -- several of which also have implementations targeting JS, CLR, and other runtimes).

👍 2
Yogesvara Das09:05:33

Is there no stdlib function to remove an item from a vector by index?


no, most likely because of undefined result of such action


How to conditionally wrap a large block without duplicating code? Any other way besides factoring the block out to a function and (if wrap? (wrap (my-fn)) (my-fn))?

Darin Douglass13:05:23

(cond-> (my-fn)
  wrap? (wrap))


I don't think that works for my case because the function would initially be called outside of the wrapper. My wrapper sets execution context for the function call.

Darin Douglass13:05:36

ah gotcha. your initial if doesn’t look that verbose to me. there are somethings you could do but are generally just putting the if in other places ¯\(ツ)


@U02EA2T7FEH heh yeah, figured as much with the if. It just seems to be a fairly common pattern for me and I was wondering if there's some sugar for it. Thanks!


in case (wrap (my-fn)) my-fn will be called before wrap so your wrapper can't affect the result of my-fn


@U04V4KLKC Shoot, yeah, you're right. I was looking to use this with some library code. My mistake is that I thought the wrappers were functions, but they're actually macros. The transformation happens before getting to the evaluator.


I am writing a Clojure program, and I want to call Java methods/grab objects of another program that's already running (I have the source code). The second system is way too complicated to import directly into my project though. Would RMI be the appropriate solution here? I read this blog that seems to support this: I'm curious to hear other perspectives.


what does too complicated to import directly mean?


@U0NCTKEV8 It's a GUI tool with a ton of dependencies. I just want to harvest a few data structures from the tool, but the data itself needs most of the rest of the system to be running for it to work.


depending on what exactly you want to do (mostly on the size and number of dependencies of the clojure program, is it kind of a one off or not), I would embed a clojure repl in the tool, and load the program into the repl and run it


if clojure is on the classpath of the tool, and the runtime is initialized (basically the clojure.lang.RT class is referenced so its static inits run) there is a system property you can set to cause clojure to run a repl socket server

Søren Sjørup20:05:53

This SO post has a way to parse all forms in a file, but is there a library that allows me to do it independent of the underlying platform? In this case I want to use nbb.


@soren nbb exposes read-string which isn't standard for CLJS, but you can use it

Søren Sjørup20:05:51

Ah thank you very much!


Let me know if this works or not for you, there's probably improvements we can make there

Søren Sjørup21:05:20

It works but I only get the first form.

Søren Sjørup21:05:14

But the hack from the SO post works 🙂


I'm considering to expose in babashka and nbb


since it's already used in there anyways

Søren Sjørup21:05:27

That would be awesome! 🙂


Already in bb master now

Søren Sjørup13:05:11

Haha, you're so fast.


nbb is still todo, should not take too long


Published in nbb 0.3.12 :)

🎉 1