简体   繁体   English

动态语言 - 我应该选择哪一个?

[英]Dynamic languages - which one should I choose?

Dynamic languages are on the rise and there are plenty of them: eg Ruby, Groovy, Jython, Scala (static, but has the look and feel of a dynamic language) etc etc. My background is in Java SE and EE programming and I want to extend my knowledge into one of these dynamic languages to be better prepared for the future. 动态语言正在兴起,其中有很多:例如Ruby,Groovy,Jython,Scala(静态,但具有动态语言的外观和感觉)等等。我的背景是Java SE和EE编程,我想要将我的知识扩展到这些动态语言之一,以便为将来做好更充分的准备。

But which dynamic language should I focus on learning and why? 但是我应该关注哪种动态语言学习?为什么? Which of these will be the preferred language in the near future? 在不久的将来,哪些将成为首选语言?

Learning Ruby or Python (and Scala to a lesser extent) means you'll have very transferrable skills - you could use the Java version, the native version or the .NET version (IronRuby/IronPython). 学习Ruby或Python(以及Scala在较小程度上)意味着您将拥有非常可转移的技能 - 您可以使用Java版本,本机版本或.NET版本(IronRuby / IronPython)。 Groovy is nice but JVM-specific. Groovy很好但是特定于JVM。

Being "better prepared for the future" is tricky unless you envisage specific scenarios. 除非你设想特定的场景,否则“为未来做好准备”是很棘手的。 What kind of thing do you want to work on? 你想做什么样的事情? Do you have a project which you could usefully implement in a dynamic language? 您是否有一个可以用动态语言实现的项目? Is it small enough to try on a couple of them, to get a feeling of how they differ? 它是否小到可以尝试其中几个,以了解它们的区别?

Scala is not a dynamic language at all. Scala根本不是一种动态语言。 Type inference doesn't mean that its untyped. 类型推断并不意味着它的无类型。 However, Its a very nice language that has nice mixture of OOPs and functional programming. 然而,它是一种非常好的语言,具有很好的OOP和函数式编程混合。 The only problem is some gotchas that you encounter along the way. 唯一的问题是你在路上遇到的一些陷阱。

Since you are already an experienced Java programmer, it will fit nicely into your skillset. 既然您已经是一名经验丰富的Java程序员,那么它将非常适合您的技能。 Now, if you want to go all the way dynamic both Ruby or Python are awesome languages. 现在,如果你想要一路动态,Ruby或Python都是很棒的语言。 There is demand for both the languages. 需要这两种语言。

I would personally recommend Clojure. 我个人推荐Clojure。 Clojure is an awesome new language that is going in popularity faster than anything I've ever seen. Clojure是一种令人敬畏的新语言,它比我见过的任何东西都更快受欢迎。 Clojure is a powerful, simple, and fast Lisp implemented on the JVM. Clojure是一个在JVM上实现的功能强大,简单,快速的Lisp。 It has access to all Java libraries of course, just like Scala. 它当然可以访问所有Java库,就像Scala一样。 It has a book written about it already, it's matured to version 1.0, and it has three IDE plugins in development, with all three very usable. 它已经有一本关于它的书,它已经成熟到版本1.0,它有三个IDE插件正在开发中,所有三个都非常实用。

I would take a look at Scala. 我会看看Scala。 Why ? 为什么?

  1. it's a JVM language, so you can leverage off your current Java skills 它是一种JVM语言,因此您可以利用当前的Java技能
  2. it now has a lot of tooling/IDE support (eg Intellij will handle Scala projects) 它现在有很多工具/ IDE支持(例如Intellij将处理Scala项目)
  3. it has a functional aspect to it. 它有一个功能方面。 Functional languages seem to be getting a lot of traction at the moment, and I think it's a paradigm worth learning for the future 功能语言目前似乎获得了很大的吸引力,我认为这是一个值得学习未来的范例

My (entirely subjective) view is that Scala seems to be getting a lot of the attention that Groovy got a year or two ago. 我的(完全主观的)观点是,Scala似乎得到了Groovy在一两年前得到的很多关注。 I'm not trying to be contentious here, or suggest that makes it a better language, but it seems to be the new JVM language de jour . 我并不想成为有争议这里,还是建议做一个更好的语言,但它似乎是新的JVM语言怨妇

As an aside, a language that has some dynamic attributes is Microsoft's F# . 另外,具有一些动态属性的语言是Microsoft的F# I'm currently looking at this (and ignoring my own advice re. points 1 and 2 above!). 我目前正在考虑这个问题(忽略了我自己的建议,重点是上面的第1点和第2点!)。 It's a functional language with objects, built on .Net, and is picking up a lot of attention at the moment. 它是一种基于.Net的对象的函数式语言,目前正引起很多关注。

在游戏行业Lua中,如果你是一名基于Adobe的设计师Lua也不错,如果你是一名嵌入式程序员,Lua几乎是唯一的轻量级解决方案,但如果你正在研究Web开发和通用工具脚本Python会更实际

I found Groovy to be a relatively easy jump from an extensive Java background -- it's sort of a more convenient version of Java. 我发现Groovy是从广泛的Java背景中相对容易的跳转 - 它是一种更方便的Java版本。 It integrates really nicely with existing Java code as well, if you need to do that sort of thing. 如果你需要做这样的事情,它也可以很好地与现有的Java代码集成。

I'd recommend Python. 我推荐Python。 It has a huge community and has a mature implementation (along with several promising not-so-mature-just-yet ones). 它有一个庞大的社区,并有一个成熟的实施(以及几个有希望的不那么成熟 - 只是那些)。 Perl is as far as I've seen loosing a lot of traction compared to the newer languages, presumably due to its "non-intuitiveness" (no, don't get me started on that). 与新语言相比,Perl在我看来失去了很多牵引力,可能是因为它的“非直观性”(不,不要让我开始)。

When you've done a project or two in Python, go on to something else to get some broader perspective. 当您在Python中完成一两个项目时,请继续阅读其他内容以获得更广泛的视角。 If you've done a few non-trivial things in two different dynamic languages, you won't have any problems assimilating any other language. 如果你用两种不同的动态语言完成了一些非平凡的事情,你就不会有任何同化任何其他语言的问题。

JScript非常有用,它当然是一种动态语言......

If you want a language with a good number of modules (for almost anything!), go for Perl . 如果你想要一个具有大量模块的语言(几乎任何东西!),请选择Perl With its CPAN , you will always find what you want without reinventing the wheel. 凭借其CPAN ,您将始终找到您想要的东西,而无需重新发明轮子。

Well keeping in mind your background, i would recommend a language where the semantics are similar to what you are aware of. 记住你的背景,我会推荐一种语言,其语义类似于你所知道的。 Hence a language like Scala, Fan, Groovy would be a good starting point.Once you get a hang of the basic semantics of using a functional language(as well as start loving it), you can move onto a language like Ruby. 因此,像Scala,Fan,Groovy这样的语言将是一个很好的起点。一旦你掌握了使用函数式语言的基本语义(以及开始喜欢它),你就可以转向像Ruby这样的语言。 The turn around time for you in this way gets reduced as well as the fact that you can move towards being a polyglot programmer. 以这种方式缩短你的时间,以及你可以成为一个多语言程序员的事实。

i would vote +1 for Groovy (and Grails). 我会为Groovy(和Grails)投票+1。 You can type with Java style or Groovy still (you can also mix both and have no worry about that). 您可以使用Java样式或Groovy进行打字(您也可以将两者混合使用,不必担心)。 Also you can use Java libs. 您也可以使用Java库。

As a general rule, avoid dynamically typed languages. 作为一般规则,请避免使用动态类型语言。 The loss of compile time checking and the self-documenting nature of strong, static typing is well worth the necessity of putting type information into your source code. 编译时检查的丢失和强大的静态类型的自我记录性质非常值得将类型信息放入源代码中。 If the extra typing you need to do when writing your code is too great an effort, then a language with type inference (Scala, Haskell) might be of interest. 如果在编写代码时需要进行额外的输入,那么使用类型推断(Scala,Haskell)的语言可能会引起人们的兴趣。

Having type information makes code much more readable, and readability should be your #1 criteria in coding. 拥有类型信息使代码更具可读性,可读性应该是编码中的第一标准。 It is expensive for a person to read code, anything that inhibits clear, accurate understanding by the reader is a bad thing. 一个人阅读代码是昂贵的,任何阻碍读者清楚,准确理解的东西都是坏事。 In OO languages it is even worse, because you are always making new types. 在OO语言中,它更糟糕,因为你总是在制作新类型。 A reader just getting familiar will flounder because they do not know the types that are being passed around and modified. 刚刚熟悉的读者会挣扎,因为他们不知道传递和修改的类型。 In Groovy, for example, the following is legal def accountHistoryReport(in, out) Reading that, I have no idea what in and out are. 在Groovy中,例如,以下是合法的def accountHistoryReport(in, out)读的是,我不知道inout的。 When you are looking at 20 different report methods that look just like that, you can quickly go completely homicidal. 当您查看20种不同的报告方法时,您可以快速完全杀人。

If you really think you have to have non-static typing, then a language like Clojure is a good compromise. 如果你真的认为你必须有非静态类型,那么像Clojure这样的语言是一个很好的折衷方案。 Lisp-like languages are built on a small set of key abstractions and massive amount of capability on each of the abstractions. 类似Lisp的语言建立在一小组关键抽象上,并且每个抽象都具有大量的功能。 So in Clojure, I will create a map (hash) that has the attributes of my object. 所以在Clojure中,我将创建一个具有my对象属性的map(hash)。 It is a bit reductionalist, but I will not have to look through the whole code base for the implementation of some un-named class. 它有点简化,但我不需要查看整个代码库来实现一些未命名的类。

My rule of thumb is that I write scripts in dynamic languages, and systems in compiled, statically typed languages. 我的经验法则是我用动态语言编写脚本,用编译的静态类型语言编写系统。

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

相关问题 哪种动态语言可以轻松使用其他语言的库? - Which dynamic language can easily use libraries from other languages? 我应该首先启动哪个Rails服务器或sidekiq? - Which one should I start first rails server or sidekiq? 我应该通过OS平台选择gem依赖吗? - Should I choose gem dependencies by OS platform? 我应该使用 rails 6.1.3.2 还是 rails 6.1.4(最新版本)? - which rails version should i use rails 6.1.3.2 or rails 6.1.4 (which is the latest one)? 语言轨道的动态路径 - dynamic path with languages rails 您在Scala中缺少的动态语言(如Ruby或Clojure)的功能有哪些? - What are the features of dynamic languages (like Ruby or Clojure) which you are missing in Scala? 对于ActiveRecord一对多关联,我应该设置:foreign_key选项? - For an ActiveRecord one-to-many association, which :foreign_key option should I set? 如何选择要在Ruby中动态包含的模块版本? - How can I choose which version of a module to include dynamically in Ruby? 哪些语言支持“动态”元编程? - What languages support “dynamic” metaprogramming? therubyracer或nodejs,我应该使用哪个? - therubyracer or nodejs, which should I use?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM