After discovering Clojure I have spent the last few days immersed in it.
在发现Clojure之后,我花了最后几天沉浸其中。
What project types lend themselves to Java over Clojure, vice versa, and in combination?
哪些项目类型适用于Clojure上的Java,反之亦然,并且它们组合在一起?
What are examples of programs which you would have never attempted before Clojure?
您在Clojure之前从未尝试过的程序示例是什么?
4 个解决方案
#1
14
Clojure lends itself well to concurrent programming. It provides such wonderful tools for dealing with threading as Software Transactional Memory and mutable references.
Clojure非常适合并发编程。它提供了很好的工具来处理软件事务内存和可变引用的线程。
As a demo for the Western Mass Developer's Group, Rich Hickey made an ant colony simulation in which each ant was its own thread and all of the variables were immutable. Even with a very large number of threads things worked great. This is not only because Rich is an amazing programmer, it's also because he didn't have to worry about locking while writing his code. You can check out his presentation on the ant colony here.
作为Western Mass Developer's Group的演示,Rich Hickey进行了蚁群模拟,其中每个蚂蚁都是自己的线程,所有变量都是不可变的。即使有非常多的线程,事情也很有效。这不仅是因为Rich是一个了不起的程序员,也是因为他在编写代码时不必担心锁定问题。你可以在这里查看他对蚁群的介绍。
#2
6
If you are going to try concurrent programming, then I think clojure is much better than what you get from Java out of the box. Take a look at this presentation to see why:
如果你打算尝试并发编程,那么我认为clojure比你从Java开箱即用的东西要好得多。看看这个演示文稿,看看为什么:
I documented my first 20 days with Clojure on my blog
我在博客上记录了Clojure的前20天
http://loufranco.com/blog/files/category-20-days-of-clojure.html
I started with the SICP lectures and then built a parallel prime number sieve. I also played around with macros.
我从SICP讲座开始,然后建立一个并行素数筛。我也玩过宏。
#3
4
What project types lend themselves to using Java over Clojure, vice versa, or in combination?
哪些项目类型适合在Clojure上使用Java,反之亦然或组合使用?
A project where a GUI-building tool (such as Matisse in Netbeans) is needed would be a case where Java may still be required. Anything done in Java can be done in Clojure quite readily, with proxy and gen-class if needed, or just accessing Java as needed (., doto, new, etc.). This allows Clojure projects to easily use Java libraries or legacy Java code.
需要GUI构建工具(例如Netbeans中的Matisse)的项目可能仍然需要Java。用Java完成的任何事情都可以在Clojure中完成,如果需要可以使用代理和gen-class,或者只需要根据需要访问Java(。,doto,new等)。这允许Clojure项目轻松使用Java库或遗留Java代码。
Which programs which you would have never attempted before Clojure ?
在Clojure之前你从未尝试过哪些程序?
Before I found Clojure, I was contemplating a project that required JDBC, would run in a servlet container, and I anticipated doing a lot of iterative development because it wasn't clear what methods would work for the data I needed to analyze. I put it on the back burner because I didn't have the time or patience for the compile-debug- deploy-validation cycling that Java requires. I've now written the application in Clojure, and I'm very pleased at the ease of making changes on the fly and being able to examine the results immediately. Not to mention the joy of lock-free programming and being liberated from having to develop (and refactor) class hierarchies.
在我找到Clojure之前,我正在考虑一个需要JDBC的项目,它将在servlet容器中运行,我预计会进行大量的迭代开发,因为我不清楚哪些方法对我需要分析的数据起作用。我把它放在后面,因为我没有时间或耐心来进行Java所需的编译 - 调试 - 部署 - 验证循环。我现在已经在Clojure中编写了应用程序,我很高兴能够轻松地进行动态更改并能够立即检查结果。更不用说无锁编程的乐趣,以及从必须开发(和重构)类层次结构中解放出来。
- "MikeM" via the clojure@googlegroups.com mailinglist
- “MikeM”通过clojure@googlegroups.com邮件列表
#4
2
What project types lend themselves to Java over Clojure, vice versa, and in combination?
哪些项目类型适用于Clojure上的Java,反之亦然,并且它们组合在一起?
If you want to develop a framework that is to be consumed by Java and Clojure, I've found writing the main abstractions (interfaces ad base classes) in Java to be preferable over writing them in Clojure (I find Clojure's gen-class
to be somewhat tedious and rather use proxy
).
如果你想开发一个由Java和Clojure使用的框架,我发现在Java中编写主要的抽象(接口广告基类)比在Clojure中编写它们要好(我发现Clojure的gen-class是有点乏味,而是使用代理)。
If you're a user of Hibernate or any other framework that makes heavy use of Java-annotations without offering a programmatic alternative, you'll have some trouble, since it's not trivial to emulate annotated POJOs with Clojure's data structures.
如果您是Hibernate的用户或任何其他框架,如果不提供编程替代方案而大量使用Java注释,那么您将遇到一些麻烦,因为使用Clojure的数据结构模拟带注释的POJO并非易事。
Apart from that, I've experienced no use cases for which Clojure is less appropriate than Java; you have to cope with the loss of static typing, of course, which feels somewhat disconcerting at first, but tends to go away.
除此之外,我没有经历过Clojure不如Java的用例;当然,你必须应对静态打字的损失,起初感觉有点令人不安,但往往会消失。
#1
14
Clojure lends itself well to concurrent programming. It provides such wonderful tools for dealing with threading as Software Transactional Memory and mutable references.
Clojure非常适合并发编程。它提供了很好的工具来处理软件事务内存和可变引用的线程。
As a demo for the Western Mass Developer's Group, Rich Hickey made an ant colony simulation in which each ant was its own thread and all of the variables were immutable. Even with a very large number of threads things worked great. This is not only because Rich is an amazing programmer, it's also because he didn't have to worry about locking while writing his code. You can check out his presentation on the ant colony here.
作为Western Mass Developer's Group的演示,Rich Hickey进行了蚁群模拟,其中每个蚂蚁都是自己的线程,所有变量都是不可变的。即使有非常多的线程,事情也很有效。这不仅是因为Rich是一个了不起的程序员,也是因为他在编写代码时不必担心锁定问题。你可以在这里查看他对蚁群的介绍。
#2
6
If you are going to try concurrent programming, then I think clojure is much better than what you get from Java out of the box. Take a look at this presentation to see why:
如果你打算尝试并发编程,那么我认为clojure比你从Java开箱即用的东西要好得多。看看这个演示文稿,看看为什么:
I documented my first 20 days with Clojure on my blog
我在博客上记录了Clojure的前20天
http://loufranco.com/blog/files/category-20-days-of-clojure.html
I started with the SICP lectures and then built a parallel prime number sieve. I also played around with macros.
我从SICP讲座开始,然后建立一个并行素数筛。我也玩过宏。
#3
4
What project types lend themselves to using Java over Clojure, vice versa, or in combination?
哪些项目类型适合在Clojure上使用Java,反之亦然或组合使用?
A project where a GUI-building tool (such as Matisse in Netbeans) is needed would be a case where Java may still be required. Anything done in Java can be done in Clojure quite readily, with proxy and gen-class if needed, or just accessing Java as needed (., doto, new, etc.). This allows Clojure projects to easily use Java libraries or legacy Java code.
需要GUI构建工具(例如Netbeans中的Matisse)的项目可能仍然需要Java。用Java完成的任何事情都可以在Clojure中完成,如果需要可以使用代理和gen-class,或者只需要根据需要访问Java(。,doto,new等)。这允许Clojure项目轻松使用Java库或遗留Java代码。
Which programs which you would have never attempted before Clojure ?
在Clojure之前你从未尝试过哪些程序?
Before I found Clojure, I was contemplating a project that required JDBC, would run in a servlet container, and I anticipated doing a lot of iterative development because it wasn't clear what methods would work for the data I needed to analyze. I put it on the back burner because I didn't have the time or patience for the compile-debug- deploy-validation cycling that Java requires. I've now written the application in Clojure, and I'm very pleased at the ease of making changes on the fly and being able to examine the results immediately. Not to mention the joy of lock-free programming and being liberated from having to develop (and refactor) class hierarchies.
在我找到Clojure之前,我正在考虑一个需要JDBC的项目,它将在servlet容器中运行,我预计会进行大量的迭代开发,因为我不清楚哪些方法对我需要分析的数据起作用。我把它放在后面,因为我没有时间或耐心来进行Java所需的编译 - 调试 - 部署 - 验证循环。我现在已经在Clojure中编写了应用程序,我很高兴能够轻松地进行动态更改并能够立即检查结果。更不用说无锁编程的乐趣,以及从必须开发(和重构)类层次结构中解放出来。
- "MikeM" via the clojure@googlegroups.com mailinglist
- “MikeM”通过clojure@googlegroups.com邮件列表
#4
2
What project types lend themselves to Java over Clojure, vice versa, and in combination?
哪些项目类型适用于Clojure上的Java,反之亦然,并且它们组合在一起?
If you want to develop a framework that is to be consumed by Java and Clojure, I've found writing the main abstractions (interfaces ad base classes) in Java to be preferable over writing them in Clojure (I find Clojure's gen-class
to be somewhat tedious and rather use proxy
).
如果你想开发一个由Java和Clojure使用的框架,我发现在Java中编写主要的抽象(接口广告基类)比在Clojure中编写它们要好(我发现Clojure的gen-class是有点乏味,而是使用代理)。
If you're a user of Hibernate or any other framework that makes heavy use of Java-annotations without offering a programmatic alternative, you'll have some trouble, since it's not trivial to emulate annotated POJOs with Clojure's data structures.
如果您是Hibernate的用户或任何其他框架,如果不提供编程替代方案而大量使用Java注释,那么您将遇到一些麻烦,因为使用Clojure的数据结构模拟带注释的POJO并非易事。
Apart from that, I've experienced no use cases for which Clojure is less appropriate than Java; you have to cope with the loss of static typing, of course, which feels somewhat disconcerting at first, but tends to go away.
除此之外,我没有经历过Clojure不如Java的用例;当然,你必须应对静态打字的损失,起初感觉有点令人不安,但往往会消失。