This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-02-13
Channels
- # 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
the CLJC file is the macros file
I see. But if you then put cljs in that file, does it just merge with the .cljs file?
no merging happens
one is treated as a CLJS file, the other as a macros file
in that case, the cljc
file is only used to expand the macros
it can
I don't understand what your problem is
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
, then cljc
if 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 f
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
and current support doesn't work in every case
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
there's lots of documentation missing for the self-hosted compiler
AFAIK it's considered an advanced feature
it's also very new comparatively
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.
no problem!
I assume "looking for a macros namsepace: clj
, then cljc
if cljc
doesn't exist" has a typo
fixed
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?
This is what I have, seems to work.
(declare use-fragment) (goog-define use-fragment false)
Just tried using namespace aliasing (http://blog.fikesfarm.com/posts/2016-07-03-clojurescript-clojure-namespace-aliasing.html) with clojure.test
, but it seems
(ns foo-test
(:require
[clojure.test :refer :all]))
does not work, whereas
(ns foo-test
(:require
[clojure.test :refer [deftest testing is]]))
does work. Is it a bug in ClojureScript?I get clojure.lang.ExceptionInfo: Don't know how to create ISeq from: clojure.lang.Keyword at line 1
when using the former
I need some advice. I've agreed to teach a friend web development, starting from nothing. Right now he's just learning HTML and CSS, but soon we'll need to start doing some JavaScript. It feels like I ought to teach him vanilla JS to start with as it's an essential skill, but I'm very tempted just to jump in with ClojureScript because the experience is so much nicer, and I'm often told functional programming is easier to learn before procedural. Does anyone have any recommendations?
IMO in the context of web programming, cljs is probably harder because you can't get away with not understanding javascript
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
+ get them hooked on 4clojure and klipse
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
hi @arnaud_bos =D
@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
@conan I agree if you’re just trying to intro somebody into web programming - start with JavaScript
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
If you do Clojure you need to know Java if you do ClojureScript you need to know JavaScript
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
but i do agree that you should be able to do a lot without knowing Java or Javascript, using just clojure/script. the fact that this is not the case is a huge missed opportunity imho, but i am alone with this view 🙂
@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
@ejelome I think I avoided this because since I got burned with jquery, I have been careful not to sit on any of the hype trains, and focused on things I could understand. I am using browserify, virtual-dom, toolings around these, for me there are not really too many choices, because there are too many drawback for each of them, there are not many concepts because I don't think they give more than what they require. I used cljs data structures from javascript and it is better than without, and you don't need to be very smart to see this. The different way of thinking appears already with libraries as Ramda or other languages like Elm. I admit that if people have no help, every large ecosystem looks scary, but my claim is that you can narrow javascript down to a minimal set of tools and concepts that give you just enough to do what you want, without causing fatigue. That's obviously not the case if you sit on one of these large hype trains and try to keep up with everything that's happening. Too much noise 🙂
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
i've been careful to choose my work environments ever since i was told that jquery != javascript
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:
https://github.com/binaryage/cljs-oops/blob/master/src/lib/oops/spec.clj
I jack-in cider and start node.js repl via
(require '[cemerick.piggieback]
'[cljs.repl.node])
(cemerick.piggieback/cljs-repl :repl-env (cljs.repl.node/repl-env))
Now I want to use core.async
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)
Im running on versoins
[org.clojure/clojure "1.8.0"]
[org.clojure/clojurescript "1.9.456"]
[org.clojure/core.async "0.2.395"]
I've never used node.js repl much, but I can't see what could be causing it not to work core.async.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]
the simple cljs.repl/repl is severely underappreciated
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.
How does one change the URL location in cljs? /beginner's question
the same way you change it in Javascript, https://developer.mozilla.org/en-US/docs/Web/API/Window/location
@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))
@vikeri try binding *out*
to *err*
(binding [*out* *err*]
(println "hi"))
@anmonteiro Thanks! It worked, not super obvious though
the problem is that *out*
is bound to the file the compiler is outputting to at that moment
so you'll get your thing printed, just not to the console 🙂
it'll end up in your compiled output
I see, it is not possible to automatically bind *out*
to *err*
around 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
@vikeri I'm not sure what you're asking
*out*
is explicitly bound to the IO writer for which we're outputing JS at that point in the compilation process
I’m looking at using: https://github.com/amark/gun
because cljs.compiler
functions use print
and println
to compile CLJS->JS
@anmonteiro Ah ok, then it’s not a good idea
@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)
open question: what would you use for an animations-heavy frontend? (i have the overall feeling that react-based stuff aren't quite the thing for it)