Fork me on GitHub
#beginners
<
2021-07-13
>
Jakub Šťastný02:07:00

I need to iterate over all items of a list and return true if all runs of a lambda returned true (and preferably not to iterate once/if it gets first no). For instance say I have `["test", "tests", "abctest", "third item"], I want only to return true if all matched #"test". (If it helps, in Ruby it's: ["tests", ...].all? { |item| item.match(/test/)

ChillPillzKillzBillz13:07:00

As a beginner I would like to vent that there is such a massive difference in all the tools associated with clojure are so different and each of them have their own specific pitfalls.... there is not a lot of text to warn beginners against these.... I started with lein. Very soon realized that adding a library in lein is not as straight forward. I kept on getting errors when I added newer libraries. Then I moved on to boot and I quickly abandoned it because it felt like it was a brand new language!! Finally I've settled on clj because I found the learn-clojurescript ebook which guides you through the process. On another note, setting up emacs is also a massive problem. I've now managed to setup VSCode with Calva and it works ok for me... but there are still issues like how does this get integrated with shadow-cljs or figwheel... maybe there should be a page which gets beginners through these pitfalls so that they can focus on just learning the language instead of having to jump hoops around tooling.... Ok rant over! 😄

drewverlee13:07:14

I understand the pain, every ecosystem is this way however. It's a natural consequence of the trade.

ChillPillzKillzBillz13:07:37

I disagree there! It is not this painful... I work quite a lot with python/C/C++/m-script in my day job. Non of it is this complicated to just setup!!

Bill O'Brien13:07:56

Anything in particular with emacs that I could help with?

ghadi13:07:58

I would love for you to expand upon "errors when adding newer libraries"

Tomas Brejla13:07:56

> adding a library in lein is not as straight forward. I kept on getting errors when I added newer libraries. Can you be more specific? Which libraries did you have issues with? While many use clj (deps.edn) these days, lein is still widely used and I don't remember havin any issue with adding newer libraries. > Then I moved on to boot and I quickly abandoned it because it felt like it was a brand new language!! Interesting. I'd not expect that boot would be a second option. If you look at https://clojure.org/news/2020/02/20/state-of-clojure-2020, boot is far less popular. It's questionable whether it's a good thing or not to study state of X -type of articles when learning X, but I'd personally use such articles to at least get some basic overview about what tools/libs/approaches are there, what's their adoption etc. > On another note, setting up emacs is also a massive problem. I'd probably skip that effort completely when learning clojure/cljs, unless I was already an emacs user before. There's so many things to be learned in the language + platform already, so it's a good idea to focus on these first. VS Code + Calva or IntelliJ IDEA + Cursive might be great choices if one doesn't want to spend ages learning the editor/ide itself. > there are still issues like how does this get integrated with shadow-cljs or figwheel Again, I'd probably spend some time getting used to basics, such as clojure language itself and its tooling, getting used to interactive REPL-driven development, learning some helpful libraries etc. I'd give it a time, relax, not try to learn too many things at once. But of course, if your main interest is to learn web frontend development, it makes sense that you want to try shadow/figwheel asap. I'd probably invest into some tutorials or at least watch some free hands-on on youtube. They might accelerate the learning (starting a project) a lot. In the end, setting up shadow-cljs project that has clj backend and cljs (for example reagent + reframe) frontend is surprisingly easy IMO. There's just quite a lot of things that can go wrong in the process and it helps when you already have some knowledge of the parts being used, got some troublesolving skills etc. IMO, the biggest problem with clojure/clojurescript ecosystem is that it's easy to get distracted and try to learn too many things at once. This process of learning takes time and needs some patience IMO.

Tomas Brejla14:07:31

Btw if I was to start learning clj/cljs again from scratch, I'd watch "on the code again" series on youtube https://www.youtube.com/user/VideosDanA. They're nicely done, short, fast... yet they still (interactively) introduce a lot of important concepts. I really like what Daniel is doing.

ChillPillzKillzBillz14:07:42

guys keep in mind that I come with absolutely NO experience in web development. What is obvious for all you seasoned professionals for me was an experience running from pillar to post and going nowhere fast.... 😄 I am in a better place now.

ChillPillzKillzBillz14:07:17

I am sure I was doing something stupid... I wish I knew about clojurians back then... I could have asked you folks... but I didnt...

ChillPillzKillzBillz14:07:08

"In the end, setting up shadow-cljs project that has clj backend and cljs (for example reagent + reframe) frontend is surprisingly easy IMO. There's just quite a lot of things that can go wrong in the process and it helps when you already have some knowledge of the parts being used, got some troublesolving skills etc." Can you point me to a tutorial on this?

ChillPillzKillzBillz14:07:13

the structure of the project when using lein is different to clj to boot... and comon guys, this is hard as a new beginner!! Especially if you come from a background of C/C++ like me, where the project structure is a lot more fluid... ok maybe more familiar...

Cora (she/her)14:07:57

when I was learning I struggled with this stuff a lot, too, and I wasn't even using clojurescript on the frontend

Cora (she/her)14:07:55

I got lucky, in a way, that I was using spacemacs and then doom emacs at the time since it made emacs setup for clojure so easy

alpox16:07:19

I felt that emacs is one of the biggest stepping-stones for newcomers. Whoever I heard of trying to get started with clojure entered a book (e.g.) Brave Clojure where the first step is setting up Emacs. I don't think anyone I know made it past the emacs chapters. I believe if tutorials would start with setting up VSCode or Intellij beginners would already have a smoother ride. The confusion about the tools as lein/boot/deps I felt quite a lot too, I'm now happy with just using deps.edn

Cora (she/her)16:07:43

I don't think setting up emacs is the way to go, no way. it's such an investment to get started with

Cora (she/her)16:07:05

I'm lucky that I was already using it, so I didn't have to invest at all

alpox16:07:30

In my beginnings it really looked like you needed emacs to program Clojure from all the tutorials and I almost didn't make it past

Cora (she/her)16:07:30

I've heard people having decent luck with Atom as an editor for Clojure, too, but VSCode has a huge community and tons of momentum, it seems like the natural thing to recommend

Cora (she/her)16:07:26

intellij is really good but it's complex and cursive requires licensing as soon as you use it for anything commercial

alpox16:07:33

VSCode and Intellij are the two editors everyone in my company and all others I had contact with use so yes, there is a big bunch of the devs (Especially web) - well, at least in my country

Cora (she/her)16:07:49

it's all intellij and emacs for clojure, and vscode for some people for typescript and other languages, at my company

Cora (she/her)16:07:14

if calva supported good vim bindings out of the box I'd probably just use that 😅

alpox16:07:17

I'm using VSCode for Clojure after some initial tries with intellij. Calva rocks 😎

Cora (she/her)16:07:07

I should probably just unlearn all my vim muscle memory again

alpox16:07:12

I'm using VIM bindings (NeoVim) in VSCode and have no issues 😄 only very few rebindings were necessary to make paredit happy with hjkl

Cora (she/her)16:07:00

oh wow, this is much more helpful than they have been historically https://calva.io/vim/

Cora (she/her)16:07:12

"This is a call for someone to share their VIM re-mappings"

alpox16:07:38

I can DM my mappings to you 😉

Cora (she/her)16:07:05

I really want to give it a try

Cora (she/her)16:07:10

thank you!!

👍 2
seancorfield17:07:15

I sympathize with @U022LK3L4JJ about frontend/full-stack development in Clojure/Script. There seem to be three approaches: the very minimal stuff documented on http://clojurescript.org (which doesn't seem to get you past "Hello, World!"), the node/npm-centric Shadow-cljs setup (which seems to assume a lot of familiarity with JS/node that I don't have -- and don't want to have), and Figwheel Main (which certainly seems to be the simplest to me -- as a backend developer).

👍 2
seancorfield17:07:59

I don't think frontend/full-stack is easy at all in cljs. I think backend clj is much, much easier to get setup and running. I've attempted to learn cljs several times over the years (my first attempt was back in 2014 I think) and it is certainly getting easier but it is still pretty darn complex and confusing. The last time around (last year), I ended up with a Figwheel Main/`re-frame` setup that I quite liked when I was using Atom/Chlorine, but I haven't tried again since I switched to VS Code/Clover (with Calva for editing/formatting/linting etc).

seancorfield17:07:31

And I certainly do not advocate anyone trying to learn both Clojure/Script and Emacs at the same time! OMG! Stick to whatever editor you're already familiar with, if possible, and just add Clojure integration to it. I can't stand IntelliJ but a lot of people like that and Cursive is an amazing product at this point. The Calva team have also done an amazing job and I heartily recommend VS Code + Calva as another good option to start with. Only if you're already confident with Emacs would I recommend using it while learning Clojure!

ChillPillzKillzBillz17:07:28

@U6JS7B99S I'll take any pointers ... mappings or otherwise...

Tomas Brejla18:07:22

I'd say that booting into cljs is not that hard as it used to be anymore. I found especially shadow-cljs very useful. Working mostly as a backend/integration java developer,since 2007, I didn't have much trouble booting into cljs+reagent+reframe and was able to build and deploy a (rather simple but useful) web app in couple of days. But I have to admin that I already tried to do some using that stack in recent year or two. But never anything serisous. @U022LK3L4JJ > Can you point me to a tutorial on this? (web development tutorial with cljs/reagent/reframe) Check this on the code again video: https://www.youtube.com/watch?v=yVb8PS6a4Mk. It will show you how to create a simple web app - in interactive way. The basics of both reagent ( "react") and reframe ( "redux") are not too hard to understand. But be aware that by jumping directly to this area of development, you risk that you might "skip too many chapters" (and improving your problem-solving skills in new language/platform) which could assist you in your daily development.

ChillPillzKillzBillz18:07:11

@U04V70XH6 See this thread https://clojurians.slack.com/archives/C03S1L9DN/p1626088545350600 I have an issue with figwheel-main... do you know anything about this?

Tomas Brejla18:07:09

and as @U04V70XH6 said: > I don't think frontend/full-stack is easy at all in cljs. I'd say it's that web development in general is quite hard. And not only in cljs, but in js, typescript,... you name it. Too many technologies to learn, everything permanently changing, too many libraries full of bugs, too many tools...

seancorfield18:07:35

@U022LK3L4JJ I don't do cljs so I've no idea about stuff like that.

ChillPillzKillzBillz18:07:04

oh ok... worth asking

seancorfield18:07:35

@U01LFP3LA6P I agree: the frontend world is insane -- I am full of admiration for our frontend team at work... the stuff they deal with is just mind-boggling (and they're doing straight-up JS with React.js/Redux/etc).

Tomas Brejla18:07:40

Btw in fact I believe the most "easy-to-start-with" solution for playing with regent/reframe/cljs might (in the future, not now!) actually be borkdude's scittle 😄 https://borkdude.github.io/scittle/ For example this is the ultra-basic example of "full-stack" guestbook. 1 clj file for backend (can be served using single babashka binary) and 1 cljs file for frontend. https://github.com/kloimhardt/babashka-scittle-guestbook But this solution, while exciting, is very experimental and you will be missing a lot of great features (such as solid REPL integration), would you actually try to code something this way.

Tomas Brejla18:07:42

I am super happy with shadow-cljs. Didn't take too long to get the basic "skeleton" of the application up and running, hot reloading of both the cljs code and css files works superbly,.. very satisfied. I also tried figwheel-main for the same app. Made my app working in the end, but "the road was a bit more bumpy", I'd say. Both alternatives are great, I just found shadow a bit easier (and better documented) for my journey.

MatthewLisp13:07:28

Hello deps.edn masters, i want something equivalent to Leiningen's `:injections` option, to be used with a deps.edn Alias in other words, i want to execute a piece of code, whenever i fire a REPL with that profile, how can i do this?

alexmiller14:07:12

I wrote up an example of that here - https://insideclojure.org/2020/02/11/custom-repl/

👏 2
👍 4
alexmiller14:07:49

you don't need the commas in the last alias there now, that's been fixed since

Antonio Bibiano14:07:40

hello everybody, what's a good library to parse HTML? I once saw a suggestion for XML, which was to use clojure.data.xml and clojure.zip but I was curious if that's the best way for HTML too

alexmiller14:07:28

no, probably not. there are great Java libs for this and it's probably easiest to use those

alexmiller14:07:46

jsoup is one well-known one

2
Antonio Bibiano14:07:27

oh thanks i'll look into it 🙂

Daniel Getz17:07:11

Hi! is there an Wordpress analogy in Clojure?

sb17:07:23

https://www.squarespace.com/ ? If I remember good they use Clojure.. https://github.com/Squarespace/

👍 2
sb17:07:39

But that isnt opensource

seancorfield17:07:00

@daniel.z.getz Not really. Clojure's target market tends to be bespoke software solutions. If you want something like Wordpress, just use Wordpress: it does a great job for packaged software.

👍 2
sova-soars-the-sora18:07:53

Yeah we use Wordpress on a sub domain. Gets the job done in a pretty pain-free way.

sova-soars-the-sora18:07:04

I’d like to master the transducer, I get the general principle I think, but I could use some exercises to practice on

raspasov18:07:57

Have you watched the original transducer talks by RH? Those were very useful for me to grok the concept.

noisesmith19:07:00

@U3ES97LAC how about: • create a set of transducers and use them on a collection and a channel • write code that takes a transducer as an argument to modify its behavior • create a new transducing context (that is, something that uses a transducer in the same way a channel or collection op would, without converting to a channel or collection first)

👍 2
2
raspasov19:07:29

@U3ES97LAC Did you mean “master the transducer” as in use existing transducers, or write your own?

raspasov19:07:08

In any case, I agree with @U051SS2EU. After you watch some talks and get just enough of the idea, practicing the concept is the best way to proceed.

sova-soars-the-sora22:07:24

Ohh, rf is a function passed into the input arguments

sova-soars-the-sora22:07:44

so you can invoke it with (rf) … I was quite confuzzled for a sec there!

sova-soars-the-sora22:07:52

I would love to see line-by-line commentary on core.clj

dpsutton22:07:32

The thing that made it click for me the best was on the transducer page of http://clojure.org. A transducer is a function from a reducing function to a reducing function

sova-soars-the-sora23:07:37

Hmm, neat, I’ll have to ponder that.

hiredman22:07:28

that line is a fn body

hiredman22:07:54

generally you see fns like (fn [x] x)

hiredman22:07:14

but that is shorthand for (fn ([x] x))

hiredman22:07:41

where ([x] x) is a fn body, an arg list and a body

hiredman22:07:53

and a fn can have multiple fn bodies

hiredman22:07:15

(fn ([] nil) ([x] x) ([x y] [x y]))

hiredman22:07:28

so that fn can be invoked with 0, 1, or 2 args

2