成为一名合格的 Scala 程序员是否需要成为一名合格的 Java 程序员?

发布于 2024-10-03 15:37:34 字数 571 浏览 11 评论 0 原文

从美学角度来说,我是 Scala 的忠实粉丝,并且非常喜欢其类型系统和库等方面的大量概念性工作。

然而,当我开始修改 Scala(并且看到我的一些同事修改它)时,我发现自己必须挖掘越来越多的 Java 知识(尤其是库方面的知识)。

这给我带来了一些问题:

  • 我从来没有成为过 Java 程序员,所以对 Java 标准库或其他流行的库(如 Apache Commons)不熟悉或不适应。
  • 我在 Java 领域的 google-fu 很弱。很难知道要搜索什么——对于编程新手来说,大量不相关或基本的 Java 教程加剧了这个问题。

但此时此刻,我不确定是否应该硬着头皮尝试找到最快、最全面的 Java 之旅来让自己了解 20 年的 Java 开发,或者继续尝试逐步修补我的知识是否合理?当我在 scala 中漫步时获得知识。

我们将非常感谢 scala 领导者能够提供的任何智慧。

聚苯乙烯 我毫不怀疑自己有能力熟悉 Scala 语法,并且我对函数式编程和 Scala 社区中的范例感到非常满意和满意。但程序员的能力不仅仅取决于一个人自学的能力,还取决于一个人向他人学习和采用工具和技能的能力。

I am a big fan of Scala aesthetically, and of a lot of the conceptual work put into things like its typing system and libraries.

However, as I have begun tinkering with Scala (and seen some of my coworkers tinker with it) i find myself having to dig for more and more Java knowledge (especially in the way of libraries).

This presents me with a few problems:

  • Having never been a Java programmer, i'm not familiar or comfortable with the Java standard library, or additional popular libraries (like Apache Commons).
  • My google-fu in the Java-sphere is weak. It's hard to know what to search for – a problem exacerbated by the ponderously large number of irrelevant or rudimentary java tutorials for programming newbies.

At this point though, i'm not sure whether i should bite the bullet and try and find the quickest and most comprehensive tour through Java to catch myself up on 20 years of Java developments, or whether its reasonable to continue trying to incrementally patch my knowledge as i wander around scala.

Any wisdom that scala heads amongst us could offer would be greatly appreciated.

P.S.
I have no doubt in my ability to familiarize myself with Scala syntax, and i'm perfectly comfortable and happy with functional programming and the paradigms in the scala community. But a programmer's competence is not just based on one's ability to teach oneself, but also one's ability to learn from, and adopt tools and skills from other people.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

蓝颜夕 2024-10-10 15:37:34

您应该采用惰性方法来学习 Java。当你需要的时候就学习它。

在我看来,很多旧的Java知识已经过时,很多新教程都是多余的。例如,您当然不想为 Java 过时的 Collections 所困扰。许多基于 Java 的框架可以安全地忽略。并且可以安全地绕过重量级 JavaEE 堆栈,直到您被迫使用其中的一部分。

Java 中的许多常见模式在 Scala 中要简单得多,前者包含大量样板代码。核心逻辑应始终在 Scala 中实现。我相信你可以直接在 Scala 中完成大部分工作,只需要在构建 Swing 或与 Spring 集成等时深入了解 Java。

关于选择和使用 Java 库,我个人的指导方针是:

  1. 如果 Spring 可以吧,用Spring
  2. 如果Spring太重量级,就用Spring用的东西。
  3. 如果 Spring 做不到,请检查 github 项目
  4. 如果 github 上没有任何内容,请检查 Apache 项目
  5. 如果 Apache 没有任何内容,请检查 sourceforge(t)。
  6. 最后,谷歌随机或自己构建它。

这有点开玩笑,但这是我在过去 12 年使用 Java 后对第三方库的成熟度和稳定性的印象。

You should take a lazy approach to learning Java. Learn it when you need it.

In my opinion, much of the old Java knowledge is out of date, much of the new tutorials are redundant. You certainly don't want to bother yourself with Java's antiquated Collections, for example. Many Java-based frameworks can be safely ignored. And the heavyweight JavaEE stack can be safely bypassed until you were forced to use a part of it.

Many common patterns in Java are much simpler in Scala, with the former being burdened with much boilerplate code. Core logic should always be implemented in Scala. I believe you can do most of your work directly in Scala and only need to dip down into Java when building things like Swing or integrating with Spring, etc.

In regard to choosing and using Java libraries, my personal guidelines are:

  1. If Spring can do it, use Spring
  2. If Spring is too heavyweight, use what Spring uses.
  3. If Spring can't do it, check github projects
  4. If there's nothing on github, check Apache projects
  5. If there's nothing from Apache, check sourceforge(t).
  6. Finally, Google randomly or just build it yourself.

That's a bit tounge-in-cheek, but is the impression I get about the maturity and stability of third party libraries after having done Java for the last 12 years.

七七 2024-10-10 15:37:34

如果您想学习西班牙语,请开始学习西班牙语,而不是拉丁语。对于编程语言来说也是如此。 Java 有两件事是值得了解的:

第一件事是 API。但您只需要对现有内容有一个总体概述。即使是资深的 Java 程序员也不知道所有的细节。为问题找到正确的 API 或库通常很容易,因为 Java 非常常见,即使 Google Fu 很弱,您也不应该遇到任何问题。

您需要了解的第二件事是 Java 和 JVM 的一些基本原理和限制(包括如何构建和运行),这有助于您理解 Scala 的一些问题和设计决策。一个典型的例子是“类型擦除”:如果您不理解 Java 泛型的这一限制,那么在 Scala 中使用泛型时就会遇到问题。

正如您所看到的,您真正需要了解的事情是有限的。其他的东西都可以在路上取。

If you want to learn Spanish, start to learning Spanish, not Latin. Same for programming languages. There are two things from Java that are good to know:

The first thing are APIs. But you need only a general overview about what exists. Even long time Java programmers don't know all the details. And finding the right API or lib for a problem is usually easy, as Java is so common, and even with weak Google Fu you shouldn't have any problems.

The second thing you need to know are some basic principles and limitations of Java and the JVM (including how to build and run), that help you to understand some of Scala's problems and design decisions. One typical example would be "type erasure": If you don't understand this limitation of Java's generics, you'll run in problems when using generics in Scala.

As you can see, the things you really need to know is limited. Everything else can be picked up on the way.

把人绕傻吧 2024-10-10 15:37:34

这完全取决于你对“有能力的Java程序员”的定义。

充分了解 Java 内存模型和垃圾收集策略将会有所帮助。正如广泛的第三部分库的经验一样。

另一方面......如果你深深地被灌输了像 Spring 这样的库使用的 getter/setter 依赖注入,那么你必须先改掉很多坏习惯,然后才能正确处理不变性 - 在这种情况下,先接触 Java 可能会阻碍你学习 Scala。

It depends entirely on your definition of "Competent Java Programmer".

A good understanding of the Java memory model and garbage collection strategies will help. As will experience with a wide range of 3rd part libraries.

On the other hand... if you're deeply indoctrinated into getter/setter dependency injection used by libraries like Spring, then you'll have to unlearn a lot of bad habits before you can properly deal with immutability - In this case, prior Java exposure is probably going to hinder you in learning Scala.

柠檬 2024-10-10 15:37:34

有很多人从 ruby​​/python、lisp/scheme、C# 转向 scala 和 clojure,他们需要了解:

原语、自动装箱

JVM 启动选项、热点如何工作、32 位与 64 位、使用 openJDK?

基准测试、分析、如何读取堆栈跟踪;

无数的测试库满足每一个可以想象的需求。

java.util.concurrent

Swing API 调用;类路径; Maven,蚂蚁; Hudson,接口

命名空间/包/目录布局,以及所有其他自动化操作:

intelliJ、netBean 或 eclipse


http://news.ycombinator.com/item?id=1508609

http://www.mired.org/home/mwm/papers/simple-clojure.html

+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:、EscapeAnalysis 等。
http://groups.google.com/group/clojure/browse_frm/thread /c8f69037b26e2856#

压缩了哎呀,
http://blog .juma.me.uk/2009/10/26/new-jvm-options-and-scala-iteration-performance/

http://blog.headius.com/2009/01/my-favorite-hotspot-jvm-flags.html

http://groups.google.com/group/jvm-languages/topics

< a href="https://stackoverflow.com/questions/3525403/java-for-clojure-users">面向 Clojure 用户的 Java

学习 Clojure - 关于 Java 我应该了解哪些内容

http://copperthoughts.com/p/clojurists-guide-to-java/

There are lots of folk coming to scala and clojure from ruby/python, lisp/scheme, C#, who need to pick up on:

primitives, autoboxing

JVM startup options, how hotspot works, 32 vs. 64 bit, use openJDK?

benchmarks, profiling, how to read stacktraces;

zillions of test libs for every conceivable need.

java.util.concurrent

Swing API calls; Classpath; Maven, ant; Hudson, Interfaces

namespaces/packages/directory layout, and all the other things automated by:

intelliJ, netBean, or eclipse


http://news.ycombinator.com/item?id=1508609

http://www.mired.org/home/mwm/papers/simple-clojure.html

+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:, EscapeAnalysis etc.
http://groups.google.com/group/clojure/browse_frm/thread/c8f69037b26e2856#

compressed oops,
http://blog.juma.me.uk/2009/10/26/new-jvm-options-and-scala-iteration-performance/

http://blog.headius.com/2009/01/my-favorite-hotspot-jvm-flags.html

http://groups.google.com/group/jvm-languages/topics

Java for Clojure users

Learning Clojure - What should I know about Java and more

http://copperthoughts.com/p/clojurists-guide-to-java/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文