Fork me on GitHub
#clojurescript
<
2016-12-22
>
dangit00:12:48

I have written a little bit of clojure but have almost no experience with clojurescript. I want to learn cljs by writing an admin tool for work. I’m finding the options to start out a little overwhelming: om, om.next, re-frame, hoplon, … Can I can some pointers on where to start? The app is a relatively simple admin tool (superseding a rails/underscore.js app), mostly searching for users and examining their data streams. There might be some minimal visualization in the future.

shaun-mahood00:12:39

@dangit: I found re-frame to be a pretty easy entry point, but I think hoplon would be a great option as well- both have active and helpful channels on here. Rum with datascript would be a good choice as well, particularly if you are comfortable with Datomic. Om next might be a bit too much to learn at the start, but there are a quite a few people using and loving it.

bostonaholic00:12:38

@dangit may I suggest reagent? It will work well if you’re not building an SPA and doesn’t contain a lot of the complexity that exist in om

bbloom00:12:32

i rethink reagent has the shallowest learning curve if you’re already familiar with react

bbloom00:12:04

re-frame adds a lot of stuff of arguable value on top of reagent

bbloom00:12:23

but inarguable: it’s more stuff to learn

chrisoakman00:12:43

@dangit My vote would be for Rum: https://github.com/tonsky/rum Very simple API on top of React.

chrisoakman00:12:34

You could take a look at tourney-bot as a reference. Real-world application written in Rum: https://github.com/oakmac/tourney-bot

mikethompson01:12:08

@bbloom re-frame tries to deliver architecture for medium sized apps and up. Sure, if you have a small, simple app you don't have much need for architecture. Any of the "V" generation libraries will be good to use: Reagent, OM, Rum or Quiescent. But there is a reason why Redux, cyclejs, the Elm Architecture, Pux, etc exist. As your app gets beyond trivial, you need architecture. I've been embedded daily in the Reagent world for 3 years now, and I relentlessly hear the following: "I started off with Reagent, which I love, but after 6 months I had created a bit of a mess". Every single time, what that person is actually saying is: "I started in Reagent without any sense of an Architecture and I grew one in an adhoc manner which ultimately wasn't pleasing". You can't not have an architecture as the app gets bigger - the only question is which one. Reagent (and the other V libraries) don't give you archecture. But, one way or another, you are going to be growing one. So please be careful about telling people that archecture is "a lot of stuff of arguable value". I've REPEATEDLY seen where that goes. If instead you want to suggest an alternative archecture, then I'll happily discuss re-frame at the level of "why this archetecture is better than that, or not". But if your goal is to simply dismiss the need for any architecture, I'd say that's poor advice. I'll be seeing that person across in #reagent in 6 months asking for advice.

bbloom01:12:19

@mikethompson I said that it’s of arguable value because we can clearly have an argument about it 😛 I’m not trying to shit on your work. My apologies if it seems that way. Overall, I feel re-frame has its head screwed on straight and wouldn’t argue vehemently against it other than in terms of ramp up time.

bbloom01:12:20

That said, I firmly believe that most of what re-frame provides is general in a way that isn’t useful for many applications; and that most of the benefits of re-frame can be accomplished via education rather than framework.

bbloom01:12:42

For what it’s worth, I’ve seen the exact opposite problem than the one you describe:

bbloom01:12:49

“Hey, we have 400 Relay Stores"

bbloom01:12:52

"umm… what?"

bbloom01:12:29

One last thought: I did read through the re-frame docs and various wiki-materials. Overall, it’s quite well written and the docs may be even more valuable than the code 😉

bbloom01:12:58

s/relay/whatever they called that thing before relay/

mikethompson01:12:18

The docs took 10 times more work than the code :-)

bbloom01:12:26

probably the correct balance 😉

mikethompson01:12:35

Don't worry about the shitting on the work thing .. each time that happens I generally learn something. So I'm always up for that.

mikethompson01:12:03

I'm older and robust. But cantankerous.

bbloom01:12:25

for me, it’s about leverage - if i have to invest a bunch of time caring and feeding for a framework, i better be getting a lot of leverage. that means the product of value and occurrences of getting that value needs to be large

mikethompson01:12:32

flux was very early, redux dominates these days

mikethompson01:12:50

In that case you should be using re-frame :-)

bbloom01:12:11

for most apps i’ve worked on, even decently large ones, i’d be able to count the number of stores, effects, co-effects, whatever, on one hand

bbloom01:12:21

and each is slightly different

mikethompson01:12:33

A lot of apps are dominatred by a remote data store

bbloom01:12:37

usually 5-20 lines of straighforward machinery satisfies my needs

mikethompson01:12:07

But, and this is my main point, one way or another you are creating an archecture.

bbloom01:12:21

sure, and i am well versed in the design of such architectures

bbloom01:12:39

and so having someone design one for me is of lesser value than it may be for other folks

mikethompson01:12:17

If your claim is that you like your architecture more and that re-frame is too much overhead, I understand. But be careful in your advice to others on this point. They may not grow the same architecture you do.

bbloom01:12:37

no, i’m making two independent claims

mikethompson01:12:52

I end up seeing those people in the #reagent channel in 6 months from now

bbloom01:12:53

1) education is more valuable than code with respect to architecture

bbloom01:12:09

and 2) new folks should start on top of a smaller foundation

bbloom01:12:14

i’ll add one more claim

bbloom01:12:38

3) I believe #2 to be true, even if they are 100% guaranteed to show up in reagent in 6 months asking for help and/or moving to re-frame

bbloom01:12:47

the journey is important part of #1

mikethompson01:12:23

Ha! Indeed, The ones who have suffered first tend to appreciate re-frame more, yes. They tend to be the most effusive in their praise. Which is always nice for an OSS person to hear.

mikethompson01:12:39

Anyway, i think we are broadly in agreement

bbloom01:12:38

not making a judgement about re-frame specifically, but many libraries should be blog posts … for example:

bbloom01:12:55

grumble grumble let’s add an intermediate dependency!

hjeon01:12:21

Hi, I’m trying to eval cljs code in cljs code, is there any way to get current compiler state (I need compiler state with current namespaces set), other than creating it with empty-state and manipulating it directly?

fellshard02:12:07

In general, pick a tool that solves the problems you currently have. If you're growing new problems from prior choices, and a new tool helps tackle those problems, migrate to / use the new tool. Pragmatism at its finest, and removes a lot of the issues that come from trying to get it right the first time, with some cost down the road for migration.

bbrinck03:12:38

Hi, we’re seeing the warning "WARNING: :preloads should only be specified with :none optimizations” because we’re trying to use :preloads with :simple optimizations. Why is :preloads incompatible with optimizations?

bbrinck03:12:40

The use case is that we have a test build. In the test build, we want to call (enable-console-print!) as early as possible. We also were thinking that running tests at the same optimization level as our prod build might detect bugs related to optimization.

bbloom03:12:12

do you have a call to run-tests? presuambly you can just add the code you want right before that

bbrinck03:12:52

We do, but we call it in a function that happens after all the code loads. The place we’re getting into trouble is that we print out some test information as the namespace is loading (regarding the value of some test configuration variables).

bbrinck03:12:45

Sometimes that print works, because it happens to be the case that (enable-console-print!) was called previously in another file. But if we say, rename a file, then the load order can possibly change, and suddenly println will error

bbrinck03:12:13

maybe the better fix is to never call println during loading of namespaces - we could wrap that in a function and call that before run-tests

bbloom03:12:35

you can put the enable-console-print! in a test-init ns or whatever and require that first

bbloom03:12:47

but yeah, generally, you should avoid effects on ns load

bbrinck03:12:29

it is a bit easier to remember “don’t call print on ns load” than “its ok to call print on ns load, but call enable-console-print right before!” 🙂

bbloom03:12:23

no, that’s not what i’m saying

bbloom03:12:32

i’m saying that you have two entry points: 1 for your app and another for tests

bbloom03:12:40

just make sure all your tests go through a common entry point

bbloom03:12:47

and you can put the enable-console-print! in there

bbloom03:12:58

requires are processed in order

bbrinck03:12:19

OK, maybe I need to back up one step then. How do I know which files will load first? If I have a.cljs and b.cljs in a test directory, and one calls enable-console-print at ns load, and the other calls println .... I’m not sure how to guarantee any order without a preload

bbloom03:12:43

how are you running your tests?

bbrinck03:12:09

via ios with react native

bbrinck03:12:20

so we register a handler that in turn calls run-tests

bbrinck03:12:43

at some later time, but after all ns are loaded

bbloom03:12:43

hm, um, ok i’m not quite sure if that has any implications on this advice, but here goes:

bbrinck03:12:54

sure, it adds another fun layer of complexity 🙂

bbloom03:12:05

2) note specifically "it's idiomatic to create a test runner namespace "

bbloom03:12:17

3) configure your test build configuration’s main ns to be that test runner namespace

bbrinck03:12:34

> main ns to be that test runner namespace Do you mean by using the :main option? that was one thought I had, but it seems also to only work with :none.

bbrinck03:12:51

(checking out that link, thanks for that!)

bbloom03:12:55

if you can’t use :main, you can still just use goog.require from the outside or whatever you’re doing to call your entry point now

bbrinck03:12:25

Oh, that’s a good idea, yeah

bbrinck03:12:42

OK, I’ll give that a go. Thanks a ton for your help and patience!

sova-soars-the-sora05:12:01

Hi! does anybody here use Om.next and if so, might I pick your brain some?

bbloom05:12:39

@sova you’re more likely to get an answer if you just ask your question

bbloom05:12:51

people are unlikely to agree to help before they know whether or not they can help at all 🙂

kenrestivo06:12:06

the docs for re-frame talk about waiting until early 2016 before it'll be supported on most browsers

kenrestivo06:12:31

it's nearly 2017 and those docs don't appear updated. wonder what the status is

kenrestivo06:12:30

thanks. is flexbox the only blocker?

mikethompson06:12:44

From the docs for re-com: > the entire layout side of this library plus a few of the widgets rely on Flexbox which only works on modern browsers, and specifically not IE 9 and 10.

kenrestivo06:12:10

and not 11 either, it seems

mikethompson06:12:29

You will need to make your own assessment. We have the luxury of knowing our browser target

mikethompson06:12:47

@kenrestivo even bootstrap is heading towards flexbox these days so it must be getting mainstream https://github.com/twbs/bootstrap/pull/21389 But, like I said, each to their own. For exaple, flexbox used to work slowly on firefox, but then it got fixed.

kenrestivo06:12:19

not a problem, but some projects are based on re-com so i'm trying to decide if i can follow them down that primrose path

mikethompson06:12:48

@kenrestivo You got me curious. So I'm currently running the re-com demo program which obviously uses flexbox extensively on IE11 without any apparent problems. Everything works and performaance is fine. So the caniuse warnings about bugs may themselves be out of date. http://re-demo.s3-website-ap-southeast-2.amazonaws.com/

mikethompson06:12:56

No wait, I do see a couple of problems with popovers

sivertsenstian09:12:00

I'm trying to evaluate cljs on a nREPL from javascript by sending an "eval" message. It evaluates clj just fine. I'm starting an nREPL from lein, and using piggieback to start the cljs-repl (cemerick.piggieback/cljs-repl (cljs.repl.rhino/repl-env)). I have also added the wrap-cljs-repl middleware, so the repl itself in terminal is working. Its just when I send a msg to the nREPL that it fails to evaluate cljs, it seems to compile the sent expression as a temp .clj file. and complains on the js namespace "CompilerException No such namespace: js" Anyone have any idea as to why this is failing ? Do I have to communicate that I want it to evaluate as cljs somehow?

sova-soars-the-sora09:12:05

so my understanding so far with om.next is that IQuery pretty much makes my data-needs look like Datomic Pull syntax... There is a read-fn and a mutate-fn ... do I need to make many of these ? only if I want to mess with the atom that is my application-state, right?

cmal10:12:24

Hi, I am trying to use ReactCSSTransitionGroup in my project following the guide of https://github.com/reagent-project/reagent-cookbook/tree/master/recipes/ReactCSSTransitionGroup . However, I am using reagent v0.6.0 instead of v0.5.1 , so I changed project dependencies to [reagent "0.6.0" :exclusions [cljsjs/react]] [cljsjs/react-with-addons "15.4.0-0"] . But it shows Uncaught Error: js/ReactDOM is missing. How can I fix this problem? Thanks!

thheller10:12:15

@cmal you are probably missing the react-dom package

thheller10:12:04

no idea how that is bundle with react-with-addons though or if it is

thheller10:12:47

try adding [cljsjs/react-dom "15.4.0-0"]

cmal10:12:59

OK. I'll have a try.

thheller10:12:30

you might also need a (:require [cljsjs.react.dom]) if you require cljsjs.react somewhere

mikethompson10:12:47

@cmal before you go too far down that path, consider this blog post: http://www.upgradingdave.com/blog/posts/2016-12-17-permutation.html

mikethompson10:12:33

We used to use ReactCSSTransitionGroup but switched to react-flip-move (recently) and loving it

cmal10:12:47

Mike, thanks for the two working demos.

timgilbert15:12:31

Hi all, I see some advice on Stack Overflow here that one should use (try ... (catch :default e ...)) in order to catch any error in ClojureScript. Does anyone have an official-ish reference for this?

timgilbert15:12:34

(Planning to add a note on ClojureDocs, but I want to confirm first)

thheller15:12:31

@timgilbert can confirm that it is official-ish, don't know if written down anywhere though

thheller15:12:51

not totally offical since clojure doesn't support it yet

timgilbert15:12:01

Ok, yeah. I didn't see anything obvious in a superficial skim over the cljs source either

timgilbert15:12:28

Aha! Awesome, thanks, that's close enough

thheller15:12:12

that issue links most of the background story

timgilbert15:12:31

Yeah, I see it in there. Exactly what I was looking for.

tankthinks15:12:50

@yogthos have time for a quick question Dmitri?

kenny22:12:26

Is there a way to run some JS at compile time? e.g. I have some parsing I want done statically but the parsing library is written in JS.

geoffs22:12:56

@kenny you might be able to hack something together to do it, but I'd look at a clojure parsing solution instead. Unless you're replacing a specific binary parser, Instaparse will probably get what you want done https://github.com/Engelberg/instaparse

kenny22:12:50

Unfortunately, it's far too much work to re-write the parser in Clojure.

geoffs22:12:37

mmm, shell out to node in a clojure macro then?

kenny22:12:03

Something like that could work. I am looking into using nashorn. For some reason I can't find the lib on maven though..

geoffs22:12:17

nashorn is part of the Java 8 distribution I believe, not separate.

kenny22:12:28

Ah, that's easy then!

geoffs22:12:53

:thumbsup: