Fork me on GitHub
#clojurescript
<
2016-01-14
>
jaen00:01:14

Anyway, what you think is the intention could've been done like this:

(case backend
  #[email protected](:clj (:eval eval/compile))
  :base base/compile)

jaen00:01:54

#[email protected] is splicing read conditional (by analogy to splice unqoute [email protected] of macros.

bensu00:01:57

@jaen @fappy I'm guessing the original doesn't compile.

jaen00:01:16

Yeah, that would be my guess too.

jaen00:01:29

Or at least that it compiles for Clojure but not Clojurescript

bensu00:01:12

you think? I'm too lazy to try, but if the parser is well implemented it should fail

jaen00:01:02

That's just a guess; but I could imagine this being interpreted as two tags applied to the same form

bensu00:01:14

I just tried #?(:clj 1) in a cljs repl and it resolved to nothing (not nil, nothing)

bensu00:01:50

which looks what you intended

jaen00:01:56

Yeah, that's how it should be for reader conditionals, yes

bensu00:01:59

"add a case only for clj"

jaen00:01:56

I'm more curious what the original code intended, though I guess "use eval/compile only in Clojure" makes sense

jaen00:01:02

And that what leads me to the interpretation that cljx would treat is as two tags applied to single form, since this could must have worked in Clojure at least if no-one noticed this issue.

rmuslimov00:01:05

I guess this is popular question for CLJS, however I didn't found good answer in the web. Q: Let's suppose we have large working javascript react application (in my case it also use ES6 syntax), have anybody found the way how start integrate CLJS there and replace js react-components with clojurescript alternatives gradually. p.s. Could it be a good solution - to move all react components to external library and starting actively using js/interop and wrap then somehow. Thanks!

sonelliot02:01:06

Is there much in the way of DOM/CSS animation libraries for CLJS? I am found Quill, but it uses the Canvas, so I'm not sure if it's appropriate for day-to-day web apps. I suppose I could do some JS interop with something like Velocity.JS as well.

cjmurphy03:01:24

You could use SVG as well.

jaredly04:01:22

@jaen can you point me to bounce? Doesn't show up on a google search

sonelliot04:01:30

@cjmurphy: Thanks for the tip. I'm looking into that now.

cjmurphy05:01:03

My intro into SVG was a little 'Paint' program. I'll get a reference...

sonelliot05:01:16

Awesome. Thankyou 😄

mikethompson07:01:04

@darwin considerable excitement here about Dirac. No problems so far

slotkenov09:01:04

The books ClojureScript Unraveled and Modern ClojureScript have been mentioned. Would one of them be a good starting point for someone completely new to Clojure (and functional programming), for reading in a weekend?

slotkenov09:01:20

Or would an other book or article be better to start with?

meow09:01:42

Hi, Boris. Keep in mind that ClojureScript is a dialect of Clojure and since you mentioned being new to Clojure and functional programming you might be better off with a Clojure book as there are more of them to choose from.

jaen09:01:31

@slotkenov: if completely new to Clojure I suggest a Clojure book first.

jaen09:01:39

"Programming Clojure" is pretty cool (and has a swan on the cover!).

jaen09:01:33

Or if you like more fun books like "_why's poginant guide to Ruby" or "Learn you a Haskell for Great Good" then maybe "Clojure for the Brave and True" will be more appropriate.

jaen09:01:50

I've started out with the first ("Programming Clojure" that is). I already knew functional programming basics when I did, but I think their introduction to FP is good enough even if you know nothing about it.

jaen09:01:20

As a second book "Joy of Clojure" is pretty good

aurelian09:01:19

a little bit off-topic maybe, but how do you read those books? you sit at your table with the book opened and type the sample code or read it on your commute?

magomimmo09:01:32

@slotkenov: I agree with @jaen . I would read in parallel Programming Clojure and Clojure for the Brave and True. Then one of the cited cljs tutorials. Then….well, SICP, even if it does not cover the co-recursion (which it’s typical in CLJ/CLJS), IMHO, it’s still the best computer programming book ever

jaen09:01:52

Racket's How to Design Programs is also pretty cool if we're talking generic CS introductions.

magomimmo09:01:16

@aurelian: depends on your learning habits. Programming is a kind of constructive activity, so it means that the more you type the best it is

slotkenov09:01:28

Yes, indeed. It should be Clojure in general not ClojureScript.

slotkenov09:01:41

Clojure for the Brave and True is nice I think!

slotkenov09:01:10

I read “Clojure Programming” myself. Like to read “Joy of Clojure” one day as well

aurelian09:01:42

yeah, I'm working on my learning habits too :)

slotkenov09:01:57

And SICP, yeah. Awesome, that’s how I learned myself functional programming

aurelian09:01:08

I'm reading Applied Clojure on kindle while commuting and Joy of Clojure on my laptop typing stuff in repl

magomimmo09:01:42

@slotkenov: I heard that Rich said that SICP is not so fundamental for CLJ/CLJS programmers. Perhaps this is the only Rich’s opinion I do not agree with (if it’s true).

slotkenov09:01:28

Not directed at clojure. But gives a nice introduction to fp and lisp

magomimmo09:01:27

@aurelian: yep Applied Clojure it’s a very good book as well. that said I learned LISP on a LISP machines, which means by reading code from the others. The more code you read, the best you write

aurelian09:01:54

that's true

aurelian09:01:20

I'm more of a tutorial kind and like to type all the code samples

jaen09:01:29

@aurelian: it entirely depends, but I learned C by reading K&R through twice and then I just knew enough to start hacking on things to solidify that. But that was one of my first programming languages. With Clojure I started on the other end - I just started hacking on something and I used those books as references (since I already knew FP basics from playing with Haskell).

aurelian09:01:56

I usually don't buy books about programming languages or frameworks, Clojure is an exception because is my first contact with FP stuff

aurelian09:01:48

anyway, it's interesting to know how other are learning, thanks

jaen09:01:54

I sometimes do - books on C, Clojure, Scala were certainly useful to some degree.

jaen09:01:04

But for Ruby? I've found that wast of time if I can just online tutorial through it (yes, that's "online tutorial" used as a verb).

aurelian09:01:46

I have an objective-c book, read it like 1/4 and never touched again

jaen10:01:02

"Haskell Programming from First Principles" is probably the next time I will buy a CS-related book, but first I need to finally find time to learn Haskell properly ; d

jaen10:01:44

And using Clojure kind of pushes that further into the future, because I can do pretty nice FP right now (sans types, sadly) and not after I grok all them typeclasses.

jaen10:01:49

But we'll see.

jaen10:01:33

As for SICP not being fundamental to Clojure programmers - well, I can kind of agree with that in a way - Clojure is not meant to be a first language in the way Scheme or Racket are. SICP is a great foundational book, but Clojure sort of assumes you're past that level and things like abstraction are natural words in your dictionary.

jaen10:01:15

But that's also something that's discouraging - a friend wants to learn programming and I wanted to teach her using Clojure because functional paradigm is a better introduction to programming than imperative and just imagine how awesome would be to use Clojurescript and boot-reload to have some of that Bret Victor-ish immediate feedback capability. But then you're reminded that Clojure doesn't care about first timers much with it's stacktraces, bad error messages and general spots of roughness and you just decide to use Racket and "How to Design Programs" : V

geoffreymuchai13:01:31

Hey guys: I am trying to write async tests for my project but the tests fail even after i follow the example listed here https://github.com/clojure/clojurescript/wiki/Testing This is how my test looks:

(deftest test-async-function
  (testing "Async Test"
      (println "[debug] - about to async test")
      (async pass
        (go
          (is (= (<! (http/get ""))
                 :true))
          (pass)))))
Any suggestions on what I can do to get this working will be greatly appreciated

skardan13:01:50

@dnolen @mfikes I documented Remote REPL configuration https://github.com/clojure/clojurescript/wiki/Remote-REPL (feedback appreciated)

nberger13:01:02

@geoffreymuchai: I think async should be the top level form in deftest, so first wrap with async then with deftest

nberger13:01:16

I mean, first async then testing

geoffreymuchai13:01:34

oh… ok… lemme give it a try

geoffreymuchai13:01:34

that doesn’t work unfortunately @nberger

nberger13:01:31

It should 😛. What happens?

nberger13:01:08

You now have:

(deftest test-async-function
  (async pass
    (testing "Async test"
      (println ...)
      (go
        (is ....)
        (pass)))))
right?

nberger13:01:11

how is it that "it doesn't work"? it doesn't show a test failure? a simple non-async test works, I mean it shows failures?

geoffreymuchai13:01:41

that is what i have and…. this is the output

nberger13:01:26

"Tests failed!" is promising! simple_smile If you remove the assertion entirely, it stops showing "Tests failed!"?

geoffreymuchai13:01:06

actually… i have posted the wrong output… lemme run the test again real quick

geoffreymuchai13:01:19

it doesn’t print anything within the go block

nberger13:01:39

you mean if you put a println there?

geoffreymuchai13:01:09

wait… it does… my apologies

geoffreymuchai13:01:14

lemme remove the assertion

nberger13:01:23

cool, no worries

geoffreymuchai13:01:53

the test still fails with the same error… this is how the test looks

nberger13:01:13

you can try with something simpler like:

(go
  (<! (async/timeout 100))
  (is false)
  (pass))

geoffreymuchai13:01:13

(deftest test-async-block
  (async pass
    (testing "Async Test"
      (println "[debug] - about to async test")
      (go
        (pass)))))

nberger13:01:55

(simpler in that it's more directly clear what's happening, and you can change the false for a true to make it pass)

nberger13:01:13

but ok, your last example should pass too

nberger13:01:01

what about a non-async test?

(deftest non-async
  (is true))

nberger13:01:40

because you might have issues with your test runner

geoffreymuchai13:01:29

It doesn’t run any other tests in the namespace the async tests are but when i remove it, they work

nberger13:01:53

Ok... something similar happened to me where the test runner didn't properly wait for the tests to finish... in a way that it worked for sync tests, but not with async tests... what are you using as runner? doo or something ad-hoc?

slotkenov13:01:40

What would be the best way to use sass in a ClojureScript project?

slotkenov13:01:10

I would say by using libsass via node.js

slotkenov13:01:37

How would I kick that off via leiningen (or boot)?

nberger13:01:03

I had part of my runner writing the test report into a div with some id, and then another part of the runner inspecting that div content... but it didn't wait for it to exist

nberger13:01:30

so, how are you running the tests? simple_smile

geoffreymuchai13:01:42

we have created something ad-hoc using cljs.test

geoffreymuchai13:01:42

we haven’t done anything fancy on our code base… we use the testing library available in cljs i.e. cljs.test

nberger13:01:51

Ok... you probably write the test report to somewhere in something like (defmethod cljs.test/report [:cljs.test/default :end-run-tests] ...)?

nberger13:01:21

you have to look into that runner... we can't be sure if it is properly implemented for async tests

geoffreymuchai13:01:04

ok… let me confirm

geoffreymuchai13:01:06

@nberger: our report code looks like this:

(defmethod report [::test/default :summary] [m]
  (println "\nRan" (:test m) "tests containing"
           (+ (:pass m) (:fail m) (:error m)) "assertions.")
  (println (:fail m) "failures," (:error m) "errors.")
  (aset js/window "test-failures" (+ (:fail m) (:error m))))

nberger13:01:25

and then you have something else checking the content of "#test-failures" and it prints "Tests failed" if it doesn't have 0 as its content?

nberger13:01:41

Ok, what's happening is that test-failures is empty, because tests haven't finished yet... the code that's checking "#test-failures" content, it should wait until there's a number there simple_smile

nberger13:01:45

We have a similar setup in a project, and we use selenium (through clj-webdriver), so we have this before checking our "#test-results":

(taxi/wait-until #(taxi/exists? "#test-results") (* 10 1000))
(it waits at most 10 seconds for it to appear)

geoffreymuchai13:01:55

that explains why the tests don’t continue running once it hits the async block

geoffreymuchai13:01:23

nice… thanks @nberger for this useful insight. Much appreciated

nberger13:01:35

no problem, glad to be of help simple_smile

geoffreymuchai13:01:50

lemme refactor our runner to better support async tests

nberger13:01:23

You can also try switching to https://github.com/bensu/doo, it handles this for sure

geoffreymuchai13:01:07

ok… will review it to determine what works best

slotkenov14:01:11

Anyone experience with using SASS in a ClojureScript project?

shanekilkelly14:01:58

@slotkenov: I’d imagine you just set up the sass compiler same as any project. are there any particular issues you’re running into?

slotkenov14:01:01

I’m not sure how to kick off the sass compiler from leiningen

shanekilkelly14:01:39

then just use that to do the sass thing

slotkenov14:01:18

Ah yes, I was looking for something like that, I think that should do the trick$

slotkenov14:01:01

That’s even better. Thanks!

jaen16:01:50

@slotkenov: if you decided to use boot I suggest https://github.com/jgdavey/boot-middleman - you then have the whole middleman at your disposal.

jaen16:01:07

Otherwise sass4clj seems to be pretty good for either boot or lein.

jaen16:01:40

The minor difference is (if it counts in your case) sass4clj uses jsass (Java port of Sass compiler) while boot-middleman uses the original Ruby compiler through JRuby.

juhoteperi16:01:16

Not exactly. Jsass is JNA wrapper for Libsass which is the official(?) C implementation of Sass, though it doesn't support all features of Ruby Sass.

juhoteperi16:01:57

Which means that Jsass contains compiled native libs for multiple operating systems and only the linux libs have been automatically tested, so it's possible that it's not very reliable on OS X or Windows.

jaen16:01:47

Right, my bad; still not 100% Ruby Sass, though. When I tried libsass last time it didn't compile to the exact same CSS Ruby Sass would, so that's why I mention it. Maybe it had been improved by now.

slotkenov16:01:57

Libsass compiles way faster though, I've read

slotkenov16:01:53

And I prefer not to have the Ruby dependency

jaen16:01:19

@slotkenov: It's not a Ruby dependency, it runs inside JVM on JRuby. No need to have Ruby installed.

jaen16:01:29

But libsass is certainly faster, that's true.

jaen16:01:20

So if you don't need other things middleman offer then sure (I for example liked it because you can take a middleman project from designers as-is, plug it into boot-middleman and then use kioo for templates), libsass is probably a better choice.

jaen16:01:08

So if you ever need to work with external designers that don't know hiccup it might be a nice option.

slotkenov16:01:55

OK interesting. I work with an external designer now. She doesn't create any html though

shanekilkelly16:01:20

@juhoteperi: that description of Jsass fills me with dread.

jaen16:01:00

All the cool kids use loonix anyway! P ;

jaen16:01:23

But more seriously - that's binary blobs for you.

donmullen17:01:31

@juhoteperi: I thought libsass was now in sync feature wise with RubySass. ?

aurelian17:01:47

I thought everyone is using garden already

jaen17:01:27

I dunno, I like my Sass. I can just use Bootstrap or something and don't care about styling.

juhoteperi17:01:44

I hear Compass needs Ruby sass

jaen17:01:40

But it seems that Compass got deprecated

jaen17:01:05

So it maybe only makes sense for legacy projects to be hung up on this requirement. I always preferred bourbon anyway, but at some point Sass port of bootstrap required compass which kept me from migrating to libsass.

shaun-mahood17:01:43

There's also a SASS watcher for figwheel - I've not used it but it might work as well. https://github.com/bhauman/lein-figwheel/wiki/SASS-watcher

grav17:01:11

@slotkenov: we use inline-styles all the way with good results

grav17:01:49

(in a react context)

grav17:01:21

we did do sass but it was not easy to maintain across a team of 10 people

peeja18:01:25

I'm getting a bunch of WARNING: Use of undeclared Var foo/bar, and I'm trying to track them down. Is there a way to get the compiler to point you to the site where the var is used?

jaen18:01:02

It should make the compiler say what namespace it's analysing (among other things) so it will make it easier for you to track it down.

peeja18:01:11

@jaen: Ah, that helps. Thanks!

billharten18:01:01

Which HTTP/clojurescript libraries are currently most solid/used/respected, IYO? I'm new to clojurescript, building a HTTPS pipeline where one record leads to another, many stages deep, leaning towards using core.async. Tried cljs-http but it's not working (cross scripting issues) and I'm not committed to it yet.

jcromartie18:01:14

XSS will be a problem no matter what lib you use, I'd expect

maio20:01:25

@peeja: just curious, are you using parallel build compiler option?

peeja20:01:51

@maio: No, I'm not

peeja20:01:11

Could someone help me understand what the warning "Required namespace not provided for…" means?

slotkenov20:01:15

@grav Sounds like a good match in combination with react components actually. Using plain old CSS then? In there a way to keep the styles isolated per component, to avoid naming conflicts?

peeja20:01:53

(Oh. I see the problem. I had an underscore-hyphen issue…) 😛

grav20:01:09

@slotkenov: you mean class name-naming conflicts? we don’t use css classes at all ...

slotkenov20:01:06

Oh, you mean in line at the tag level? And that remains manageable?

jaen21:01:45

I don't know how manageable that is, but some people seem to swear by it to the point of making whole libraries - https://github.com/FormidableLabs/radium