Fork me on GitHub
#beginners
<
2021-09-02
>
adi04:09:41

@harsjoshi1614 To augment the great resources above, here's hands-on material that drills the REPL-oriented habit (among other things important for newcomers): https://github.com/inclojure-org/clojure-by-example (I'm the primary author of the workshop. We teach it at IN/Clojure every year.)

gratitude 4
👀 2
❤️ 2
pez05:09:10

That's a lovely and wonderful README! I have completely missed this resource. Will give it a spin!

gratitude 2
adi06:09:11

Thanks! I love Calva, by the way. It's become my go-to choice for absolute newcomers, because it's so lightweight to set up out of the box, and ... smooth ... especially with the inline eval + display of results. It makes me not miss LightTable any more. The very first avatar of our workshop used LT for similar reasons. Personally, I'm firmly in the Emacs world. You'll have to pry it from my cold dead hands, but overall I love how far Clojure IDEs have come. It's awesome! IntelliJ + Cursive, VSCode + Calva, and Emacs + CIDER (+EVIL for Vimmers) is the holy trinity for me. I use all three with my Emacs keybindings :)

calva 2
Harshit Joshi08:09:54

@U051MHSEK thanks i will check this out too !

2
😎 2
avfonarev10:09:14

Has anyone looked at the Learn Reagent, Learn Re-frame, and Learn Reitit courses? Are they worth recommending to someone who wants to jump in quickly?

ChillPillzKillzBillz13:09:06

I can only speak from my own experience. As a beginner I spent a long time just learning clojure first. Once you have wrapped your head around clojure, reagent or other frameworks are easier... IMHO!! I started with the usual books Clojure for the brave, http://learn-clojurescript.com etc. Then after a lot of experimentation got my head around reagent. I am not brave enought to start with Re-frame or reitit yet... best of luck to you!!

avfonarev13:09:47

Actually, it’s not for me. I have a decent understanding of Clojure, have been toying with it for several years as a research tool. It’s just that a fellow company is exploring quick learning opportunities related to “full stack Clojure”.

practicalli-johnny20:09:01

They all seem very high quality courses, although I suggest some general experience of Clojure first will make them easier to understand. I don't believe they are ment to teach Clojure, outside the specific needs of their subject. So yes, if someone want to know the specific topic quickly, they seem very good.

👍 2
ChillPillzKillzBillz12:09:29

is there a way to check using clojure.spec if an entity is a function?

Alex Miller (Clojure team)13:09:21

I'm not sure what you mean by entity but there is the ifn? predicate

ChillPillzKillzBillz13:09:13

Thanks Alex. By entity I mean the variable?... value? we are checking in spec... (s/valid? ::function <entity>)

Alex Miller (Clojure team)13:09:43

then yes, ifn? is the best predicate for that

Noah Bogart15:09:43

is it possible to add a path to the clj repl invocation without using -Sdeps? i can say clj -Sdeps {:example {:extra-paths ["test"]}} -M:example, but that’s much more verbose than something like clj -Spaths ["test"] or similar

Noah Bogart15:09:21

to be clear, i want to add to the existing :paths vector that already exists in the deps.edn, not replace

Noah Bogart15:09:41

the reason i ask is because i have an alias :test {:extra-deps {lambdaisland/kaocha {:mvn/version "1.0.861"}} :extra-paths ["test"] :main-opts ["-m" "kaocha.runner"]} , and the :main-opts is run when i use clj -M:test, when what i’m looking for is to just pull in the deps and path

seancorfield15:09:28

@UEENNMX0T Do you mean "I just want to pull down the deps and not run anything" or "I want to pull down the deps and run something other than Kaocha's --main` function"?

Noah Bogart15:09:25

First one. I don’t want to run anything, just pull in the deps and paths

seancorfield15:09:33

The former can be done using the -P option (before -M).

Noah Bogart15:09:03

Oh, I’m sorry, I mean that the repl loads

Noah Bogart15:09:15

“Run something other” yes, the repl lol

seancorfield15:09:10

You have to separate out the :main-opts to another alias like :runner

👍 2
seancorfield15:09:37

Eventually -A will stop running :main-opts and will just start a REPL. Right @U064X3EF3?

Alex Miller (Clojure team)16:09:24

it's still better to separate out your aliases imo

4
seancorfield16:09:39

I tend to use -X to run most stuff now, so when I use -A it "does the right thing" because there's no :main-opts anymore. I don't know if Kaocha has an exec fn entry point tho'?

Noah Bogart16:09:13

Oh yeah, I forgot about exec-fn. That isn’t run when using -M, right? Just -X. That’s a good way to handle this

41ph4_Ph4un15:09:47

A quick clarification on specs and instrumentation. Am I correct if I'm under the assumption that instrumentation means that all used functions get their inputs validated and no other checks are generated?

noisesmith15:09:11

if I understand you correctly, yes, but there can be surprises, eg. an arg that is a function can get called with generated args to verify it has the expected type

41ph4_Ph4un15:09:23

a-huh.. hence the problems with higher-order-functions

Adam Stokes21:09:36

Hi all, does clojure.tools.cli support not having short flags? I couldn't find any reference of anyone doing something like that

Adam Stokes21:09:07

(def cli-opts
  [["-d", "--boot-disk-size SIZE", "Size of boot disk (format: 150GB)"]
   ["-b", "--boot-disk-type TYPE", "Type of disk (eg. pd-ssd)"]
   ["-n", "--name NAME", "Name of instance"]
   ["-t", "--machine-type TYPE", "Type of instance"]
   ["-i", "--image-family IMAGE", "Name of OS image to boot"]
   ["-z", "--zone ZONE", "Region to boot instance"]
   ["-x", "--no-address", "No address?"]
   ["-h", "--help", "Display help"]])
I'd like to do away with those short flags if possible

dpsutton21:09:04

> Option specifications are a sequence of vectors with the following format: > [short-opt long-opt-with-required-description description > :property value] > The first three string parameters in an option spec are positional and > optional, and may be nil in order to specify a later parameter.

dpsutton21:09:17

sounds like you must include the position but can make it nil

Adam Stokes21:09:51

ah! great thank you @dpsutton

Franco Gasperino22:09:11

Is it common to assign a global binding with def when performing interactive / repl development, even if it's intended to be assigned with a defonce? Is this the preferred route during iteration to avoid restarting the jvm?

noisesmith22:09:34

the principled version is something like component / integrant / mount

☝️ 2
noisesmith22:09:09

but using def to bind in the repl is a normal thing yes

☝️ 2
dpsutton22:09:15

i do lots of (comment (def foo ...)) all the time

👍 2
2
Brandon Olivier23:09:38

I’m trying to work with Playwright in CLojure and they have a Java line that looks like this

Browser browser = chromium.launch(new BrowserType.LaunchOptions()  .setIgnoreDefaultArgs(Arrays.asList("--mute-audio")));
How would I translate that to Clojure?

Brandon Olivier23:09:30

I think I have something. I can import it with

(import com.microsoft.playwright.BrowserType$LaunchOptions)

Brandon Olivier23:09:42

Then I can instantiate it w/ the name BrowserType$LaunchOptions

noisesmith02:09:11

(.launch chromium (-> (BrowserType$LaunchOptions.)
                      (.setIgnoreDefaultArgs ["--mute-audio])) 

noisesmith02:09:46

something like that