Fork me on GitHub
#clojurescript
<
2015-07-13
>
eggsyntax02:07:15

Has anyone here used MathBox (https://github.com/unconed/MathBox.js/) in cljs? It's gonna be my first shot at bringing in an unwrapped js library, so I'd love to hear other people's experiences (or their thoughts on how this library might be to use in cljs). It's pretty object-oriented, but with a strong focus on method chaining, which seems like it translates fairly nicely into cljs's .. syntax.

eggsyntax02:07:13

(I've got some clj experience, but I'm definitely still a cljs n00b.)

dnolen02:07:56

@mfikes: cljs.js is kinda interesting

mfikes02:07:26

@dnolen: Yes. There could be a cljs.jvm to fulfill needs for that “environment” as well.

mfikes03:07:26

cljs.js crossed my mind, but sounded too close to CLJSJS but—written as a namespace—perhaps avoids the ambiguity that exists verbally.

colin.yates08:07:13

@dnolen @mfikes cljs.js and cljs.jvm have my vote for expressiveness. I was toying with cljs.birth, cljs.womb, cljs.oven etc.

borkdude08:07:46

@dnolen @gigasquid : I re-watched the core.async webinar. A thought I had: I think re-usable bits of clojure education like this could scale. For example, many people could use this material to organize lunch sessions for their colleagues, without having to write a talk etc. themselves.

dnolen11:07:21

kind of interesting, now that a good chunk of ClojureScript is also technically written in ClojureScript - that’s 21,000 lines of ClojureScript and only about 4,000 lines of Clojure.

dnolen11:07:46

going with cljs.js for now, I like how it keeps door open for cljs.jvm in the future if needed.

robert-stuttaford11:07:53

@dnolen: not sure how familiar you are with clj-refactor, but i’m curious what’s needed to support it’s ns editing capabilities for cljs

dnolen11:07:41

well not that familiar, I think it uses tools.analyzer?

robert-stuttaford11:07:46

i see mention of building an AST for the current clean-ns stuff. i guess the big differences in the ns methodologies between jvm and gclosure necessitates completely fresh code

angusiguess11:07:17

Looks to require cider with the nrepl-refactor middleware to boot, which narrows repl options.

magnars11:07:58

@robert-stuttaford: I think the latest version of clean-ns doesn't rely on an AST, since it fails on macros (think (go (<!))), but only looks at the symbols in the source file.

magnars11:07:17

not sure if that effort has been merged yet tho

robert-stuttaford11:07:55

awesome. i’ll be a good patient programmer, then simple_smile

dnolen11:07:15

@robert-stuttaford: I don’t think bootstrap work really changes things here for clj-refactor. If it uses tools.analyzer the bigger issue is the long outstanding ticket to make the ClojureScript AST conform.

robert-stuttaford11:07:49

i see lots of clojure.tools.analyzer, so that sounds right

dnolen12:07:03

minimum size if ClojureScript includes itself, 2mb, 300K gzipped 😛

robert-stuttaford12:07:36

considering what’s included, that’s nothing!

robert-stuttaford12:07:17

you can fit two copies on a 720kb stiffy disk simple_smile

dnolen12:07:24

@robert-stuttaford: haha true, but that’s also 15X bigger than where ClojureScript applications start (~20K gzipped)

robert-stuttaford12:07:39

we have a cljs app that’s bigger than that 😒

dnolen12:07:15

haha, right I expect very large CLJS applications with many 3rd party JS bits to be around that size.

dnolen12:07:22

But to double the payload would be killer.

robert-stuttaford12:07:13

we don’t need eval though. i doubt many apps would. unless you’re writing amazeballs ios repls

robert-stuttaford12:07:47

perfect for things like himera and cljskoans

dnolen12:07:02

definitely

mitchelkuijpers12:07:29

@dnolen: Is it already possible to try out the amd support in the clojurescript compiler?

dnolen12:07:51

@mitchelkuijpers: only if you’re feeling adventurous enough to use master

dnolen12:07:18

and even when we cut a release it’ll probably take some time to sort out the issues

mitchelkuijpers12:07:09

@dnolen: Then ill just write an externs for now, can't do that for now. have to go in production in 2 months.. 😉

dnolen12:07:23

@mitchelkuijpers: yeah the module work is great but I would give it some time. Worth experimenting with on non-critical projects.

mitchelkuijpers12:07:54

@dnolen: Will do, thank you!

borkdude12:07:12

I've never used eval explicitly in clojure, maybe only for fun

tcrayford13:07:07

datomic uses eval in it's implementation, as does riemann 😉

ricardo13:07:37

What’s the accepted way of converting html to hiccup on the ClojureScript side of things? I’m looking to render some markdown I get from the backend. There’s @yogthos’ madkdown-clj, which gets me from md->html. It’s a reagent application, don’t want to dangerouslySetInnerHtml.

ricardo13:07:57

I could just use that on the backend and return a hiccup structure… but that requires my sending a “format” parameter. It’d feel cleaner to just have the conversion happen on the client (if desired).

cfleming13:07:09

definline uses eval, so anyone using that (or loading clojure.core which uses definline) implicitly uses it.

cfleming13:07:37

But in user code I don’t think I’ve ever used it.

ricardo13:07:14

Backend path could be going md->html via markdown-clj and then html->hiccup via enlive.

tcrayford14:07:17

@cfleming: datomic and riemann both use it for compiling queries into functions

tcrayford14:07:25

(they're then usually cached in an LRU or something)

meow15:07:30

@ricardo: I've not used any of these, but have you looked at these options? https://github.com/weavejester/hiccup/wiki/Converting-html-to-hiccup

lazy-lambda15:07:13

in which ns does zipmap belong to ?

lazy-lambda15:07:44

it’s in the core

arohner16:07:20

@dnolen: I got closure’s dynamic module loading thing working, and wrote a blog on it: https://rasterize.io/blog/cljs-dynamic-module-loading.html

dnolen16:07:17

The amount of functionality in Closure never ceases to amaze :)

arohner17:07:14

yeah, once I understood the docs it was surprisingly easy

bhauman17:07:06

arohner: that looks great!

bhauman17:07:16

and bidi looks really good as well

bhauman17:07:33

@arohner: ^ really awesome this should be a cljs wiki page.

bhauman17:07:18

@robert-stuttaford: ^ dynamic module loading

dnolen17:07:13

yes wiki page would be good.

robert-stuttaford17:07:57

@arohner: you’re a legend simple_smile +1 for the wiki page simple_smile

robert-stuttaford17:07:09

thanks for the ping, @bhauman !

curtosis18:07:52

I’m working on an app using the luminus default setup (w/reagent) and am a little confused by the env profiles… they call init! in the cljs project source (which mounts the components, etc)

curtosis18:07:22

am I understanding it correctly that the env code (prod.cljs or dev.cljs) gets added to the compiled app.js blob, and so gets called for every requested page?

curtosis18:07:50

It’s not very clear to me yet what on the html page is actually triggering the clojurescript to run.

gtrak18:07:24

if there's a top-level form in the namespace that has side-effects, it will be run when the namespace is loaded

gtrak18:07:03

if your cljs is all 'pure', then you'll have to write some code in a script tag or elsewhere to mount your reagent components.

curtosis18:07:05

oh, duh. that’s actually what’s in the prod.cljs file (which is in the project.app ns) - the top-level form.

curtosis18:07:31

Java damage temporarily overrode my Lisp brain. simple_smile

gtrak18:07:05

even spring requires a servletcontextlistener simple_smile

curtosis18:07:29

yeah… just blanked on the fact that the source is evaluated not just compiled.

curtosis18:07:13

this structure seems to assume that there is one and only one app

curtosis18:07:09

oh, nvm… I see, it’s :app in the cljsbuild :builds map. one could presumably declare different apps there, with the tradeoff of everything getting more complicated.

annapawlicka19:07:11

@dnolen: hey! changes.md in cljs mentions Clojure 1.7.0-RC1 as a dependency but it works with 1.7.0 just fine. The reason is ask is I want to create a patch for readme to mention that Clojure is a hard dependency - not everyone looks at release notes and this is often a problem for people new to cljs. They can’t compile the project because of version mismatch and the error doesn’t say anything that would help with that.

ricardo19:07:48

@meow: Thanks, I have. They all seem to be clj-side, where I can just use enlive. hiccup-bridge actually uses enlive itself.

dnolen19:07:51

@annapawlicka: sounds good to me.

dnolen19:07:34

master already depends on 1.7, hoping to get a new release out this or next week

ricardo19:07:38

@arohner @meow I haven’t tried hickory yet, seems to be a cljx so I’ll look into it. Hasn’t been updated in a while, but that might not be an issue. Thanks!

dnolen19:07:46

@annapawlicka: people have requested it before and I’ve declined but I suppose enough people lose time on this. If you have time to create a patch for cljs.closure/build that checks the Clojure version number I’m fine with that too.

annapawlicka19:07:27

@dnolen: sure, I’ll do that later tonight

dnolen19:07:52

just something that throws and states you need Clojure >= 1.7 is good

annapawlicka19:07:18

i can imagine that will make some folks life easier simple_smile

Petrus Theron19:07:15

Boot compalins about Different CLJS version via transitive dependency: 0.0-2816. Can I resolve this?

bhauman19:07:02

@dnolen: that pure ui post describes one reason why I am so excited about the possibility of Devcards or something like it

martinklepsch19:07:27

@petrus: specify Clojurescript as a dependency

juhoteperi19:07:29

@petrus: Probably some of your dependencies has transitive dependency to different clojurescript version as the boot-cljs. You should add direct clojurescript dependency to your project.

Petrus Theron19:07:16

thanks! I had to add an explicit cljs dep and add boot.properties to get it to build. However, now after adding [re-com "0.5.4"] dependency, I'm seeing this beastie: clojure.lang.Compiler$CompilerException: java.lang.IllegalArgumentException: No single method: _setup of interface: cljs.repl.IJavaScriptEnv found for function: -setup of protocol: IJavaScriptEnv, compiling:(cemerick/piggieback.clj:149:5)

martinklepsch19:07:49

@petrus: maybe best to take this to #C053K90BR ? simple_smile

annapawlicka20:07:24

@dnolen: I can’t invoke`cljs.closure/build` as I can’t even do (require '[cljs.closure :as cc]) on 1.7.0-alpha2. It’s failing to load cljs.util with this error IllegalAccessError tried to access method clojure.lang.RT.classForNameNonLoading(Ljava/lang/String;)Ljava/lang/Class; from class cljs.util$loading__5340__auto____5 cljs.util$loading__5340__auto____5.invoke (util.cljc:9) which is basically what I’m seeing when I’m trying to compile sample cljs project. Do you have any other suggestions? It’s a first time I’m looking in these parts of cljs simple_smile

dnolen20:07:27

@annapawlicka: any reason you are trying with alpha2 instead of just 1.7?

annapawlicka20:07:53

@dnolen: i was trying to test using older clojure version and locally built cljs

dnolen20:07:15

@annapawlicka: I would try again with 1.7, that error seems bizarre

dnolen20:07:45

be sure to rm -rf target to to make sure you classpath is clean

annapawlicka20:07:47

@dnolen: but how does that help with telling the user they need to use > 1.7 ?

dnolen20:07:34

I would also check libs directory to make sure you only have one version of each lib.

annapawlicka20:07:56

gonna do that now, cheers

dnolen20:07:54

@annapawlicka: ah right, hrm yeah I didn’t think that through, you will need to put the check before the cljs.closure ns form

annapawlicka20:07:01

actually before before, or is there another function that’s being called earlier?

dnolen20:07:28

@annapawlicka: it needs to come actually before

dnolen20:07:39

otherwise the ns form will load namespaces it can’t possibly load

dnolen20:07:31

@annapawlicka: thinking about this even more there are 5 namespaces which are common entry points where this should probably done

dnolen20:07:58

hrm it’s trickier than I first thought as usual simple_smile

dnolen20:07:12

typical case of good error messages being really hard to get right

dnolen20:07:34

the problem really is that there are many namespaces that people might load

dnolen21:07:30

@annapawlicka: let’s make a real issue for this and I will write down some notes

annapawlicka21:07:50

adding the same check all over the place doesn’t sound like a good solution 😉

dnolen21:07:44

@annapawlicka: please open a JIRA issue and assign to yourself, I’ll leave a comment on how it should probably be done.

dnolen21:07:58

basically a check in cljs.closure

dnolen21:07:07

and a check in cljs.repl

dnolen21:07:20

and converting cljs/repl.clj should cover our bases

annapawlicka21:07:37

@dnolen: thanks! should i ping you with a link or do you get automatic emails?

dnolen21:07:02

switching repl.cljc back to repl.clj, feel free to ping me the link.

curtosis21:07:15

any pointers where to look to see why goog.require can’t find my project.app ? this is only lightly-modified from the luminus template.

annapawlicka21:07:30

@dnolen: I’m just a mere human and can’t assign anything to anyone. But here’s the link http://dev.clojure.org/jira/browse/CLJS-1340

dnolen21:07:06

@annapawlicka: I have granted you superpowers

dnolen21:07:08

let me know if you have any questions

annapawlicka21:07:31

@dnolen: thanks, looks pretty straightforward. will probably look into that tomorrow