• Save
Presentation about ClosureScript fraemework
Upcoming SlideShare
Loading in...5
×
 

Presentation about ClosureScript fraemework

on

  • 3,233 views

 

Statistics

Views

Total Views
3,233
Views on SlideShare
3,233
Embed Views
0

Actions

Likes
2
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Presentation about ClosureScript fraemework Presentation about ClosureScript fraemework Presentation Transcript

  • ClojureScript Ilegra – LDC By Jackson dos Santos - @cyber_jso
  • What is It?
    • A Clojure API that allow us generate Javascript code from clojure code.
  • How it Works? Download API git clone git://github.com/clojure/clojurescript.git cd clojurescript ./script/bootstraP (ns hello) (defn ^:export greet [n] (str "Hello " n)) Do some Clojure Code ./bin/cljsc samples/ldc/src/hello-ldc/hello-ldc.cljs > hello.js Compilie IT
  • How it Works? Download API git clone git://github.com/clojure/clojurescript.git cd clojurescript ./script/bootstraP (ns hello) (defn ^:export greet [n] (str "Hello " n)) Do some Clojure Code ./bin/cljsc samples/ldc/src/hello-ldc/hello-ldc.cljs > hello.js Compilie IT
  • More About Compilation Phase
    • In order
      • Clojurescript transforms clojure code in JS code.
      • Google closure does
        • It provides dependency management
        • Minification Javascript code.
        • Reduce the code size as small it can
        • Kill dead code
  • Some Examples
    • core.cljs
    • (ns hello.core
    • (:require [hello.foo.bar :as bar]))
    • (defn ^{:export greet} greet [n]
    • (str "Hello " n))
    • (defn ^:export sum [xs]
    • (bar/sum xs))
  • Some Examples
    • foo.cljs
    • (ns hello.foo.bar)
    • (defn sum [xs]
    • (reduce + 0 xs))
  • Some Examples
    • Compile your code:
      • ./bin/cljsc samples/hello/ > samples/hello/hello.js
    • Or use the optimized format
    • ./bin/cljsc samples/hello/ '{:optimizations :advanced}' > samples/hello/hello.js
  • Some Examples
    • Setup your view:
      • <html>
      • <head>
      • <title>Hello ClojureScript</title>
      • </head>
      • <body>
      • <h1>Hello ClojureScript!</h1>
      • <script type=&quot;text/javascript&quot; src=&quot;hello.js&quot;></script>
      • <script>
      • alert(greet(&quot;Everybody know that Jeff is a gay Fish&quot;));
      • alert(&quot;The sum of [1,2,3,4,5,6,7,8,9] is: &quot; + hello.core.sum([1,2,3,4,5,6,7,8,9]));
      • </script>
      • </body>
      • </html>
  • And Then...
  • The generated JS Code
    • The optimized format
  • The Generated JS Code
    • The unoptimized format
  • More Examples
    • Calling an external JS library
      • Clojure-side.cljls
    • (ns hello.extern-example)
    • (defn ^:export foo [] 42)
    • (external.lib/send_alert &quot;ClojureScript calling a function defined in an externed JavaScript library&quot;)
  • More Examples
    • Calling an external JS library
      • Library.js
      • external = {};
      • external.lib = {
      • send_alert : function (msg) {
      • alert(&quot;Sending Alert via &quot; + msg + &quot;!&quot;);
      • }
      • };
  • More Examples
    • Calling an external JS library
      • View.html
      • <html>
      • <head>
      • <title>Hello Externed JavaScript Library</title> </head>
      • <body>
      • <script type=&quot;text/javascript&quot; src=&quot;out/goog/base.js&quot;></script>
      • <script type=&quot;text/javascript&quot; src=&quot;library.js&quot;></script>
      • <script type=&quot;text/javascript&quot; src=&quot;hello-extern.js&quot;></script>
      • <script>
      • goog.require('hello.extern_example');
      • </script>
  • What Can I Do With Clojurescript?
    • An application that has dependency to others name spaces.
    • Use clojure data structures
    • Integrate it with Nodejs
    • Use the DOM (event handling, build components)
  • What Can't i Do With Clojurescript?
    • Clojure transactions feature
    • Agents, Atoms
    • Protocol handling
  • What Are the Benefits In Use It?
    • Mix the JS flexibility with the Clojure power
    • Target the web like application plataform
    • Build complex client web applications
  • Witch Kind Of Problems Can I've For Starting With It?
    • The application can get complex to test
    • It's alpha
    • Integrate it with JQUERY and others JS libraries.
    • Problems to build the compiled JS Code
      • (Setup your $CLOJURESCRIPT_HOME! Read the all documentation before starting)