Fork me on GitHub
#beginners
<
2022-05-03
>
Job03:05:21

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?

hiredman03:05:12

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

hiredman03:05:15

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

hiredman03:05:19

https://www.clojure.org/about/rationale is a good read if you haven't seen it yet

👍 2
hiredman03:05:01

rhickey gave some talks (over a decade ago now?) at a New York lisp users group https://youtu.be/cPNkH-7PRTk called clojure for Lisp programmers

leifericf04:05:55

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.

seancorfield04:05:14

@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
leifericf05:05:18

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.

leifericf05:05:21

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.

seancorfield05:05:15

Perhaps also worth a read is https://en.wikipedia.org/wiki/List_of_JVM_languages 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?

delaguardo10:05:01

no, most likely because of undefined result of such action

sheluchin13:05:11

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))

sheluchin13:05:03

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 ¯\(ツ)

sheluchin13:05:31

@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!

delaguardo14:05:58

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

sheluchin14:05:53

@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.

Dave20:05:39

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: https://nakkaya.com/2009/12/05/distributed-clojure-using-rmi/ I'm curious to hear other perspectives.

hiredman20:05:28

what does too complicated to import directly mean?

Dave20:05:22

@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.

hiredman20:05:00

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

hiredman20:05:22

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 https://stackoverflow.com/a/24922859/ 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.

borkdude20:05:25

@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!

borkdude20:05:28

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 🙂

borkdude21:05:39

I'm considering to expose https://github.com/borkdude/edamame in babashka and nbb

borkdude21:05:05

since it's already used in there anyways

Søren Sjørup21:05:27

That would be awesome! 🙂

borkdude13:05:01

Already in bb master now

Søren Sjørup13:05:11

Haha, you're so fast.

borkdude13:05:29

nbb is still todo, should not take too long

borkdude15:05:27

Published in nbb 0.3.12 :)

🎉 1