Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Clojure for the Erlang VM (unofficial)

License

NotificationsYou must be signed in to change notification settings

clojerl/clojerl

Repository files navigation

BuildHex.pm

Clojure implemented on the Erlang VM.

Building

Buildingclojerl requiresErlang/OTP 21+ andrebar3.

git clone https://github.com/clojerl/clojerlcd clojerlmake

On Windows:

git clone https://github.com/clojerl/clojerlcd clojerlrebar3 clojerl compile

Getting Started

Documentation and Resources

There is more information regarding Clojerl inclojerl.io, where youcan find whatfeatures does Clojerl include andhow it differs fromClojure.

Online REPL

To try it out and get a sense of what you can do, you can visitTry Clojerl.

Docker REPL

To quickly try outclojerl via docker you can make use of the dockerimage like so:

docker pull clojerl/clojerldocker run -it clojerl/clojerl

Then you should be able to see the prompt:

Clojure0.6.0clje.user=>

Local REPL

Runningmake repl (on Windows first runrebar3 clojerl compile andthenbin/clje.bat) will start the REPL and show its prompt:

Clojure 0.6.0clje.user=>

From the REPL it's possible to start evaluating Clojure expressions:

clje.user=> (map inc (range 10))(1 2 3 4 5 6 7 8 9 10)clje.user=> (doc map)-------------------------clojure.core/map([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls])  Returns a lazy sequence consisting of the result of applying f to  the set of first items of each coll, followed by applying f to the  set of second items in each coll, until any one of the colls is  exhausted.  Any remaining items in other colls are ignored. Function  f should accept number-of-colls arguments. Returns a transducer when  no collection is provided.nilclje.user=> (doc inc)-------------------------clojure.core/inc([x])  Returns a number one greater than num.nilclje.user=>

Code Examples

There are some very basic examples in thescripts/examplesdirectory. These are meant to be references on how special forms inClojure on the BEAM are used and how they sometimes differ from ClojureJVM.

Web Application Example

For a very basic example of a web project please check theexample-web-app repository.

Building Your Own App

The build tool for Clojerl is therebar3_clojerlplugin.rebar3 is the official build tool in the Erlangcommunity.

The plugin provides helpful commands to:

  • Build a basic directory scaffolding for a new project
  • Compile
  • Run tests
  • Start a REPL

For more information on how to use this plugin please check thedocumentation inrebar3_clojerl.

Rationale

Erlang is a great language for building safe, reliable and scalablesystems. It provides immutable, persistent data structuresout of the box and its concurrency semantics are unequalled by anyother language.

Clojure is a Lisp and as such comes with all the goodies Lispsprovide. Apart from these Clojure also introduces powerfulabstractions such as protocols, multimethods and seqs, to name a few.

Clojure was built to simplify the development of concurrent programsand some of its concurrency abstractions could be adapted to Erlang.It is fair to say that combining the power of the Erlang VM with theexpressiveness of Clojure could provide an interesting, useful resultto make the lives of many programmers simpler and make the world ahappier place.

Goals

  • Interoperability as smooth as possible, just like Clojure proper andClojureScript do.
  • Provide most Clojure abstractions.
  • Provide all Erlang abstractions and toolset.
  • Include a default OTP library in Clojerl.

Personal Goal

Learn more about Erlang (and its VM), Clojure and languageimplementation.

This project is an experiment that I hope others will find useful.Regardless of whether it becomes a fully functional implementation ofClojure or not, I will have learned a lot along the way.

QAs

What is Clojerl?

Clojerl is an experimental implementation of Clojure on the Erlang VM.Its goal is to leverage the features and abstractions of Clojure thatwe love (macros, collections, seq, protocols, multimethods, metadata,etc.), with the robustness the Erlang VM provides for building(distributed) systems.

Have you heard about LFE and Joxa?

Yes. LFE and Joxa were each created with very specific and differentgoals in mind. LFE was born to provide a LISP syntax for Erlang. Joxawas mainly created as a platform for creating DSLs that could takeadvantage of the Erlang VM. Its syntax was inspired by Clojure but thecreators weren't interested in implementing all of Clojure's features.

Aren't the language constructs for concurrency very different between Clojure and Erlang?

Yes, they are. On one hand Clojure provides tools to handle mutablestate in a sane way, while making a clear distinction between identityand state through reference types. On the other, concurrency in theErlang VM is implemented through processes and message passing. Theidea in Clojerl is to encourage the Erlang/OTP concurrency model, butsupport as many Clojure constructs as possible and as far as they makesense in the Erlang VM.

But... but... Rich Hickey listshere some of the reasons why he chose not to use the actor model in Clojure.

That is not a question, but I see what you mean :). The points hemakes are of course very good. For example, when no state is sharedbetween processes there is some communication overhead, but thisisolation is also an advantage under a lot of circumstances. He alsomentionshere thatbuilding for the distributed case (a.k.a processes and messagepassing) is more complex and not always necessary, so he decided tooptimise for the non-distributed case and add distribution to theparts of the system that need it. Rich Hickey calls Erlang "quiteimpressive", so my interpretation of these writings is that they aremore about exposing the rationale behind the decisions and thetrade-offs he made when designing Clojure (on the JVM), than aboutdisregarding the actor model.

Will Clojerl support every single Clojure feature?

No. Some of Clojure's features are implemented by relying on theunderlying mutability of the JVM and its object system. The Erlang VMprovides very few mutability constructs and no support for definingnew types. This makes it very hard or nearly impossible to port somefeatures into Clojerl's implementation.

Can I reuse existing Clojure(Script) libraries?

Yes, but they will need to be ported, just like for ClojureScript. Infact, most of Clojure's core namespaces were ported from the original.clj files in the Clojure JVM repository.

Discussion

Join the conversation in theClojerl mailinglist or in the#clojerl Slack channel!

You can also find news and updates through@clojerl.Or if you have any questions you can find me@jfacorro or lurkingonClojure'sandErlang'smailing lists.

Any feedback, comment and/or suggestion is welcome!

About

Clojure for the Erlang VM (unofficial)

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

    Packages

    No packages published

    Contributors8

    Languages


    [8]ページ先頭

    ©2009-2025 Movatter.jp