This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-04-29
Channels
- # aws-lambda (13)
- # beginners (4)
- # cider (6)
- # cljs-dev (1)
- # cljsrn (4)
- # clojure (134)
- # clojure-android (7)
- # clojure-dev (14)
- # clojure-russia (18)
- # clojure-spec (3)
- # clojurescript (81)
- # core-matrix (2)
- # datomic (9)
- # figwheel (1)
- # hoplon (11)
- # lumo (10)
- # off-topic (18)
- # onyx (78)
- # pedestal (5)
- # portkey (2)
- # re-frame (8)
- # reagent (3)
- # rum (1)
- # spacemacs (23)
- # yada (5)
@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-str
ed of said method is truncated or long? Should reliably be truncated on every :advanced
compile, right?
Thank you @mobileink
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.
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.
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
with :nodejs target, how can I access the filename and dirname global variables? Are there special variables for those in cljs?
+cljs.user=> js/__filename
"[eval]"
+cljs.user=> js/__dirname
"."
@bobcalco it looks like you can access them via js/ like any other global
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!
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.
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?is 20 seconds for :optimixations advanced normal for something whilch compiles in 2 seconds for optimixzations none ?
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?
@bobcalco use these externs for node, they are much higher quality ... https://github.com/google/closure-compiler/tree/master/contrib/nodejs
@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&list=PLZdCLR02grLp4W4ySd1sHPOsK83gvqBQp&index=10
@noisesmith : for lazy ppl, what is the conclusion ?
it's a four sided graph based on how much CPU you use, and whether latency is more important than performance
I linked them wrong, they didn't actually have the time in the url
this is the four way graph https://youtu.be/GINI0T8FPD4?t=43m47s
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
about right, yeah
it's about warmup time and CPU usage differences between node and the jvm, yes
and this isn't relaly clj vs cljs, it's about "jvm takes longer than node to startup, but jvm more performant than node"
right - it's for lambda where spin ups are likely
(I mean, it's clj vs cljs, but the result is due to jvm vs node, not clj vs cljs differences)
right
but I figured the comparison might be good input to a team that is suspicious of using the jvm
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
right lambda does similar
yes, it is pretty great
i'd ever use clj for shell scripting; but givbe how fast lumo starts up, I'm very tempted to use cljs for scripting
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
I've experimented with lumo scripting, and ran into some annoyances with async shell scripting
but that's easily as much me being inexperienced using node as anything else
thinking that certain results would be ready before other code ran, and being wrong
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
probably user error
right
having things be ubiquitously async by default doesn't make for convenient scripting for me
wait, so in node (mk-dir "foo") (cd "foo") might fail because line 2 execs before line1 finishes ?
that was my experience yes - but I was probably doing it wrong
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
seems harmless to change lines like ‘var events =require(“events”)’ to, e.g., ‘var events = {};’ — no?
@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
that said, Node.js has synchronous counterparts for every async API so you can easily do synchronous shell scripting if you'd like
yeah - I think I just need to read the docs more and make sure I'm actually doing things sync
thanks
lumo has been pretty cool just for having a quick cljs repl if nothing else
@anmonteiro : the biggest problem with lumo is that no one has ported over emacs yet, so I still have to write elisp
doesn't really seem like a problem with Lumo 🙂
I should totally make one (and a tiny lib to make it more clj-friendly)
I mean something that helps build cli interfaces, like https://github.com/pallet/cli-cmds or https://github.com/clojure/tools.cli
oh right, an arg parser would be good for sure
Is this the kind of thing you mean? https://lambdaisland.com/episodes/building-cli-apps-with-lumo-part-1
you can definitely use tools.cli with Lumo