简体   繁体   English

要编写下载器,请使用Clojure.java.io还是Java的io api?

[英]To write a downloader, Clojure.java.io or Java's io api?

I am trying to write a general http/ftp file downloader in Clojure. 我正在尝试在Clojure中编写一个常规的http / ftp文件下载器。 I did a little research and found that I can either use java's api -- BufferedReader BufferedInputStream etc, or Clojure.java.io's api -- writer, reader, input-stream, output-stream. 我进行了一些研究,发现可以使用java的api-BufferedReader BufferedInputStream等,也可以使用Clojure.java.io的api-作家,读者,输入流,输出流。

  1. I found Clojure's api somewhat easier to use and read than java's api, but how about in terms of performance, speed, etc, will java's api be a better choice then? 我发现Clojure的api比Java的api更易于使用和阅读,但是在性能,速度等方面,java的api会是一个更好的选择吗?

  2. Is there any other reason to choose one instead of the other? 还有其他理由选择一个而不是另一个吗?

  3. As a jvm platform language, is Clojure a good choice for file downloader project, in terms of performance? 作为一种jvm平台语言,就性能而言,Clojure是文件下载程序项目的不错选择吗? While doing research, I also read some posts debating on speed & memory performance on jvm platform, and I guess now I wanna know if my language choice is a good match to my project.. 在进行研究时,我还阅读了一些有关jvm平台上的速度和内存性能的文章,现在我想知道我的语言选择是否与我的项目非常匹配。

Clojure API should feels more natural as it is created with Clojure idioms in mind. 考虑到Clojure习语创建的Clojure API应该更加自然。 Of course, you can still use the Java API but then expect a lot of Java interop functions calls. 当然,您仍然可以使用Java API,但随后会调用许多Java互操作函数。
Which of course there nothing wrong with that but it is only not a fluent Clojure API. 当然,这没有什么错,但是它并不是流利的Clojure API。

I don't see performance penalties, JVM is slow to boot no matter what you are using, whether it is Java, Scala, Clojure or JRuby. 我看不到性能损失,无论您使用的是Java,Scala,Clojure还是JRuby,JVM的启动速度都很慢。 Clojure is really performant. Clojure确实表现出色。 By the way, do you know that in Clojure you can compile your project to Bytecode format? 顺便说一句,您是否知道可以在Clojure中将项目编译为Bytecode格式?

Is Clojure as good choice for file downloader project? Clojure是文件下载器项目的不错选择吗?
I would say definitely! 我肯定会说!
One main advantage is how Clojure deal with concurrency. 主要优势之一是Clojure如何处理并发。 If you think about it, your project will do a lot of threading, locking and synchronization (you are building a downloader that can download many files simultaneously, correct)? 如果您考虑一下,您的项目将执行大量线程,锁定和同步操作(您正在构建一个可以同时下载许多文件的下载器,对吗?)?
In Clojure you will use a higher abstractions such as agents (really convenient for your project), refs and atoms. 在Clojure中,您将使用更高的抽象,例如代理(对于您的项目而言非常方便),引用和原子。

I'm not sure about the resources you read about JVM performance and memory management. 我不确定您阅读的有关JVM性能和内存管理的资源。 JVM is a sophisticated piece of software. JVM是一款复杂的软件。 JVM offers many strategies to manage memory. JVM提供了许多策略来管理内存。 Some are suitable for desktop applications, others are suitable for servers. 有些适用于桌面应用程序,有些适用于服务器。 You can pick the suitable strategy depending on your application/system requirements. 您可以根据您的应用程序/系统要求选择合适的策略。

By the way, are planning to build your application with Swing? 顺便说一句,是否打算使用Swing构建您的应用程序? If yes and you decided to go with Clojure, then have a look at Seesaw . 如果是,那么您决定选择Clojure,然后看看Seesaw

Seesaw is a library/DSL for constructing user interfaces in Clojure. 跷跷板是用于在Clojure中构建用户界面的库/ DSL。 It happens to be built on Swing, but please don't hold that against it. 它恰好建立在Swing上,但是请不要反对它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 clojure.java.io ClassNotFoundException - clojure.java.io ClassNotFoundException Clojure:clojure.java.io/resource如何加载文件? - Clojure: How does clojure.java.io/resource load file? 为什么在这种情况下clojure.java.io/resource不起作用? - Why doesn't clojure.java.io/resource work in this case? 我如何使用 lein exec 要求 clojure.java.io? - How do I require clojure.java.io with lein exec? clojure的读取文件结构,即with-open和clojure.java.io/reader,是否足够频繁访问? - Is clojure's read file structure, i.e. with-open and clojure.java.io/reader, efficient enough for frequent access? 没有方法的实现::协议的as-file:#'clojure.java.io /为类发现的强制:clojure.lang.PersistentVector - No implementation of method: :as-file of protocol: #'clojure.java.io/Coercions found for class: clojure.lang.PersistentVector 没有实现方法:: make-reader of protocol:#'clojure.java.io / IOFactory for class:nil - No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil Clojure Clostache错误-没有实现方法::make-reader of protocol:#'clojure.java.io / IOFactory为类nil找到 - Clojure Clostache error - No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil 使用clojure twitter-api获取“java.io.EOFException:JSON错误” - Getting “java.io.EOFException: JSON error” using the clojure twitter-api line-seq在clojure中冻结在java.io.BufferedReader上 - line-seq freezes on java.io.BufferedReader in clojure
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM