This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-11-27
Channels
- # beginners (91)
- # cider (1)
- # cljsjs (29)
- # cljsrn (8)
- # clojure (51)
- # clojure-berlin (1)
- # clojure-india (1)
- # clojure-russia (26)
- # clojure-spec (15)
- # clojure-uk (1)
- # clojurebridge (1)
- # clojurescript (240)
- # code-reviews (1)
- # cursive (22)
- # datomic (3)
- # editors (6)
- # emacs (24)
- # figwheel (3)
- # lein-figwheel (57)
- # off-topic (4)
- # om (3)
- # proto-repl (7)
- # protorepl (8)
- # reagent (2)
- # rum (23)
- # slack-help (1)
- # spacemacs (2)
hi! I'm stuck on a frustrating compilation problem; compilation is working fine, but actually attempting to call many procedures just produces an error like
#object[TypeError TypeError: undefined is not an object (evaluating 'adhoc.core.util')]
the missing code is in .cljc files, so I think I'm looking for a difference in a single file that could cause require to ignore others, maybe? the util namespace, for instance, is unchanged from an older version that both compiles and is usable. Is there a way to get a more specific error message in the case that a namespace fails to load?
calling require on that namespace does not return an error, but calling procedures defined inside it still fails
@langmartin each namespace ends up with a corresponding script tag in the DOM - you should be able to look at the DOM and verify that your namespace did in fact get loaded
if you see the script tag there - then perhaps you overwriting definitions (namespaces and vars can clash) - the compiler warns about this
@dnolen yes! I sorted that out. I think what happened is that rum/mount failed a bit, and was mounting to a div with the id adhoc, which is also the root of my namespaces
adhoc in the debug console certainly ends up bound to a dom object
in the case that it mostly works, I can still hit my namespaces. in the case that it fails, I end up with a dom object in place of it
that part I don't understand
gotcha
@dnolen thanks, that helps
sure, it makes sense why it'd be difficult to detect
If I didn't just miss a note in the docs to that effect, it might belong on a list of gotchas somewhere. I might have missed a doc
would be a good thing for a FAQ of some kind on the http://clojurescript.org website though
when I compile a simple "Hello World!" in ClojureScript with advanced optimizations, it compiles to 94k or ungzipped code
is this expected?
why doesn't it eliminate most of it to turn into just console.log("Hello, World!")
?
@ericnormand it should do that.
@ericnormand: if you use str
case
without an else case and stuff like that this can be pretty significant when trying to produce really small builds
@dnolen: @langmartin there's this discussion no the Closure library mailing list which has a bit more context on that problem: https://groups.google.com/forum/m/#!searchin/closure-library-discuss/cRYwOSIzALg
@ericnormand it is somewhat expected yes, not a goal to optimize this as any program that actually uses cljs.core will retain this much anyways
Hi there. I did en emacs mode for clojure, it supports compiling clojurescript at the repl, no file watcher needed. It also support cljs autocompletion, eldoc style documentation and jump to definition. I would love for someone to try and give me feedback. https://github.com/EwenG/replique.el
I just started playing around with clojurescript. It's a game, which runs only in js, now I want to make a back-end run with clojure, so multiple users can be in the same environment. Would it be best to try to make it one project, or two seperate ones? Eventually I wanted to make it one project, but looking at https://8thlight.com/blog/andrew-zures/2014/03/08/combining-clj-and-cljs-libraries.html it seems a little harder then I thought, also some logic will be moved to the back-end, but I think little to none of the logic will be shared.
@gklijs that blog post uses .cljx. I believe you should use .cljc nowadays if you want to write code that runs in both clojure and cljs
What do you mean by having multiple users in the same environment? Do you mean you want the game to use a server for multiplayer, or something else?
yes, multiplayer, so actually little to none code which will need to run on both sides
So you'd run the cljs game in the client, and you have a server written in clojure. Just like a normal web application, or even just a web site 🙂 There's nothing difficult or strange about it.
You can look at any of the popular templates and see how they do it. You don't need to use the template if you don't want to, just use it as an example
It seems a good fit, I was already using bootstrap, but with the loose minified js files added as source to the html
@martinklepsch @thheller the reason I ask is someone was asking me about splitting up their modules
if each piece is 95k, it's not really worth it
@ericnormand if you do modules only one will contain cljs.core
oh what do you mean by modules though? closure modules or js modules? not the same thing 😛
so here is my current problem with clojurescript (besides the obvious jvm), if I want to pick up Elm, the error messages help me. If I want to pick up React, Angular, the error messages do not help, but I can dive into the code. But if I want to learn clojurescript, I have nothing what to look for and the error message is not really helpful.
at least if I google, i would expect to find some help, but no, even when it looks its relevant, it's not useful. how do clojurescript people find information? where do you search?
I actually just click on the exception, and we have awesome source maps so you see right where the problem originated since you have the full stack available
On a cljs day I have about ~10-15 Exceptions, and it usually takes me <1min to fix them.
i’ve been out of cljs land for a while - is piggieback/weasel still the preferred browser repl setup?
@bbloom the alternative is dirac but you execute code in the google dev console
@bbloom I would say figwheel
is the preferred browser REPL ... no idea about the state of nREPL. I think figwheel does it but I don't know.
@bbloom piggieback and weasel haven’t developed much - figwheel is what most people use
i see that figwheel now has it’s own browser repl in it - but what about talking to my repl from a remote process? ie from vim? that still needs piggieback from what i can tell
@ashnur we try to produce informative error messages when we can and some tools do better (Cursive, Figwheel). This is also why wes spent so much time on decent source mapping - just set a breakpoint if you’re really lost.
there’s still WAY TOO MANY things i need to add to my project to get a simple thing working
@bbloom I’ve been sticking with Maven + simple Clojure scripts and life is significantly less complicated
my impression is that Boot alleviates some of the issues - but I’m a Cursive person and the integration isn’t there yet for Boot
@dnolen yeah, i had project.clj w/ all the deps listed & NO PLUGINS, then just ran everything from a dev.clj file
depending on your editor also, figwheel uses piggieback underneath so in any case you need it in the dep vector, more info here: https://github.com/bhauman/lein-figwheel/wiki/Using-the-Figwheel-REPL-within-NRepl#launching-the-figwheel-cljs-repl
I'd say boot's setup is easier
that said it’s possible to use Lein as a thin layer over Maven and mostly avoid the complications
somebody should really get a minimal socket REPL thing going and avoid all the nREPL complications
(I am kind of working on making the client a bit more figwheel-like though, the experience is different, aka, no very cool and nice error messages at the moment)
@bbloom a while ago I put together a minimal project just demoing how to get a (reloading) CLJS setup with Boot: https://github.com/anmonteiro/cljs-simple-reload
@ericnormand it’s always been like that - for like 5 years 🙂 we don’t really care though
if you can connect to nREPL in Vim, you should be able to get a CLJS REPL setup too
94k ungzipped is smaller than dropping jQuery or React onto a webpage which most people are doing
that said I can't really help with the Vim stuff as I don't use it
@anmonteiro thanks for that - that’s much simpler than the other cljs examples i’ve seen for boot
@bbloom @anmonteiro Boot-cljs-repl should work fine with Vim-fireplace, just run :Piggieback (adzerk.boot-cljs-repl/repl-env)
once you have Boot running and the app open in browser
^ oh cool didn't know that
oooh yeah, now i remember why i found boot so annoying - the insistence on all the commandline integration stuff
@bbloom you can execute tasks at the repl with (boot.core/boot (dev))
'vim-fireplace' doesn't have anywhere near the commitment that cider or cursive has ... just the way it is right now
Vim supports async operations nowadays, vim-fireplace doesn't
So to be honest, it is not perfect
Another problem I've perceived from feedback is that it appears momentum behind spacemacs is taking effort from where it might otherwise be applied to improving Vim integration
what i don’t understand is why i have so much problem with these sorts of things? am i wrong in perceiving everybody else as having this stuff all working fine?
it seems like no matter what what language/ecosystem i stumble in to, the standard tools fight me every step of the way
and then i just gut all the crazy stuff and replace it with a shell script & my life is better
Well at some point you're confined by taste and time - wanting to use vim and not wanting to contribute to fixing the tooling ;)
@dnolen i did contribute to fixing the tooling - i bought tpope beer and coached him through how vim fireplace should work 😉
tooling and ide integration is hard, I am going through a lot of of pain trying to use emacs and java
If the old thing doesn't work that would be news to me - we haven't changed anything around REPLs in 2 years or so
but it’s stuff like this that blows my mind: https://github.com/pandeiro/boot-http/issues/25 - if i ^c the dev task in a boot repl, i have to kill & restart my repl to kill the http server
@dnolen ok - i’m going to revive my old approach of manually running hte cljs compiler, weasel repl, etc
If the tool is only used to manage (download) deps, it doesn't matter if it is Maven, Lein or Boot
yeah, that’s all i’m using it for.... in fact, just doing: export CLASSPATH=$(lein classpath) java -jar clojure.main ........
@dnolen, i am not sure where i could set a breakpoint 🙂, i am not there yet. I just get a cryptic error message from figwheel that resource not found and i see zero leads what can be wrong
@bbloom what did you end up using?
manually run http-kit server, w/ manually configured wrap-file ring middleware, with manually run cljs.build.api/watch, with manually run weasel/nrepl server
oh cool, with auto-refresh/auto-reload in the browser as well?
yes that's is what I like as well, I would love to see your conf, would you mind sharing? 🙂
give me a few minutes - dealing with some project-specific stuff & then i’ll extract relevant bits
@bbloom ah ah no take all the time you want of course 😄
@dnolen eh, i didn't see that i should load the file through the filesystem. I was trying the server through ssh. I just found out now because @bhauman bring it to my attention that i am trying something that is not expected to work.
@dnolen didn't you work with chas at somepoint to make piggieback work with the standard builtin browser websocket repl?
yeah, that’s what i’m doing now: running my clojure repl directly via java -jar and then starting an nrepl server for cljs use
yeah, that’s more or less why i’ve never got involved w/ the tooling stuff - so much stuff going on that i just don’t have the patience to understand it all
like I said, Socket REPL really simple - people should consider rethinking tooling around it
yeah, that’s why i asked about it - i’d rather use that, but fireplace relies on nrepl (and hence piggieback for cljs)
definitely agreed with the socket REPL stuff
would also help e.g. Planck & Lumo downstream 🙂
Lumo has builtin support for a simple socket REPL - integrating with nREPL for example is just far beyond the scope
I'm definitely not going to spend any time doing it
Am I doing something wrong, or does cljs.build.api/build
require that macro files be on the java classpath as opposed to in the passed source
dir?
It would make sense if that were the case. I just kind of assumed it would pick it up from either.
@potetm I'm pretty sure they need to be on the classpath, or else the ClojureScript compiler would have to mess with adding them dynamically
Cool. Thanks @anmonteiro!
btw @bbloom there is a very nice doc to explain it all by @darwin here: https://github.com/binaryage/dirac/blob/master/docs/about-repls.md
richiardiandrea thanks, but the problem isn’t understanding the concepts - it’s just dealing w/ the complexity of configuration
there’s numerous ports involved in doing even the simplest of things & they are all configured differently, run from different jvms, etc
I think the middleware approach is not that bad. For instance I was looking at Java/Clojure mixed project and at how to use middleware on top of nrepl for providing functionalities. For instance there could be a jdk-middleware
that provides stuff to Scala/Java/Clojure projects, then the cider-nrepl
middleware only Clojure specific stuff
yeah you are right there is no real advantage...the problem is that nrepl
tooling was built that way
Yeah...compromise right? it is the eternal battle of declarative vs code/lein vs boot/ yada (that has interceptors) vs ring, I personally have always preferred coding...but I agree with you about the complexity
i don’t believe that “declarative” is a goal unto itself, nor do i believe it is at odds with “code"
The real problem to solve probably is: given a repl server, what is the best way for devs to add functionality in there. What cider-repl
and refactor-nrepl
do is basically just provide functions and a layer of responses, potentially there could be a cursive-nrepl
middleware (maybe there is one already). There probably is a better way then middleware but nobody has had time yet to work on it
there’s no functionality to be added to the repl server - the repl server shouldn’t do anything other than shuffle bits back and forth
Yes, the only small thing Socket REPL really does above netcat is “isolation” of things like *1
, *2
, in the event that you have multiple connections 🙂
I agree with this point as well. But at some point you would need to provide those features for "high-level" tooling like cider
I guess
@bbloom the problem with socket REPL i see is that it has absolutely no messaging semantics
the problem i have is vim-fireplace is built on nrepl, which existed before the socket repl
i’m not convinced that’s true, given how nicely the simpler cljs repl seems to work for me .... until i need vim integration
I made a small “bridge” (Tubular), but I’d like to see tools directly support Socket REPL.
don't shoot me but ... did you ever try emacs + evil mode? (I was a vim-user myself before that)
Slimv should work like inf-lisp
Fireplace has been built with support for multiple protocols in mind, so adding Socket REPL support might be feasible. At least it shouldn't require complete rewrite.
And the low level connection code in Fireplace is already async, it just the "user interface" code that is synchronous.
Talking about tooling @ewen came up with a nice one it seems, it was on #announcements earlier on
speaking about socket repls, replique runs on a socket repl (https://github.com/EwenG/replique.el)
to be more precise, one socket repl by repl session (stream oriented) + 1 extra socket for tooling stuff (message oriented)
i don’t think separate endpoints for clj and cljs makes sense - i want to be able to switch where evaluation happens just like in-ns lets me switch namespaces
@bhauman i didn’t see any of this sidecar stuff, looking at it now - might be closer to what i want
So related to cljs dev tooling: I just deployed this to clojars: https://github.com/potetm/tire-iron
Literally just pressed the button on that, so pre-alpha. But it's not monstrously complicated, so I should hope it kind of works out of the box.