Fork me on GitHub
#clojurescript
<
2016-01-05
>
crocket04:01:22

Are there decent react alternatives on clojurescript rather than react bindings?

jethroksy04:01:09

@crocket not sure I understand your request, what feature are you specifically looking for?

crocket04:01:53

I'm looking for something like reboot of react on clojurescript.

jethroksy04:01:16

I don't think there are any clojurescript libraries that try to reinvent the wheel here

jethroksy04:01:55

if you're looking for something that's not written in react but jquery there's Hoplon

jethroksy04:01:12

it's quite different from react though

jethroksy04:01:28

but it does have reactive bindings and such

crocket04:01:27

By the way, does clojurescript work with ES6 libraries?

jethroksy04:01:19

not too sure, but I think there isn't plans to support it until everything about ES6 is finalized

jethroksy04:01:36

some of ES6's features are already compatible

jethroksy04:01:39

like collections

jethroksy04:01:20

you have to check what ES6 features are used by the libraries

jethroksy04:01:10

its "in progress" but this was last updated in june

crocket04:01:05

I'm not sure on whether imported ES6 modules need to be specified in :externs option of google closure.

atroche04:01:47

does anyone know when clojurescript started setting the “name” property on functions? or has it done that since early releases?

be905:01:34

What’s the current best practice to work with assets in context of a clojurescript app? I want to use SASS stylesheets instead of bare CSS

crocket05:01:01

Which one between Reagent and Om is better? Or, is there a better alternative to both?

jethroksy06:01:12

@be9 you need your tooling to compile the sass to css for you to serve up

be906:01:01

@jethroksy: thanks, currently considering to use boot

jethroksy06:01:29

make sure you install sassc though

jethroksy06:01:25

@crocket: better is subjective, but i suggest you start with reagent before you try Om, not just because it's easier to get started with, but that Om Next is coming out soon, and now's not a good time to dive into it as an inexperienced clojurescript developer

jethroksy06:01:21

can't tell you about ES6 and clojurescript, no experience with it myself

be906:01:40

@jethroksy: I’m also concerned about deployment. is it possible to get everything (clojure backend app, clojurescript app with assets and fingerprinting) into one big uberjar? is it desirable to?

be906:01:21

not going to use a CDN for now, b/c the app will have max. 2 users

jethroksy06:01:00

uberjars is the usual method of deployment. Clojurescript shouldn't be a problem since your code is already compiled to javascript.

jethroksy06:01:34

uberjars include all your project deps so you should be able to run it in the JVM

jethroksy06:01:09

In heroku a Procfile is created with java $JVM_OPTS ....

jethroksy06:01:40

where do you intend to deploy to?

be906:01:43

I basically have a linux server I want to run this thing on

jethroksy06:01:46

the easy way imo is to run your ring server (if ring) on some port like 8080 and use nginx to expose it

be906:01:10

is there any example of such a full-stack app somewhere? (with boot)

jethroksy06:01:44

the only boot apps i've seen running servers use boot-s3 to push their app up to s3 lol

jethroksy06:01:09

maybe @micha would know some

jethroksy06:01:03

boot can make uberjars too in case you're worried it doesn't

be906:01:13

haha, thanks @jethroksy, maybe it’s time to move to #C053K90BR

jethroksy06:01:30

so deployment should be independent of the tooling, unless you're using the tool to push the app up to your server

be906:01:02

I’m quite accustomed to Rails way of things (much experience in that), but CLJS workflow is much different

jethroksy06:01:19

also regarding the s3 point, i think they may all have been static sites in retrospect...

jethroksy06:01:41

I came from rails too, and tbh capistrano was a PITA

be906:01:27

I’ve used ansible to automate the deployment. I wonder if there is any native clojure tooling for such tasks

jethroksy06:01:20

if you self manage the server i'm sure you can use boot to write the deployment process

jethroksy06:01:37

this question is better directed to #C053K90BR though

jethroksy06:01:46

have yet to deploy a boot app myself

micha06:01:14

i run servers in docker, with boot as the entrypoint

micha06:01:33

basically my docker container boots into boot serve -p 8080 repl -sp 1337 wait

jaen07:01:27

@crocket: Well, my recomendation stays the same - use webpack/browserify/whatever to compile the modules out. Also transpiling ES6 -> ES5 in general is a good idea; though since you're probably talking about node where you can be sure of the support this may be less important. Not sure how interoperable Clojurescript is with ES6. GClosure has a language in and out options for ES6 and ES6 strict which Clojurescript exposes, but I didn't have any need to test ES6 as out (as opposed to in, since React uses it). I guess you could use :foreign-libs with :module-type :es6, but that again requires you to have control of the code you are including since you can reliably use only relative paths as it stands. And either way - yes, you still need to write externs for the foreign library or goog.object.get everything if you plan on using advanced compilation for your Clojurescript code. As for the other question - IMO reagent is better than om.prev. Reagent is simple. Om.prev is unnecessarily complex and verbose. Between reagent and om.next it all depends on your requirements. Om.next is a forward-looking library that aims to solve problems you will have in a rich SPA (or on mobile), but it's not as simple to grok as reagent due to that. Rum also seems like a nice alternative to reagent, it's main feature being able to use mixins fairly effortlessly. As for reactless libraries - there's Holpon and freactive I can recall off the top of my head, both of which reactive but do not use React. @jethroksy: I'm gonna suggest using https://github.com/jgdavey/boot-middleman instead. It basically lets you use full power of Middleman 3.x to create your assets, which is really convenient and gives you some semblance of Rails' asset pipeline.

jethroksy07:01:11

@jaen: that's great too, if you're not too concerned with being dependent on ruby ^^

jaen07:01:49

It's not.

jaen07:01:07

It runs on JRuby, so no need to have system Ruby.

jaen07:01:26

But guys like designers or something can run the middleman project with MRI if they so prefer.

jethroksy07:01:59

ah ok cool thanks!

crocket07:01:40

Thanks for information.

djebbz08:01:35

Hello everyone

djebbz08:01:39

Happy 2016

atroche09:01:08

be9: i was wondering that too, and this just popped up in my feed: https://adambard.com/blog/deploying-a-clojure-project-with-pallet/

atroche09:01:27

(i've never used pallet)

be910:01:46

@jaen it seems that rails asset pipeline has been thrown away from middleman: https://middlemanapp.com/advanced/asset_pipeline/, https://middlemanapp.com/advanced/external-pipeline/ I wonder if it’s easier to directly call gulp & friends instead of middleman

crocket12:01:32

@jaen Are ES6 modules really supported by :foreign-lib?

crocket13:01:57

How do cljsjs packages insert :externs into closure? It feels that it's a magic.

crocket13:01:39

Is deps.cljs in classpath automatically assimilated to :compiler option by clojurescript compiler?

crocket13:01:38

Why is -main passed nothing on :advanced optimization and command line arguments on other optimizations?

crocket13:01:16

It seems I forgot to pass nodejs externs to google closure.

crocket14:01:15

externs can't protect property access on objects returned by javascript functions protected by externs. This can be overcome with some dirty hacks that I don't like.

crocket14:01:05

It seems externs are not really worth the effort on nodejs.

exupero15:01:03

@crocket: Externs aren’t usually necessary on Node because minification isn’t usually necessary.

gabe15:01:08

What’s a good way to dispatch on data type?

gabe15:01:06

I’d like to use cond or case

csmith15:01:21

another options is (condp (= (type n)) …. each case will be the type. Another option is using multimethods and dispatching on type

roberto15:01:28

why not use multimethods?

gabe15:01:44

multimethods are a bit of overkill for what i want

csmith15:01:26

primary advantage of multimethods is making it open to extension of new types while cond and friends makes it closed. (depends on what you’d rather have). If you are checking the same thing over and over in your cond (such as the type and comparing for equality) condp is a nice bit of sugar

gabe15:01:09

i really just need to distinguish b/w a vector and a map at runtime

roberto15:01:14

what do you mean by data type? A type in the sense of java types?

roberto15:01:50

either one would be fine. case is faster but also has some limitations.

roberto15:01:26

hmmm, on second tought, I think cond would be the better option in this case.

gabe15:01:13

looks like cond will work. case doesn’t match properly

gabe15:01:23

thank’s guys

gabe16:01:18

what if I want to dispatch on interface?

gabe16:01:26

if I try (isa? [] IPersistentVector) I get false

gabe16:01:13

It looks like IPeristentVector isn’t declared

jethroksy16:01:07

isa? seems like its definitely not the correct pred to use

gabe16:01:11

i see…`isa?` compares classes and interfaces

jethroksy16:01:58

my bad, seems like you could use isa? here

jaen16:01:14

@be9: boot-middleman still uses middleman 3.x AFAIR

gabe16:01:57

does PersistentVector implement IPersistentVector?

jethroksy16:01:17

a quick scan shows that IPersistentVector isn't actually an implemented protocol

jethroksy16:01:46

actually rather curious what the es6 function below d oes

gabe16:01:15

@jethroksy: Thanks I was just looking at that source

Alex Miller (Clojure team)16:01:04

We're happy to announce that Clojure/west 2016 will be held in Seattle, Apr 15-16th - please see http://clojurewest.org for more info.

Alex Miller (Clojure team)16:01:21

See http://clojurewest.org/cfp for more info on the call for presentations and http://clojurewest.org/sponsorship for more info on sponsoring!

gabe17:01:31

Trying to figure out why this returns true:

gabe17:01:42

(satisfies? IMap {})

gabe17:01:48

but this returns false:

gabe17:01:12

((fn [p] (satisfies? p {})) IMap)

dnolen18:01:43

@gabe: satisfies? is not dynamic at all for perf reasons, you cannot use it higher like that

edbond18:01:24

why for doesn't print anything in clojurescript?

(for [x (range 6)]
  (prn x))

Tim18:01:42

maybe use (js/console.log x)

Tim18:01:56

instead of prn

edbond18:01:14

well I changed to doseq and it works fine.

edbond18:01:16

@dnolen: thanks, I remember it was something with laziness

meow19:01:52

@edbond: ^ Stuart Sierra has a lot of good blog posts. That one helped me appreciate lazy side effect issues.

spieden19:01:10

i’ve mostly switched to transducers from lazy seqs personally, except for infinite computations as sierra describes

spieden19:01:06

still don’t really grok how to write one, but i can use the built-in map, cat, filter, etc. well enough 😃

meow19:01:25

@spieden: Then you might like this:

(defn produce
  "Returns a lazy sequence of colls from a recursive, axiomatic,
   transformative process."
  [seed prep-f get-xf]
  (letfn [(process
            [coll]
            (lazy-seq
              (when (seq coll)
                (let [new-coll (into (empty coll) (get-xf coll) (prep-f coll))]
                  (cons new-coll (process new-coll))))))]
    (process seed)))

meow19:01:53

It's got a little bit of everything in it. simple_smile

spieden19:01:51

@meow: hmm, any example usage?

thomas20:01:19

hiya.... I am trying to write an extern file for a JS lib and having some problems...

thomas20:01:29

This is the warning I am getting:

thomas20:01:30

accessing name host in externs has no effect. Perhaps you forgot to add a var keyword?

thomas20:01:43

but not sure what to do about it.

dnolen21:01:41

@thomas sounds like a syntax error in your externs file - it’s even giving you a suggestion

thomas21:01:32

hi @dnolen but what do I add? that I am not sure about (please forgive as I know very little about JS)

dnolen21:01:00

how externs work is pretty well documented, there’s nothing special or specific to ClojureScript

thomas21:01:34

looking at the docs now... thanks

crocket23:01:10

@exupero: :simple optimization produces a single javascript file, and :none optimization produces multiple javascript files. It is not trivial to upload multiple javascript files to npm. :simple optimization simplifies npm deployment.

crocket23:01:38

@jaen: Ok. I expect es6 interop to be fragile for now.