I suppose this is a strange question to the huge majority of programmers that work daily with Java. I don't. I know Java-the-language, because I worked on Java projects, but not Java-the-world. I never made a web app from scratch in Java. If I have to do it with Python, Ruby, I know where to go (Django or Rails), but if I want to make a web application in Clojure, not because I'm forced to live in a Java world, but because I like the language and I want to give it a try, what libraries and frameworks should I use?
当前回答
Compojure是我用来创建一个小型博客应用程序的工具。它以Sinatra为蓝本,Sinatra是一个最小的、轻量级的Ruby web框架。我主要使用的是路由,就像Sinatra的一样。它看起来是这样的:
(GET "/post/:id/:slug"
(some-function-that-returns-html :id :slug))
没有ORM或模板库,但它有将向量转换为HTML的函数。
其他回答
Webjure, Clojure的web编程框架。
特性:分派servlet调用Clojure函数。动态HTML生成。SQL查询接口(通过JDBC)。
这个答案是Webjure信息的占位符。
你也可以看看下面这些框架(摘自clojure/projects):
级联 召唤
关于Stack Overflow还有一个相关的问题:成熟的Clojure web框架?
我将对来自@weavejester (Compojure和Ring的维护者)的pipe发表我的意见。
它的核心是将Component和Ring路由器放在一个屋檐下。我使用管道的原因:
Excellent philosophical foundation: it encourages you to build your app as a series of small components, and it strikes a nice balance between holding few opinions while providing sane defaults. Stable path: I speak for myself, but over the years I've felt that the Clojure community has presented one less-than-credible web framework after another. A couple simply felt too experimental (my experience with Om and client-side Pedestal) for "getting things done" (not that they won't prove superior down the road). On the other hand, I feel like @weavejester has brought the same stability and measured progress to Duct that he did to Compojure and Ring, which have been superbly born out in the community. It's super lightweight, and out of the way of my components.
主要特点:
通过“端点”组织路由,你可以把这些小组件想象成迷你web服务器(或者,HTTP路由的小截面)。 重新加载工作流的开箱即用支持。 与Ring和Compojure完美集成。 开发和生产配置(这是我在其他地方发现的明显缺失的部分)。 带有示例的良好文档。
注意:这是不言而喻的,但对于web开发新手来说,就像大多数Clojurey的东西一样,pipe要求扎实掌握Clojure语言。我还建议先阅读Component。
在另一个个人注意,我已经在几个生产应用程序中使用了一年多了,对它非常满意。
声明:我是作者。
我把一个leiningen模板结合luminusweb和栗子模板。 所以你得到了一些东西,你可以用它来构建clojure代码以及前端和后端clojurescript代码。 此外,它还提供用户管理、一些简单的CRUD生成和一些更小的功能:https://github.com/sveri/closp
如今,Pedestal是一个值得一看的框架。它是一个构建在Ring之上的服务器端框架,但是通过暂停和恢复特定的请求(否则缓慢的请求实际上会阻塞服务器线程),也可以从初始线程中释放传入的请求。可能有点像JavaBean。
其他很酷的框架还有hoplon。io和David Nolen的Om(基于React)