1. I suppose you can't call any Java library from ClojureScript if you want it to compile to JS. Can you call any Clojure library and have it translated?
2. If I'd create a DSL with Clojure, could it be deployed to JS through ClojureScript also?
3. One of my main concerns is that what drives me to start developing client web apps is all the innovation and ideas that are being developed in the JS ecosystem. As far as I've read ClojureScript can interact with JS libraries, but seeing that the C2 library prefered to implement from scratch with ClojureScript instead of wrapping D3, makes me wonder how easy or convenient this is. I'd like to use things like Knockout but more generally any good JS library that can come out (and also WebGL, the future WebCL, etc)...
From what I've investigated, I'd love to learn Clojure, I do know it would help me have a better mental approach to the problems, but heavy client web apps being my main short term focus I wonder if it's going to be more hassle than opting for a more "direct" way using CoffeeScript with the rest of JS ecosystem.
As to your first point and only to clarify, had you made it a wrapper for D3 and in a node.js application, there would still be no problem in using it server-side, am I right?
So, in short I've got a toy application in mind to learn either way, but the end project in mind is a trading application on the browser (which is my main field right now) that should deploy in as many devices/OS as possible (so, Javascript again). C2 fits in just perfect.
Many thanks for the answer as well as the talks, which have been trully great!
I've been building out substantial ClojureScript apps for a few months now.
Previously I had written an HTML5 game engine, so I'm no stranger to lots of JavaScript.
My CLJS code base is smaller, easier to organize/maintain, more functional and declarative, and boasts a level of server-side interop that surpasses JS's best attempts (like meteor js). Having the reader (and a REPL) in the browser opens up a lot of possibilities.
As Kevin stated there are a few sticky spots when working with ClojureScript, but those are quickly being solved.
If you're new to Clojure and client-side development (JavaScript), the lack of CLJS examples and documentation is going to be a hurdle for you.
Errors in the console are not obvious unless you have some idea about the implementation details of ClojureScript. Error reporting will not tell you what line of CLJS code your error is on (or what you did wrong), you just have to look at the compiled JS source, know where in your CLJS source that code is being generated, and scan carefully until you spot the error in your code. This was my biggest hurdle starting out.
Since you're picking up a toy project, I would choose whatever language you're most excited to learn. Enthusiasm is a great motivator for overcoming any challenge.
Paul
Since you love FP I wanted to mention another option:LiveScriptIt's a script that compiles down to JavaScript. Inspired by CoffeeScript but Haskell and F# as well.Read the blog about it's FP capabilities.It fits with all JS/CS projects.Hope it helps.
I have developed a tiny web app in Clojure/ClojureScript and have written an overview here. In general, it was an exciting experience, but I also faced several problems with ClojureScript. For example, if you compile your code to JS, then the output file (in contrast to CoffeeScript) will contain other code (~18kb or so): this code contains the Google Closure libraries, which do a lot of stuff, like accessing the DOM elements.
Furthermore, I did experience some performance problems with ClojureScript, which I didn't investigate further, so I'm not sure, that these problems hold in general. I did some per-character computations on a very large text and it took just too long for such a primitive operation. Since my code was quite high-level I assumed, that the GC of JS engine was choked.
I think the only problem (if it is a problem at all), which won't be solved soon is ClojureScript's performance resulting from creating a lot of implicit objects in very high level computations. Something like (filter (map (reduce ... ... (map ...)))) can't be as fast and as memory-efficient for loops and in-place array operations of JS. In theory, the same holds for Clojure and Java as well, however, in contrast to ClojureScript, I never faced this problem on JVM yet.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
I have developed a tiny web app in Clojure/ClojureScript and have written an overview here. In general, it was an exciting experience, but I also faced several problems with ClojureScript. For example, if you compile your code to JS, then the output file (in contrast to CoffeeScript) will contain other code (~18kb or so): this code contains the Google Closure libraries, which do a lot of stuff, like accessing the DOM elements. However, I found it *much* easier to use jQuery (through the jayq library written in ClojureScript). Hence, in my case, a lot of this additional code will be loaded for nothing. And the first-time load times are not negligible!
Furthermore, I did experience some performance problems with ClojureScript, which I didn't investigate further, so I'm not sure, that these problems hold in general. I did some per-character computations on a very large text and it took just too long for such a primitive operation. Since my code was quite high-level I assumed, that the GC of JS engine was choked.
Now to your questions
1. I suppose you can't call any Java library from ClojureScript if you want it to compile to JS. Can you call any Clojure library and have it translated?
This is right, what is supported in ClojureScript is _almost_ everything what is supported in _native_ Clojure only, so don't expect things like Integer/parseInt or all String methods to work in JS!
2. If I'd create a DSL with Clojure, could it be deployed to JS through ClojureScript also?
If you manage to keep it platform-independent, then of course. However, even if you'll need some platform-specific calls, you can abstract them: I had a similar problem with my web app (the problem is described in my overview) when I needed a simple hash function, which would work on the client and on the server. The problem is that you run into the platform much faster, than you assume: JS (and therefore ClojureScript) has no chars, it doesn't produce overflows, the entire String API is different and so on. What I did, I just implemented my code with dependency injections in form of higher order functions injected as arguments. Such code can be run on the client and on the server with different platform-specific parameter. This was fun.3. One of my main concerns ...I can't give more insightful answers as already given.I know the tooling is raw at the moment and that it'll get better overtime, so I'm asking more about the fundamental problems that are hardly going to be solved in the near time.
I think the only problem (if it is a problem at all), which won't be solved soon is ClojureScript's performance resulting from creating a lot of implicit objects in very high level computations. Something like (filter (map (reduce ... ... (map ...)))) can't be as fast and as memory-efficient for loops and in-place array operations of JS. In theory, the same holds for Clojure and Java as well, however, in contrast to ClojureScript, I never faced this problem on JVM yet.
Hey,AFAIK the clojure reducers library gains its performance boost since the underlying JVM can make use of multiple cores. I wonder how this changes with Javascript being the platform. Don't JS engines have a single execution thread?Balint
László Török