Giter VIP home page Giter VIP logo

himera's Introduction

himera

ClojureScript compiler as service with a simple in-browser REPL.

Try it on Heroku

Build

lein deps
lein cljsbuild once

Usage

To start Himera locally using Leiningen, type the following from the project directory.

lein run 8080

Then visit http://localhost:8080/ and never stop typing. For example, common ClojureScript functions and macros work as expected:

    (map (fn [n] (* n n n)) [1 2 3 4])
	;=> (1 8 27 64)
	
	(for [[k v] {:a 1 :b 2}] [v k])
	;=> ([1 :a] [2 :b])
	
	(if (< x 10) :less :more)
	;=> :less
	
	(defn sqr [n] (* n n))
	
	(map sqr [1 2 3])
	;=> (1 4 9)
	
	(deftype Cons [h t])
	
	(.-t (Cons. 1 108))
	;=> 108
	
	(defmulti classify-age :age)
	
	(defmethod classify-age 36 [_] :ancient)
	
	(classify-age {:age 36})
	;=> :ancient

To use jQuery from the Himera REPL, try the following:

    (def anchor (js/jQuery "a"))
	
	(.text anchor)
	;=> "Source..."
	
	(.text anchor "Github repo...")

To exercise the compilation service from the command line, try the following:

    $ curl -X POST -H "Content-Type: application/clojure" \
	    -d '{:expr ((fn foo [x] (js/alert x)) 42)}' \
		http://localhost:8080/compile
	
	#=> {:js "(function foo(x){\nreturn alert.call(null,x);\n}).call(null,42)"}

Current limitations

  • No way to override functions defined in cljs.core
  • defrecord access is not working
  • Creating namespaces does not work
  • Other problems not yet discovered
  • ClojureScript's / function is not munged properly

Plans

  • Fix the limitations above
  • Stateless service
  • More clients
  • Dynamic JS library loading
  • Other plans not yet devised

Thanks

Thanks to Tim McCormack, Paul Michael Bauer, and Anthony Grimes for the hard work in blazing the trail for online Clojure and ClojureScript REPLage and compilationation. Also thanks to Craig Andera and Chris Redinger for moral support and letting me bounce insane ideas off of them.

License

Copyright (C) 2012-2015 Fogus and Cognitect, Inc.

Distributed under the Eclipse Public License, the same as Clojure.

himera's People

Contributors

bronsa avatar candera avatar dribnet avatar fogus avatar j201 avatar jenmyers avatar johnkpaul avatar konrad-garus avatar mfikes avatar michaelsbradleyjr avatar mjackson avatar montogeek avatar mytrile avatar ozanmakes avatar sirn avatar swannodette avatar wagjo avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.