要写一个下载器,Clojure.java.io或者Java的io api? [英] To write a downloader, Clojure.java.io or Java's io api?

查看:232
本文介绍了要写一个下载器,Clojure.java.io或者Java的io api?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Clojure中编写一个通用的http / ftp文件下载器。我做了一些研究,发现我可以使用java的api - BufferedReader BufferedInputStream等,或者Clojure.java.io的api - writer,reader,input-stream,output-stream。


  1. 我发现Clojure的api比java的api更容易使用和读取,但是在性能,速度等方面,java的api是一个更好的选择


  2. 是否有其他理由选择一个而非另一个?

    作为一个jvm平台语言,Clojure是文件下载项目的一个不错的选择,在性能方面?在做研究的同时,我也阅读了一些关于速度&内存性能在jvm平台,我想现在我想知道如果我的语言选择是一个很好的匹配我的项目..



< Clojure API应该感觉更自然,因为它是用Clojure成语创建的。当然,你仍然可以使用Java API,但是期望很多Java互操作函数调用。

这当然没有什么错,但它只是一个流利的Clojure API。



我看不到性能损失,无论你使用什么,JVM都很慢引导,无论是Java,Scala,Clojure还是JRuby。 Clojure真的很高效。顺便说一句,你知道,在Clojure,你可以编译你的项目到字节码格式?



Clojure是文件下载工程的不错选择吗?

我会说绝对!

一个主要优点是Clojure处理并发。如果你考虑它,你的项目将做很多线程,锁定和同步(你正在建立一个下载器,可以同时下载许多文件,正确)?

在Clojure中,你将使用更高的抽象作为代理(真的方便您的项目),refs和原子。



我不知道你读过的关于JVM性能和内存管理的资源。 JVM是一个复杂的软件。 JVM提供了许多管理内存的策略。一些适合于桌面应用程序,另一些适合服务器。您可以根据应用/系统要求选择合适的策略。



顺便说一下,是否计划使用Swing构建应用程序?如果是,您决定使用Clojure,那么请查看跷跷板


Seesaw是一个用于在Clojure中构建用户界面的库/ DSL。它恰好是在Swing上构建的,但请不要抱着它。



I am trying to write a general http/ftp file downloader in Clojure. 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.

  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?

  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? 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..

解决方案

Clojure API should feels more natural as it is created with Clojure idioms in mind. Of course, you can still use the Java API but then expect a lot of Java interop functions calls.
Which of course there nothing wrong with that but it is only not a fluent 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. Clojure is really performant. By the way, do you know that in Clojure you can compile your project to Bytecode format?

Is Clojure as good choice for file downloader project?
I would say definitely!
One main advantage is how Clojure deal with concurrency. 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.

I'm not sure about the resources you read about JVM performance and memory management. JVM is a sophisticated piece of software. JVM offers many strategies to manage memory. 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? If yes and you decided to go with Clojure, then have a look at Seesaw.

Seesaw is a library/DSL for constructing user interfaces in Clojure. It happens to be built on Swing, but please don't hold that against it.

这篇关于要写一个下载器,Clojure.java.io或者Java的io api?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆