GithubHelp home page GithubHelp logo

clojurescript-lua's Introduction

Clojurescript-Lua

Welcome, ClojureScript/Lua is a lisp language targeting Lua. It is using the ClojureScript compiler, and provides a different backend and ecosystem for the ClojureScript language.

The current version of ClojureScript/Lua is 0.1.0-ALPHA. It is in alpha stage, hence the name, and you should expect that a lot of things are not working yet !

ClojureScript/Lua should run on any posix system that has bash, lua and java installed.

If you find any bug, don't hesitate to submit issues on github, especially if Cljs/Lua doesn't work at all on your computer, and you find a fix :)

Here is hello world in Cljs/Lua :

(println "Hello, world !")

Distinctive traits of ClojureScript are :

  • Lisp language (s-expression syntax, code is data, etc)
  • Functional (mostly)
  • Functional data structures with literal syntax
(def my-map {:john "doe" :jack "daniels"})
(println (my-map :john)) ;; prints "doe"

Getting started

You need to have leiningen installed. This is the only prerequisite (with of course java & all). After that, you just need to grab yourself a copy of the repo, either via cloning it or downloading an archive.

Running the Cljs/Lua repl

To run the repl, you need to have Lua 5.1 installed, as well as a few dependencies:

  • lua json library
  • lua bit ops library

The two are quite standard lua libs that should be available in your distribution's repositories.

To run the REPL, issue the following command

./cljslua repl

On the first run, Cljs/Lua will install some components that it needs.

REPL options

By default, the repl shows the output of compiled Cljs commands. You can switch that off by calling the function

(switch-verbose)

You can also switch off execution by calling

(switch-exec)

Cljs/Lua compiler

Cljs/Lua has a very basic compiler that works the following way

./cljslua compile <in-file> <out-file>
  1. You give it a in-file and an out-file.
  2. It will compile everything to the out-file. That means, the content of the core library, of the compiled file, and of any dependencies.
  3. It will search for required namespaces in subdirectories of the directory containing the in-file. File layout doesn't matter for the moment.

This is very basic, but yet functionnal. The compiler will be redesigned soon, but some thoughts need to be given to the general design of it first.

Running the lein repl

If you want to see how the compiler compiles out snippets of clojurescript :

$ lein repl
REPL started; server listening on localhost port 31236
cljs.lua.compiler=> (lua (defn add [a b] (+ a b)))
"cljs.user.add = (function (a,b)
return (a + b)
end)"
nil

clojurescript-lua's People

Contributors

raph-amiard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

clojurescript-lua's Issues

Not finding cljs artifacts

There seems to be some issue with the clojurescript init process:

 % ./cljslua repl
 Installing necessary components for cljs-lua
 Getting clojurescript ...
 Cloning into clojurescript...
 Compiling clojurescript into a jar ..
 Branch lua-workbranch set up to track remote branch lua-workbranch from origin.
 Switched to a new branch 'lua-workbranch'
 Cleaning up ..
 Success !
 Exception in thread "main" java.io.FileNotFoundException: Could not locate cljs/analyzer__init.class or cljs/analyzer.clj on classpath: 
    at clojure.lang.RT.load(RT.java:432)
    at clojure.lang.RT.load(RT.java:400)
    at clojure.core$load$fn__4890.invoke(core.clj:5415)
    at clojure.core$load.doInvoke(core.clj:5414)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.core$load_one.invoke(core.clj:5227)
    at clojure.core$load_lib.doInvoke(core.clj:5264)
    at clojure.lang.RestFn.applyTo(RestFn.java:142)
    at clojure.core$apply.invoke(core.clj:603)
    at clojure.core$load_libs.doInvoke(core.clj:5298)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invoke(core.clj:603)
    at clojure.core$require.doInvoke(core.clj:5381)
    at clojure.lang.RestFn.invoke(RestFn.java:482)
    at cljs.lua.compiler$eval11$loading__4784__auto____12.invoke(compiler.clj:1)
    at cljs.lua.compiler$eval11.invoke(compiler.clj:1)
    at clojure.lang.Compiler.eval(Compiler.java:6511)
    at clojure.lang.Compiler.eval(Compiler.java:6501)
    at clojure.lang.Compiler.load(Compiler.java:6952)
    at clojure.lang.RT.loadResourceScript(RT.java:359)
    at clojure.lang.RT.loadResourceScript(RT.java:350)
    at clojure.lang.RT.load(RT.java:429)
    at clojure.lang.RT.load(RT.java:400)
    at clojure.core$load$fn__4890.invoke(core.clj:5415)
    at clojure.core$load.doInvoke(core.clj:5414)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.core$load_one.invoke(core.clj:5227)
    at clojure.core$load_lib.doInvoke(core.clj:5264)
    at clojure.lang.RestFn.applyTo(RestFn.java:142)
    at clojure.core$apply.invoke(core.clj:603)
    at clojure.core$load_libs.doInvoke(core.clj:5298)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invoke(core.clj:603)
    at clojure.core$require.doInvoke(core.clj:5381)
    at clojure.lang.RestFn.invoke(RestFn.java:512)
    at cljs.lua.repl$eval5$loading__4784__auto____6.invoke(repl.clj:1)
    at cljs.lua.repl$eval5.invoke(repl.clj:1)
    at clojure.lang.Compiler.eval(Compiler.java:6511)
    at clojure.lang.Compiler.eval(Compiler.java:6501)
    at clojure.lang.Compiler.load(Compiler.java:6952)
    at clojure.lang.RT.loadResourceScript(RT.java:359)
    at clojure.lang.RT.loadResourceScript(RT.java:350)
    at clojure.lang.RT.load(RT.java:429)
    at clojure.lang.RT.load(RT.java:400)
    at clojure.core$load$fn__4890.invoke(core.clj:5415)
    at clojure.core$load.doInvoke(core.clj:5414)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.core$load_one.invoke(core.clj:5227)
    at clojure.core$load_lib.doInvoke(core.clj:5264)
    at clojure.lang.RestFn.applyTo(RestFn.java:142)
    at clojure.core$apply.invoke(core.clj:603)
    at clojure.core$load_libs.doInvoke(core.clj:5298)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invoke(core.clj:603)
    at clojure.core$require.doInvoke(core.clj:5381)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at user$eval1.invoke(cljslua.clj:1)
    at clojure.lang.Compiler.eval(Compiler.java:6511)
    at clojure.lang.Compiler.load(Compiler.java:6952)
    at clojure.lang.Compiler.loadFile(Compiler.java:6912)
    at clojure.main$load_script.invoke(main.clj:283)
    at clojure.main$script_opt.invoke(main.clj:343)
    at clojure.main$main.doInvoke(main.clj:427)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at clojure.lang.Var.invoke(Var.java:419)
    at clojure.lang.AFn.applyToHelper(AFn.java:163)
    at clojure.lang.Var.applyTo(Var.java:532)
    at clojure.main.main(main.java:37)
 % jar tvf libclojurescript.jar | grep analy
  39858 Wed Aug 01 10:21:32 CDT 2012 clj/cljs/analyzer.clj

Exception when trying to run it for the first time

Exception in thread "main" java.io.FileNotFoundException: Could not locate cljs/analyzer__init.class or cljs/analyzer.clj

I get this exception when I try to running for the first time. I recognize this is in alpha and it seems, in fact, you gave up this project entirely but I was hoping to get it to work to expand it.

Can you just tell me if this file is really missing on the repository or is this another error?

Lua libraries

I have no experience with the Lua ecosystem and want to clarify the setup.
In the README you mention that clojurescript-lua requires luajson and luabitops.
I'm on OS X and did brew install luarocks to get the lua package system, then luarock install luajson and luarock install luabitops to get those packages.
In the latter case the luarock is 1.0.1, which is three years old according to http://bitop.luajit.org/download.html
Are you doing development against the libs in luarocks, or should we hunt down the latest sources and compile/install manually?
(If so, maybe they can be added as git submodules or at least the download URLs listed in the README?)

Make macros work

For the moment, macros outside of core.clj don't work properly

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.