Clojure

来自开放百科 - 灰狐
(版本间的差异)
跳转到: 导航, 搜索
(数据分析)
(项目)
(未显示1个用户的32个中间版本)
第1行: 第1行:
 
{{SeeWikipedia}}
 
{{SeeWikipedia}}
  
Clojure 是一个面向[[Java Virtual Machine]] 的动态语言。
+
Clojure
 
+
[[Lisp]] 是一种编程语言,以表达性和功能强大著称,但人们通常认为它不太适合应用于一般情况。Clojure 是一种运行在 [[Java]]平台上的 Lisp 方言,它的出现彻底改变了这一现状。如今,在任何具备 Java 虚拟机的地方,您都可以利用 Lisp 的强大功能。
+
  
 
[[文件:clojure-logo.png|right]]
 
[[文件:clojure-logo.png|right]]
  
 
==简介==
 
==简介==
 +
[[文件:clojure-logo-120b.png|right]]
 +
Clojure 是一个面向[[Java Virtual Machine|JVM]] 动态的通用编程语言,采用 Eclipse Public License 1.0 许可证。
 +
 +
[[Lisp]] 是一种编程语言,以表达性和功能强大著称,但人们通常认为它不太适合应用于一般情况。Clojure 是一种运行在 [[Java]]平台上的 Lisp 方言,它的出现彻底改变了这一现状。如今,在任何具备 Java 虚拟机的地方,您都可以利用 Lisp 的强大功能。
 +
 
Clojure is about Data, [[Scala]] is about Types, [[Java]] is about Objects.
 
Clojure is about Data, [[Scala]] is about Types, [[Java]] is about Objects.
 +
 +
[https://blog.cleancoder.com/uncle-bob/2019/08/22/WhyClojure.html Why Clojure?]
 +
 +
==版本==
 +
 +
==功能==
  
 
==虚拟机编译器==
 
==虚拟机编译器==
*[[ClojureCLR]]
+
*[https://github.com/clojure/clojure-clr ClojureCLR] 基于 Microsoft Dynamic Language Runtime (DLR) 和.NET Common Language Runtime (CLR),[[C Sharp|C#]] 和 Clojure 编写。
 
*[[ClojureScript]]
 
*[[ClojureScript]]
 +
 +
==语言==
 +
*[https://github.com/clj-python/libpython-clj Python bindings for Clojure]
 +
由[[Clojure]]开发的编程语言:
 +
*[https://github.com/jeaye/jank jank]
 +
*[https://github.com/LuxLang/lux lux]
 +
*[https://github.com/kanaka/mal/tree/master/clojure mal]
 +
*[https://github.com/turbopape/scheje scheje]
  
 
==指南==
 
==指南==
  wget http://repo1.maven.org/maven2/org/clojure/clojure/1.8.0/clojure-1.8.0.zip
+
[https://www.baeldung.com/clojure Introduction to Clojure]
 +
  wget https://repo1.maven.org/maven2/org/clojure/clojure/1.8.0/clojure-1.8.0.jar
 
  java -cp clojure-1.8.0.jar clojure.main
 
  java -cp clojure-1.8.0.jar clojure.main
 
  user=> (+ 1 2 3)
 
  user=> (+ 1 2 3)
第25行: 第43行:
 
或使用 Leiningen REPL,它比 Clojure 自带的 REPL 好很多。
 
或使用 Leiningen REPL,它比 Clojure 自带的 REPL 好很多。
 
  lein repl
 
  lein repl
 +
Web应用启动:
 +
lein run 或 lein ring server
  
== Leiningen==
+
==Evaluation==
 +
[[文件:traditional-evaluation.png]] [[文件:clojure-evaluation.png]]
 +
 
 +
==Windows==
 +
[https://github.com/clojure/tools.deps.alpha/wiki/clj-on-Windows clj on Windows]
 +
 
 +
C:\huihoo\clojure>powershell -noprofile -executionpolicy bypass -file .\win-install-1.10.1.469.ps1
 +
 
 +
PS C:\huihoo\clojure> clj -h
 +
 
 +
PS C:\huihoo\clojure> clj -r
 +
Clojure 1.10.1
 +
user=>
 +
 
 +
==Leiningen==
 
使用[[leiningen]]工具来管理Clojure项目和Java配置。
 
使用[[leiningen]]工具来管理Clojure项目和Java配置。
  
第51行: 第85行:
 
===插件===
 
===插件===
 
[https://github.com/technomancy/leiningen/wiki/Plugins Leiningen Plugins]
 
[https://github.com/technomancy/leiningen/wiki/Plugins Leiningen Plugins]
 +
 +
==fn,def,defn==
 +
[https://clojuredocs.org/clojure.core/fn fn] [https://clojuredocs.org/clojure.core/def def]和[https://clojuredocs.org/clojure.core/defn defn]
 +
 +
fn 创建一个匿名函数,fn 和 lambda 类似。
 +
user=> (map (fn [x] (* x x)))
 +
def 可以将一个匿名函数绑定到一个name上。
 +
user=> (def my-function (fn [x] (* x x )))
 +
defn 是 def 与 fn 的简写。
 +
user=> (defn my-function [x] (* x x))
  
 
==Clojars==
 
==Clojars==
第64行: 第108行:
  
 
==数据分析==
 
==数据分析==
数据分析和商业智能
+
统计、数据分析和商业智能
 +
*[[Incanter]]
 
*[[Metabase]]
 
*[[Metabase]]
  
第86行: 第131行:
  
 
==事件CEP==
 
==事件CEP==
*[https://github.com/clojurewerkz/eep EEP], Embedded Event Processing in Clojure
+
*[https://github.com/clojurewerkz/eep EEP] Embedded Event Processing in Clojure
*[https://github.com/clojurewerkz/meltdown Meltdown], a Clojure Interface to Reactor
+
*[https://github.com/clojurewerkz/meltdown Meltdown] a Clojure Interface to Reactor
  
 
==并行并发==
 
==并行并发==
第105行: 第150行:
 
==数据库存储==
 
==数据库存储==
 
*[[Datomic]]
 
*[[Datomic]]
 +
*[https://github.com/tonsky/datascript DataScript]
 
*[http://clojurewerkz.org/ Clojure libraries for MongoDB, RabbitMQ, validations, Neo4J, ElasticSearch, Apache Cassandra, Riak, Memcached, stream processing]
 
*[http://clojurewerkz.org/ Clojure libraries for MongoDB, RabbitMQ, validations, Neo4J, ElasticSearch, Apache Cassandra, Riak, Memcached, stream processing]
 
*[https://github.com/tomekw/hikari-cp hikari-cp] 连接池
 
*[https://github.com/tomekw/hikari-cp hikari-cp] 连接池
第111行: 第157行:
  
 
===SQL===
 
===SQL===
*[https://github.com/korma/Korma Korma]: Tasty SQL for Clojure
+
*[https://github.com/korma/Korma Korma] Tasty SQL for Clojure
*[https://github.com/jkk/honeysql Honey SQL]: Turn Clojure data structures into SQL
+
*[https://github.com/jkk/honeysql Honey SQL] Turn Clojure data structures into SQL
*[https://github.com/krisajenkins/yesql yesql]: https://github.com/krisajenkins/yesql
+
*[https://github.com/krisajenkins/yesql yesql] https://github.com/krisajenkins/yesql
  
 
===PostgreSQL===
 
===PostgreSQL===
第136行: 第182行:
 
*[http://clojureelasticsearch.info/ Elastisch]
 
*[http://clojureelasticsearch.info/ Elastisch]
  
==HTTP==
+
==Web HTTP==
 
*[[ring]]
 
*[[ring]]
 +
*[[Compojure]]
 
*[https://github.com/dakrone/clj-http clj-http]
 
*[https://github.com/dakrone/clj-http clj-http]
 
*[https://github.com/http-kit/http-kit http-kit]
 
*[https://github.com/http-kit/http-kit http-kit]
第144行: 第191行:
 
*[https://github.com/brehaut/necessary-evil necessary-evil] [[XML-RPC]]
 
*[https://github.com/brehaut/necessary-evil necessary-evil] [[XML-RPC]]
 
*[https://github.com/nginx-clojure/nginx-clojure nginx-clojure]
 
*[https://github.com/nginx-clojure/nginx-clojure nginx-clojure]
 +
*[https://github.com/pedestal/pedestal Pedestal]
 +
*[https://github.com/weavejester/hiccup Hiccup]
  
 
==RESTful API==
 
==RESTful API==
第153行: 第202行:
 
==IDE和Editor==
 
==IDE和Editor==
 
*[[Light Table]]
 
*[[Light Table]]
 +
*[https://github.com/oakes/Nightcode Nightcode]
 
*[[Cursive|Cursive IDE]]
 
*[[Cursive|Cursive IDE]]
 
*[[CCW IDE]]
 
*[[CCW IDE]]
第167行: 第217行:
  
 
==项目==
 
==项目==
 +
[https://github.com/razum2um/awesome-clojure Awesome Clojure] [[image:awesome.png]]
 
*[https://github.com/clojurewerkz ClojureWerkz]团队开发了众多开源项目
 
*[https://github.com/clojurewerkz ClojureWerkz]团队开发了众多开源项目
 
*[[Apache Storm]]
 
*[[Apache Storm]]
 
*[https://github.com/Raynes/tryclojure tryclojure]
 
*[https://github.com/Raynes/tryclojure tryclojure]
 
*[[ClojureScript]]
 
*[[ClojureScript]]
 +
*[https://github.com/clojure/test.check test.check] [https://github.com/BurntSushi/quickcheck QuickCheck] for Clojure
 
*[[incanter]]
 
*[[incanter]]
 
*[[Ring]]
 
*[[Ring]]
第208行: 第260行:
 
image:castra-rpc-for-clojure-architecture.png|Castra RPC
 
image:castra-rpc-for-clojure-architecture.png|Castra RPC
 
image:cursive-ide.png|Cursive IDE
 
image:cursive-ide.png|Cursive IDE
 +
image:clojure-tools.png|Tools
 +
image:clojure-structure-and-semantics.png|Expression
 +
image:clojure-dev-process.png|开发工作流
 +
image:cider-architecture.png|CIDER架构
 
</gallery>
 
</gallery>
  
第216行: 第272行:
 
*[http://blog.cognitect.com/blog/?tag=Clojure Clojure Blog]
 
*[http://blog.cognitect.com/blog/?tag=Clojure Clojure Blog]
 
*[http://planet.clojure.in/ Planet Clojure]
 
*[http://planet.clojure.in/ Planet Clojure]
*[https://github.com/razum2um/awesome-clojure Awesome Clojure] [[image:awesome.png]]
 
 
*[https://clojars.org/ Clojars]
 
*[https://clojars.org/ Clojars]
 
*[http://www.clojure-toolbox.com/ The Clojure Toolbox]
 
*[http://www.clojure-toolbox.com/ The Clojure Toolbox]

2021年10月25日 (一) 05:20的版本

Wikipedia-35x35.png 您可以在Wikipedia上了解到此条目的英文信息 Clojure Thanks, Wikipedia.

Clojure

Clojure-logo.png

目录

简介

Clojure-logo-120b.png

Clojure 是一个面向JVM 动态的通用编程语言,采用 Eclipse Public License 1.0 许可证。

Lisp 是一种编程语言,以表达性和功能强大著称,但人们通常认为它不太适合应用于一般情况。Clojure 是一种运行在 Java平台上的 Lisp 方言,它的出现彻底改变了这一现状。如今,在任何具备 Java 虚拟机的地方,您都可以利用 Lisp 的强大功能。

Clojure is about Data, Scala is about Types, Java is about Objects.

Why Clojure?

版本

功能

虚拟机编译器

  • ClojureCLR 基于 Microsoft Dynamic Language Runtime (DLR) 和.NET Common Language Runtime (CLR),C# 和 Clojure 编写。
  • ClojureScript

语言

Clojure开发的编程语言:

指南

Introduction to Clojure

wget https://repo1.maven.org/maven2/org/clojure/clojure/1.8.0/clojure-1.8.0.jar
java -cp clojure-1.8.0.jar clojure.main
user=> (+ 1 2 3)
6
user=> (def hello (fn [] "Hello world"))
#'user/hello
user=> (hello)
"Hello world"

或使用 Leiningen REPL,它比 Clojure 自带的 REPL 好很多。

lein repl

Web应用启动:

lein run 或 lein ring server

Evaluation

Traditional-evaluation.png Clojure-evaluation.png

Windows

clj on Windows

C:\huihoo\clojure>powershell -noprofile -executionpolicy bypass -file .\win-install-1.10.1.469.ps1

PS C:\huihoo\clojure> clj -h

PS C:\huihoo\clojure> clj -r

Clojure 1.10.1
user=>

Leiningen

使用leiningen工具来管理Clojure项目和Java配置。

brew install leiningen

或者获得 https://raw.github.com/technomancy/leiningen/preview/bin/lein 并放到 /bin 目录下,chmod 755

cd bin,执行 ./lein // 开始安装 Leiningen

lein help

lein help $TASK for details.

接着:

lein new start-clojure
cd start-clojure
lein repl
将获得一些jar,如:
Retrieving org/clojure/clojure/1.4.0/clojure-1.4.0.jar ...
user=>  (println "Give me some Clojure!")
Give me some Clojure!
nil

插件

Leiningen Plugins

fn,def,defn

fn defdefn

fn 创建一个匿名函数,fn 和 lambda 类似。

user=> (map (fn [x] (* x x)))

def 可以将一个匿名函数绑定到一个name上。

user=> (def my-function (fn [x] (* x x )))

defn 是 def 与 fn 的简写。

user=> (defn my-function [x] (* x x))

Clojars

大数据

数据分析

统计、数据分析和商业智能

机器学习

计算机视觉

自然语言处理

消息通信

事件CEP

  • EEP Embedded Event Processing in Clojure
  • Meltdown a Clojure Interface to Reactor

并行并发

金融货币

验证授权

数据库存储

SQL

PostgreSQL

MongoDB

Clojure Monger, Monger @ GitHub

Cassandra

  • cassaforte 建议:暂不使用高版本Cassandar,因为可能不支持。
  • alia: High performance Cassandra client for clojure
  • hayt: CQL3 DSL for Clojure

Redis

HBase

BI

Elasticsearch

Web HTTP

RESTful API

IDE和Editor

GUI

项目

Awesome Clojure Awesome.png

文档

图书

用户

  • Cognitect, Clojue之父,Rich Hickey 是该公司Co-Founder & CTO。
  • 花旗信用实时风险估值系统Java/Clojure后端(1500节点分布计算)花旗投资信用部实时风险计算系统,逻辑使用Clojure。
  • Puppet: Puppet Server, Trapperkeeper, PuppetDB, Trapperkeeper Webserver Service
  • 沃尔玛: “Our Clojure system just handled its first Walmart black Friday and came out without a scratch.” - Walmart Labs
  • Riemann
  • LeanCloud 采用了多种语言混合来构建整个后端系统,包括 Clojure、Java、Node.js、Scala 等。其中 Clojure 构建了整个网站门户、存储开放 API、推送、聊天等核心服务,Node.js构建了云端代码服务(类似应用代码托管),我们还使用 Scala 编写的 Spark 任务来处理离线数据分析,此外,还有大量的统计类 MapReduce 任务使用 Java 编写并运行在 Hadoop 集群上。不同服务之间使用 RESTful 协议、RPC 框架或者队列进行通信。

更多用户>>>

图集

链接

分享您的观点
个人工具
名字空间

变换
操作
导航
工具箱