clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
2020-10-26T01:06:14.270500Z

@p-himik Hmm..it actually looks to be unrelated to fighweel, like the error persists even when I run the compiled JS from an entirely different server.

2020-10-26T01:18:42.270700Z

@p-himik GOT IT...kinda: https://javascript.info/modifying-document

2020-10-26T01:19:01.270900Z

Its because if write is called after a page is loaded the document gets erased.

2020-10-26T01:19:57.271100Z

Which....seems to indicate that as long as the cojurescript compiler uses write it might not be possible, at least not without reconstructing the whole document within clojurescript itself.

2020-10-26T01:20:20.271300Z

Either way though, this seems like an interesting enough question on its own I'm going to ask it in the main thread. Thanks again for your feedback.

2020-10-26T01:22:31.272600Z

Hey, I noticed the clojurescript compiler seems to compile to uses of document.write. Is there any particular reason it does that over something like appendChild?

2020-10-26T01:33:53.273Z

Oh wiat, never mind, that was absolutely introduced by figwheel. Sorry about that.

p-himik 2020-10-26T07:59:17.273800Z

The code that does it is in cljs.closure/output-main-file, so it has nothing to do with Figwheel, I think.

thheller 2020-10-26T08:59:58.275300Z

yeah its CLJS but its only in development builds. optimized builds don't do that.

thheller 2020-10-26T09:04:46.275500Z

well technically its not even CLJS. it is the debug load mechanism of the closure library. CLJS just adopted that.

2020-10-26T16:37:57.290600Z

Ah, okay, taht makes sense, thanks.

2020-10-26T16:39:44.291Z

Is there any way to have a non-development, non-optimized build?

2020-10-26T16:40:58.291200Z

(When the build is optimized, I'm getting an error saying a.aZa is not a function, which I suspect means something that should be an extern is getting optimized, but obviously I have no idea what a.aZa is so its kind of hard to debug that without figuring that out first...

thheller 2020-10-26T17:58:28.294300Z

you can set :pseudo-names true in your compiler options. that will make the name recognizable

thheller 2020-10-26T17:58:50.294700Z

:optimizations :simple also works if you don't care about file size

2020-10-26T18:29:55.295200Z

@thheller Oh cool, thanks.

2020-10-26T18:30:47.295400Z

Also the advanced optimizations compile size is 7 MB, while the simple one is 10 MB, so ya. :)

2020-10-26T19:46:47.296500Z

Ah, the problem seems to be with identifiers with a . in it.

2020-10-26T19:46:58.296700Z

In this case, react bootstraps Modal.Header.

2020-10-26T19:48:34.296900Z

Which Makes sense. It looks like Object.Modal is making it into the inferred_exports.js file, but not Object.Modal.Header

Karol Wójcik 2020-10-26T08:50:42.275200Z

Hi. Could somebody please point me to benchmark json vs transit-cljs? I’m trying to find it without any success

thheller 2020-10-26T10:25:33.276200Z

what would you want to benchmark? it is always going to be slower given that it is built on top of json and uses persistent collections

mkvlr 2020-10-26T12:58:53.280800Z

@karol.wojcik there’s https://swannodette.github.io/2014/07/23/a-closer-look-at-transit/ and it links to http://jsperf.com/json-vs-transit/2 (archive link https://web.archive.org/web/20160310101542/http://jsperf.com/json-vs-transit/2 doens’t seem to useful?). @thheller I do remember @dnolen talking about it being faster than json in some cases due to compression.

dnolen 2020-10-26T13:08:09.281700Z

there were some interesting moments in the past where I think it was faster on V8 or something, but not generally true

dnolen 2020-10-26T13:09:45.283Z

overall it's a reasonably small performance hit over JSON

dnolen 2020-10-26T13:10:22.283200Z

https://cognitect.github.io/transit-tour/

dnolen 2020-10-26T13:10:31.283500Z

at the bottom it has very simple benchmarks

thheller 2020-10-26T14:23:27.287400Z

yeah comparing to JSON is not very interesting since we don't want to work with JS objects/strings. when we actually want CLJS datastructures then the transit overhead is very minimal and well worth it. also a whole lot faster than cljs.reader. the compression is nice too. overall I don't see an argument against transit 😉

✔️ 1
theeternalpulse 2020-10-26T15:45:39.289100Z

Anyone have a link to some good example projects that use datascript for the application state?

➕ 2
afhammad 2020-10-26T19:10:35.296300Z

Can anyone point me to any docs on Clojurescript's core.async support (given its a subset of Clojure's)?

uosl 2020-10-26T20:09:03.297200Z

I think the only difference is you can't use blocking calls (double exclamation mark) due to JS event loop. https://cljdoc.org/d/org.clojure/core.async/0.7.559/api/cljs.core.async

uosl 2020-10-26T20:09:59.297500Z

So everything has to be done inside a Go block and returned asynchronously (similarly to JS promises).

afhammad 2020-10-26T20:58:04.297700Z

Thanks, the link is helpful.