Fork me on GitHub
#beginners
<
2018-08-31
>
brandon.n.atkinson04:08:57

what is the idiomatic way to iterate over HTMLCollection and NodeList in cljs? I'm surprised it doesn't work out of the box

coinedtalk06:08:24

https://cljs.github.io/api/cljs.core/array-seq or

(extend-type js/NodeList
  ISeqable
  (-seq [array] (array-seq array 0)))

tobias.vetter07:08:09

@admay Is Cursive so much better than its alternatives?

tobias.vetter07:08:02

@sbauer I am sad to hear this. But I already had that feeling…

tobias.vetter07:08:22

Thing is that Emacs and Vim have a rather steep learning curve. (Example: Yesterday I wanted to install the Clojure Layer to Spacemacs, and now the editor can not even start correctly anymore because of some error. I am sure it would take me hours to debug that. Calva for VS Code, on the other hand, worked out of the box.) So easier alternatives are good for starters with Clojure.

zdot10107:08:22

I wonder if Spacemacs is a bit more fragile? I've hardly had any issues with vanilla emacs, even after maintaining 3 or 4 configurations spread across a few computers over the years with varied package stacks, but Spacemacs seemed to break a lot right away when I tried it (not saying its like that, just that in my limited experience it was).

sb08:08:22

As a beginner (1-2yo experience), i could say .. start with emacs not so good idea. I used many editors, VScode etc.. in the first half year with terminal/repl, after this switched to intellij/ cursive which i use now too. Since 2-3 months ago i can use emacs in good way, i know when is that emacs ‘bug’ (i did smthg wrong) or clojure code fail. So as you see, that is learning path. I did a mistake, i started with emacs.. that is killer for beginners

tobias.vetter12:08:00

I agree. I think this is a downside of that Clojure for the Brave and True book. It wants to sell you Clojure and Emacs in a bundle.

novel08:08:32

I think the fragility of Spacemacs is due to the fact that the packages are loaded from MELPA and not from MELPA stable. But right now the Clojure-Layer from Spacemacs seems not to get well along with the latest Cider version. I think Spacemacs has a solution for this problem in their upcoming version (0.300), where they introduce some sort of stable repo for the packages. Hence, until the release of Spacemacs 0.300 I’d consider Clojure to be broken for Spacemacs (unless you use Spacemacs’ devel-branch, or you manually pin the cider packages to MELPA-stable).

tobias.vetter12:08:11

This is correct from my understanding. They need to fix this fast, because for beginners this makes Spacemacs nearly unusable without hours of hacking around in its config. I want it to work so much, but everytime I try I am back to VSCode after 30 minutes.

coinedtalk08:08:52

If I want to make a one page clojurescript app that runs entirely in the browser, what should I use? reagent?

tobias.vetter12:08:14

Other persons here pointed me out to Re-Frame, which is based on Reagent. https://github.com/Day8/re-frame

tobias.vetter12:08:37

However, I have not really tried it. But it looks good from far away.

curlyfry08:08:05

@coinedtalk There are a few alternatives, but my personal favorite for that purpose is reagent (take a look at re-frame too after you've learned the ropes in reagent, it brings some very nice structure to the application)

chokheli12:08:59

Hi Clojurians, I’m having hard time updating record via HugSQL. SQL:

-- :name update-person! :! :n
-- :doc updates an existing person record
UPDATE persons
SET first_name = :first_name, last_name = :last_name
WHERE id = :id
Code: (db/update-person! {:id 15 :first_name "F" :last_name "L"}) Error: ExceptionInfo Parameter Mismatch: :first_name parameter data not found. :face_with_monocle: The fact is it does actually retrieve the data with that very ID if I call get-data function.

manutter5112:08:49

Looks right, maybe a stale compile hanging around somewhere?

chokheli12:08:39

No idea, has already restarted REPL a few times…

manutter5112:08:04

try quit REPL/ lein clean/ restart REPL?

manutter5112:08:36

Also double check for dash-vs-underscore typo, it’s real easy to do and to miss

chokheli12:08:22

Well, here’s a catch: I have a configuration in the same namespace: db. and somehow REPL doesn’t seem to resolve configuration def when I evaluate it, although eval is successful.

manutter5112:08:28

Hmm, I dunno then, it’s weird

manutter5112:08:33

There’s a #hugsql channel, seems fairly inactive, but you might want to try it

chokheli12:08:56

I’ve solved it, name duplication was the problem. Thank you!

tobias.vetter12:08:42

Are those books any good? https://www.manning.com/books/the-joy-of-clojure-second-edition https://pragprog.com/book/shcloj3/programming-clojure-third-edition Is there another good introduction other then Clojure for the Brave and True?

eggsyntax13:08:36

@tobias.vetter Joy of Clojure is my very favorite Clojure book, but it's somewhat dense; possibly better as a second book (although if you've done Brave &amp; True already, you may well be ready for it). Programming Clojure is also good, and should work well as a first book.

jaihindh.reddy13:08:38

@tobias.vetter Absolutely. Joy of Clojure was a joy to read. The pace is a bit high though. It's a whirlwind tour of the ideas behind Clojure more than the details (although there are quite a few useful tidbits). If you've watched all of Rich's and Stu's talks, then you'll feel right at home. Programming Clojure is closer to a cookbook than Joy of Clojure and has more details.

jaihindh.reddy14:08:46

Stuart Halloway. Many members of Cognitect in fact, have given great talks about Clojure and software engineering. Stuart Sierra, Timothy Baldridge, Michael Nygard, David Nolen, Alex Miller and Fogus are the ones off the top of my head. Stuart's Narcissistic Design is especially funny. https://www.youtube.com/watch?v=LEZv-kQUSi4

tobias.vetter11:09:36

Was a quite interesting watch.

jaihindh.reddy13:08:13

Note: I'm a beginner myself. Haven't used Clojure in a professional setting (, yet).

coinedtalk13:08:37

I like codinggame

tobias.vetter14:08:56

I think this is web based?

coinedtalk13:08:50

lets you learn clojure at your own pace with minigames

coinedtalk13:08:07

like help batman defuse the bomb etc

alexmiller13:08:30

Programming Clojure is amazing

alexmiller13:08:43

you should buy copies for all your friends

alexmiller13:08:29

for intro books, I think the best options right now are Brave Clojure, Getting Clojure, Living Clojure, or Programming Clojure

tobias.vetter14:08:07

Pragmatic Bookshelf describes Getting Clojure as an expert book: https://pragprog.com/book/roclojure/getting-clojure

alexmiller14:08:35

My personal opinion having read it is that that is a misclassification

alexmiller14:08:29

I’d check out the book excerpts and see what you think http://media.pragprog.com/titles/roclojure/hello.pdf

ericcervin21:08:21

I finished Getting Clojure a few days ago. I think the author does a great job of splitting the text into Basics/Intermediate/Advanced topics.

tobias.vetter11:09:56

Looks good. I actually have read another book (Eloquent Ruby) by the author.

alexmiller13:08:58

they all have different approaches and so if you try one and don’t like it, try another one!

john14:08:00

Programming Clojure is my fav'

rcustodio14:08:11

Good morning

rcustodio14:08:58

I did this macro, but it keeps giving me warning, any tips??

(defmacro execute [pool func & body]
  `(.execute ^ExecutorService ~pool
             (fn [] (~func [email protected]))))
Reflection warning, catalog/services/es.clj:60:22 - call to method execute can't be resolved (target class is unknown).

rcustodio14:08:07

Thanks @schmee

mario.cordova.86214:08:08

@tobias.vetter I don't know if you have made up your mind but I also thought Spacemacs would have a deep learning curve after I first tried it and got stuck inside a buffer. But in all honesty if you stick to it for a week and give it an honest shot you will pick it up well enough to be able to work with it. I am also a beginner and have been using it for a little over a month. I can move around and do editing.

tobias.vetter14:08:04

I want to like it, but stuff always breaks on my with Spacemacs. I am not trapped in some window or menu, but it breaks when it wants to install dependencies.

dadair15:08:48

You could configure it to not auto update

dadair15:08:57

So you can stay on a stable build

eggsyntax16:08:18

@tobias.vetter are you seeing breakage related to CIDER, or other stuff? CIDER breakage is due to an unfortunate disagreement between the author of CIDER and the author of SM about whether it's reasonable to treat snapshot builds as deployable code. CIDER has had a ton of churn lately (working on improvements!) some of which has broken stuff for users; SM unfortunately goes with the latest-n-greatest build. Hopefully not a long-term problem (and SM is adding the option of defaulting to only using stable builds), but as dadair points out, you may want to stick with a stable build for now.

tobias.vetter17:08:44

It broke after I agreed to install the Clojure layer after I first opened a Clojure file.

eggsyntax17:08:22

Oh, interesting. Fair enough, just wanted to toss out a warning signpost for the SM update issue I'm aware of. BTW I'd expect you could solve that problem by deleting your .emacs.d directory and re-cloning it from Spacemacs. Wouldn't hurt to delete your .spacemacs too to ensure nothing there is broken, but probably only worth it if you haven't modified it much yet (and of course you would need to re-add the clojure layer to dotspacemacs-configuration-layers).

eggsyntax17:08:58

Or actually it sounds like you didn't explicitly add that layer -- so that would be a good thing to do.

eggsyntax17:08:12

I can understand just giving it up as a bad job for now, though 😉

tobias.vetter17:08:08

I just did that. Now it breaks on another step.

tobias.vetter17:08:08

This happened after I did this:

mario.cordova.86217:08:32

What instructions are you following to install spacemacs?

tobias.vetter17:08:45

git clone ~/.emacs.d

eggsyntax17:08:27

Well, that one does look CIDER-related, so you may be tripping over the thing I mentioned. This may be a bit of a process, I’m afraid. What I’ve done to keep things stable is add the following at the beginning of my dotspacemacs/init (in .spacemacs). It may or may not work for you. You should be able to get a definitive solution by posting the error in #cider — hopefully someone can walk you through whatever the current fix is.

(add-to-list 'configuration-layer-elpa-archives '("melpa-stable" . ""))
  (add-to-list 'package-pinned-packages '(cider   . "melpa-stable") t)
  (add-to-list 'package-pinned-packages '(clojure . "melpa-stable") t)

tobias.vetter17:08:33

Thanks for the help. But I think I will stick to VSCode for a while and then will look if Spacemacs and its dependencies work.

eggsyntax18:08:11

Can't blame ya 🙂

chase-lambert01:09:18

if you do decide to give spacemacs another try you might want to use the develop branch. it was explained to me that in some ways it can be more stable than the stable branch because it's seeing a lot more active bug fixes I think. I'm usually a stable version of everything kind of dude but I made the switch and it's not only been smooth running, it also starts up much quicker for me. To try it out, after you clone the github repository as you did, you would just do:

cd emacs.d
git checkout develop
then when you start spacemacs you will be in the develop branch and can install the clojure layer. Sounds like a lot but it worked great for me and I'm loving it.

tobias.vetter07:09:18

I will try... But isn’t the develop more unstable?

eggsyntax16:09:57

Yeah, things break more often, but then they git fixed faster 😜

eggsyntax16:09:57

I’d say consider giving it a shot, and if it’s working well, freeze it for a while and don’t worry about updating until you’re ready to turn your attention back to tweaking your dev environment.

alexmiller15:08:10

probably good too, I haven’t looked at it since the 1st edition. The second ed targets Clojure 1.6 (currently stable is 1.9).

mario.cordova.86215:08:59

Lmao whats with the book covers for Clojure? :rolling_on_the_floor_laughing:

schmee15:08:26

not Clojure, all the books from that publisher look like that 🙂

mario.cordova.86215:08:22

If anyone is curious

seancorfield15:08:35

As I recall, both editions of Clojure in Action were rushed to print: a new version of Clojure appeared before each edition was published but the editors refused to allow another pass over the book to ensure it was brought up to date. Much as I like a lot of the Manning books, their editorial process leaves a lot to be desired, IMO.

alexmiller15:08:33

That is a particularly bad Manning cover :)

eggsyntax15:08:01

Oh, I dunno, I kinda like it 🙂

alexmiller15:08:12

Book authors typically have little influence over the cover btw

nisehl16:08:25

Hello, are there any clojure workshops with more in depth material ? this one was a joy to go through but only covers topics up to concurrency https://github.com/cognitect/clojure-lab

alexmiller17:08:40

that material is based on the intro workshops we do before the Clojure conferences (like the upcoming Clojure/conj). http://2018.clojure-conj.org/training/ in case you’re interested

denisgrebennicov17:08:23

Can I have 2 projects inside of a projects.clj? For example for client and server apps? Define twice (defproject ...) ?

lilactown17:08:34

@denis.fuenzalida for client and server, you would usually use profiles

lilactown17:08:05

e.g. you’d have a :client profile with client dependencies and commands, and a :server profile for server dependencies and commands

denisgrebennicov17:08:22

@lilactown thanks Will. Another fast question regarding websockets. For this the best framework to use is aleph, right? Any other alternatives? What would you recommend

dadair17:08:16

@denisgrebennicov there’s Sente and Pedestal as well

noisesmith17:08:33

sente is a wrapper on the communication layer, it works with aleph or pedestal

john17:08:38

http-kit too, I think

john18:08:01

TooTallNate's websocket server is pretty easy to wrap too

denisgrebennicov18:08:22

Aren't agents like actors but with a function being passed to the actor in order to process the message? I mean of course agents do not have supervision and stuff, but it could have been implemented, right? Link to stackoverflow question: https://stackoverflow.com/questions/3259296/how-clojures-agents-compare-to-scalas-actors

noisesmith18:08:30

the message is the function so it's inverted - you don't send data to a function and get data back, you send a function to some data and it updates itself

john18:08:51

IIUC, the traditional "actor model" is a non shared memory situation

john18:08:21

So agents can bang on the same state. But actually you usually use them in more of an actor like way

risinglight18:08:49

how do you folks deal with so many options to explore? It sometimes feels a bit like the JS world with 3-5 different popular choices at each lib decision

dadair18:08:24

I generally grab one that looks ok, try it out, and if it works for my problem I keep it. I also don’t generally use too many libraries (especially compared to front-end JS projects).

seancorfield18:08:55

@risinglight You can always ask for advice on library choices -- but don't be surprised if there are two or three that seem equally popular and also well-maintained. Clojure is opinionated about some things (at a core abstraction level, mostly) but not about others -- and libraries proliferate because of that.

seancorfield18:08:22

But also, in Clojure, libraries all tend to follow those core, idiomatic abstractions too so any choice tends to be "good".

risinglight18:08:36

That’s good to know. It just feels overwhelming after awhile 🙂

seancorfield18:08:59

It feels less and less overwhelming over time as you get used to the ecosystem -- if that's any consolation? 🙂

hiredman18:08:08

it is also an evolving space, jetty supports websockets these days too (I am not sure if are any clojure libraries around that, or any attempts to unify that with ring anywhere)

hiredman18:08:08

so what was true when a lot of clojure libraries and abstractions got their start (ring, aleph) isn't true now

seancorfield18:08:09

This can be quite a helpful site for library choices, or at least to look at the landscape https://crossclj.info/ (but, yes, also a bit overwhelming).

seancorfield18:08:46

@hiredman What are we using for websockets these days? Several years ago Fumiko and I built a p.o.c. based on Sente and Netty, as I recall...

hiredman18:08:49

we are using https://github.com/mrniko/netty-socketio which provides all of http and websockets, and http://socket.io on top of http and websockets

seancorfield18:08:57

You're not using much of an abstraction layer over that, right?

seancorfield18:08:46

(a lot of core.async but otherwise... just raw interop? you can tell I haven't dug into that part of our codebase yet!)

hiredman18:08:12

no, I guess, we aren't using a lot of http://socket.io stuff, mostly just as a transport layer for messages

hiredman18:08:05

we do have a ring adapter so we can write regular ring handlers on top of the webserver provided there, but it isn't used very much

hoopes19:08:28

Has anyone done development on cljs from "within" a flask (or any other web framework)? For example, I have a python flask server, and I want to have it serve my cljs from /app. This is easy enough once I build the final JS/CSS/etc assets, but during development, how would I go about that? I have a flask dev server running and serving my HTML templates, but I can't also have live reloading? Should I just do my dev with the cljs live reloader, and expect to build/serve it from the flask app later?

noisesmith19:08:57

figwheel can make reloading work via a web socket, while your app talks to your real server

risinglight19:08:28

@hoopes I just figured this out myself w/ figwheel-main and the Django dev server the other day w/ the help of bhauman in #figwheel-main. Long story short, you can use :output-to and :output-dir to get the js files into a dir that is served by Django dev server, in my case /static. The dev JS in turn connects to the figwheel dev server for hot reloading

noisesmith19:08:34

(I think this does require figwheel and your server being on the same host, but I'd assume that's easy to ensure during dev)

hoopes19:08:52

no kidding

noisesmith19:08:08

yeah, what @risinglight said in more detail :D

noisesmith19:08:32

yeah, the thing that makes it just work is that figwheel just wants a socket connection, it doesn't need to be the http server serving the js itself

hoopes19:08:41

awesome, i'll give it a shot - the funny thing about this slack is i have like a directory full of chat snippets from super-helpful things i don't want to lose to slack limits 🙂

hoopes19:08:50

thanks @noisesmith and @risinglight!

bhauman19:08:31

@noisesmith the same host isn’t required

noisesmith19:08:22

oh - I thought it would run into cross host validation issues

bhauman19:08:39

it already does if you have a different port

noisesmith19:08:50

oh, good to know

bhauman19:08:28

the browser allows you to talk to a local websocket regardless of crosshost issues

bhauman19:08:36

implemented some super hairy stuff that that communicated to a locally running auth process that way once

john19:08:19

hyeah, there's a lot of un-exploited opportunity down that avenue

m13122:08:47

what jvm version does clojure 1.9 require?

m13122:08:28

I wanted to build a javafx integration for alpine Linux but theyre stuck at java 8

seancorfield22:08:19

@m131 Clojure 1.9 will run on Java 6 onward. Clojure 1.10 will require Java 8 onward.

m13122:08:22

thank you! it's been a long time since I've compiled a jar to distribute- i found my java 10 compilation failed to run on java 8, but is it backward compatible? if I make a lein uberjar on a java 6 runtime can any user with java 6 onward run the jar?

seancorfield22:08:29

I don't use AOT and haven't had a Java 6 environment around for years so I can't say with any certainty, sorry.

m13122:08:09

ok thanks, i guess at the least, if I get it working in alpine that's a good starting point

seancorfield22:08:37

I would expect that a compiled uberjar, built on Java 6 would run on Java 6, 7, and 8, because I would expect that level of backward compatibility from the JVM...