Fork me on GitHub
#beginners
<
2022-03-22
>
dominikk11:03:50

Hello Clojure-experts! I've been trying to learn clojure/script for quite some time know but I'm struggling with moving forward. I'm not a professional programmer but more of an enthusiastic amateur. I read a couple of books, did the exercism track and solved quite a few 4clojure problems ("middle"-difficulty is usually not a big challenge). I'd like to be able to build anything useful, so I thought learning about simple web-applications might be a good way. I looked into the "web development with clojure" book but I feel like it's way too much for someone who has no real prior knowledge of web development. I've been working through the "http://learn-clojurescript.com" ebook and although I've already learnt quite a lot and I'm able to understand most of the explanations, I get totally lost when it comes to the later section's "capstone"-projects. They are very convoluted and complex and I cannot follow the logic of all the different parts. Understanding the functions and code itself is not really an issue I just don't get how it all works as a whole. Apparently I'm still in need of more guidance. Maybe some of the more experienced clojurists can offer some advice on how to continue from here? Maybe you know of some resources which can take my hand and lead me to this next step in learning how to write simple applications?

oxalorg (Mitesh)11:03:33

Hey dominikk! Welcome to the clojure community 🙂 Great work on doing 4clojure and other exercises by youself! 🚀 When you say "simple applications", do you want to write a simple backend (w/ server rendered html pages) or a clojurescript frontend Single page application? Shameless self plug here but I have a video which helps you create a simple todo application in Clojurescript: https://www.youtube.com/watch?v=tRYreGS53Z4 I've heard from a few folks that they were able to follow it along quite well! Maybe give it a try?

dominikk12:03:51

hey! Thanks for the fast reply. I actually watched your videos (and set up the project myself) before I started reading the learn-clojurescript ebook. I liked it a lot and it helped me getting started! I was actually kind of sad the 3rd video you announced in part 2 apparently never came to be, because the other ones where so helpful. Back then I was also still struggling with the tooling and was quite occupied with keeping all the moving parts working 🙂 I was thinking about starting with front-end and after learning enough extending this by connecting it to a database of some sort. I'm an avid rock climber and creating an app to log the routes I climbed (doing some statistics about difficulties etc.) seemed like a neat exercise.

3
oxalorg (Mitesh)12:03:14

Thanks! Glad you found them helpful! :dancer: > I was actually kind of sad the 3rd video you announced in part 2 apparently never came to be, because the other ones where so helpful Sorry about this I just got confused on how I should proceed and what would be the best thing to explain next. > I'm an avid rock climber and creating an app to log the routes I climbed (doing some statistics about difficulties etc.) seemed like a neat exercise. Would you mind if I ask you a bunch more questions? I'm working on something new (https://clojure.quest) to help introduce people to full stack web development in clojure out and this seems like the perfect use-case. 1. Do you have prior experience with web app development? If so which frameworks/languages? 2. Have you created dynamic or static websites before? 3. Have you deployed them? 4. Did you setup an editor for running Clojure code? If so which one? 5. Were you able to "evaluate" code from the editor by sending it to the REPL? 6. Do you understand how HTTP works? HTTP status, body parameteres, POST vs GET, etc? 7. Have you worked with a database before? If so which one? 8. Are you familiar with git and command line/terminal? 9. Why did you decide to learn clj/cljs? Sorry for bombarding you with these questions haha!

dominikk12:03:45

Thank you for your input, I'm happy to answer your questions: 1. no 2. when I was a teenager some 20 years ago 🙂 3. I had a very simple website back then but "deploy" sounds a bit to big of a word 4. Emacs, using cider and kondo. Works great. The http://learn-clojurescript.com ebook showed me how to setup figwheel. 5. yes 6. I know the basics but mostly from a theoretical perspective. Very little practical experience 7. I learned about relational databases using "access". Does that count? 🙂 8. yes, not a bash expert but I'm able to use it for everyday tasks. 9. I had a colleague who is a commonLisp fan. Got interested and fascinated. Clojure seemed more practical than standard commonLisp.

dominikk13:03:41

I need to check https://practical.li/clojure-web-services/ again. The last time I looked at it I got confused and did not understand if it's supposed to be a structured lesson or more of a collection of separated topics. Maybe know, with more knowledge about tooling and libraries I can make sense of it.

oxalorg (Mitesh)15:03:18

Thank you this was really really helpful to understand the gaps in current resources! Sorry I don't have very specific advise for you here except for just fighting through and figuring stuff out, but there are some great videos by Practicalli, and On the code again as well.

oxalorg (Mitesh)15:03:07

I will also be glad to get on a pairing session if you ever need any help, or feel free to ping me personally!

dominikk17:03:07

Thank you, that's very kind! Maybe my approach of studying until I feel like I know everything was a bit off. I decided to be optimistic and just start with my exercise project. I'll just see how it goes and solve problems on the way. Thank you for your input!

🙌 1
Michaël Salihi08:04:58

You can also take a look at https://github.com/prestancedesign/babashka-htmx-todoapp/blob/master/htmx_todoapp.clj Easy and quick to run, commented and you'll learn some basics like: • Run a server in Clojure • How routing basically works in conjunction of Ring: https://github.com/ring-clojure/ring • How to use Clojure Atom (mutable state) https://clojure.org/reference/atoms • Hiccup (the defacto Clojure html "template language")

sheluchin12:03:00

(keyword "x" "1")
=> :x/1
:x/1
=> ExceptionInfo
Syntax error reading source at (REPL:298:1).
Invalid token: :x/1
This doesn't make sense. Can anyone explain please?

oxalorg (Mitesh)12:03:22

Keywords like vars/symbols shouldn't start with numbers. Although something like this: :123 works, it isn't conforming to the spec and will break things like destructuring etc.

V12:03:28

https://clojuredocs.org/clojure.core/keyword

;; keyword does not validate input strings for ns and name, and may
;; return improper keywords with undefined behavior for non-conformant
;; ns and name.

sheluchin12:03:25

Ah, thanks. Didn't catch that part.

oddsor13:03:52

Keywords are cool, but conversion to/from strings can cause issues 🙈 It’s pretty normal to turn map-keys into keywords when reading json, for instance, but json object-keys can be strings with spaces. And it’ll work fine up until you serialize and deserialize the data.

(->> {"stringWithoutSpaces" "ok"
      "string with some spaces" "not ok"}
     (into {} (map (fn [[k v]] [(keyword k) v])))
     (into {} (map (fn [[k v]] [(name k) v]))))
; => {"stringWithoutSpaces" "ok", "string with some spaces" "not ok"}
(->> {"stringWithoutSpaces" "ok"
      "string with some spaces" "not ok"}
     (into {} (map (fn [[k v]] [(keyword k) v])))
     str
     read-string)
; => The map literal starting with :stringWithoutSpaces contains 7 form(s). Map literals must contain an even number of forms. [at <repl>:1:1]

sheluchin13:03:20

@UDB2Q0W13 thanks for highlighting that. I've also noticed that sometimes the namespace portion gets lost when doing JS interop stuff.

fabrao17:03:31

I can't remember what is the function to do this -> [[1] [2]] -> [1 2]

tschady17:03:24

flatten (not advised),or apply concat then wrap in vec, mapcat conj . probably something simpler i can’t think of either.

craftybones17:03:24

(into [] cat [[1] [2]])

craftybones17:03:02

This uses transducers, so you might actually get more out of it than simply flatten or mapcat conj

craftybones17:03:10

flatten is really not a good idea

emccue18:03:14

mapcat identity

aratare23:03:49

out of curiosity, why is flatten not a good idea?

emccue05:03:24

@U013F1Q1R7G @fabrao flatten is recursive. So (flatten [[[2]] [[3]]]) gives (2 3) if you don't know what the items in a sequence are going to be (mapcat identity [[[2]] [[3]]]) gives more reliable results (flattening only one level)

fabrao17:03:15

I remember now, it flatten thank you

craftybones17:03:02

flatten gives you (1 2) not [1 2]

fabrao17:03:21

yes, so (into []) to it

craftybones18:03:09

Since you anyway have to do an (into [] then cat would be preferable

craftybones18:03:29

OF course, it would not matter very much for small vectors

vlad_poh19:03:15

howdy y'all is this the easiest way to build an electron app for clojure https://github.com/Gonzih/cljs-electron

😢 1
vlad_poh19:03:38

hasn't been updated in a while