This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-12-13
Channels
- # adventofcode (77)
- # beginners (132)
- # boot (11)
- # cider (40)
- # clara (10)
- # cljsjs (1)
- # cljsrn (4)
- # clojure (148)
- # clojure-android (1)
- # clojure-greece (5)
- # clojure-italy (5)
- # clojure-nl (7)
- # clojure-spec (57)
- # clojure-uk (9)
- # clojurescript (115)
- # core-matrix (1)
- # cursive (3)
- # data-science (1)
- # datomic (1)
- # duct (7)
- # emacs (20)
- # fulcro (29)
- # funcool (4)
- # graphql (31)
- # instaparse (15)
- # java (1)
- # jobs (6)
- # jobs-discuss (95)
- # leiningen (2)
- # off-topic (30)
- # om (4)
- # onyx (7)
- # pedestal (6)
- # quil (4)
- # re-frame (52)
- # reagent (59)
- # rum (1)
- # spacemacs (3)
- # specter (61)
- # test-check (3)
@martinklepsch checkout status-react
Hi guys, sorry if you get this question often, but is Clojurescript really suitable for beginners? I know basic JS and basic Clojure (from a book), but have never coded. I want to make a web application from scratch. Is Clojurescript most suited to experienced developers?
There isn't much in the way of newbie-oriented documentation and tutorials out there with Clojurescript, so I'm worrying it's just too difficult to figure out how to go from zero to app, versus the more popular tech stacks.
@max675 There isn't a huge amount of difference between Clojure and ClojureScript, so most of the Clojure learning materials will apply (apart from JVM interop)
@danielcompton It's just hard to figure out what I need to learn. I've been studying pure Clojure via Clojure for the Brave, and the koans. Now what? With JS, there is a lot of material for guiding you from zero to a working app
As far as CLJS learning materials, there are some good ones out there (http://purelyfunctional.tv, Lambda Island)
But you're right that it's not as rich as say JavaScript
What should be my next step after I am comfortable with Clojure language basics? @danielcompton
I'm a little bit biased, but you could take a look at re-frame's docs, they're top tier IMO https://github.com/Day8/re-frame
Hey, does anyone who has been using node-modules have any idea how I would require this https://www.npmjs.com/package/@blueprintjs/core
Hey! I started exploring this issue last night, but didn’t get very far unfortunately. Dunno if you came across this link, but perhaps it might help? https://clojurescript.org/reference/packaging-foreign-deps
I’ve tried :blueprintjs-core and :blueprintjs/core, neither work :@blueprintjs/core causes an error with lein immediately
@danielcompton I'll check it out 😁
@max675 I’d check out Reagent, and look at the source code for projects like re-com or zetawar
Also, @timothypratley has a lot of great posts on his blog and youtube channel
So, um, I can check those out and then... ? They have docs for how to use them, that a newb could understand? I've found most docs to be aimed at people already using JS and JS frameworks.
I’m not suggesting you use those projects, I’m suggesting you try and read their source code
I'm finding the readme on @danielcompton’s Re-frame to be helpful, especially the six-domino analogy. What an event is, that an event-handler is, and so on.
I've learned how to use Clojure to make little programs that are typical of coding tutorials. When I look at real project source code, however, I find that the complexity immediately confuses me. I can't tell what the code is doing, especially because it usually refers back to functions in other files. So I can't find a link between what I learned in the "pure" form, and these applications.
Re-frame is a great library and will give you some great patterns. I definitely empathize with your current challenge. My suggestion when reading other people’s code would be to write down all things you don’t understand, by hand, in a notebook, and try and figure out what is important to understand. Personally, reading the zetawar code was one of the best learning experiences I’ve ever had, but it took quite a long time.
Just like you wouldn’t read The Odyssey in a night, I wouldn’t expect that you could read and understand someone elses code in a night
also, 4clojure problems are great, but they won’t help you build apps, just learn the clojure idioms
I’d suggest trying to pick something you want to build, then going piece by piece to build that
I love firebase because it allowed me to not have to worry about setting up a server, just could focus on cljs
here is a project skeleton I’ve used for starting new projects using datascript and firebase. Might be something helpful there https://github.com/Conaws/clojunto
Feel free to PM if you want advice on how to approach a problem, once you know what you’re trying to build
I'll check out firebase. I'm actually okay with Linux and setting up servers, but anything that reduces the cognitive load is welcome. I'm looking at zetawar now. This looks way more complicated than what I want to do. I'm just trying to do a CRUD app, a jobs listing website.
let's say (because it's true) that I have a clojurescript library using lein-cljsbuild, and would like to quickly iterate on some tests using a repl is there a straightforward way to start a nodejs repl? I'd rather not bother with a browser if possible.
(require '[cljs.repl :as repl] '[cljs.repl.node :as node])
(repl/repl (node/repl-env))
hmm; fighting with cljsbuild now, but that's a good start. thanks!
@max675 I’ll second using firebase - I’ve played with it a lot on the JS side - and it’s very easy to make something functional with it. Otherwise I’m kind of in the same boat - wanting to learn some clojurescript, but intimidated by the getting started. On the other hand, a couple years ago I went from never having seen a front-end framework before to being pretty competent - so just dive in! I’m making my way through the “modern-cljs” tutorials right now - expecting that’ll get me rolling.
@gfredericks if you’re using the new brew clojure
tool you don’t even need that
@gfredericks nothing specific about new clj
tool here - valid for lein run
too, but it also depends on whether you’re expecting nREPL
I don't need nREPL; mainly just a way to reload changed code (by hand if necessary) and re-run a test
does the tactic mentioned in the tweet allow me to include the source code for the library as well?
(i.e., use the code on the filesystem rather than a released jar)
Hi, How to make Leiningen to use Clojure as well as Clojurescript in a project. For now it tries to search for ":require " as .cljs, but I have them as .clj . I presume that would be a plugin or something like that
Have anyone tried deps.edn
with Figwheel? I’m having issues with starting the build.
@roman01la should work, makes me think that Figwheel should provide a main
method for command line usage \cc @bhauman
but they are external dependencies like [com.taoensso/sente "1.11.0"] contains taoensso/sente/server_adapters/http_kit.clj, but lein complains No such namespace: taoensso.sente.server-adapters.http-kit, could not locate taoensso/sente/server_adapters/http_kit.cljs
this is my project.clj https://pastebin.com/umQ4siBN
Hello, what do people use to exchange data between Cljs frontend and Clj backend? Json? Edn? Transit? Anything else? Need to pick something for our app. I guess json is a good choice if we dont use dates, sets & other advanced data, right?
@dnolen @bhauman I’m running it with clj --init dev/watch.clj -r
with the following config
(require '[figwheel-sidecar.repl-api :as ra])
(ra/start-figwheel!
{:build-ids ["dev"]
:all-builds
[{:id "dev"
:figwheel true
:source-paths ["src"]
:compiler {:main "example.core"
:asset-path "out"
:output-to "out/bundle.js"
:output-dir "out"
:verbose true}}]})
(ra/cljs-repl)
and getting this error Unable to find static field: FUNCTION_PARAMS in class com.google.javascript.jscomp.DiagnosticGroups, compiling:(cljs/closure.clj:100:1)
@roman01la just sounds like a bad Closure dep - maybe make it explicit?
@dnolen like this?
{:deps {org.clojure/clojurescript {:mvn/version "1.9.946"}
figwheel-sidecar {:mvn/version "0.5.14"}
org.clojure/google-closure-library {:mvn/version "0.0-20170809-b9c14c6b"}
com.google.javascript/closure-compiler-unshaded {:mvn/version "v20170910"}}}
didn’t helpchecking now…
@dnolen you are right, somehow an older version of com.google.javascript/closure-compiler
sneaked in
is that bc com.google.javascript/closure-compiler
is not in clojurescript’s deps?
@gfredericks An exaple of what David was saying with respect to the new clojure
tool: For test.check
, if you put this in deps.edn
at the top of the tree
{:deps {org.clojure/clojurescript {:mvn/version "1.9.854"}}
:paths ["src/main/clojure" "src/test/clojure" "src/target/cljs/node"]}
Then you can clj -m cljs.repl.node
an you are in a working node REPL that can use test.check
code.@mfikes how about for reloading a file when it changes?
general clojurescript question - what's the most common idiom for replicating :hover
- do people just do it in plain CSS, or is there some clojurescript-y way for me to define that stuff inline?
@gfredericks (require 'some-namespace.core :reload)
it’s doable, but on-mouse-enter
& on-mouse-out
is more robust
@gfredericks By the way, the :reload
and :reload-all
flags are just like in Clojure.
@mfikes excellent, thanks
what's the state of code splitting in cljs? would you recommend it? does it require a lot of attention/care to implement/maintain it?
@vemv I have been using it for 4+ years so very stable and definitely recommended. also very easy to implement/maintain
just a tad different architecture wise if you are used to webpack-ish code splitting since we do this statically in CLJS not dynamically
@thheller is there a way to code split into a bundle of dependencies (which change not so often) and the app (which changes more often)?
@danielcompton vendorization is possible with you enable a reuse names flag to Closure - shadow-cljs already supports it, far as I can tell it’s trivial patch for anybody who wants to add it to ClojureScript generally
Oh that’s super exciting! I was always a bit disappointed that code splitting couldn’t be used that way, great to hear that this is within reach 🙂
These ones? --variable_map_input_file
, --variable_map_output_file
, --property_map_input_file
, --property_map_output_file
. http://closuretools.blogspot.co.nz/2011/01/property-by-any-other-name-part-3.html
hi everyone, do you guys have any idea about this one? https://stackoverflow.com/questions/47802747/how-to-get-files-from-input-type-file-in-clojurescript
> is there a way to code split into a bundle of dependencies (which change not so often) and the app (which changes more often)? I was wondering the same. we have an monolithic project big enough to get 90-120 second initial compilation times (unoptimized). and pretty slow CIDER... it doesn't seem obvious how to split the project in a way that is productive/pleasant to develop and will perform well in production
https://dev.clojure.org/jira/browse/CLJS-2441 is the ticket, but after that I think there will need to be some good docs explaining how to set this up
@danielcompton yes but we can also supply a much simpler option that takes care of the details for you like :stable-names
I left a comment in the ticket about this
Cool, that makes sense, thanks!
@vemv splitting largely depends on the needs of your app so its hard to come up with general advice. Sometimes it make sense to just “vendor” out “rarely changing” code and sometimes it makes more sense to split code by actual sections of your site (ie. base, shop, user-panel, etc), maybe even combined with “vendoring”
@danielcompton this is pretty much all the code required, + actually calling the functions before and after compilation. https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/closure.clj#L456-L498
I'm familiar with the concept of "vendoring out rarely-changing code", but I'm not 100% sure if that is synonymous with introducing Closure Modules. Is it? IOW, can I use Closure Modules as a means of getting faster compilation times, leaving aside the user-facing benefits (however desirable)?
if you want faster compilation times use shadow-cljs but no closure modules will not make your compilation faster.
closure is built around whole program optimization so it needs your whole program as input
nice! good guidance I was looking at shadow-cljs just now. where does it strength lie? can it get me things otherwise impossible with lein-cljsbuild + fighwheel? (that's my current stack; my understanding is that s-c competes against both)
I can’t really do a fair comparison since I haven’t used figwheel ever and cljsbuild not for 4+ years
big focus is on easier configs with better defaults so half the stuff you need to configure in those tools goes away
ace. will try out and let you know. the report from my team's project (~800 cljs files including tests) will make a pretty interesting comparison 🙂
indeed, feel free to ping me with any questions. things are quite a bit different due to the full npm integration
https://code.thheller.com/blog/shadow-cljs/2017/11/10/js-dependencies-in-practice.html hopefully has the basics
Oh that’s super exciting! I was always a bit disappointed that code splitting couldn’t be used that way, great to hear that this is within reach 🙂