Fork me on GitHub
#beginners
<
2018-05-19
>
guru0115:05:49

Hi all. I'd like to know how would you recommend to get started in Web development for a (reasonably smart) newbie? I love clojure, haskell, SICP - so very partial to functional programming. But essentially 0 experience in the web. I want to learn the basics - starting from building a server, deploying some single page apps, security / crypto - to eventually distributed systems - preferably sticking to clojure(script). Could someone be kind enough to suggest a path please? I'm planning to devote a couple of years - so asking for a path. Or you think going via java(script) would be wiser?

johnj15:05:00

learn html/css/javascript first

guru0115:05:31

i know decent html/css

johnj15:05:40

html/css are obvious and there's no escaping javascript 😉

guru0115:05:41

not js though

johnj15:05:58

you could spent a month learning JS and then move to cljs

mfikes15:05:38

FWIW, I succeeded in writing lots of JavaScript-based apps without learning JavaScript. (Honest!)

johnj15:05:39

or if you already know clojure you can learn cljs and js at the same time

guru0116:05:04

i've done almost all exercises on 4clojure - so clojure level is decent too. And 4 chaps on SICP - so i get programming. Maybe I'm just hoping I don't need to delve into JS...

johnj16:05:40

for none toy programs I would guess knowing the underlying basics of JS would be really helpful

guru0116:05:45

OK - would you reco a good JS source to teach web? Not the language or programming in general

mfikes16:05:55

I didn't delve into JavaScript. I just used my knowledge of Clojure to program in ClojureScript, and muddled through the JavaScript interop when needed.

guru0116:05:35

@mfikes - where do i start?!?

mfikes16:05:03

All I can say, is, that it is possible to start with ClojureScript.

mfikes16:05:59

Learn a bit of Figwheel and Re-Frame and you can make web-based apps.

mfikes16:05:29

(To this day, if I had to sit down and actually write a web-based app in JavaScript, I would have a huge ramp-up.)

johnj16:05:52

@guru01 mozilla has nice documentation

johnj16:05:38

the thing is most documentation for web stuff is in JS, if you can't read it well you might get frustrated

guru0116:05:02

how about sotnikov's book on web development? @lockdown- - yes I've been glancing at that - but again maybe wishfully trying to avoid JS

guru0116:05:42

yogthos/sotnikov - web dev in clojure 2nd ed

mfikes16:05:44

You can actually read a programming language without truly knowing how to write in that language.

johnj16:05:40

to have read levels you need to understand it though

mfikes16:05:54

I'm just saying, you don't need to go off and master JavaScript before learning ClojureScript. Same is true with Java and Clojure. It is possible to start with ClojureScript and Clojure and fill in knowledge in the host languages over time.

johnj16:05:02

correct, that's why I mentioned know the underlying basics

johnj16:05:51

there's going to be some cognitive load at the beginning when reading javascript libs documentation

guru0116:05:07

@lockdown- - so you would reco the mozilla route?

johnj16:05:43

they are pretty good

johnj16:05:42

I'm having a clojurescript repl and a node repl side by side while learning cljs

johnj16:05:51

knowing javascript is very helpful anyway because is everywhere

johnj16:05:20

for example, I was using it today with google sheets

johnj16:05:40

setting up cljs for that would be overkill

guru0116:05:53

OK thanks a lot guys @lockdown-and @mfikes. I'll probably do that then. Start with the mozilla docs, and then see where i get to. Quite keen to move on to cljs though

xlevus20:05:44

how are tests for lein test discovered? at the moment it just prints out testing user which is the value of [:profiles :project/dev :repl-options :init-ns] but it's not collecting any tests. Even when I run lein test :only path.to.tests/mytest

xlevus20:05:21

ahh I know why

tdantas21:05:53

is it possible, using macro, generate something like that

(defmacro protocol ....)

(protocol cmds
  ("LIST" (list-handler))
  ("EXIT" (exit-handler)))
will generate something like
(defn cmds [command]
  (condp = command
    "LIST" (list-handler)
    "EXIT" (exit-handler)))
i’m suffering to generate the condp expressions LIST , EXIT … with macros

seancorfield21:05:11

@oliv What have you got so far?

seancorfield21:05:44

This might do what you want

(defmacro protocol [name & clauses]
  `(defn ~name [~'command] (condp = ~'command [email protected])))

seancorfield21:05:55

I suspect the probably you were running into was that you tried to declare the argument as [command] and you got a syntax error from defn? @oliv

tdantas21:05:01

let me try to show you, struggling try to “expand” the

("LIST" (list-handler))
  ("EXIT" (exit-handler))
into
(condp 
     ("LIST" (list-handler))
  ("EXIT" (exit-handler))

tdantas21:05:37

that is my first approach but didn’t even finished

(defmacro protocol [name & commands]
   `(defn ~name [request]
      (let [cmd (first request)
            arguments (rest request)]
          (condp = cmd
            ~))))

tdantas21:05:44

not working, is commented on my code

mfikes21:05:27

That's what the [email protected] construct does, so in your example [email protected].

tdantas21:05:30

that is super cool

tdantas21:05:43

you guys are super nice ! thanks

tdantas21:05:55

what ~'command does

mfikes21:05:02

By the way [email protected] is called "Unquote-splicing" if you need to google it

mfikes21:05:23

~'command would literally put the symbol command in your output

seancorfield21:05:18

I think ~' would be a good addition to this section https://clojure.org/guides/weird_characters#unqote

athomasoriginal22:05:45

I am working through the Edge project. Currently trying to understand how Juxt is configuring their reloaded-workflow. What is this line doing https://github.com/juxt/edge/blob/master/app/aliases/nrepl/nrepl.clj#L1?

athomasoriginal22:05:58

I believe it is related to this https://github.com/juxt/edge/blob/master/app/deps.edn#L66 and my thought is that the above line is telling that ns to only load when this variable is true? As in, wait for the dependencies you need before you load...because when the nrepl ns is required, it seems like it is going to immediately run a nrep-server.