funcool / clojurescript-unraveled Goto Github PK
View Code? Open in Web Editor NEWAn open source book about ClojureScript
Home Page: http://funcool.github.io/clojurescript-unraveled/
License: Other
An open source book about ClojureScript
Home Page: http://funcool.github.io/clojurescript-unraveled/
License: Other
The target audience will need more hand holding on setting up that first project.
In Chapter 4: Getting Started with Compiler, there are no explicit instructions on where to put cljs.jar or build.clj.
Having seen linengen projects, I might guess that these go above src (or at least build.clj might) but it's not obvious. We probably want a little graphic or tree-chart showing where each file goes and probably a sidebar about project structure.
Also, capitalize Compiler in the section title.
Hi, the book looks great.
Under the definition of my-mapt
, I think the following line should be (def incer (my-mapt inc))
instead of (def incer (my-mapr inc))
For any OSX user with outdated system ruby gem + X11:
brew install ruby
which gem # /usr/local/bin/gem
gem -v # 2.6.2. in my case
(sudo) gem install asciidoctor
which asciidoctor # returned binary path
make git # no errors
make pdf # warnings, and X11 install popup
good god, X11 again:
brew install Caskroom/cask/xquartz # completes without error
make pdf # completes without errors, though pops up invisible java thingy
open -a Preview dist/clojurescript-unraveled.pdf
Awesome!
In order to get the code to work correctly, I needed to add:
:asset-path "js/leapyears"
I think we should have a section on macros but not sure where, talking about them before introducing the compiler tooling might be confusing since they have to be written in Clojure.
Hi.
Would it be possible to translate clojurescript-unraveled into Japanese? I started learning Clojure(Script) and this document is the best for beginners like me.
I read the License and it seems that I need to keep the original English as it is so that I'll publish it online. So I'd like to add Japanese translation bellow the original English sentences like this:
https://t-cool.github.io/clojurescript-unraveled
I won't claim copyright for my Japanese translation.
I'd appreciate your understanding.
In order to create what I believe to be the intended behavior I needed to make the definition of the "on-change" function the following:
(defn on-change
[event]
(let [target (.-target event)
value-string (.-value target)]
(if (str/blank? value-string)
(set! (.-innerHTML result) "----")
(let [value (read-string value-string)]
(if (leap? value)
(set! (.-innerHTML result) "YES")
(set! (.-innerHTML result) "NO"))))))
I've just made a (hopfully) portable bootstrapped REPL w/ auto-complete, auto-documentation, and parinfer, and I'm looking for places that might benefit from a REPL :D
this book is frequently recommended, and I imagine it would be a big value add to have a repl side-by-side w/ the text, especially if you could click a code sample & eval it right there.
I'd be happy to work on integration, but I thought I'd first ask if there's interest
I'm interested in clojure+clojurescript. The book so far is interesting, but it doesn't bridge the key gap of "how do I, as someone who doesn't currently do browser-based development in another language, approach clojurescript in the browser to accomplish a task".
In a CLI world, I can take a language and know where my inputs and outputs are (files, sockets, apis etc.). What does one do with clojurescript in order to understand the inputs and outputs from the browser, and how does someone learning clojurescript bootstrap themselves into more knowledge? E.g. in order to use D3.js, how would you know where data is coming from, how it is transformed in cljs, and how it could be displayed? This sort of knowledge all seems to be a huge haze of "well, it depends" and having a treatment of this topic seems to be something that would get clojurescript a lot more use.
I think the book needs at least one more example for both map and reduce that shows a user-defined function. (The problem here is that you know too much--you know that the higher-order-function can be user defined, but the beginner doesn't.) I'll be happy to add the examples and the wording.
An brief introduction to how to work with third party javascript libraries, how to include it in you application, treat with different javascript module systems and how to package a library that uses javascript libraries.
I'm referring to "function", "object", "number", "string", "array", and "boolean" (instead of js/Function, ...)
More explanation: https://groups.google.com/d/msg/clojurescript/MKEZ9CBU77o/Bm0yxo8yCgAJ
According to the Clojurescript wiki at https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure#namespaces
:import is available for importing Google Closure classes
ClojureScript types and records should be brought in with :use or :require :refer, not :imported
The book incorrectly says otherwise at http://funcool.github.io/clojurescript-unraveled/#deftype
The types in ClojureScript should be imported with the :import directive of the ns macro
The following Clojure code:
(assoc build-opts
:main 'leapyears.test.main
:output-to "out/tests.js"
:output-dir "out/tests"
:target :nodejs)
needs to be:
(assoc build-opts
:main 'leapyears.test.main
:output-to "out/tests.js"
:output-dir "out/tests"
:asset-path "out/tests"
:target :nodejs)
and the following Clojure code:
(assoc build-opts
:main 'leapyears.test.main
:watch-fn run-tests
:output-to "out/tests.js"
:output-dir "out/tests"
:target :nodejs)
needs to be:
(assoc build-opts
:main 'leapyears.test.main
:watch-fn run-tests
:output-to "out/tests.js"
:output-dir "out/tests"
:asset-path "out/tests"
:target :nodejs)
when the operation is waiting for has been performed.
they look like they synchronous code.
I disagree with this statement:
3.7.2. Blocks [...]
A side effect is something that is not necessary for the return value.
(do
(println "something") ; this is a side effect
(- 1 2) ; this isn't
(+ 3 4))
Related doc:
http://rundis.github.io/blog/2015/clojurescript_performance_tuning.html
TODO: type hints.
The text "clojure tools build:tests" should be "clojure tools.clj build:tests"
In the current online version, It seems that the leap?
predicate has wrong definition. According to wikipedia:
if (year is not divisible by 4) then (it is a common year)
else if (year is not divisible by 100) then (it is a leap year)
else if (year is not divisible by 400) then (it is a common year)
else (it is a leap year)
So leap?
may be defined as
(defn leap?
[year]
(or (zero? (js-mod year 400))
(and (pos? (js-mod year 100))
(zero? (js-mod year 4)))))
Hope I didn't make a mistake.
The text "This is how looks the deps.edn file with the changes applied:" should be "This is how looks the tools.clj file with the changes applied:"
Hi! In the first example of the core.async section the code shows the following:
(put! ch 42)
;; Got a value: 42
;; => 42
Note that put! returned the value that was just put to the channel.
Just running the example in the REPL the put!
returns true
instead of 42
.
Just wanted to share how I got the HTML to build on macOS Mojave 10.4.5.
Dependencies:
gem install pygments.rb -v 0.6.3
)gem install asciidoctor -v 1.5.4
)Then use make html
. To get the HTML to look right I had to move dist/index.html
to the root of the git checkout and then open it (so ./assets/*
and ./images/*
could be found by the browser).
(NOTE: It might pay for the Makefile to copy ./assets
and ./images
into ./dist
for the html
target.)
Since CLJS is built on top of protocols, would it make sense to have a section (maybe in "Mixed bag") with the core protocol reference? That would include it's name, functions and examples of implementations and usage.
->
, as->
, cond->
, some->
and their variants.
On the language chapter.
Hi - I was going to fix a typo but noticed it was already fixed in the source on GH. Do we need a procedure to periodically push the most current version to http://funcool.github.io/clojurescript-unraveled ?
Alan
The use of http://www.clojurescript.io/ is recommended, which is great. But many examples in the first tutorial contain the println function, which does not work on this site.
Is there a way to get println working, and should this be mentioned somewhere in the book?
So people can follow along as they read, trying the examples in a REPL.
I think it would be great to explain Lisp machinery such as the reader. Not only Lisp syntax but how Lisp programs are read and what benefits it has (e.g. reader extensions with tagged literals).
The following code:
(ns leapyears.test.main
(:require [cljs.test :as t]
[leapyears.vendor.util-closure :as util]))
should be:
(ns leapyears.test.main
(:require [cljs.test :as t]
[leapyears.util :as util]))
I am trying to lower the thresholds of setting up a Clojurescript development environment with an extension to VS Code I call Calva. I could write a first version of an Appendix B section about Calva, if you like. It's pretty easy with Calva, since it is mainly about installing the extension and, in case of shadow-cljs
include a dependency on cider/nrepl
. Similar to this: https://shadow-cljs.github.io/docs/UsersGuide.html#_calva_vs_code
Let me know if you want me to issue a PR.
Hello! Quickly went through the 2nd edition, it's great, thank you! IMO It would be valuable for readers to know about cljs.main
, perhaps a couple of sentences with an example would be enough. WDYT?
With regards to:
(let [{tenth 10} (range 100)]
tenth)
;; => 11
Maybe it should be clarified that this is equivalent to:
(get (apply hash-map (range 100)) 10)
;; => 11
and NOT equivalent to:
(get (vec (range 100)) 10)
;; => 10
:require-macros explicitly tells compiler to look for clj files, but with other forms of require compiler first requires cljs files
Hi - reading section 4.1.3 I am trying to run under Node.js and get an error. It appears that references to the google closure compiler libs are not being included correctly(?). Output:
~/work/clojurescript-unraveled/myapp > cat src/myapp/core.cljs
(ns myapp.core
(:require [cljs.nodejs :as nodejs] ))
(nodejs/enable-util-print!)
(defn -main [& args]
(println "Hello world!"))
(set! *main-cli-fn* -main)
~/work/clojurescript-unraveled/myapp > cat build.clj
(require '[cljs.build.api :as b] )
(b/build "src" {:main 'myapp.core
:output-to "main.js"
:output-dir "out"
:target ":nodejs"
:verbose true } )
~/work/clojurescript-unraveled/myapp > java -cp cljs.jar:src clojure.main build.clj
~/work/clojurescript-unraveled/myapp > java -version
java version "1.8.0_72"
Java(TM) SE Runtime Environment (build 1.8.0_72-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.72-b15, mixed mode)
~/work/clojurescript-unraveled/myapp > node --version
v5.4.1
~/work/clojurescript-unraveled/myapp >
~/work/clojurescript-unraveled/myapp > d *
-rw-rw-r-- 1 alan alan 254 Apr 2 19:26 build.clj
-rw-rw-r-- 1 alan alan 20078770 Apr 2 19:30 cljs.jar
-rw-rw-r-- 1 alan alan 430 Apr 2 19:45 main.js
drwxrwxr-x 5 alan alan 4096 Apr 2 19:33 out/
drwxrwxr-x 3 alan alan 4096 Apr 2 19:23 src/
~/work/clojurescript-unraveled/myapp > node main.js
/home/alan/work/clojurescript-unraveled/myapp/main.js:2
if(typeof goog == "undefined") document.write('<script src="out/goog/base.js"></script>');
^
ReferenceError: document is not defined
at Object.<anonymous> (/home/alan/work/clojurescript-unraveled/myapp/main.js:2:32)
at Module._compile (module.js:397:26)
at Object.Module._extensions..js (module.js:404:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:429:10)
at startup (node.js:139:18)
at node.js:999:3
~/work/clojurescript-unraveled/myapp >
I needed to ad the following line of text to the tools.clj file, in addition to the ones noted in the document:
(require '[figwheel.main :as figwheel])
Link rot is Études for ClojureScript
. "http://catcode.com/etudes-for-clojurescript/toc.html" replace "http://catcode.com/etudes-for-clojurescript/toc01.html".
Hi,
Any updates on the Leanpub page of the book?
This book is 75% complete
Updated 9 months Ago
Thank you.
I followed the steps here:
#134
$ make pdf
mkdir -p docs/
asciidoctor -b docbook45 -a numbered -d book -a data-uri! src/index.adoc -o docs/clojurescript-unraveled.xml
asciidoctor: FAILED: missing converter for backend 'docbook45'. Processing aborted.
Use --trace for backtrace
make: *** [docbook] Error 1
I made a search on 'docbook45' and found this repo:
https://github.com/asciidoctor/asciidoctor-backends/tree/master/haml/docbook45
Could anyone advice me how to fix this issue?
I'd appreciate your help.
The cljs compiler now allows use of namespaced maps syntax. This should be reflected in the doc.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.