Fork me on GitHub
#clojurescript
<
2017-12-13
>
binora00:12:34

@martinklepsch checkout status-react

max02:12:30

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?

max02:12:40

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.

danielcompton02:12:50

@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)

max02:12:56

@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

danielcompton02:12:00

As far as CLJS learning materials, there are some good ones out there (http://purelyfunctional.tv, Lambda Island)

danielcompton02:12:01

But you're right that it's not as rich as say JavaScript

max02:12:56

What should be my next step after I am comfortable with Clojure language basics? @danielcompton

danielcompton02:12:30

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

conaw03:12:35

Hey, does anyone who has been using node-modules have any idea how I would require this https://www.npmjs.com/package/@blueprintjs/core

Anthony Ciacci14:12:03

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

conaw03:12:43

I’ve tried :blueprintjs-core and :blueprintjs/core, neither work :@blueprintjs/core causes an error with lein immediately

max03:12:59

@danielcompton I'll check it out 😁

conaw03:12:42

@max675 I’d check out Reagent, and look at the source code for projects like re-com or zetawar

conaw03:12:20

Also, @timothypratley has a lot of great posts on his blog and youtube channel

conaw03:12:58

its helpful to have some background in JS, but I think CLJS is a great first language

max03:12:09

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.

conaw03:12:27

Build something

conaw03:12:34

deploy it with surge.sh

conaw03:12:48

I use firebase for all my backend needs

conaw03:12:27

Look at the reagent project for basics

conaw03:12:05

I’m not suggesting you use those projects, I’m suggesting you try and read their source code

conaw03:12:24

key is to have a project you want to build, then figure out how to build it

conaw03:12:50

Reagent is alot friendlier than react

max03:12:56

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.

max03:12:22

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.

conaw03:12:57

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.

conaw03:12:28

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

conaw03:12:53

also, 4clojure problems are great, but they won’t help you build apps, just learn the clojure idioms

conaw03:12:59

if it isn’t hard you aren’t growing

max03:12:24

Sure, I'm not expecting to really be functional for another 6 months

max03:12:25

I'd like to get there in six months though

conaw03:12:06

I’d suggest trying to pick something you want to build, then going piece by piece to build that

conaw03:12:34

I love firebase because it allowed me to not have to worry about setting up a server, just could focus on cljs

conaw03:12:53

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

conaw03:12:09

but definitely recommend zetawar as best course of study

conaw03:12:10

Feel free to PM if you want advice on how to approach a problem, once you know what you’re trying to build

conaw03:12:21

also, recommend reading Polya’s How to Solve it

max03:12:58

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.

conaw04:12:51

cool, then take a look at integrant

conaw04:12:09

you don’t need re-frame

gfredericks13:12:03

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.

hlolli13:12:25

@gfredericks

(require '[cljs.repl :as repl] '[cljs.repl.node :as node])
(repl/repl (node/repl-env))

gfredericks13:12:39

hmm; fighting with cljsbuild now, but that's a good start. thanks!

michaels14:12:57

@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.

dnolen14:12:27

@gfredericks if you’re using the new brew clojure tool you don’t even need that

dnolen14:12:07

@gfredericks nothing specific about new clj tool here - valid for lein run too, but it also depends on whether you’re expecting nREPL

gfredericks15:12:41

I don't need nREPL; mainly just a way to reload changed code (by hand if necessary) and re-run a test

gfredericks15:12:18

does the tactic mentioned in the tweet allow me to include the source code for the library as well?

gfredericks15:12:37

(i.e., use the code on the filesystem rather than a released jar)

dnolen15:12:22

yes just add to classpath

Audrius15:12:44

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

Roman Liutikov15:12:26

Have anyone tried deps.edn with Figwheel? I’m having issues with starting the build.

dnolen15:12:40

@vienas00 .cljc extension is required

dnolen15:12:05

@roman01la should work, makes me think that Figwheel should provide a main method for command line usage \cc @bhauman

Audrius15:12:18

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

Audrius15:12:32

it wants that "s" from jar...

Jakub Holý (HolyJak)15:12:46

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?

Roman Liutikov15:12:23

@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)

manuel15:12:05

@holyjak I have only used JSON so far, and not experienced any problems.

dnolen15:12:07

@roman01la just sounds like a bad Closure dep - maybe make it explicit?

dnolen15:12:55

@holyjak EDN/Transit is pretty common

Roman Liutikov15:12:10

@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 help

dnolen16:12:38

there’s definitely something wrong with your closure-compiler dep

dnolen16:12:31

check the classpath and make sure everything matches

Roman Liutikov16:12:09

checking now…

Roman Liutikov16:12:05

@dnolen you are right, somehow an older version of com.google.javascript/closure-compiler sneaked in

Roman Liutikov16:12:43

is that bc com.google.javascript/closure-compiler is not in clojurescript’s deps?

adamvh16:12:12

this has an interactive tutorial

adamvh16:12:28

that you can work through, to get a small example full-stack app running

mfikes16:12:46

@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.

gfredericks16:12:39

@mfikes how about for reloading a file when it changes?

adamvh16:12:44

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?

mfikes16:12:50

@gfredericks (require 'some-namespace.core :reload)

adamvh16:12:02

use onMouseOver?

Roman Liutikov16:12:44

it’s doable, but on-mouse-enter & on-mouse-out is more robust

mfikes16:12:48

@gfredericks By the way, the :reload and :reload-all flags are just like in Clojure.

gfredericks16:12:02

@mfikes excellent, thanks

vemv18:12:24

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?

thheller20:12:37

@vemv I have been using it for 4+ years so very stable and definitely recommended. also very easy to implement/maintain

thheller20:12:29

just a tad different architecture wise if you are used to webpack-ish code splitting since we do this statically in CLJS not dynamically

vemv20:12:14

@thheller precisely the kind of feedback I was looking for 🙂 appreciated, thanks

danielcompton21:12:49

@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)?

dnolen21:12:05

@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

martinklepsch12:12:32

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 🙂

danielcompton21:12:27

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

vemv22:12:40

> 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

danielcompton22:12:24

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

dnolen22:12:22

@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

danielcompton22:12:46

Cool, that makes sense, thanks!

thheller22:12:47

@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”

thheller22:12:27

@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

vemv22:12:18

thanks for the input!

vemv22:12:34

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)?

thheller22:12:24

if you want faster compilation times use shadow-cljs but no closure modules will not make your compilation faster.

thheller22:12:47

closure is built around whole program optimization so it needs your whole program as input

thheller22:12:24

splitting only happens after compilation, can’t do a partial optimization

vemv23:12:21

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)

thheller23:12:24

faster compile times by far more aggressive (and robust) caching for one

thheller23:12:16

I can’t really do a fair comparison since I haven’t used figwheel ever and cljsbuild not for 4+ years

thheller23:12:40

but I think it does everything they do, if not let me know 😉

thheller23:12:35

big focus is on easier configs with better defaults so half the stuff you need to configure in those tools goes away

thheller23:12:51

big downside is docs …

vemv23:12:59

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 🙂

thheller23:12:48

indeed, feel free to ping me with any questions. things are quite a bit different due to the full npm integration

martinklepsch12:12:32

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 🙂