Fork me on GitHub

Here's a straightforward Reagent / reframe SO question: I've heard people say here that map is prefered to for with Reagent. Can someone tell me what it is and I'll add it in (or put your own answer obviously)? I think people know that map is better than for, but most of us glance over the technical reason for this...


@cjmurphy: I use map instead of for because I can never remember the syntax for the latter 😕


@abdullahibra: what you're asking for is a Distributed System. Which are hard. and also were helpful for me when getting started thinking about this kind of thing. Even now, cljs libraries like Om Next and posh are just figuring out how to do client⇔server⇔other clients transfer reliably and efficiently. You can hand-roll something simple, for sure, but in general, the problem is hard, so things like Firebase, Parse, Meteor, etc. exist and are popular (though some of those complect other concerns too).


@darwin: gun looks awesome


What is best practice in serializing js-objects to edn? I have a ( that I would like to serialize and store. With pr-str I just get "#object[Object 20160512]” which naturally fails to be parsed by cljs.reader/read-string. Seems like tagged literals is not fully supported in cljs still?


You probably want cljs.reader/register-tag-parser!, example here:


@vikeri: I believe one of transit’s design goals was to robustly serialize objects/data-types into EDN:


@danielwoelfel: Great, I’ll check it out!


@darwin: Spoke with @bensu and he said that transit should not be used for storage since the format/api might change.


@danielwoelfel: Where do I add the tag and transform the object when writing it? I don't have to traverse the data structure first and replace all occurrences of right? My initial hypothesis was that pr-str would have an optional argument with serializing functions.


@vikeri: pr uses print-method under the hood, which is a multimethod, so you can add implementations for new types


at least that's true in Clojure, haven't tried it in Clojurescript


seems it isn't true in Clojurescript... I can trace it down to pr-writer-impl, but it doesn't seem like there's an easy way to extend it


or maybe there is, it seems IPrintWithWriter is a protocol you can implement


@plexus: Thanks! Seems the last blog post is what I want.


Got it working, these things ought to be better documented...


@dnolen I noticed you said you don’t use loops which is all Clojure seems to offer. How do you do recursion in Clojure because it’s not very Clojure to use recursion as far as I have seen?


urbanslug: Recursion is done with the loop/recur form, because the compiler doesn’t otherwise do any tail call optimizations. It’s dogma not to use it in end-user code, though a lot of core functions are implemented with it.


anyone know how i can see output to *out* or *err* during cljs macroexpansion... it's being suppressed in my setup


@dnolen: Isn't it possible for ClojureScript to implement true TCO? From my understanding, true TCO wasn't implemented for Clojure because of the current limitations of the JVM security model. But Javascript doesn't have that kind of limitation.


@jarcane: Not to use what in end user code?


@risto: I thought TCO was new in JS, based on things like ?


The ES6 standard does call for TCO.


The vendors are complaining about actually implementing it though.


@fasiha: Yeah, ES6 is still pretty new and not fully implemented in browsers. Everyone is still targeting ES3 or ES5. I think ClojureScript could implement true TCO similar to how Babel has done it, and it would work for older browsers too.


I would love to see it happen, one way or another.


I know Fable, the new F#->JS compiler, does it by just compiling to ES6 and feeding that to Babel, but CLJS isn’t likely to go down that route.


@risto what's the difference between the current TCO and the true TCO you're referring to?


I could feel myself getting more and more educated the more of it I read @mikethompson !


Fixing five criminal uses of map-indexed in views.cljs 😕


@lewix: Partly, I suspect he means that in most languages TCO is done for the whole program. Clojure’s is limited to the loop/recur form which IIRC just uses some local optimisation tricks to turn itself into a loop. It definitely can’t do clever stuff like mutual recursion (though I don’t think ES6 can do that either)


And yeah, it's only done using loop-recur rather than for the whole program by default


Kawa Scheme apparently does have full TCO but it has performance and interop consequences when enabled.


@risto JS does have that limitation


anything that isn’t uniformly implemented is never going to be under consideration


The security model? how so?


JS doesn’t have that


and no we’re not going to implement on our own, the perf hit is huge


and tooling integration nightmare


Couldn't the perf hit be mitigated by the closure compiler?


Well, in any case, would something in a tail call position be transpiled like that via closure?


In other words, once browsers implement TCO for JS (because of ES6), then clojurescript would get that for free


But only if the transpiled code is still in tail recursive form


perf hits can be mitigated with requisite amounts of free time


usually there are more impactful things to work on


TCO just isn’t that important


Yeah, that's probably true. But it does make a lot of algorithms more elegant


sure typical Scheme textbook algorithms, after a lot of time with Clojure, I just don’t think it really matters much other than “that’s pretty"


Yeah, Clojure can probably get away with making most non-recursive algos still completely readable. But in a lot of languages the recursive form definitely is easier to read.


is there any example of an :externs shimmed standalone library I can copy? there’s a security flaw in a current cljsjs lib and while I’ve got a PR to update it I need to move more quickly than they are


ah ah, sorry, I’m looking for how to do it with leiningen


google-maps, google-platform-js and stripe are currently packaged like that


You can also just set up deps.cljs on your app project and include extern in the project


that’s true, hm, and probably the simplest


I liked the notion of keeping deps all in one place


we’re using jitpack internally, so I can easily throw up a vendored version of the auth0 lib


but it only supports lein


@tel: I have a couple


cljsjs updated in the mean time, but I’ll keep these bookmarked


Both of these libraries required messing around with their respective upstream build pipelines, which is a no-no for the CLJSJS team. But if you're trying to rope something in and the authors didn't like using --standalone for browserify you're sort of screwed...


JavaScript fatigue at its finest.


@xcthulhu: What do you mean with "messing around with build pipelines"? I think some cljsjs packages modify some build configuration or something like that


Anyway, packaging JS libs separate from Cljsjs is fine. Makes my life easier when I don't have to maintain them.


@juhoteperi: In the case of bitauth, I have to go in to their gulp file and monkey around with their browserify command (or skip their build system all together and run browserify out of band).


In the case of SJCL, I have to pull down the clojure compiler and compile with simple optimizations, set pretty-printing to true, and wipe their comments and run their unit tests over the result to get a functional "unminified" version of their library. I wish it wasn't so but SJCL both needs the closure compiler's optimizations to be functional and also fails to write their javadoc comments in a way that doesn't make the closure compiler throw a fit.


Heh. Some JavaScript libraries are quite inconvenient to use.


In the case of bitauth, I'm ready to retire that library. An upstream dependency (elliptic.js) doesn't support advanced compilation and it's too much yak-shaving to fix.


@juhoteperi: Sadly, SJCL's bignum library is actually more functional than the google closure library's goog.math.Integer 😞


At this point I've sunk like 100 hours into this little hall of mirrors that is JS crypto libraries.


@all: What are people's thoughts on js/window.crypto.subtle ? Would a clojurescript wrapper + polyfill for legacy browsers be welcome?


I'm like 50% of the way there...


(I had one buddy say he didn't trust window.crypto.subtle...)


So I finally got my CIDER + Boot + browser-REPL setup sorted have no problems getting two REPLs established, one for CLJ, one for CLJS. Thanks to everyone who offered suggestions and pointers to tutorials. I've got Reagent on the front end, and a whole lot of data on the backend I want to turn into dynamic visualizations. Any recommendations for where to look next for a good way to set up the flow?


@pataprogramming: for reagent is probably the hot sauce currenty, i also like (watch the linked talk)


Scanning the (extensive!) re-frame README, the bit that's currently missing for me is how the data gets from the backend into the app-db ratom.


Say I've got some metrics that take a fair number of CPU cycles to crunch coming in on the backend. What are the architecture options for pushing that stream out to the CLJS side of things on the browser?


whatever floats your boat really, rest, websockets.. is pretty awesome


Cool. I poked around with sente + Om a year ago, but only to get a toy scenario set up. If that's still state of the art, I'll dive back in. Thanks!


if you haven't checked it out yet: makes things a breeze, atleast for the backend part


I've worked with component in the past, but not system. I think I've heard it plays nicely with Boot?


This is the first project I've converted to Boot, and I'm really liking it. Faster and lighter, and it's been really easy to stick my fingers into the pie when I needed to make some tweaks.


Any thoughts on http-kit vs Immutant? I used http-kit the last time I was playing around with sente.


@patapizza: These benchmarks are kind of old, but immutant has better performance:


@pataprogramming: Yea it does play very nice with boot indeed, coming from gradle boot was a no brainer as soon as i saw it. 😛 Can't comment on http-kit vs immutant, but shouldn't really matter as you can switch at any time with sente.


Does a predicate like regular-expression? exist in CLJS?


Hi all, stupid question - is it possible to make cljsbuild faster (cache, multi-threading, etc)? It's becoming slowest part in our Continuous Delivery Pipeline 😞


@nicola cljs supports parallel builds


But not - parallel build ?! We have just a couple of builds - should we split them somehow?


thx! - let me check it



cljs.user> (regexp? #"")


@pataprogramming: thanks! how did I not find this haah


does anyone debug clojurescript apps on mobile devices? if so any suggestions?


i.e. no console available.


@fenton: if it’s a web app in a mobile browser on iOS you can debug, also thought this was true for Android


for native, I suppose you’ll have to be OK with logging if your platform doesn’t have better JS debugging integration


on iOS at least with JSC logging works same as NSLog far as I know


@dnolen what I was trying to do is serve it up with boot and the various cljs-repl, reload, etc..., then i should have all the power of a repl, cider, etc... however am having trouble using this arrangement when all devices are not the localhost.


@fenton: I would get this working with the simplest thing first if you’re just interested in debugging


for example, some mobile phones dont work...for some reason, but I don't have access to the phone, but if they connect to the site....then with the above setup, theoretically, I'd be golden with a repl in their browser.


then add bells and whistles later


as far as making this work with every possible mobile phone - probably not gonna happen


true for sure, but this development setup would be powerful... i think everything is basically there for this setup too... raised an issue with boot-cljs-repl...


well in my mind at least actual debugging means source mapping and stepping, you need access to the phone for that


spending a lot of effort to just get a REPL to some random phone doesn’t sound like it would help that much with serious debugging at least to me


repl is usually my first stop...but perhaps you are right.


but i dont think this needs to be setup for each different should be a generic setup for any browser connected device.


well also being to connect to someone else device via browser through a REPL is also a probably a pretty bad security hole so I don’t know 🙂


(but maybe misunderstood here)


yes i wouldn't run in production like that!


i'd just serve the static files...but when they aren't working i can wind up this jetty served site with all the repl connection trappings...


@fenton: well if this is for debug builds then I don’t see why it couldn’t be made to work


I don’t see why localhost would be an issue


@dnolen. basically my setup is I'm running the site on a remote server. In the simplest case, I open up a local browser (just as a test) that is pointed to this remote server (being served by boot cljs-repl reload serve, etc...). At this point everything is fine. Then I open up a repl (either cider connected or a terminal right on the server), but (start-repl) but weasel complains, hangs... The bug i raised for it is:


I'm pretty noob'ish on the build perhaps i'm doing something wrong...or maybe there is a bug... a bit surprised others haven't run into this tho... would make mobile development a lot easier IMO


@fenton: I haven’t been following the cider integration, and definitely not weasel or piggieback, I suspect you may have more luck with Figwheel


@dnolen okay maybe I'll give that a try...


(I could be wrong about all of this, I only use Figwheel + Cursive myself)


@fenton: People developing for mobile platforms are small section of people writing Cljs (or using Boot) and people using browser-repl are another small section, those who use both are even smaller section


@juhoteperi: but i think developing for mobile should be peoples first thoughts when using cljs, no? Mobile is the future right?


@juhoteperi: but what you say is true...


@fenton now that I understand what you are trying to accomplish, I’ve had stuff like this working before BTW


I think like 3 years ago I played around with browser REPL interacting with many connected clients - desktop browser, iPad, and iPhone, and Android device browsers


but my advice would be stick with the simplest thing


forget about Cider, Weasel, etc. for now


just try to get Figwheel to do what you want at a terminal and go from there


@dnolen yes, i'll give that a try, not sure conceptually if it makes sense as I haven't used figwheel for sometime now...but i guess it should?


@fenton: how is it any different than what you described?


Figwheel does other things, but it’s also a REPL


@dnolen yes you are right... just haven't used figwheel for a while...sorry my statement was not helpful 🙂


I’m only suggesting it because it’s really popular and thus probably less issues, more help


@dnolen i'll report back! thanks again! 🙂


People who have rich text editors in their app, how did you do it? 🙂 I recently stumbled upon and the more I'm playing with it the more I'm liking it. Draft is an alternative but mobiledoc seems much simpler


hello! What is better? react-native with a clojurescript wrapper or lein-droid package?


@fenton At the last Clojure/West the Untangled team had a nice feature for bug reporting...a classic log of all the events up to the bug, which is not step through but very neat 🙂


@richiardiandrea: OK I'll chat with you offline soon... Just at sailing center waiting for sailing partner! ;)