mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-02-28 01:01:09 +08:00
Update 20210523 3 reasons to learn Java in 2021.md
This commit is contained in:
parent
25cc578d8a
commit
cb54eb2cbb
@ -23,9 +23,9 @@ Java是在1995年发布的,当我写这篇文章的时候,它已经26岁了
|
||||
|
||||
### 1\. 一次编码, 任意环境都能跑通
|
||||
|
||||
如果代码只能在特定的操作系统和环境下运行,那这会很令人惊讶甚至是失望的。代码必须从一种对人友好的高级程序设计语言编译成机器语言,即被设计可以用于响应CPU的一系列二进制指令。It feels arcane in the world of advanced computers that we can't just write code and send it to anyone who wants to run it without worrying about what platform they're on.
|
||||
如果代码只能在特定的操作系统和环境下运行,那这会很令人惊讶甚至是失望的。代码必须从一种对人友好的高级程序设计语言编译成机器语言,即被设计可以用于响应CPU的一系列二进制指令。在先进的计算机世界中,我们很难理解为什么不能仅仅编写代码后,就能将它发送给任何一个想要稳定运行它的平台,而且无需担忧它们处在什么样的平台中。
|
||||
|
||||
Java is the solution to this incongruity. It's the realization of cross-platform code that works the same across any system you run it on. Java's approach to achieving this feat is counterintuitive at first. In a way, Java isn't compatible with anything but one computer. Stranger still, this computer doesn't actually exist. The computer that Java code targets is the Java Virtual Machine (JVM). This is a program written by Java's creators and distributed for practically any computing device you can think of. As long as you have it installed, any Java code you run is handled by this "imaginary" computer living inside your computer. 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 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.
|
||||
|
||||
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.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user