也许现在还不注销scala

As programmers, we care about what programming languages other programmers are using. Scala shows a 0.2% decline in the PYPL index. The trends on Google and YouTube are also discouraging. Therefore, no one should bother to learn Scala, right?

作为程序员,我们关心其他程序员使用什么编程语言。 Scala的PYPL指数下降了0.2%。 Google和YouTube上的趋势也令人沮丧。 因此,没有人应该去学习Scala,对吗?

For perspective, Java is currently at #2 on the PYPL despite a 3.1% decline, and Kotlin is at #12 with a 0.1% increase.

从角度来看,尽管下降了3.1%,Java在PYPL上目前排名第二,而Kotlin则在0.1%的情况下排名第12。

The inescapable conclusion would seem to be that if you like the Java Virtual Machine (JVM), then Java is the language to learn, and neither Kotlin nor Scala are worth learning.

不可避免的结论似乎是,如果您喜欢Java虚拟机(JVM),那么Java是要学习的语言,而Kotlin和Scala都不值得学习。

But Java is itself a language that has been written off many times before, perhaps for as long as it has existed. Java did fail to become as ubiquitous as its namesake, the superficially similar JavaScript. And yet now JavaScript is behind Java on the PYPL at #3.

但是Java本身是一种已经被多次注销的语言,也许已经存在了很长时间。 Java确实没有像其同名的表面相似JavaScript那样普遍存在。 但是现在,JavaScript在PYPL上排名第三,落后于Java。

To focus so narrowly on the trends for a programming language is to ignore what it is, what it’s used for, what it’s good at and what it’s not so good at.

如此狭on地关注一种编程语言的趋势就是忽略它的用途,用途,优缺点。

Consider COBOL, for example. It shows a slight upward trend on the PYPL. Maybe if the coronavirus pandemic had been handled in a caring and competent manner, COBOL would show a slight decrease on the PYPL.

例如,考虑使用COBOL。 PYPL略有上升趋势。 也许如果冠状病毒大流行得到了认真和有力的处理,COBOL的PYPL会略有下降。

Some people would be amazed that it’s on the PYPL at all. But, regardless of the trend, the reasons for COBOL programs to still be used today would not magically disappear based on current events.

有些人会对PYPL上的所有内容感到惊讶。 但是,不管趋势如何,今天仍然使用COBOL程序的原因不会根据当前事件而神奇地消失。

There is a debate as to whether or not it’s time to move old mainframes away from COBOL. It’s not a debate I care to weigh in on without knowing a lot more about what COBOL than I currently know.

关于是否应该将旧的大型机从COBOL移开,目前尚有争议。 在不了解比我目前所了解的更多的COBOL知识的情况下,我不打算参加辩论。

So, what is Scala? What is it used for? What’s it good at?And what is it not so good at?

那么,什么是Scala? 它是干什么用的? 擅长什么?不擅长什么?

Scala is an object-oriented programming language with a lot of functional features. Maybe the perception of Scala as some kind of JVM Haskell has hurt its popularity. Scala is not that.

Scala是一种具有许多功能的面向对象编程语言。 也许将Scala作为某种JVM Haskell的看法损害了它的流行性。 Scala不是那样。

Scala was invented by Martin Odersky, who wrote the Java 1.3 compiler. But Java wasn’t evolving as fast as he would have liked it to. Thus Scala is what Odersky wished Java had become, and more.

Scala是由编写Java 1.3编译器的Martin Odersky发明的。 但是Java并没有像他希望的那样发展。 因此,Scala是Odersky希望Java成为甚至更多的东西。

This means that Scala can be used for anything that Java can be used for, and it can use any Java library. And Scala libraries can be used by Java programs, though with a few caveats.

这意味着Scala可以用于Java可以使用的任何东西,并且可以使用任何Java库。 Java程序也可以使用Scala库,但有一些警告。

I for one use JUnit to test Scala, and I have yet to see a reason to use ScalaTest. Presumably Kafka can be used with Scala, but Scala programmers seem to prefer Akka, which can also be used by Java programs.

我曾经使用JUnit测试Scala,但我还没有看到使用ScalaTest的理由。 大概Kafka可以与Scala一起使用,但是Scala程序员似乎更喜欢Akka,它也可以由Java程序使用。

Despite Scala being a general purpose language, it seems to have gotten a reputation as being mostly for big data and machine learning.

尽管Scala是一种通用语言,但它似乎已经在大多数大数据和机器学习中赢得了声誉。

There are a few things for which using Scala is inadvisable or close to impossible. Some people have used Scala for Android programming, but when I tried to I ran into way too many problems. Probably better to go with Java or Kotlin for Android programming.

在某些情况下,建议不要使用Scala或几乎不可能使用Scala。 有些人已经将Scala用于Android编程,但是当我尝试这样做时,遇到了太多问题。 使用Java或Kotlin进行Android编程可能更好。

I would also advise against trying to use Scala for embedded systems. It’s probably no good for operating systems either. But then again, I wouldn’t advise using Java for embedded systems or operating systems either.

我也建议不要尝试将Scala用于嵌入式系统。 这对操作系统也可能没有好处。 但是话又说回来,我也不建议将Java用于嵌入式系统或操作系统。

If we’re going to write off a programming language, we should at least look at a little program, a toy example, written in that language. Nothing too complicated, but just a little more involved than Hello World.

如果要编写一种编程语言,至少应该看一个用该语言编写的小程序,一个玩具示例。 没什么复杂的,但是比“ Hello World”更复杂。

Let’s say you want a list of world currencies sorted by their 3-letter codes in ISO-4217 and you also want that list sorted by their numeric codes. Not sure why anyone would want that, but it’s easy enough to do in Scala.

假设您想要一个按ISO-4217中的3个字母代码排序的世界货币列表,并且还希望按其数字代码排序的列表。 不知道为什么有人会这样,但是在Scala中做起来很容易。

The Java Runtime Environment provides a list of currencies, so we can just access those by importing a Java package.

Java运行时环境提供了货币列表,因此我们只需导入Java包即可访问货币。

import java.util.Currency
import scala.jdk.CollectionConverters._val currencies = Currency.getAvailableCurrencies.asScala.toList
currencies.sortBy(_.getSymbol)
currencies.sortBy(_.getNumericCode)

I have this in a Scastie snippet that you can access from Firefox or Chrome, and probably also Edge and Safari.

我在Scastie代码段中提供了该代码,您可以从Firefox或Chrome浏览器访问它,也可以从Edge和Safari访问。

The first sorted list starts with United States dollars (USD), which is wrong — but that’s my fault for forgetting that getSymbol() depends on the locale, which in my case puts USD as “$”, and thus ahead of all the others, even Andorran pesetas (ADP) and United Arab Emirates darahim (AED).

第一个排序的列表以美元(USD)开头,这是错误的-但这是我的错,因为忘记了getSymbol()取决于语言环境,在我的情况下,该语言环境将USD表示为“ $”,因此在所有其他语言之前,甚至安道尔比塞塔(ADP)和阿拉伯联合酋长国达拉希姆(AED)。

I should have used toString() instead of getSymbol(). If you have the Scastie snippet open in another tab, I encourage you to make that change, click “Save” and see that USD gets moved to later on in the list.

我应该使用toString()而不是getSymbol() 。 如果您在另一个标签中打开了Scastie摘录,则建议您进行更改,单击“保存”,然后将USD移至列表的后面。

The second sorted list consists of French UIC francs (XFU, 0), French gold francs (XFO, also 0), the old Afghan Afghani (AFA, 4), Albanian leks (ALL, 8), Algerian dinars (DZD, 12), etc.

第二个排序的列表包括法国UIC法郎(XFU,0),法国金法郎(XFO,也为0),旧阿富汗阿富汗尼(AFA,4),阿尔巴尼亚列克(ALL,8),阿尔及利亚第纳尔(DZD,12)等

Obviously we can also accomplish this in Java. But we would have to create two different comparators, which would be very verbose even if we implemented them as anonymous classes. And still more comparators if we wanted to sort by other fields.

显然,我们也可以在Java中完成此操作。 但是我们将不得不创建两个不同的比较器,即使我们将它们实现为匿名类也非常冗长。 如果我们想按其他字段排序,还有更多的比较器。

Most programming languages are very similar to each other. Maybe you don’t need to program load lifters anymore. But you might just find yourself in a situation in which you need to program moisture vaporators.

大多数编程语言彼此非常相似。 也许您不再需要对起重器进行编程。 但是您可能会发现自己处于需要对水分蒸发器进行编程的情况。

So I wouldn’t write off the binary language of load lifters. The galaxy might just depend on it some day.

因此,我不会取消负载提升器的二进制语言。 这个星系可能有一天会依赖它。

翻译自: https://medium.com/@alonso.delarte/maybe-dont-write-off-scala-just-yet-f0c128a570f0

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值