Web 快速开发很多人用 Python 及其它动态语言,Clojure 作为 Lisp 的一种方言,也很灵活。那么它适合用来做 Web 快速开发么? 理由是什么?
相对比 Python,Clojure 又有什么优劣势?
回复内容:
应该说还是蛮适合的。Clojure虽然历史不长但是支持web开发的"框架"[0]已经有了:Ring以及基于Ring的Compojure。Ring支持middleware机制(可以理解为插件),很多核心的功能都是通过middleware来实现的,比如session、cookie,params解析[1]等等,middleware机制使得你可以很轻松的向ring上面组装你需要的功能,比如这里[2]有一些已有的第三方的middleware。对了Ring类库本身大量借鉴了Ruby里面的Rack、Python里面的WSGI特性,因此在快速开发方面不用担心。
虽然Clojure本身是JVM上面的语言,但是比Java爽的是,用Ring开发的代码你不需要任何特殊配置就可以做到:不管你是改html代码还是Clojure代码都是可以马上刷新就可以看到效果 —— 而不用重启服务器。这应该对于web开发速度比较重要的一个特性吧。
跟Python相比的缺点?一时还真的想不起来,可能我用的也不算多吧。这里是我晚上花了两个小时用Clojure写出来的东西,你可以感受一下: 公积金贷款计算器
[0] Clojure里面其实更喜欢叫类库,而不是框架,因为框架听起来是个很重的东西
[1] https://github.com/ring-clojure/ring/tree/master/ring-core/src/ring/middleware
[2] https://github.com/ring-clojure/ring/wiki/Third-Party-Libraries 开发还是很快的。http://rebajie.net 是我用clojure写的。这个是我用clojure写的blog 。。 http://github.com/baoliang/clojure-blog > 相对比 Python,Clojure 又有什么优劣势?
举例说明。
我前同事,原来专业写python的。后来因为clojure,到了我们公司,一直写clojure。他自己做的好几个项目都是Clojure写的。
我写Clojure2年多了,很喜欢这么语言,中间写过几个月python。这次到了新公司,公司大部分代码都是python+php。我就写python了。他们要我把服务搞快+稳定。python还是有点累,不过应该可以解决。
python应该还是一门不错的语言。Clojure更是。 很好用,可以开放端口,用来热调试,同时可以实现插件动态管理,开发流程很简单,快速,
(defn render-test [ret tmt]
(-> (resp/response "------render----test------")
(#(resp/content-type %1 "text/plain"))))
(defn foo
"I don't do a whole lot."
[x]
(str "来自源码目录的参数:" x))
(defn handler [^Integer x]
{:$r render-test :text (str "hello world, road goes sucess!" (foo x))})
(defn home [req content ^Integer num]
{:hiccup "home.clj" :content (str "home" content) :num num})
(defroad road (GET "/web-test-0.1.0-SNAPSHOT-standalone/main" handler)
(GET "/web-test-0.1.0-SNAPSHOT-standalone/home/:num{\\d+}" home))
(defn -main [& args]
(log/info "---------log4j test-------")
(jetty/run-jetty road {:port 3000}))

ForhandlinglargedatasetsinPython,useNumPyarraysforbetterperformance.1)NumPyarraysarememory-efficientandfasterfornumericaloperations.2)Avoidunnecessarytypeconversions.3)Leveragevectorizationforreducedtimecomplexity.4)Managememoryusagewithefficientdata

Inpython,ListSusedynamicMemoryAllocationWithOver-Asalose,而alenumpyArraySallaySallocateFixedMemory.1)listssallocatemoremoremoremorythanneededinentientary上,respizeTized.2)numpyarsallaysallaysallocateAllocateAllocateAlcocateExactMemoryForements,OfferingPrediCtableSageButlessemageButlesseflextlessibility。

Inpython,YouCansspecthedatatAtatatPeyFelemereModeRernSpant.1)Usenpynernrump.1)Usenpynyp.dloatp.dloatp.ploatm64,formor professisconsiscontrolatatypes。

NumPyisessentialfornumericalcomputinginPythonduetoitsspeed,memoryefficiency,andcomprehensivemathematicalfunctions.1)It'sfastbecauseitperformsoperationsinC.2)NumPyarraysaremorememory-efficientthanPythonlists.3)Itoffersawiderangeofmathematicaloperation

Contiguousmemoryallocationiscrucialforarraysbecauseitallowsforefficientandfastelementaccess.1)Itenablesconstanttimeaccess,O(1),duetodirectaddresscalculation.2)Itimprovescacheefficiencybyallowingmultipleelementfetchespercacheline.3)Itsimplifiesmemorym

SlicingaPythonlistisdoneusingthesyntaxlist[start:stop:step].Here'showitworks:1)Startistheindexofthefirstelementtoinclude.2)Stopistheindexofthefirstelementtoexclude.3)Stepistheincrementbetweenelements.It'susefulforextractingportionsoflistsandcanuseneg

numpyallowsforvariousoperationsonArrays:1)basicarithmeticlikeaddition,減法,乘法和division; 2)evationAperationssuchasmatrixmultiplication; 3)element-wiseOperations wiseOperationswithOutexpliitloops; 4)

Arresinpython,尤其是Throughnumpyandpandas,weessentialFordataAnalysis,offeringSpeedAndeffied.1)NumpyArseNable efflaysenable efficefliceHandlingAtaSetSetSetSetSetSetSetSetSetSetSetsetSetSetSetSetsopplexoperationslikemovingaverages.2)


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

ZendStudio 13.5.1 Mac
強大的PHP整合開發環境

MinGW - Minimalist GNU for Windows
這個專案正在遷移到osdn.net/projects/mingw的過程中,你可以繼續在那裡關注我們。 MinGW:GNU編譯器集合(GCC)的本機Windows移植版本,可自由分發的導入函式庫和用於建置本機Windows應用程式的頭檔;包括對MSVC執行時間的擴展,以支援C99功能。 MinGW的所有軟體都可以在64位元Windows平台上運作。

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

記事本++7.3.1
好用且免費的程式碼編輯器

EditPlus 中文破解版
體積小,語法高亮,不支援程式碼提示功能