Update 20210523 3 reasons to learn Java in 2021.md

This commit is contained in:
菜梨子 2021-06-10 21:21:01 +08:00 committed by GitHub
parent cb54eb2cbb
commit b1c8ba0204
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,15 +25,15 @@ Java是在1995年发布的当我写这篇文章的时候它已经26岁了
如果代码只能在特定的操作系统和环境下运行那这会很令人惊讶甚至是失望的。代码必须从一种对人友好的高级程序设计语言编译成机器语言即被设计可以用于响应CPU的一系列二进制指令。在先进的计算机世界中我们很难理解为什么不能仅仅编写代码后就能将它发送给任何一个想要稳定运行它的平台而且无需担忧它们处在什么样的平台中。
Java 是解决这种不协调的方法。它的代码是可以跨平台进行工作的在任何运行它的系统上都可以执行相同的工作。Java 实现这一壮举的方法起初是有驳常理的。在某种程度上Java 只与一台计算机兼容。更奇怪的是这台电脑实际上并不存在。Java 代码的目标计算机是 Java 虚拟机 (JVM)。这是一个由Java的创建者编写的程序实际上可用于您能想到的任何计算设备。只要您安装了它您运行的任何 Java 代码都会由位于您计算机中的这台“虚拟”计算机进行处理。 Java code is executed by the JVM, which sends appropriate platform-specific instructions to your computer, so everything works the same on every OS and architecture.
Java 是解决这种不协调的方法。它的代码是可以跨平台进行工作的在任何运行它的系统上都可以执行相同的工作。Java 实现这一壮举的方法起初是有驳常理的。在某种程度上Java 只与一台计算机兼容。更奇怪的是这台电脑实际上并不存在。Java 代码的目标计算机是 Java 虚拟机 (JVM)。这是一个由Java的创建者编写的程序实际上可用于您能想到的任何计算设备。只要您安装了它您运行的任何 Java 代码都会由位于您计算机中的这台“虚拟”计算机进行处理。Java 代码由 JVM 执行VM向您的计算机发送适当的特定于平台的指令因此所有内容在每个操作系统和架构上都相同。
Of course, the method used by Java isn't really the selling point here. Most users and many developers don't care how software compatibility is achieved, only that it happens. Many languages promise cross-platform functionality, and usually, that promise is ultimately true, but the journey isn't always easy. Programming languages must be compiled for their target platforms, scripting languages require platform-specific interpreters, and it's rare that either can ensure consistent access to low-level system resources. Cross-platform support is getting better and better, with libraries to help with translating paths and environment variables and settings, and some frameworks (notably [Qt][2]) do much to bridge the gap for peripheral access. But Java has it and delivers it consistently and reliably.
当然Java 使用的方法并不是真正的卖点。大多数用户和许多开发人员并不关心软件兼容性是如何实现的,只关心它是否具备兼容性。许多语言都承诺提供跨平台的功能,而且通常情况下,这个承诺最终都是真的,但是这个过程并不总是容易的。编程语言必须针对其目标平台进行编译,脚本语言需要特定于平台的解释器,而且两者都很难确保对底层系统资源的一致访问。跨平台支持越来越好,库可以帮助转换路径、环境变量和设置,并且一些框架(特别是 [Qt][2])在弥补外设访问的差距方面做了很多工作。但是 Java 拥有兼容性,并始终可靠地提供它。
### 2\. Sensible code
### 2\. 明智的代码
Java's syntax is boring in the best of ways. If you took all the popular programming languages and put them in a rock tumbler, Java is what you'd get. Looking at source code written in Java, you more or less see the average of all the unique expressions of programming. Brackets indicate the scope of functions and flow control, variables are clearly declared and instantiated before being used, and there's a clear and consistent structure to expressions.
Java 的语法即使是在最好的方面都很无聊。如果你把所有流行的编程语言都放在一个摇滚杯中,那么你会得到 Java。 看看用Java编写的源代码您或多或少会看到编程中所有唯一表达式的平均值。括号表示函数和流程控制的范围变量在使用前被清楚地声明和实例化并且表达式具有清晰一致的结构。
I've found that learning Java often encourages self-taught programmers using less structured languages to write smarter code. There are lots of "basic" programming lessons you can't learn by gleaning techniques from source code you study online, such as keeping global variable declarations together in the style of Java's public fields, properly anticipating and handling exceptions, using classes and functions, and more. Little touches borrowed from Java can make a big difference.
我发现Java学习过程中通常会鼓励自学的程序员使用结构较少的语言编写更精炼的代码。有许多“基本”编程课程是无法通过从在线学习的源代码中收集技术来学习的比如将全局变量声明保持在Java公共字段的风格中、正确地预测和处理异常、使用类和函数、和许多其他的技术。从Java借鉴的一点小改动可以产生很大的不同。
### 3\. Scaffolding and support