[ClojureScript] Re: How is Clojure loaded by java from cljs.jar?

2017-08-05 Thread Alex Miller
cljs.jar is self-contained (includes its dependencies) and includes Clojure 
itself (including clojure.main).

The cljs.jar is built using this script:

https://github.com/clojure/clojurescript/blob/master/script/build

You can walk through that process to learn more if needed.


On Saturday, August 5, 2017 at 12:15:31 PM UTC-5, Jay Martin wrote:
>
> In the "ClojureScript Compiler" section of the ClojureScript Quick Start 
> Guide , we run the build 
> script with the java command:
>
> java -cp cljs.jar:src clojure.main build.clj
>
>
> This command starts a JVM and loads the cljs.jar file and all of the 
> contents of the 'src' directory, to the JVM Classpath.
>
> According to the man page for the java program, clojure.main is a class 
> file, (I'm assuming this one 
> )
>  
> and build.clj is its argument.
>
> My question is: *How is the clojure.main class getting loaded to the 
> classpath?*
>
> Obviously clojure.main is part of Clojure. By unzipping the cljs.jar, I 
> see that it has a project.clj file with the following contents:
>
> (defproject org.clojure/clojurescript "0.0-SNAPSHOT"
>   :description "ClojureScript compiler and core runtime library"
>   :parent [org.clojure/pom.contrib "0.1.2"]
>   :url "https://github.com/clojure/clojurescript;
>   :license {:name "Eclipse Public License"
> :url "http://www.eclipse.org/legal/epl-v10.html"}
>   :jvm-opts ^:replace ["-Dclojure.compiler.direct-linking=true" "-Xmx512m" 
> "-server"]
>   :source-paths ["src/main/clojure" "src/main/cljs"]
>   :resource-paths ["src/main/cljs"]
>   :test-paths ["src/test/clojure" "src/test/cljs" "src/test/self" 
> "src/test/cljs_cp"]
>   :dependencies [[org.clojure/clojure "1.8.0"]
>  [org.clojure/data.json "0.2.6"]
>  [org.clojure/tools.reader "1.0.3"]
>  [org.clojure/test.check "0.10.0-alpha2" :scope "test"]
>  [com.cognitect/transit-clj "0.8.300"]
>  [org.clojure/google-closure-library 
> "0.0-20170519-fa0499ef"]
>  [com.google.javascript/closure-compiler-unshaded 
> "v20170626"]
>  [org.mozilla/rhino "1.7R5"]]
>   :profiles {:1.6 {:dependencies [[org.clojure/clojure "1.6.0"]]}
>  :uberjar {:aot :all :main clojure.main}}
>   :aliases {"test-all" ["with-profile" "test,1.5:test,1.6" "test"]
> "check-all" ["with-profile" "1.5:1.6" "check"]}
>   :min-lein-version "2.0.0")
>
>
> [org.clojure/clojure "1.8.0"] is listed as a dependency. Is this how 
> Clojure is getting loaded to the JVM Classpath?
>
> If so, how is this happening? It doesn't seem like the java program would 
> be smart enough to parse a project.clj file. 
>
>
>

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at https://groups.google.com/group/clojurescript.


[ClojureScript] How is Clojure loaded by java from cljs.jar?

2017-08-05 Thread Jay Martin
In the "ClojureScript Compiler" section of the ClojureScript Quick Start 
Guide , we run the build 
script with the java command:

java -cp cljs.jar:src clojure.main build.clj


This command starts a JVM and loads the cljs.jar file and all of the 
contents of the 'src' directory, to the JVM Classpath.

According to the man page for the java program, clojure.main is a class 
file, (I'm assuming this one 
) 
and build.clj is its argument.

My question is: *How is the clojure.main class getting loaded to the 
classpath?*

Obviously clojure.main is part of Clojure. By unzipping the cljs.jar, I see 
that it has a project.clj file with the following contents:

(defproject org.clojure/clojurescript "0.0-SNAPSHOT"
  :description "ClojureScript compiler and core runtime library"
  :parent [org.clojure/pom.contrib "0.1.2"]
  :url "https://github.com/clojure/clojurescript;
  :license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
  :jvm-opts ^:replace ["-Dclojure.compiler.direct-linking=true" "-Xmx512m" 
"-server"]
  :source-paths ["src/main/clojure" "src/main/cljs"]
  :resource-paths ["src/main/cljs"]
  :test-paths ["src/test/clojure" "src/test/cljs" "src/test/self" 
"src/test/cljs_cp"]
  :dependencies [[org.clojure/clojure "1.8.0"]
 [org.clojure/data.json "0.2.6"]
 [org.clojure/tools.reader "1.0.3"]
 [org.clojure/test.check "0.10.0-alpha2" :scope "test"]
 [com.cognitect/transit-clj "0.8.300"]
 [org.clojure/google-closure-library 
"0.0-20170519-fa0499ef"]
 [com.google.javascript/closure-compiler-unshaded 
"v20170626"]
 [org.mozilla/rhino "1.7R5"]]
  :profiles {:1.6 {:dependencies [[org.clojure/clojure "1.6.0"]]}
 :uberjar {:aot :all :main clojure.main}}
  :aliases {"test-all" ["with-profile" "test,1.5:test,1.6" "test"]
"check-all" ["with-profile" "1.5:1.6" "check"]}
  :min-lein-version "2.0.0")


[org.clojure/clojure "1.8.0"] is listed as a dependency. Is this how 
Clojure is getting loaded to the JVM Classpath?

If so, how is this happening? It doesn't seem like the java program would 
be smart enough to parse a project.clj file. 


-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at https://groups.google.com/group/clojurescript.


[ClojureScript] Re: Clojurescript equivalent for JS to access table rows

2017-08-05 Thread Jay Martin
jQuery includes CSS-like dom selection syntax. There are many ClojureScript 
libs which do this too, some of which are here 
:, along with their relative 
tradeoffs.

You might get more replies by going through the exercise of doing an 
initial translation yourself and then asking for feedback. And also by 
explaining why you're interested in such a translation. E.g., are you 
shopping for elegant syntax in your next language of choice? If so, I'd 
recommend researching Lisp macros, because Clojure/Script is a Lisp and 
provides elegant meta-programming facilities via its (initially) funny 
looking syntax, which is in fact very consistent within itself, much like 
legos are consistent in the way they snap together and compose. This is its 
superpower, a point which may get lost in a superficial comparison of 
syntax aesthetics.

Here's a resource  
to help with learning JavaScript interop via ClojureScript.

It might be a more reasonable comparison to first translate your jQuery 
code into JavaScript, and only then translate the JavaScript into 
ClojreScript, because JavaScript is the lingua franca between them. Let me 
know if you bump into any difficulties.

 

On Thursday, August 3, 2017 at 5:25:33 PM UTC-4, zbm wrote:
>
> Jquery to get the table td values
>
> $('#table1 tbody > tr').each(function() {
>  name = $(this).find('td.name').text();
>  id = $(this).find('td.id').text();
> }
>
> What will be clojurescript equivalent of the above jquery?
>
>

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at https://groups.google.com/group/clojurescript.