This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # bangalore-clj (1)
- # beginners (29)
- # boot (13)
- # braveandtrue (5)
- # clara (5)
- # cljs-dev (42)
- # cljsrn (7)
- # clojure (55)
- # clojure-france (46)
- # clojure-nl (11)
- # clojure-portugal (1)
- # clojure-russia (268)
- # clojure-spec (26)
- # clojure-uk (32)
- # clojurescript (173)
- # clr (2)
- # core-async (46)
- # cursive (22)
- # datomic (33)
- # devcards (1)
- # emacs (5)
- # events (8)
- # figwheel (2)
- # flambo (4)
- # instaparse (8)
- # jobs (11)
- # klipse (46)
- # lein-figwheel (3)
- # london-clojurians (2)
- # nrepl (1)
- # off-topic (29)
- # om (4)
- # om-next (8)
- # pedestal (3)
- # rdf (4)
- # re-frame (51)
- # reagent (104)
- # remote-jobs (1)
- # rum (4)
- # schema (2)
- # specter (19)
- # untangled (16)
- # vim (52)
I've noticed in cljs.core there are cljc and cljs files for the same namespace. I don't see any documentation on doing this, and it seems a bit strange to me to not at least say the order of evaluation. Or is this just an internal artifact of that source base that you should not do in your own projects?
not that I want to do it...things that surprise me just make me think I'm not understanding things well enough
@tony.kay the only reason to do it is supporting regular + self-hosted ClojureScript
I see. But if you then put cljs in that file, does it just merge with the .cljs file?
here's how the compiler figures things out:
looking for a non-macros namespace:
.cljs, only check for
.cljc if the first doesnt exist
looking for a macros namsepace:
clj doesn't exist
@tony.kay if both files declare the same namespace, only
g should be in your end product
that was my question. No docs I could find specify that is the behavior...but if I have just a cljc file I would certainly get
but if I can use cljc when self-hosting, why would I ever want to confuse myself by having cljs and cljc
until very recently there wasn't support in the self-hosted compiler for the single
.cljc file pattern
I see. OK. The rules help. Might make sense for those to end up in some kind of docs. Or perhaps they are and I didn't find them
yeah, and I understand these things get "grown and corrected". Just in the interest of trying to get my libraries "right" for general consumption
I keep doing macros subtly wrong, and decided to dedicate today to at least understanding what I don't clearly understand
and while I'm already working on them, might as well at least make some effort to ensure I won't have to do it again.
I assume "looking for a macros namsepace:
cljc doesn't exist" has a typo
Ah. Found this, which helped me some too: http://blog.fikesfarm.com/posts/2016-03-01-clojurescript-macro-sugar.html Thanks @mfikes
@tony.kay It is interesting that this appears to be undocumented. (Perhaps that can be addressed.) Related aspect that might help: If in a REPL you do
(require ‘foo.core) and it doesn’t exist, the error message indicates the order in which the loads were attempted. For
(require-macros ‘foo.core) to work, http://dev.clojure.org/jira/browse/CLJ-1797 needs to be accepted / landed.
thanks for the tip. At the moment I'm aimed at getting libraries that support both clj and cljs right.
the implicit loading (with refer on macros) also seems to be a bit buggy, I think. It looks like if I have a namespace pulling in something with require-macros that gets compiled before one that is trying to do implicit loading on a file that does not self-refer, then it will compile even though it should not.
it's like the earlier require macros has pre-loaded the macros so that the incorrect file "gets away" with it
yeah, I just verified that. Not nice to have a compilation that is order-dependent 😞
The ability to affect ordering of requires is actually very new http://dev.clojure.org/jira/browse/CLJS-1453
This is file a.cljs does an include-macros, and file b.cljs works "by accident" because it compiles later
yeah, I'm working on a large library. Will have to distill, but don't want to get sidetracked just now 😕
anybody know how to get a
def'd value to be a default when using
goog-define? For instance,
(def thing "abc") (goog-define foo thing) fails because
goog-define is a macro and receives the symbol
thing. Unfortunately, my go to of
(goog-define foo ~thing) doesn't work either. do i need to do something weird like wrap the call in my own macro and call that?
Just tried using namespace aliasing (http://blog.fikesfarm.com/posts/2016-07-03-clojurescript-clojure-namespace-aliasing.html) with
clojure.test, but it seems
does not work, whereas
(ns foo-test (:require [clojure.test :refer :all]))
does work. Is it a bug in ClojureScript?
(ns foo-test (:require [clojure.test :refer [deftest testing is]]))
clojure.lang.ExceptionInfo: Don't know how to create ISeq from: clojure.lang.Keyword at line 1 when using the former
you need to understand the host to some degree -- not perfectly but enough to make educated guesses
JS has googleability on its side, and codepen etc. make it easy to collaborate and experiment
my vote is for some JS before diving into CLJS, as otherwise the fear is you'll get stuck eventually
the other thing is, you as a teacher also count so if you enjoy teaching cljs more, maybe that's a consideration?
I have a very good experience using re-frame, and done very little with JS before. So I think you could ‘skip’ the JS part, as long as you setup the project to some degree
try giving the learner jquery and let the guy experiment, then guide the guy how to implement that in cljs
Hi @conan 🙂 I guess it depends what for. I mean if it's in order to get a job right away, I would personally skip Cljs and go to JS only I think. I wouldn't put the burden of having to evangelize people to a friend of mine if all he wants is a career change, even if I wouldn't mind having a side-kick in my local area ^^ On the other hand if it's in order to work with you on a particular project where you happen to use Cljs, then, why not. My 2 cents.
I guess for a total beginner, it's html -> css -> jquery -> vanilla js -> clojurescript, there's too much advanced topics in clojure(script) that will hurt a beginner
Oh, good idea on the jquery, as someone who doesn't write much JS i wouldn't have thought of that
@gklijs yeah, the aim is really for him to be able to set up his own projects, and of course i was only thinking about the project. i'm not convinced bower + npm is any easier than leiningen or boot, but there is a lot more help out there
@pesterhazy that's a good point about what i enjoy teaching, but to be honest it probably wouldn't hurt for me to brush up my js skills rather than sticking to what i know!
@conan hi 🙂 congrats for the launch! Last year I gave a JS training course and one of the attendees was new to programming and used to "do" websites using jQuery, I noticed quickly he had no programming background at all, and the moment he had to do more advanced stuff or even debug, he was stuck in great pain. I took him appart and went back to basics with him. So don't skip the basic before introducing jQuery I would suggest.
i don't think clojure in itself is too advanced for a beginner, but i do think that the tooling is too hard even for an advanced user to pick it up from scratch
I’m on the fence about full stack though - I don’t personally like Node.js for backend stuff
bower and npm are definitely harder than boot/leiningen, but they're also more resume-friendly, sadly.
@dnolen yeah, it does seem a shame though. i wouldn't feel the need to teach somebody java before clojure
maybe there’s some variance for the beginners but that’s where you end up pretty quick
i definitely think it helps to understand the runtime, and you're always going to fall back on interop for some things. starting out though, you could build plenty of useful projects using just clojure, with no understanding of OOP and other things from the Java world. I'd say knowing how the JVM works is more valuable than actually learning Java for a Clojure engineer.
By the same token, knowing how the browser works is valuable for a ClojureScript engineer.
i think knowing how a VM works is already quite an advanced topic be it the JVM or v8 or whatever else
@conan yeah you’re right - and that’s what I mean some platform understanding is necessary
not everyone can afford that. Halfway through learning clojure it seems to me that the learning curve is kept artificially high just so the practitioners can be conceited about their skills. Just the same what I see in academia everywhere.
too many choices (libraries, frameworks, platforms), too many concepts for each topic (react, ssjs, flux, etc.), and if you start with cljs, it's a diff way of thinking (immutable, atom, repl, macros, etc), it might look easy for us since we've past that understanding stage, but for someone who never touched JS, just imagine their horror https://clojurians.slack.com/archives/clojurescript/p1486994360018581
someone hit me with this before and he was right, it changed the way how I think and approach beginners (esp. if you want to share something to them) https://en.wikipedia.org/wiki/Curse_of_knowledge
yeah, this link could be pinned here to be mentioned regularly when people ask beginners to write docs 😄
I agree if you always have the freedom to choose your tools, but on a work environment, where diff requirements and diff level of hype (or noise) exists, it becomes a diff story XD
that's great, really, back then, I wish I had someone to mentor me, I was self taught all these years, so I have to learn the hard mistakes just to realize I was/going to the wrong direction, haha
i had a colleague at my first job as a "web developer" in 2004 who told me that lisp is stupid and a waste of time and i did not know it better, i had such respect toward them, i believed it completely and took me a lot of time to look again
huge mistake, i could've learned much faster about a lot of important things that are in any lisp
well, i think it's not the best way but clj->js or js/obj and then setting properties both are working possibilities
unless you mean clojure.spec in which case i don't think that is going to work, but i am curious
admittedly it’s advanced but somebody should try to figure it out and share a gist or something
Question: My rest API now returns transit, but in clojurescript I now and then see [Tagged Value, f, 8] rendered, rather than 8
yeah but before i didn't have to care, basically my rest api does a DB query using yesql, and I basically return that vector of maps (db records)
this basically 'happened' when upgrading both compojure (server-side) and clojurescript / cljs-ajax to the latest version if i remember correctly
good thing, it's now transit (if that's better than json that is ;-)), bad thing i have to deal with this some way
@mss: haven’t done any deep spec work yet, but had to write this and use it instead of
s/* for js arrays:
I jack-in cider and start node.js repl via
Now I want to use core.async
(require '[cemerick.piggieback] '[cljs.repl.node]) (cemerick.piggieback/cljs-repl :repl-env (cljs.repl.node/repl-env))
Im running on versoins
core> (require '[cljs.core.async :as async]) nil core> (async/chan) ExceptionInfo TypeError: Cannot read property 'chan' of undefined at repl:1:84 at repl:9:3 at ContextifyScript.Script.runInThisContext (vm.js:25:33) at Object.exports.runInThisContext (vm.js:77:17) at Domain.<anonymous> ([stdin]:50:34) at Domain.run (domain.js:221:14) at Socket.<anonymous> ([stdin]:49:25) at emitOne (events.js:96:13) at Socket.emit (events.js:188:7) at readableAddChunk (_stream_readable.js:176:18) clojure.core/ex-info (core.clj:4617)
I've never used node.js repl much, but I can't see what could be causing it not to work core.async.
[org.clojure/clojure "1.8.0"] [org.clojure/clojurescript "1.9.456"] [org.clojure/core.async "0.2.395"]
ok lesson learned, this error was caused by the piggieback cljs-repl. Core.async works okay like this
user=> (require 'cljs.repl) (require 'cljs.repl.node) (cljs.repl/repl (cljs.repl.node/repl-env)) nil nil ClojureScript Node.js REPL server listening on 54510 To quit, type: :cljs/quit cljs.user=> (require '[cljs.core.async :as async]) true cljs.user=> (async/chan) #object[cljs.core.async.impl.channels.ManyToManyChannel]
With core.async working now with piggieback missing, I can't user cider, as it doesn't detect cljs repl.
ok for slack.logs storage, don't use old version of piggieback 🙂 bit confusing that the github releases has latest 0.1.5 but on clojars its 0.2.2. That was causing all of this confusion.
@samcf here's a quick dump of my code for managing browser locations in a re-frame app: https://gist.github.com/anonymous/e9e4c1c1c3d40afaf49cf6be154ae87a
Why can’t I seem to get compile time
println to work? Calling this macro fails:
(defmacro printer [s] (println "Compile time:" s) (list 'println "Runtime:" s))
the problem is that
*out* is bound to the file the compiler is outputting to at that moment
I see, it is not possible to automatically bind
println statements? It works in clj but not in cljs. At least it probably should be added to: https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure
*out* is explicitly bound to the IO writer for which we're outputing JS at that point in the compilation process
@petr have you looked at https://clojurescript.org/guides/externs . I actually have Gun on my list and get around to looking at using it in the next couple of weeks
@rayk @petr speaking of externs, I stumbled upon this today: https://github.com/binaryage/cljs-oops#externs-from-hell and kinda like this alternative approach (in theory at least)