clojure 初试

Twitter开源的著名的分布式并行计算框架Storm就是用Clojure编写的。
http server 例子:https://github.com/moonranger/clj.tr069

Datomic
http://jerrypeng.me/2015/05/26/talk-about-monitoring-again/

Leiningen for project automation package management and dependencies and is configured using Clojure syntax.
Maven integration

readers for: maps, sets, vectors, lists.
Lisp-1
macro: qualify symbols with namespace.
concurrent: software transactional memory, reactive system, channel-based

clojure download

clojure国内镜像下载

http://maven.ibiblio.org/maven2/org/clojure/clojure/1.9.0-alpha9/
http://maven.aliyun.com/nexus/content/groups/public/org/clojure/clojure

leiningen下载:

在~/.lein 目录下:

https://github.com/technomancy/leiningen/tree/master/bin/lein.bat 放到bin/

https://github.com/technomancy/leiningen/releases/download/2.7.1/leiningen-2.7.1-standalone.zip 重命名为
/self-installs/leiningen-2.7.1-standalone.jar

clojure repl

java -cp ~/tmp/clojure-1.9.0-alpha9.jar clojure.main

(println (str "Hello, " \u4e16)) ; to the console
(javax.swing.JOptionPane/showMessageDialog nil (str "Hello, " \u4e16 "!")) ; using Java GUI

leiningen repl

usage

lein new hello
cd hello
lein run -m hello.core/foo 123
> 123 Hello, World!

lein deps
lein test

project.clj 中加入 :main xx <==> -m xx

lein repl
> (require 'hello.core)
> (hello.core/foo 123)

lein trampoline run -m hello.core/foo 5000 ;省内存

emacs clojure repl

init.el
(defvar my-packages '(better-defaults
                      projectile
                      clojure-mode
                      cider))

(dolist (p my-packages)
  (unless (package-installed-p p)
    (package-install p)))

~/.lein/profiles.clj
 {:user {:plugins [[cider/cider-nrepl "0.8.1"]]}}

;;;M-x eval-buffer
;;;M-x package-list-packages
;;;start repl: M-x cider-jack-in
;;;toggle menu: M-x menu-bar-mode

分发给终端用户使用

(defproject my-stuff ... :main my.stuff)
src/my/stuff.clj
(ns my.stuff (:gen-class))
(defn -main [& args]
 (println "your args:" args))

lein uberjar
java -jar my-stuff-standalone.jar are you ok

在线修改服务器

不重启开发服务器的情况下重载源文件 [3]

project.clj
:plugins [[lein-ring "0.8.7"]]
:ring {:handler your-app.core/handler}

lein deps
lein ring server

todo

compojure-clojure
http://blog.csdn.net/lrq1988/article/details/12155119

destruct
http://blog.csdn.net/lrq1988/article/details/14120401

ref

[1] http://wiki.fnil.net/index.php?title=Leiningen%E6%95%99%E7%A8%8B%E4%B8%AD%E6%96%87%E7%89%88

[2] (http://wiki.fnil.net/index.php?title=Clojure%E5%B9%B6%E5%8F%91)

[3] https://github.com/ring-clojure/ring/wiki

[4] 速成教程 http://blog.csdn.net/ithomer/article/details/16807461
http://java.ociweb.com/mark/clojure/article.html#Macros

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值