Fork me on GitHub
#clojurescript
<
2017-04-29
>
john00:04:59

@tbaldridge do you think you could make a reliable test out of that method? Like, def a thing and then check of the name-space on the pr-stred of said method is truncated or long? Should reliably be truncated on every :advanced compile, right?

iluk00:04:00

Hello) Does anyone developing electron apps with clojurescript here?

iluk00:04:04

If so how can one debug or get a repl into main process?

john02:04:09

Okay, so it wasn't easy, but I've got an agent implementation. Got a demo running to show cellular automata processing the the main thread and on web worker threads, using the agent system that fans the work out over a worker pool. Got buttons hooked up to start and stop the main and worker automata. Just confirmed that the whole thing still works in :advanced mode.

john02:04:30

So there may still be lots of edge cases where this doesn't make sense, but for some demonstrable cases, you can use them far easier than creating message passing APIs between web workers.

john02:04:23

So now that I've got that working I'm going to try to clean up the whole code base, document how to get things working and throw it up on github

bobcalco15:04:38

with :nodejs target, how can I access the filename and dirname global variables? Are there special variables for those in cljs?

noisesmith15:04:19

+cljs.user=> js/__filename
"[eval]"
+cljs.user=> js/__dirname
"."

noisesmith15:04:45

@bobcalco it looks like you can access them via js/ like any other global

bobcalco16:04:14

Hmm. Quite so. OK I thought I tried that and got a compiler error but perhaps I typo’d it. Tried again and it worked this time. Thanks!

bobcalco16:04:06

I also added the core.js externs since then from https://github.com/dcodeIO/node.js-closure-compiler-externs/blob/master/core.js and that probably was the real issue.

tianshu17:04:21

Met some problem with require javascript dependencies in node_modules. I want to compile my code to target browser, and I have a libs/npm_deps.js file, which have the following content:

var Deku = require("deku");

module.exports = {
    Deku: Deku
};
And also, I use figwheel, so I have cljsbuild configuration like this:
:foreign-libs [{:file "libs/npm_deps.js"
          :provides ["lib"]
          :module-type :commonjs}]
When I run lein figwheel, I saw WARNING: JSC_JS_MODULE_LOAD_WARNING. Failed to load module "deku" at libs/npm_deps.js line 1 : 4. What should I do?

qqq18:04:13

is 20 seconds

qqq18:04:27

is 20 seconds for :optimixations advanced normal for something whilch compiles in 2 seconds for optimixzations none ?

tianshu18:04:55

Yes, optimizations advance needs more time.

qqq18:04:08

10x is normla ?

tianshu18:04:37

maybe more, but generally, you only use advanced mode for production build I think.

mj_langford18:04:32

Hi there. I'm trying to figure out what's working well using node libs used in server side ClojureScript. I am focusing on a minimum toolset, preferably java free if possible. (Sorry, audience has a anti java bias). I've seen a lot of stuff that doesn't seem like it got all the way, and while I've seen Machiato, it's examples have a lot of bidi and such, and still are lein centered. Am I missing an obvious project to bring the "node-like quick development experience" to non-java devs interested in ClojureScript? Or it is up to me to write it?

noisesmith18:04:58

@mj_langford regarding the anti-java-bias, there was a talk from clojure west about deploying to aws lambda that had really good comparisons of node vs. java latency and resource usage. https://www.youtube.com/watch?v=GINI0T8FPD4&amp;list=PLZdCLR02grLp4W4ySd1sHPOsK83gvqBQp&amp;index=10

qqq18:04:25

@noisesmith : for lazy ppl, what is the conclusion ?

noisesmith18:04:41

it's a four sided graph based on how much CPU you use, and whether latency is more important than performance

qqq19:04:33

what happened to your msg with the slides ? they seem to have vanished

noisesmith19:04:50

I linked them wrong, they didn't actually have the time in the url

qqq19:04:47

hmm, so high volume = use clj low volume = cljs if low latency; either if don't care

noisesmith19:04:54

summary is that cljs wins for low volume, low latency; clj and cljs tie for low volume, higher latency; jvm wins for all high volume cases

qqq19:04:02

and this is all due to startup time + performance of jvm right?

noisesmith19:04:03

about right, yeah

noisesmith19:04:19

it's about warmup time and CPU usage differences between node and the jvm, yes

qqq19:04:32

and this isn't relaly clj vs cljs, it's about "jvm takes longer than node to startup, but jvm more performant than node"

noisesmith19:04:51

right - it's for lambda where spin ups are likely

qqq19:04:54

(I mean, it's clj vs cljs, but the result is due to jvm vs node, not clj vs cljs differences)

qqq19:04:16

so I'm using google app engne, where it's sorta like taht for the spinups

qqq19:04:26

I think google just keeps spun up jvms around for 10 miknutes after an request

noisesmith19:04:41

but I figured the comparison might be good input to a team that is suspicious of using the jvm

qqq19:04:50

so if you're the first perso nin 10 mins to make a request, you suffer the startup; but otherwise, there's no noticable delay

noisesmith19:04:57

right lambda does similar

qqq19:04:18

oh a related note, lumo is amazing

noisesmith19:04:28

yes, it is pretty great

qqq19:04:31

i'd ever use clj for shell scripting; but givbe how fast lumo starts up, I'm very tempted to use cljs for scripting

qqq19:04:34

s/ever/never/

noisesmith19:04:50

even for a browser based cljs codebase I regularly use lumo as a cljs repl that doesn't require a full client env running during dev

noisesmith19:04:27

I've experimented with lumo scripting, and ran into some annoyances with async shell scripting

noisesmith19:04:42

but that's easily as much me being inexperienced using node as anything else

qqq19:04:43

what in particular ?

noisesmith19:04:04

thinking that certain results would be ready before other code ran, and being wrong

noisesmith19:04:35

eg. shell command that creates a file, thought I was doing it sync or using the callback correctly, file did not exist yet when next code ran

noisesmith19:04:49

probably user error

qqq19:04:50

oh; because node is async everything?

noisesmith19:04:25

having things be ubiquitously async by default doesn't make for convenient scripting for me

qqq19:04:23

wait, so in node (mk-dir "foo") (cd "foo") might fail because line 2 execs before line1 finishes ?

noisesmith19:04:02

that was my experience yes - but I was probably doing it wrong

bobcalco19:04:22

@thheller The definitions are better but it compiles with warnings

thheller19:04:47

hmm? which one?

bobcalco19:04:48

Apr 29, 2017 3:14:33 PM com.google.javascript.jscomp.LoggerErrorManager println WARNING: /Users/bobcalco/projects/com/kindling-cli/resources/externs/fs.js:23: WARNING - accessing name require in externs has no effect. Perhaps you forgot to add a var keyword? var events = require(‘events’); ^^^^^^^ Apr 29, 2017 3:14:33 PM com.google.javascript.jscomp.LoggerErrorManager println WARNING: /Users/bobcalco/projects/com/kindling-cli/resources/externs/fs.js:24: WARNING - accessing name require in externs has no effect. Perhaps you forgot to add a var keyword? var stream = require(‘stream’); ^^^^^^^ Apr 29, 2017 3:14:33 PM com.google.javascript.jscomp.LoggerErrorManager println WARNING: /Users/bobcalco/projects/com/kindling-cli/resources/externs/os.js:112: WARNING - name module is not defined in the externs. module.exports = os; ^^^^^^ Apr 29, 2017 3:14:33 PM com.google.javascript.jscomp.LoggerErrorManager printSummary

thheller19:04:23

do you have the globals.js externs?

bobcalco19:04:12

seems harmless to change lines like ‘var events =require(“events”)’ to, e.g., ‘var events = {};’ — no?

thheller19:04:40

I don't know I tested it a while back and it worked quite well

bobcalco19:04:26

minor changes got rid of the warnings

bobcalco19:04:38

everything else still works

anmonteiro20:04:52

@noisesmith @qqq happy to hear every and all feedback. If you run into these annoyances either post them in #lumo or open issues in https://github.com/anmonteiro/lumo

anmonteiro20:04:19

that said, Node.js has synchronous counterparts for every async API so you can easily do synchronous shell scripting if you'd like

noisesmith20:04:38

yeah - I think I just need to read the docs more and make sure I'm actually doing things sync

noisesmith20:04:08

lumo has been pretty cool just for having a quick cljs repl if nothing else

qqq20:04:11

@anmonteiro : the biggest problem with lumo is that no one has ported over emacs yet, so I still have to write elisp

anmonteiro20:04:37

doesn't really seem like a problem with Lumo 🙂

john20:04:14

Is there a tutorial on shell scripting with Lumo out there yet?

noisesmith20:04:25

I should totally make one (and a tiny lib to make it more clj-friendly)

john20:04:01

yeah, a varargs lib would be needed, for sure, right?

john21:04:25

I mean something that helps build cli interfaces, like https://github.com/pallet/cli-cmds or https://github.com/clojure/tools.cli

noisesmith21:04:31

oh right, an arg parser would be good for sure

anmonteiro21:04:03

you can definitely use tools.cli with Lumo