mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-29 21:41:00 +08:00
commit
a38c52c4da
55
published/20201012 My top 7 keywords in Rust.md
Normal file
55
published/20201012 My top 7 keywords in Rust.md
Normal file
@ -0,0 +1,55 @@
|
||||
[#]: collector: "lujun9972"
|
||||
[#]: translator: "mcfd"
|
||||
[#]: reviewer: "wxy"
|
||||
[#]: publisher: "wxy"
|
||||
[#]: url: "https://linux.cn/article-13589-1.html"
|
||||
[#]: subject: "My top 7 keywords in Rust"
|
||||
[#]: via: "https://opensource.com/article/20/10/keywords-rust"
|
||||
[#]: author: "Mike Bursell https://opensource.com/users/mikecamel"
|
||||
|
||||
我的 7 大 Rust 关键字
|
||||
======
|
||||
|
||||
> 从 Rust 标准库学习一些有用的关键字。
|
||||
|
||||
![Rustacean t-shirt][1]
|
||||
|
||||
我使用 [Rust][2] 已经有几个月了,写的东西比我预期的要多——尽管随着我的学习,我改进了所写的代码,并完成了一些超出我最初意图的更复杂的任务,相当多的东西已经被扔掉了。
|
||||
|
||||
我仍然喜欢它,并认为谈论一些在 Rust 中反复出现的重要关键字可能会有好处。我会提供我个人对它们的作用的总结:为什么你需要考虑如何使用它们,以及任何其他有用的东西,特别是对于刚接触 Rust 的新手或来自另一种语言的人(如 Java;请阅读我的文章 [为什么作为一个 Java 程序员的我喜欢学习 Rust][3])。
|
||||
|
||||
事不宜迟,让我们开始吧。获取更多信息的好地方总是 Rust 官方文档 —— 你可能想从 [std 标准库][4]开始。
|
||||
|
||||
1. `const` – 你可以用 `const` 来声明常量,而且你应该这样做。虽然这不是造火箭,但请一定要用 `const` ,如果你要在不同的模块中使用常量,那请创建一个 `lib.rs` 文件(Rust 默认的),你可以把所有的常量放在一个命名良好的模块中。我曾经在不同模块的不同文件中发生过 `const` 变量名(和值)的冲突,仅仅是因为我太懒了,除了在不同文件中剪切和粘贴之外,我本可以通过创建一个共享模块来节省大量的工作。
|
||||
2. `let` – 你并不 _总是_ 需要用 `let` 语句声明一个变量,但当你这样做时你的代码会更加清晰。此外,如果可以,请一定要添加变量类型。Rust 会尽最大努力猜测它应该是什么类型的变量,但它不一定总能在运行时做到这一点(在这种情况下,编译器 [Cargo][5] 会提示你),它甚至可能做不到你期望的那样。在后一种情况下,对于 Cargo 来说,抱怨你所赋值的函数(例如)与声明不一致,总比 Rust 试图帮助你做错事,而你却不得不在其他地方花费大量时间来进行调试要简单。
|
||||
3. `match` – `match` 对我来说是新鲜事物,我喜欢使用它。它与其他编程语言中的 `switch` 没有什么不同,但在 Rust 中被广泛使用。它使代码更清晰易读,如果你做了一些愚蠢的事情(例如错过一些可能的情况),Cargo 会很好地提示你。我一般的经验法则是,在管理不同的选项或进行分支时,如果可以使用 `match`,那就请一定要使用它。
|
||||
4. `mut` – 在声明一个变量时,如果它的值在声明后会发生变化,那么你需要声明它是可变的(LCTT 译注:Rust 中变量默认是不可变的)。常见的错误是在某个变量 _没有_ 变化的情况下声明它是可变的,这时编译器会警告你。如果你收到了 Cargo 的警告,说一个可变的变量没有被改变,而你认为它被 _改变_ 了,那么你可能要检查该变量的范围,并确保你使用的是正确的那个。
|
||||
5. `return` – 实际上我很少使用 `return`,它用于从函数中返回一个值,但是如果你只是在函数的最后一行提供值(或提供返回值的函数),通常会变得更简单,能更清晰地阅读。警告:在很多情况下,你 _会_ 忘记省略这一行末尾的分号(`;`),如果你这样做,编译器会不高兴的。
|
||||
6. `unsafe` – 如其意:如果你想做一些不能保证 Rust 内存安全的事情,那么你就需要使用这个关键字。我绝对无意在现在或将来的任何时候宣布我的任何 Rust 代码不安全;Rust 如此友好的原因之一是它阻止了这种黑客行为。如果你真的需要这样做,再想想,再想想,然后重新设计代码。除非你是一个非常低级的系统程序员,否则要 _避免_ 使用 `unsafe`。
|
||||
7. `use` – 当你想使用另一个 crate 中的东西时,例如结构体、变量、函数等,那么你需要在你要使用它的代码的代码块的开头声明它。另一个常见的错误是,你这样做了,但没有在 `Cargo.toml` 文件中添加该 crate (最好有一个最小版本号)。
|
||||
|
||||
我知道,这不是我写过的最复杂的文章,但这是我在开始学习 Rust 时会欣赏的那种文章。我计划在关键函数和其他 Rust 必知知识方面编写类似的文章:如果你有任何要求,请告诉我!
|
||||
|
||||
* * *
|
||||
|
||||
_本文最初发表于 [Alice, Eve, and Bob][6] 经作者许可转载。_
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/10/keywords-rust
|
||||
|
||||
作者:[Mike Bursell][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[mcfd](https://github.com/mcfd)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/mikecamel
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rustacean-tshirt.jpg?itok=u7LBmyaj "Rustacean t-shirt"
|
||||
[2]: https://www.rust-lang.org/
|
||||
[3]: https://opensource.com/article/20/5/rust-java
|
||||
[4]: https://doc.rust-lang.org/std/
|
||||
[5]: https://doc.rust-lang.org/cargo/
|
||||
[6]: https://aliceevebob.com/2020/09/01/rust-my-top-7-keywords/
|
@ -3,22 +3,27 @@
|
||||
[#]: author: (Ankush Das https://news.itsfoss.com/author/ankush/)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (zz-air)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13588-1.html)
|
||||
|
||||
Windows 11 能影响 Linux 发行版吗?
|
||||
======
|
||||
|
||||
微软的 Windows11 终于发布了。 有些人将其与 macOS 进行比较,另一些人则比较其本质细节以找到与 GNOME 和 KDE 的相似之处(这没有多大意义)。
|
||||
> Windows 11 正在为全球的桌面用户制造新闻。它会影响 Linux 发行版走向桌面用户吗?
|
||||
|
||||
但是,在所以的热议中,我对另一件事很好奇—— **微软的 Windows 11 能影响桌面 Linux 发行版未来的决策吗?**
|
||||
![](https://i1.wp.com/news.itsfoss.com/wp-content/uploads/2021/07/windows-linux-desktop-influence.png?w=1200&ssl=1)
|
||||
|
||||
在这里,如果它以前发生过,我将提到一些我的想法,关于它为什么会发生,以及 Linux 发行版未来会发生什么。
|
||||
微软的 Windows11 终于发布了。有些人将其与 macOS 进行比较,另一些人则比较其细枝末节发现与 GNOME 和 KDE 的相似之处(这没有多大意义)。
|
||||
|
||||
但是,在所有的热议当中,我对另一件事很好奇—— **微软的 Windows 11 能影响桌面 Linux 发行版未来的决策吗?**
|
||||
|
||||
在这里,我将提到一些我的想法,即如果它以前发生过,为什么会发生?以及 Linux 发行版未来会怎样。
|
||||
|
||||
### 一些 Linux 发行版已经关注类似 Windows 的体验:但是,为什么呢?
|
||||
|
||||
微软的 Windows 是最受欢迎的桌面操作系统,因其易操作、软件支持和硬件兼容占据了 88% 的市场分额。
|
||||
|
||||
相反, Linux 占有 **大约 2% 的市场分额,** [即使 Linux 比 Windows 有更多的优势][1]。
|
||||
|
||||
那么 Linux 能做什么来说服更多的用户将 Linux 作为他们的桌面操作系统呢?
|
||||
@ -30,7 +35,9 @@ Windows 11 能影响 Linux 发行版吗?
|
||||
而且,由于这些发行版的存在,[在 2021 年切换到 Linux][3] 比以往任何时候都更有意义。
|
||||
|
||||
因此,为了让更多的用户跳转到 Linux ,微软 Window 多年来已经影响了许多发行版。
|
||||
|
||||
### Windows 11 在某些方面比 Linux 好?
|
||||
|
||||
用户界面随着 Windows 的发展而不断的发展。即使这是主观的,它似乎是大多数桌面用户的选择。
|
||||
|
||||
所以我要说 Windows 11 在这方面做了一些有吸引力的改进。
|
||||
@ -41,26 +48,25 @@ Windows 11 能影响 Linux 发行版吗?
|
||||
|
||||
**虽然 Linux 发行版没有自己成熟的服务,但是像这样定制的更多开箱即用的集成,应该会使新用户更容易上手。**
|
||||
|
||||
并且这让我想起了 Windows 11 的另一个方面——一个个性化的欣慰和信息提要。
|
||||
并且这让我想起了 Windows 11 的另一个方面——个性化的新闻和信息提要。
|
||||
|
||||
当然,微软会为此收集数据,你可能需要使用微软账号登录。但这也减少了用户寻找独立应用程序来跟踪天气、新闻和其他日常信息。
|
||||
当然,微软会为此收集数据,你可能需要使用微软账号登录。但这也减少了用户寻找独立应用程序来跟踪天气、新闻和其他日常信息的摩擦。
|
||||
|
||||
Linux 不会强迫用户做出这些选择,但是像这样的特性/集成可以作为额外的选项添加,可以以选择的形式呈现给用户。
|
||||
|
||||
**换句话说,在与操作系统集成的同时使事物更容易访问,应该可以摆脱陡峭的学习曲线。**
|
||||
**换句话说,在与操作系统集成的同时,使事物更容易访问,应该可以摆脱陡峭的学习曲线。**
|
||||
|
||||
而且,可怕的微软商店也在 Windows 11 上进行了重大升级。
|
||||
|
||||
![][5]
|
||||
|
||||
不幸的是,对于 Linux 发行版,我没有看到对应用中心进行有意义的升级,来使其在视觉上更吸引人,更有趣。
|
||||
不幸的是,对于 Linux 发行版,我没有看到对应用中心进行多少有意义的升级,来使其在视觉上更吸引人,更有趣。
|
||||
|
||||
|
||||
elementaryOS 可能正努力专注于 UX/UI ,并发展应用中心的体验,但对于大多数其他发行版,没有重大的升级。
|
||||
elementaryOS 可能正努力专注于 UX/UI ,并不断发展应用中心的体验,但对于大多数其他发行版,没有重大的升级。
|
||||
|
||||
![Linux Mint 20.1 中的软件管理器][6]
|
||||
|
||||
虽然我很欣赏 Deepin Linux 在这方面所做的,但它并不是许多用户第一次尝试 Linux 时的热门选择。
|
||||
虽然我很欣赏深度 Linux 在这方面所做的,但它并不是许多用户第一次尝试 Linux 时的热门选择。
|
||||
|
||||
### Windows 11 引入了更多的竞争:Linux 必须跟上
|
||||
|
||||
@ -68,29 +74,24 @@ elementaryOS 可能正努力专注于 UX/UI ,并发展应用中心的体验,
|
||||
|
||||
虽然在 Linux 世界中,我们确实有一些 Windows 10 经验的替代品,但还没有针对 Windows 11 的。
|
||||
|
||||
但这让我们看到了来自 Linux 社区的明显回应—— **在 Windows 11 上使用 dab 的 Linux 发行版**.
|
||||
但这让我们看到了来自 Linux 社区的明显反击—— **一个针对 Windows 11 的 Linux 发行版**。
|
||||
|
||||
不管是讨厌还是喜欢微软最新的 Windows 11 设计方案,在接下来的几年里,大众将会接受它。
|
||||
|
||||
并且,为了使 Linux 成为一个引人注目的桌面替代品,Linux 发行版的设计语言也必须发展。
|
||||
|
||||
不仅仅是桌面市场————还有笔记本专用的设计选择————也需要对 Linux 发行版进行显著改进。
|
||||
不仅仅是桌面市场,还有笔记本专用的设计选择也需要对 Linux 发行版进行重大改进。
|
||||
|
||||
有些选择想 [Pop!_OS_System 76 ][7] 一直试图为 Linux 提供这种体验,这是一个良好的开端。
|
||||
像 [Pop!_OS_System 76][7] 这些选择一直试图为 Linux 提供这种体验,这是一个良好的开端。
|
||||
|
||||
我认为 Zorin 操作系统开源作为一个发行版引入 “**Windows 11**” 布局作为一个选择,让更多用户尝试 Linux。
|
||||
别忘了——在 windows 11 将 Android 应用程序支持作为一项功能推向市场之后,[Deepin Linux 就引入了 Android 应用程序支持。][8]
|
||||
我认为 Zorin OS 可以作为一个引入 “**Windows 11**” 布局的发行版,作为让更多用户尝试 Linux 的一个选择。
|
||||
|
||||
所以,你看,当微软的 Windows 采取行动时,对 Linux 也会产生连锁反应。而 Deepin Linux 的 Android 应用支持只是一个开始......让我们看看接下来还会出现什么。
|
||||
别忘了,在 Windows 11 将 Android 应用程序支持作为一项功能推向市场之后,[深度 Linux 就引入了 Android 应用程序支持。][8]
|
||||
|
||||
所以,你看,当微软的 Windows 采取行动时,对 Linux 也会产生连锁反应。而深度 Linux 的 Android 应用支持只是一个开始……让我们看看接下来还会出现什么。
|
||||
|
||||
_你对 Windows 11 影响 Linux 桌面的未来有什么看法?我们也需要进化吗?或者我们应该继续与众不同,不受大众选择的影响?_
|
||||
|
||||
#### 大型科技网站获得数百万美元的收入, 是自由/开源软件吸引了你!
|
||||
|
||||
如果你喜欢我们的自由/开源软件,请考虑捐款支持我们的独立出版。您的支持将帮助我们继续发布专注于桌面 Linux 和开源软件的内容。
|
||||
|
||||
我不感兴趣
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://news.itsfoss.com/can-windows-11-influence-linux/
|
||||
@ -98,7 +99,7 @@ via: https://news.itsfoss.com/can-windows-11-influence-linux/
|
||||
作者:[Ankush Das][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[zz-air](https://github.com/zz-air)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
@ -107,8 +108,8 @@ via: https://news.itsfoss.com/can-windows-11-influence-linux/
|
||||
[1]: https://itsfoss.com/linux-better-than-windows/
|
||||
[2]: https://itsfoss.com/windows-like-linux-distributions/
|
||||
[3]: https://news.itsfoss.com/switch-to-linux-in-2021/
|
||||
[4]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQ4OCIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4=
|
||||
[5]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjUyMCIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4=
|
||||
[6]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjY0OSIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4=
|
||||
[4]: https://i1.wp.com/news.itsfoss.com/wp-content/uploads/2021/07/windows-11-home.png?w=1024&ssl=1
|
||||
[5]: https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2021/07/windows-10-app-store.png?w=1024&ssl=1
|
||||
[6]: https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2021/07/software-manager-linux-mint.png?w=862&ssl=1
|
||||
[7]: https://pop.system76.com
|
||||
[8]: https://news.itsfoss.com/deepin-linux-20-2-2-release/
|
@ -4,40 +4,40 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: (turbokernel)
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13592-1.html)
|
||||
|
||||
在 Linux 上用密码加密和解密文件
|
||||
======
|
||||
age 是一个简单的、易于使用的工具,允许你用一个密码来加密和解密文件。
|
||||
![Scissors cutting open access to files][1]
|
||||
|
||||
文件的保护和敏感文档的安全加密是用户长期以来关心的问题。即使越来越多的数据被存放在网站和云服务上,并由带有越来越安全和高强度密码的用户账户来保护,但我们能够在自己的文件系统中存储敏感数据仍有很大的价值,特别是我们能够快速和容易地加密这些数据时。
|
||||
> age 是一个简单的、易于使用的工具,允许你用一个密码来加密和解密文件。
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202107/18/102604m808ppq4ddd8w910.jpg)
|
||||
|
||||
文件的保护和敏感文档的安全加密是用户长期以来关心的问题。即使越来越多的数据被存放在网站和云服务上,并由具有越来越安全和高强度密码的用户账户来保护,但我们能够在自己的文件系统中存储敏感数据仍有很大的价值,特别是我们能够快速和容易地加密这些数据时。
|
||||
|
||||
[age][2] 能帮你这样做。它是一个小型且易于使用的工具,允许你用一个密码加密一个文件,并根据需要解密。
|
||||
|
||||
### 安装 age
|
||||
|
||||
age 可以在众多 Linux 软件库中[安装][3]。
|
||||
`age` 可以从众多 Linux 软件库中 [安装][3]。
|
||||
|
||||
在 Fedora 上安装它:
|
||||
|
||||
|
||||
```
|
||||
`$ sudo dnf install age -y`
|
||||
$ sudo dnf install age -y
|
||||
```
|
||||
|
||||
在 macOS 上,使用 [MacPorts][4] 或 [Homebrew][5] 来安装。在 Windows 上,使用 [Chocolatey][6] 来安装。
|
||||
|
||||
### 用 age 加密和解密文件
|
||||
|
||||
age 可以用公钥或用户自定义密码来加密和解密文件。
|
||||
`age` 可以用公钥或用户自定义密码来加密和解密文件。
|
||||
|
||||
#### 在 age 中使用公钥
|
||||
|
||||
首先,生成一个公钥并写入 `key.txt` 文件:
|
||||
|
||||
|
||||
```
|
||||
$ age-keygen -o key.txt
|
||||
Public key: age16frc22wz6z206hslrjzuv2tnsuw32rk80pnrku07fh7hrmxhudawase896m9
|
||||
@ -47,55 +47,53 @@ Public key: age16frc22wz6z206hslrjzuv2tnsuw32rk80pnrku07fh7hrmxhudawase896m9
|
||||
|
||||
要用你的公钥加密一个文件:
|
||||
|
||||
|
||||
```
|
||||
`$ touch mypasswds.txt | age -r ageage16frc22wz6z206hslrjzuv2tnsuw32rk80pnrku07fh7hrmxhudawase896m9 > mypass.tar.gz.age`
|
||||
$ touch mypasswds.txt | age -r \
|
||||
ageage16frc22wz6z206hslrjzuv2tnsuw32rk80pnrku07fh7hrmxhudawase896m9 \
|
||||
> mypass.tar.gz.age
|
||||
```
|
||||
|
||||
在这个例子中,文件 `mypasswds.txt` 被我使用生成的公钥加密,放保存在名为 `mypass.tar.gz.age` 的加密文件中。
|
||||
在这个例子中,我使用生成的公钥加密文件 `mypasswds.txt`,保存在名为 `mypass.tar.gz.age` 的加密文件中。
|
||||
|
||||
### 用公钥解密
|
||||
|
||||
如需解密加密文件,使用 `age` 命令和 `--decrypt` 选项:
|
||||
|
||||
|
||||
```
|
||||
`$ age --decrypt -i key.txt -o mypass.tar.gz mypass.tar.gz.age`
|
||||
$ age --decrypt -i key.txt -o mypass.tar.gz mypass.tar.gz.age
|
||||
```
|
||||
|
||||
在这个例子中,age 使用存储在 `key.text` 中的密钥,并解密了我在上一步创建的加密文件。
|
||||
在这个例子中,`age` 使用存储在 `key.text` 中的密钥,并解密了我在上一步创建的加密文件。
|
||||
|
||||
### 使用密码加密
|
||||
|
||||
不使用公钥的情况下对文件进行加密被称为对称加密。它允许用户设置密码来加密和解密一个文件。要做到这一点:
|
||||
|
||||
|
||||
```
|
||||
$ age --passphrase --output mypasswd-encrypted.txt mypasswd.txt
|
||||
Enter passphrase (leave empty to autogenerate a secure one):
|
||||
Confirm passphrase:
|
||||
```
|
||||
|
||||
在这个例子中,age 提示你输入一个密码,它将通过这个密码对输入文件 `mypasswd.txt` 进行加密,并生成加密文件 `mypasswd-encrypted.txt`。
|
||||
在这个例子中,`age` 提示你输入一个密码,它将通过这个密码对输入文件 `mypasswd.txt` 进行加密,并生成加密文件 `mypasswd-encrypted.txt`。
|
||||
|
||||
### 使用密码解密
|
||||
|
||||
如需将用密码加密的文件解密,可以使用 `age` 命令和 `--decrypt` 选项:
|
||||
|
||||
|
||||
```
|
||||
`$ age --decrypt --output passwd-decrypt.txt mypasswd-encrypted.txt`
|
||||
$ age --decrypt --output passwd-decrypt.txt mypasswd-encrypted.txt
|
||||
```
|
||||
|
||||
在这个例子中,age 提示你输入密码,只要你提供的密码与加密时设置的密码一致,age 随后将 `mypasswd-encrypted.txt` 加密文件的内容解密为 `passwd-decrypt.txt`。
|
||||
在这个例子中,`age` 提示你输入密码,只要你提供的密码与加密时设置的密码一致,`age` 随后将 `mypasswd-encrypted.txt` 加密文件的内容解密为 `passwd-decrypt.txt`。
|
||||
|
||||
### 不要丢失你的密钥
|
||||
|
||||
无论你是使用密码加密还是公钥加密,你都_不能_丢失加密数据的凭证。根据设计,如果没有用于加密的密钥,通过 age 加密的文件是不能被解密的。所以,请备份你的公钥,并记住这些密码!
|
||||
无论你是使用密码加密还是公钥加密,你都_不能_丢失加密数据的凭证。根据设计,如果没有用于加密的密钥,通过 `age` 加密的文件是不能被解密的。所以,请备份你的公钥,并记住这些密码!
|
||||
|
||||
### 轻松实现加密
|
||||
|
||||
age 是一个真正强大的工具。我喜欢把我的敏感文件,特别是税务记录和其他档案数据,加密到 `.tz` 文件中,以便以后访问。age 是用户友好的,使其非常容易随时加密。
|
||||
`age` 是一个真正强大的工具。我喜欢把我的敏感文件,特别是税务记录和其他档案数据,加密到 `.tz` 文件中,以便以后访问。`age` 是用户友好的,使其非常容易随时加密。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@ -104,7 +102,7 @@ via: https://opensource.com/article/21/7/linux-age
|
||||
作者:[Sumantro Mukherjee][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/turbokernel)
|
||||
校对:[turbokernel](https://github.com/turbokernel)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -0,0 +1,64 @@
|
||||
[#]: subject: (Box64 Emulator Released for Arm64 Linux)
|
||||
[#]: via: (https://news.itsfoss.com/box64-emulator-released/)
|
||||
[#]: author: (Jacob Crume https://news.itsfoss.com/author/jacob/)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (zd200572)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13591-1.html)
|
||||
|
||||
Box64 模拟器发布 Arm64 Linux 版本
|
||||
======
|
||||
|
||||
> 在 Box64 模拟器的帮助下,在 ARM 设备上运行 x64 Linux 程序。想试试吗?
|
||||
|
||||
![](https://i2.wp.com/news.itsfoss.com/wp-content/uploads/2021/07/box64-arm.jpg?w=1200&ssl=1)
|
||||
|
||||
[Box86][1] 是一个流行的 X86 模拟器,刚进行了一次巨大的升级。发布了 [Box64][2],也就是对应的 ARM64 版本。
|
||||
|
||||
可能你还不了解这个模拟器,Box64_86 允许你在 ARM 系统上运行 32 或 64 位的 X86/64 Linux 程序。换句话说,它能让你在树莓派或者 [树莓派替代品][3] 上运行 Linux 桌面程序。
|
||||
|
||||
幸运的是,现在我们有 Box86 和 Box64 的支持,无论你的 ARM 系统是什么类型。
|
||||
|
||||
### Box64 是什么?
|
||||
|
||||
![][4]
|
||||
|
||||
你可能听说过苹果的 Rosetta 2,它是一个翻译层,允许为老款 Mac(Intel X86 处理器)设计的应用程序在新的 M1(ARM 处理器)驱动的 Mac 上运行。Box64 与之类似,允许为 X86 设计的应用程序运行在 ARM Linux 设备上。
|
||||
|
||||
由于它的 Dynarec 模块,它能够做到这一点,同时又是 100% 开源的、免费的,而且速度惊人。它通过重新编译 ARM 程序来提升速度,这意味着和其他 ARM 原生应用一样快。
|
||||
|
||||
但是,即使 Box64 无法重新编译应用,它仍然可以使用即时模拟,也有令人印象深刻的结果。
|
||||
|
||||
许多树莓派用户很熟悉 Box86,这是一个大约一年前发布的类似程序。二者最大的区别是 Box86 只兼容 Arm32,而 Box64 只兼容 Arm64。
|
||||
|
||||
这就是 Box64,一个非常棒的兼容层,允许你在 ARM 电脑上运行 x86_64 应用。
|
||||
|
||||
### 总结
|
||||
|
||||
如果你问我认为 Box64 怎么样,我会说这是一个绝对的游戏规则改变者。在难以置信的性能和巨大的潜力之间,这个兼容层肯定会在未来的 ARM 电脑中扮演一个重要角色。
|
||||
|
||||
如果你想知道它的工作原理,以及如何开始使用它,请查看其 [GitHub 页面][5]。
|
||||
|
||||
就这样吧,现在你自己去潜入其中并测试吧。
|
||||
|
||||
你觉得 Box64 怎样?写下你的评论让我知道。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://news.itsfoss.com/box64-emulator-released/
|
||||
|
||||
作者:[Jacob Crume][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[zde200572](https://github.com/zd200572)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://news.itsfoss.com/author/jacob/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: http://github.com/ptitseb/box86
|
||||
[2]: http://github.com/ptitseb/box64
|
||||
[3]: https://itsfoss.com/raspberry-pi-alternatives/
|
||||
[4]: https://i2.wp.com/news.itsfoss.com/wp-content/uploads/2021/07/Box64Logo-1024x287-1.png?w=1024&ssl=1
|
||||
[5]: https://github.com/ptitseb/box64
|
@ -1,66 +0,0 @@
|
||||
[#]: subject: (Box64 Emulator Released for Arm64 Linux)
|
||||
[#]: via: (https://news.itsfoss.com/box64-emulator-released/)
|
||||
[#]: author: (Jacob Crume https://news.itsfoss.com/author/jacob/)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
Box64 Emulator Released for Arm64 Linux
|
||||
======
|
||||
|
||||
[Box86][1], the popular x86 emulator, has just received a huge upgrade. This comes in the form of [Box64][2], the ARM64 equivalent.
|
||||
|
||||
If you did not know, Box64_86 lets you run 64-bit or 32-bit Linux programs on ARM systems. In other words, it makes it possible for you to access desktop Linux programs on your Raspberry Pi or [Raspberry Pi alternatives][3].
|
||||
|
||||
Fortunately, now we have Box86 and Box64 to the rescue no matter what type of ARM system you’ve got.
|
||||
|
||||
### What is Box64?
|
||||
|
||||
![][4]
|
||||
|
||||
You may have heard about Apple’s Rosetta 2, a translation layer that allows apps designed for older Macs to run on the new M1-powered Macs. Box64 is something similar that allows apps designed for x86 to run on ARM Linux devices.
|
||||
|
||||
It manages to do this all while being 100% open-source, free, and surprisingly fast, thanks to its Dynarec module. This improves speed by re-compiling the program for ARM, meaning that it runs the same as any other ARM-supported app.
|
||||
|
||||
However, even if Box64 is unable to recompile the app, it can still run it using on-the-fly emulation, with impressive results here too.
|
||||
|
||||
Many Raspberry Pi users will be familiar with Box86, a similar program that has been around for about a year now. The biggest difference is that Box86 is only compatible with Arm32, while Box64 is only compatible with Arm64.
|
||||
|
||||
So that’s Box64, the awesome compatibility layer that allows users to run x86_64 apps on your ARM-based PCs.
|
||||
|
||||
### Wrapping Up
|
||||
|
||||
If you were to ask me what I think about Box64, I would say it’s an absolute game changer. Between the incredible performance and massive potential, this compatibility layer is sure to play a huge role in the future ARM-based Linux PCs.
|
||||
|
||||
Check out its [GitHub page][5] if you are curious to know how it works, and how you can get started with it.
|
||||
|
||||
With that, I’ll leave you now to dive into and test for yourself.
|
||||
|
||||
_What do you think of Box64? Let me know down in the comments below!_
|
||||
|
||||
#### Big Tech Websites Get Millions in Revenue, It's FOSS Got You!
|
||||
|
||||
If you like what we do here at It's FOSS, please consider making a donation to support our independent publication. Your support will help us keep publishing content focusing on desktop Linux and open source software.
|
||||
|
||||
I'm not interested
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://news.itsfoss.com/box64-emulator-released/
|
||||
|
||||
作者:[Jacob Crume][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://news.itsfoss.com/author/jacob/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: http://github.com/ptitseb/box86
|
||||
[2]: http://github.com/ptitseb/box64
|
||||
[3]: https://itsfoss.com/raspberry-pi-alternatives/
|
||||
[4]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjIxOSIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4=
|
||||
[5]: https://github.com/ptitseb/box64
|
@ -0,0 +1,66 @@
|
||||
[#]: subject: (Dear Mozilla, Please Remove This Annoying ‘Feature’ from Firefox)
|
||||
[#]: via: (https://news.itsfoss.com/mozilla-annoying-new-tab/)
|
||||
[#]: author: (Abhishek https://news.itsfoss.com/author/root/)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
Dear Mozilla, Please Remove This Annoying ‘Feature’ from Firefox
|
||||
======
|
||||
|
||||
Despite its receding user base, Mozilla Firefox has remained my primary browser. Mozilla has revamped Firefox in the last couple of years and have added several features to it specially focused on protecting user privacy. I respect that.
|
||||
|
||||
However, there is one ‘feature’ that annoys the hell out of me. This so-called feature relates to the auto-update of Firefox in the background.
|
||||
|
||||
Auto-upgrade immediately remind of Windows updates. I mean, Windows is infamous for the forced restarts and updates, right?
|
||||
|
||||
![Image Credit: Digital Trend][1]
|
||||
|
||||
But why am I talking about this in reference to Firefox? Because Firefox, too, has a ‘Windows-que’ feature.
|
||||
|
||||
It updates Firefox in the background. No problem there. That’s not entirely a bad thing.
|
||||
|
||||
But then if you try to open a website in the new tab, it won’t let you do that unless you restart the browser.
|
||||
|
||||
![][2]
|
||||
|
||||
And that small thing stops the users from keep going with their work. What the hell, Mozilla!
|
||||
|
||||
You may argue that it’s not that much of a pain. A quick restart won’t bring your world down, Abhishek.
|
||||
|
||||
Right but imagine you are busy at work. You have more than 20 tabs opened. That’s normal if you are trying to troubleshoot as a developer, sysadmin, student or just trying to learn something in your field of interest.
|
||||
|
||||
You cannot open a new webpage anymore. You have to restart the browser and when you restart, you have to click on each tab manually because Firefox does not load the previously opened webpages on its own. Sure you can see the tabs but the web pages are not actually loaded.
|
||||
|
||||
This should be considered a bug, not a feature. Users should be given a choice to between rebooting right away or doing it later.
|
||||
|
||||
I don’t remember any other browser infringing like this on its users, not even Google Chrome. But somehow Mozilla eggheads thought that this is a good “feature” to add to their open source browser.
|
||||
|
||||
No, Mozilla! This is not a feature. This is a bug and should be fixed. You just cannot annoy your users like this otherwise they will be forced to use [alternate browsers like Brave][3] or Vivaldi and of course, Chrome.
|
||||
|
||||
I end my rant and leave the field open for you. What do you think of these forced restarts by Mozilla Firefox?
|
||||
|
||||
### Big Tech Websites Get Millions in Revenue, It's FOSS Got You!
|
||||
|
||||
If you like what we do here at It's FOSS, please consider making a donation to support our independent publication. Your support will help us keep publishing content focusing on desktop Linux and open source software.
|
||||
|
||||
I'm not interested
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://news.itsfoss.com/mozilla-annoying-new-tab/
|
||||
|
||||
作者:[Abhishek][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://news.itsfoss.com/author/root/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQyNyIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4=
|
||||
[2]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjMwOCIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4=
|
||||
[3]: https://news.itsfoss.com/chrome-like-browsers-2021/
|
@ -2,7 +2,7 @@
|
||||
[#]: via: (https://opensource.com/article/21/3/io-java)
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (piaoshi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
@ -2,7 +2,7 @@
|
||||
[#]: via: (https://opensource.com/article/21/7/programming-read-write)
|
||||
[#]: author: (Alan Smithee https://opensource.com/users/alansmithee)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (MjSeven)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
@ -0,0 +1,112 @@
|
||||
[#]: subject: (Apps for daily needs part 1: web browsers)
|
||||
[#]: via: (https://fedoramagazine.org/apps-for-daily-needs-part-1-web-browsers/)
|
||||
[#]: author: (Arman Arisman https://fedoramagazine.org/author/armanwu/)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
Apps for daily needs part 1: web browsers
|
||||
======
|
||||
|
||||
![][1]
|
||||
|
||||
Photo by [Brooke Cagle][2] on [Unsplash][3]
|
||||
|
||||
One of the important apps for daily needs is a web browser. That’s because surfing the internet is an activity most people do in front of the computer. This article will introduce some of the open source web browsers that you can use on Fedora Linux. You need to install the software mentioned. All the browsers mentioned in this article are already available in the official Fedora repository. If you are unfamiliar with how to add software packages in Fedora Linux, see my earlier article [Things to do after installing Fedora 34 Workstation][4].
|
||||
|
||||
### Firefox
|
||||
|
||||
Firefox is a fast and privacy-focused browser that works across many devices. It was created by [Mozilla][5] and is a browser with complete features offering many extensions. You can add many powerful functions and useful features to your Firefox browser. It uses just enough memory to create a smooth experience so your computer stays responsive to other tasks. You can create an account that will allow you to share configurations on multiple devices, so you don’t need to set up Firefox on each device.
|
||||
|
||||
![][6]
|
||||
|
||||
Firefox offers the following features:
|
||||
|
||||
* Private Browsing mode
|
||||
* Ad tracker blocking
|
||||
* Password manager
|
||||
* Sync between devices
|
||||
* Picture-in-Picture
|
||||
|
||||
|
||||
|
||||
More information about Firefox browser is available at this link: [https://www.mozilla.org/en-US/firefox][7]
|
||||
|
||||
### GNOME Web
|
||||
|
||||
GNOME Web is a browser for GNOME desktop which is the default desktop environment for Fedora Workstation. It may be very appropriate as your main browser if you use Fedora Workstation with GNOME as the default desktop environment. This browser has a simple, clean, and beautiful look. GNOME Web has fewer features than Firefox, but it is sufficient for common uses.
|
||||
|
||||
![][8]
|
||||
|
||||
GNOME Web offers the following features:
|
||||
|
||||
* Incognito mode
|
||||
* GNOME desktop integration
|
||||
* built-in adblocker
|
||||
* Intelligent tracking prevention
|
||||
|
||||
|
||||
|
||||
More information about GNOME Web is available at this link: <https://wiki.gnome.org/Apps/Web>
|
||||
|
||||
### Chromium
|
||||
|
||||
Chromium is an open-source web browser from the Chromium Project and has a minimalist user interface. It has a similar appearance to Chrome, because it actually serves as the base for Chrome and several other browsers. Many people use Chromium because they are used to Chrome.
|
||||
|
||||
![][9]
|
||||
|
||||
Chromium offers the following features:
|
||||
|
||||
* Incognito mode
|
||||
* Extensions
|
||||
* Autofill for passwords
|
||||
|
||||
|
||||
|
||||
More information about Chromium browser is available at this link: <https://www.chromium.org/Home>
|
||||
|
||||
### qutebrowser
|
||||
|
||||
This browser is a little bit different than the browsers mentioned above. qutebrowser is a keyboard-focused browser with a minimal GUI. Therefore, you won’t find the buttons normally found in other browsers, like back, home, reload, etc. Instead, you can type commands with the keyboard to run functions in the qutebrowser. It uses Vim-style key bindings, so it’s suitable for Vim users. You should try this browser if you are interested in getting a different experience in surfing the internet.
|
||||
|
||||
![][10]
|
||||
|
||||
qutebrowser offers the following features:
|
||||
|
||||
* Adblock
|
||||
* Private browsing mode
|
||||
* Quickmarks
|
||||
|
||||
|
||||
|
||||
More information about qutebrowser browser is available at this link: <https://qutebrowser.org/>
|
||||
|
||||
### Conclusion
|
||||
|
||||
Everyone has different needs in using the internet, especially for browsing. Each browser mentioned in this article has different features. So choose a browser that suits your daily needs and preferences. If you use the browsers mentioned in this article, share your story in the comments. And if you use a browser other than the one mentioned in this article, please mention it. Hopefully this article can help you in choosing the browser that you will use for your daily needs on Fedora.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://fedoramagazine.org/apps-for-daily-needs-part-1-web-browsers/
|
||||
|
||||
作者:[Arman Arisman][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://fedoramagazine.org/author/armanwu/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://fedoramagazine.org/wp-content/uploads/2021/07/FedoraMagz-Apps-1-Browsers-2-816x345.jpg
|
||||
[2]: https://unsplash.com/@brookecagle?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText
|
||||
[3]: https://unsplash.com/s/photos/meeting-on-cafe-computer?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText
|
||||
[4]: https://fedoramagazine.org/things-to-do-after-installing-fedora-34-workstation/
|
||||
[5]: https://www.mozilla.org/en-US/
|
||||
[6]: https://fedoramagazine.org/wp-content/uploads/2021/07/Browsers-Firefox-1-1024x707.png
|
||||
[7]: https://www.mozilla.org/en-US/firefox/
|
||||
[8]: https://fedoramagazine.org/wp-content/uploads/2021/07/Browsers-Web-1024x658.png
|
||||
[9]: https://fedoramagazine.org/wp-content/uploads/2021/07/Browsers-Chromium-1-1024x690.png
|
||||
[10]: https://fedoramagazine.org/wp-content/uploads/2021/07/Browsers-qb-1024x687.png
|
@ -0,0 +1,80 @@
|
||||
[#]: subject: (What does the Open-Closed Principle mean for refactoring?)
|
||||
[#]: via: (https://opensource.com/article/21/7/open-closed-principle-refactoring)
|
||||
[#]: author: (Alex Bunardzic https://opensource.com/users/alex-bunardzic)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
What does the Open-Closed Principle mean for refactoring?
|
||||
======
|
||||
Resolve the tension between protecting clients from unwanted changes and
|
||||
extending the capabilities of services.
|
||||
![Brain on a computer screen][1]
|
||||
|
||||
In his 1988 book, _[Object-Oriented Software Construction][2]_, professor [Bertrand Meyer][3] defined the [Open-Closed Principle][4] as:
|
||||
|
||||
> "A module will be said to be open if it is still available for extension. For example, it should be possible to add fields to the data structures it contains or new elements to the set of functions it performs.
|
||||
>
|
||||
> "A module will be said to be closed if it is available for use by other modules. This assumes that the module has been given a well-defined, stable description (the interface in the sense of information hiding)."
|
||||
|
||||
A more succinct way to put it would be:
|
||||
|
||||
> Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification.
|
||||
|
||||
Similarly (and in parallel to Meyer's findings), [Alistair Cockburn][5] defined the [Protected Variation][6] pattern:
|
||||
|
||||
> "Identify points of predicted variation and create a stable interface around them."
|
||||
|
||||
Both of these deal with volatility in software. When, as is always the case, you need to make some change to a software module, the ripple effects can be disastrous. The root cause of disastrous ripple effects is tight coupling, so the Open-Closed Principle and Protected Variation Pattern teach us how to properly decouple various modules, components, functions, and so forth.
|
||||
|
||||
### Does the Open-Closed Principle preclude refactoring?
|
||||
|
||||
If a module (i.e., a named block of code) must remain closed to any modifications, does that mean you're not allowed to touch it once it gets deployed? And if yes, wouldn't that eliminate any possibility of refactoring?
|
||||
|
||||
Without the ability to refactor the code, you are forced to adopt the Finality Principle. This holds that rework is not allowed (why would stakeholders agree to pay you to work again on something they already paid for?) and you must carefully craft your code, because you will get only one chance to do it right. This is in total contradiction to the discipline of refactoring.
|
||||
|
||||
If you are allowed to extend the deployed code but not change it, are you doomed to swim forever in the waterfall rivers? Being given only one shot at doing anything is a recipe for disaster.
|
||||
|
||||
Let's review the approach to solve this conundrum.
|
||||
|
||||
### How to protect clients from unwanted changes
|
||||
|
||||
Clients (meaning modules or functions that use some block of code) utilize some functionality by adhering to the protocol as originally implemented in the component or service. However, as the component or service inevitably changes, the original "partnership" between the service or component and various clients breaks down. Clients "discover" the change by breakage, which is always an unpleasant surprise that often ruins the initial trust.
|
||||
|
||||
Clients must be protected from those breakages. The only way to do so is by introducing a layer of abstraction between the clients and the service or component. In software engineering lingo, we call that layer of abstraction an "interface" (or an API).
|
||||
|
||||
Interfaces and APIs hide the implementation. Once you arrange for a service to be delivered via an interface or API, you free yourself from the worries of changing the implementation code. No matter how much you change the service's implementation, your clients remain blissfully unaffected.
|
||||
|
||||
That way, you are back to your comfortable world of iterations. You are now completely free to refactor, to rearrange the code, and to keep rearranging it in pursuit of a more optimal solution.
|
||||
|
||||
The thing in this arrangement that remains closed for modification is the interface or API. The volatility of an interface or API is the thing that threatens to break the established trust between the service and its clients. Interfaces and APIs must remain open for extension. And that extension happens behind the scenes—by refactoring and adding new capabilities while guaranteeing non-volatility of the public-facing protocol.
|
||||
|
||||
### How to extend capabilities of services
|
||||
|
||||
While services remain non-volatile from the client's perspective, they also remain open for business when it comes to enhancing their capabilities. This Open-Closed Principle is implemented through refactoring.
|
||||
|
||||
For example, if the first increment of the `OrderPayment` service offers mere bare-bones capabilities (e.g., able to process the order total and calculate sales tax), the next increment can be safely added by respecting the Open-Closed Principle. Without breaking the handshake between the clients and the `OrderPayment` service, you can refactor the implementation behind the `OrderPayment` API by adding new blocks of code.
|
||||
|
||||
So, the second increment could contain the ability to calculate shipping costs. And so on, you get the picture; you accomplish the Protected Variation Pattern by observing the Open-Closed Principle. It's all about carefully modeling business abstractions.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/7/open-closed-principle-refactoring
|
||||
|
||||
作者:[Alex Bunardzic][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/alex-bunardzic
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/brain_computer_solve_fix_tool.png?itok=okq8joti (Brain on a computer screen)
|
||||
[2]: https://en.wikipedia.org/wiki/Object-Oriented_Software_Construction
|
||||
[3]: https://en.wikipedia.org/wiki/Bertrand_Meyer
|
||||
[4]: https://en.wikipedia.org/wiki/Open%E2%80%93closed_principle
|
||||
[5]: https://en.wikipedia.org/wiki/Alistair_Cockburn
|
||||
[6]: https://martinfowler.com/ieeeSoftware/protectedVariation.pdf
|
@ -0,0 +1,84 @@
|
||||
[#]: subject: (How to avoid waste when writing code)
|
||||
[#]: via: (https://opensource.com/article/21/7/avoid-waste-coding)
|
||||
[#]: author: (Alex Bunardzic https://opensource.com/users/alex-bunardzic)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
How to avoid waste when writing code
|
||||
======
|
||||
The more we can reduce waste in software development, the better off
|
||||
everyone will be.
|
||||
![Learning to program][1]
|
||||
|
||||
The long road toward quality is filled with diversions, false starts, and detours. The enemy of quality is waste, because waste is never desirable. No one pays anyone to deliver waste. We sometimes tolerate waste as part of the process of making something useful and desirable, but the more we can reduce waste while making something, the better.
|
||||
|
||||
In software engineering, waste can be expressed in a few ways:
|
||||
|
||||
1. Defects
|
||||
2. Idling and waiting
|
||||
3. Overproduction
|
||||
4. Overprocessing
|
||||
5. Any other activity that doesn't directly put value in users' hands
|
||||
|
||||
|
||||
|
||||
Let's examine each of these five types of waste.
|
||||
|
||||
### Defects
|
||||
|
||||
There seems to be a prevailing sentiment in the software industry that bugs (defects) are inevitable. It's not if—but when and how many—bugs find their way into production.
|
||||
|
||||
You can fight that defeatist sentiment by reminding software engineers that each and every bug is authored. Bugs don't occur spontaneously. They're created by us, human beings trying to do the best software development we can. But nobody's perfect. Of course we don't create bugs intentionally, but they do happen. They're often a result of rushing things through, or perhaps due to inadequate education and training.
|
||||
|
||||
Whatever the reason, bugs are _caused_, which means we can eliminate bugs by solving the problems that cause them.
|
||||
|
||||
### Idling and waiting
|
||||
|
||||
Our business partners funding our software development efforts tend to perceive any time we're not producing shipping code as time spent idling. Why are we idling, and what are we waiting on? It's a reasonable question to ask, if you consider they're paying potentially thousands of dollars per hour to keep the team going.
|
||||
|
||||
Idling is wasteful. It does not contribute to the bottom line and may be a sign of confusion. If the team says they're waiting on someone to return from their leave of absence, that signals poor organizing skills. No team should ever get to the point where they paint themselves into a corner and are suffering from a single point of failure. If a team member can't participate, other members should step in and continue the work. If that's not possible, you are dealing with a very brittle, inflexible, and unreliable team.
|
||||
|
||||
Of course, there are many other possible reasons the team is idling. Maybe there is confusion about the current highest priority, so the team is hanging and waiting to learn about the correct priority.
|
||||
|
||||
There are many other [reasonable causes of idling][2], which is why this type of waste seems hardest to get on top of. Whatever the case, mature organizations take precautionary steps to minimize potential idling and waiting time.
|
||||
|
||||
### Overproduction
|
||||
|
||||
Often labeled "gold plating," overproduction is one of the most insidious forms of waste. Software engineers are notorious for their propensity to go overboard in their enthusiasm for building features and nifty capabilities. And because software, as its name implies, is very pliable and malleable, there is very little pushback against the onslaught of bloat.
|
||||
|
||||
This dreadful bloat creates a lot of waste. Fighting bloat is what prudent software engineering discipline is all about.
|
||||
|
||||
### Overprocessing
|
||||
|
||||
One of the biggest problems in software engineering is known as Geek-At-Keyboard (GAK). A common misconception is that software engineers spend most of their time writing code. That is far from the truth. Most of the time spent on regular daily activities (aside from attending meetings) goes toward keyboard activities unrelated to writing code: messing with configurations and environments, manually running and navigating the app, typing and retyping test data, stepping through the debugger, etc.
|
||||
|
||||
All those activities are waste. They don't contribute to delivering value. One of the most effective remedies for minimizing unproductive GAK time is [test-driven development][3] (TDD). Writing tests before writing code is a proven method for avoiding overprocessing. The test-first approach is a very effective way of eliminating waste.
|
||||
|
||||
### Other activities that don't put value in users' hands
|
||||
|
||||
In the early days of our profession, value was measured by the number of lines of code produced per unit of time (per day, week, month, etc.). Later, this rather ineffective way of measuring value was abandoned in favor of working code. There is no convincing correlation between the number of lines of code and working code. And once working code became the measure of value, the number of lines of code became irrelevant.
|
||||
|
||||
Today, we recognize that [working code][4] is also a meaningless metric. Just because code compiles, builds, and works doesn't mean it is doing anything of value. Successfully running code could be doing inane processing, such as counting from 0 to 10 and then back to 0. It is much more important to focus on code that meets end users' expectations.
|
||||
|
||||
Helping end users fulfill their goals when using your software product is the only measure of value. Any other activity that does not contribute to that value should be regarded as waste.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/7/avoid-waste-coding
|
||||
|
||||
作者:[Alex Bunardzic][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/alex-bunardzic
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/learn-programming-code-keyboard.png?itok=xaLyptT4 (Learning to program)
|
||||
[2]: https://opensource.com/article/21/2/simplicity
|
||||
[3]: https://opensource.com/article/20/1/test-driven-development
|
||||
[4]: https://opensource.com/article/20/7/code-tdd
|
@ -0,0 +1,140 @@
|
||||
[#]: subject: (Up for a Challenge? Try These ‘Advanced’ Linux Distros [Not Based on Debian, Arch or Red Hat])
|
||||
[#]: via: (https://itsfoss.com/advanced-linux-distros/)
|
||||
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
Up for a Challenge? Try These ‘Advanced’ Linux Distros [Not Based on Debian, Arch or Red Hat]
|
||||
======
|
||||
|
||||
There are hundreds of Linux distributions. Some are for general purpose usage, while some are specifically tailored for education, robotics, hacking, gaming and what not.
|
||||
|
||||
You’ll notice that most of them originate from Debian/Ubuntu, Arch and Red Hat/Fedora. If you like distrohopping and experiment with a range of distributions, you may soon get ‘bored’ out of it. Most Linux distributions would feel too similar after a point and apart from a few visual changes here and there, you won’t get a different experience.
|
||||
|
||||
Does that sound familiar? If yes, let me list some advanced, independent, Linux distributions to test your expertise.
|
||||
|
||||
### Advanced Linux distributions for experts
|
||||
|
||||
![][1]
|
||||
|
||||
You may argue against the use of term “expert” here. After all, ‘expert Linux users’ don’t necessarily need to use advanced Linux distributions. They can easily utilize their expertise on [beginner-friendly distributions like Linux Mint][2].
|
||||
|
||||
The term expert here is intended for people who won’t easily get overwhelmed when they are taken out of their comfort zone and land in an unfamiliar environment.
|
||||
|
||||
Alright then. Let’s see which distributions you can use to test your expertise on.
|
||||
|
||||
#### NixOS
|
||||
|
||||
![NixOS Linux illustration][3]
|
||||
|
||||
[NixOS][4] is a unique distribution in the terms of how it approaches everything from the kernel to configuration to applications.
|
||||
|
||||
NixOS is built on top of the Nix package manager and everything from the kernel to configuration is based on it. All packages are kept in isolation from each other.
|
||||
|
||||
It ensures that installing or upgrading one package does not break other packages. You can also easily roll back to previous versions.
|
||||
|
||||
The isolation feature also helps you in trying new tools without hesitation, creating development environments and more.
|
||||
|
||||
Sounds good enough to give it a try? You call, truly.
|
||||
|
||||
#### Void Linux
|
||||
|
||||
![Void Linux illustration][5]
|
||||
|
||||
[Void Linux][6] is another independent Linux distribution which was implemented from scratch. It is a rolling release distribution but it focuses on stability rather than being bleeding edge like Arch Linux.
|
||||
|
||||
Void Linux has its own XBPS package management system for installing and removing software with option to build packages from sources (from XBPS source packages collection).
|
||||
|
||||
Another thing that sets Void Linux apart from the crowd of other distribution is its use of [runit][7] as init system instead of systemd.
|
||||
|
||||
Can Void Linux fill the void in your distrohopping life? Find it out yourself.
|
||||
|
||||
#### Slackware
|
||||
|
||||
![Slackware Linux illustration][8]
|
||||
|
||||
The oldest active Linux distribution, [Slackware][9], can surely be counted as an expert Linux distribution.
|
||||
|
||||
Which is amusing because once upon a time, many new Linux users started their Linux journey with Slackware. But that was back in the mid-90s and it is safe to assume that those newbies have turned into veteran with their neck beard touching the ground.
|
||||
|
||||
Originally, Slackware was based on Softlanding Linux System (SLS), one of the earliest Linux distributions in 1992.
|
||||
|
||||
Slackware is an advanced Linux distribution with aim to produce the most “UNIX-like” Linux distribution out there.
|
||||
|
||||
No slacking here. Be ready to use the command line extensively in Slackware.
|
||||
|
||||
#### Gentoo
|
||||
|
||||
![Gentoo Linux illustration][10]
|
||||
|
||||
[Gentoo Linux][11] is named after the fast swimming Gentoo penguin. It reflects the speed optimization capabilities of Gentoo Linux.
|
||||
|
||||
How? It’s software distribution system, Portage, gives it extreme configurability and performance. Portage keeps a collection of build scripts for the packages and it automatically builds a custom version of package based on end user’s preference and optimized for end user’s hardware.
|
||||
|
||||
This ‘build’ stuff is why there are many jokes and meme in Linux-verse about compiling everything in Gentoo.
|
||||
|
||||
Can you catch up with the Gentoo?
|
||||
|
||||
#### Clear Linux
|
||||
|
||||
![Clear Linux illustration][12]
|
||||
|
||||
[Clear Linux][13] is not your general purpose desktop Linux distribution. It is an open source, rolling release distribution, created from the ground up by Intel and obviously, it is highly tuned for Intel platforms.
|
||||
|
||||
Clear Linux OS primarily targets professionals in the field of IT, DevOps, Cloud/Container deployments, and AI.
|
||||
|
||||
The package management is done through [swupd][14] but unlike regular package managers, versioning happens at the individual file level. This means that it generates an entirely new OS version when any software change takes place in the system.
|
||||
|
||||
Is it clear enough to try Clear Linux?
|
||||
|
||||
#### Linux From Scratch
|
||||
|
||||
![Linux From Scratch illustration][15]
|
||||
|
||||
If you think installing Arch Linux was a challenge, try [Linux From Scratch][16] (LFS). As the name suggests, here you ~~get~~ have to do everything from scratch.
|
||||
|
||||
From installing to using, you do everything at a low level and that’s the beauty of it. You are not installing a pre-compiled Linux distribution here. You build your own customized Linux system entirely from the source code.
|
||||
|
||||
It is often suggested to use Linux From Scratch to learn the core functioning of the Linux and it is indeed a learning experience.
|
||||
|
||||
Still scratching your head about Linux From Scratch? You can [read it][17][s][17] [documentation in book format][17].
|
||||
|
||||
#### Conclusion
|
||||
|
||||
There are a few more independent Linux distributions. Mageia and Solus are two of the relatively more popular ones. I did not include them in this list because I consider them more friendly and not as complicated to use as others on the list. Feel free to disagree with me in the comments.
|
||||
|
||||
It is your turn now. Have you used any advanced Linux distributions ever? Was it in the past or are you still using it?
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/advanced-linux-distros/
|
||||
|
||||
作者:[Abhishek Prakash][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/abhishek/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/07/advanced-linux-distros.png?resize=800%2C450&ssl=1
|
||||
[2]: https://itsfoss.com/best-linux-beginners/
|
||||
[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/07/nix-os.png?resize=800%2C350&ssl=1
|
||||
[4]: https://nixos.org/
|
||||
[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/07/void-linux.png?resize=800%2C350&ssl=1
|
||||
[6]: https://voidlinux.org/
|
||||
[7]: http://smarden.org/runit/
|
||||
[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/07/slackware.png?resize=800%2C350&ssl=1
|
||||
[9]: http://www.slackware.com/
|
||||
[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/07/gentoo-linux.png?resize=800%2C350&ssl=1
|
||||
[11]: https://www.gentoo.org/
|
||||
[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/07/clear-linux.png?resize=800%2C350&ssl=1
|
||||
[13]: https://clearlinux.org/
|
||||
[14]: https://docs.01.org/clearlinux/latest/guides/clear/swupd.html#swupd-guide
|
||||
[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/07/linux-from-scratch.png?resize=800%2C350&ssl=1
|
||||
[16]: https://www.linuxfromscratch.org/
|
||||
[17]: https://www.linuxfromscratch.org/lfs/read.html
|
@ -24,7 +24,7 @@
|
||||
|
||||
### WordNet 和<ruby>同义词集<rt>synsets</rt></ruby>
|
||||
|
||||
[WordNet][4] 是 NLTK 里的一个大型词典数据库。WordNet 包含各单词的诸多<ruby>认知同义词<rt>cognitive synonyms</rt></ruby> (一个<ruby>认知同义词<rt>cognitive synonyms</rt></ruby>常被称作 synset)。
|
||||
[WordNet][4] 是 NLTK 里的一个大型词典数据库。WordNet 包含各单词的诸多<ruby>认知同义词<rt>cognitive synonyms</rt></ruby> (一个认知同义词常被称作 synset)。在 WordNet 里,名词、动词、形容词和副词,各自被组织成一个同义词的网络。
|
||||
|
||||
WordNet 是文本分析的一个很有用的工具。它有面向多种语言的版本 (汉语、英语、日语、俄语和西班牙语等),也使用多种许可证 (从开源许可证到商业许可证都有)。初代版本的 WordNet 由普林斯顿大学研发,面向英语,使用<ruby>类 MIT 许可证<rt>MIT-like license</rt></ruby>。
|
||||
|
||||
@ -34,13 +34,13 @@ WordNet 是文本分析的一个很有用的工具。它有面向多种语言的
|
||||
|---|---|---|
|
||||
|<ruby>名称<rt>Name</rt></ruby>| 此 synset 的名称 | 单词 code 有 5 个 synset,名称分别是 `code.n.01`、 `code.n.02`、 `code.n.03`、`code.v.01` 和 `code.v.02`|
|
||||
|<ruby>词性<rt>POS</rt></ruby>| 此 synset 的词性 | 单词 code 有 3 个名词词性的 synset 和 2 个动词词性的 synset|
|
||||
|<ruby>定义<rt>Definition</rt></ruby>| 该词作对应词性时的定义 | 动词 code 的一个定义是: (<ruby>计算机科学<rt>computer science</rt></ruby>)数据或计算机程序指令的<ruby>象征性排列<rt>symbolic arrangement</rt></ruby>|
|
||||
|<ruby>定义<rt>Definition</rt></ruby>| 该词作对应词性时的定义 | 动词 code 的一个定义是:(计算机科学) 数据或计算机程序指令的<ruby>象征性排列<rt>symbolic arrangement</rt></ruby>|
|
||||
|<ruby>例子<rt>Examples</rt></ruby>| 使用该词的例子 | code 一词的例子:<ruby>为了安全,我们应该给信息编码。<rt>We should encode the message for security reasons</rt></ruby>|
|
||||
|<ruby>词元<rt>Lemmas</rt></ruby>| 与该词向关联的其他 synset (包括那些不一定严格地是该词的同义词,但可以大体看作同义词的);<ruby>词元<rt>lemma</rt></ruby>直接与其他<ruby>词元<rt>lemma</rt></ruby>连关联,而不是直接与<ruby>单词<rt>words/rt></ruby>相关联| `code.v.02` 的<ruby>词元<rt>lemma</rt></ruby>是`code.v.02.encipher`、`code.v.02.cipher`、`code.v.02.cypher`、`code.v.02.encrypt`、`code.v.02.inscribe` 和 `code.v.02.write_in_code`|
|
||||
|<ruby>反义词<rt>Antonyms</rt></ruby>| 意思相反的词 | <ruby>词元<rt>lemma</rt></ruby>`encode.v.01.encode` 的<ruby>反义词<rt>antonym</rt></ruby>是 `decode.v.01.decode`|
|
||||
|<ruby>上义词<rt>Hypernym</rt></ruby>|该词所属的一个范畴更大的词 | `code.v.01` 的一个<ruby>上义词<rt>hypernym</rt></ruby>是 `tag.v.01`|
|
||||
|<ruby>分项词<rt>Meronym</rt></ruby>| 属于该词组成部分的词 | <ruby>计算机<rt>computer</rt></ruby>的一个<ruby>分项词<rt>meronym</rt></ruby>是<ruby>芯片<rt>chip</rt></ruby>|
|
||||
|<ruby>总项词<rt>Holonym</rt></ruby>| 该词作为组成部分所属的词 | <ruby>窗<rt>window</rt></ruby>的一个<ruby>总项词<rt>holonym</rt></ruby>是<ruby>电脑屏幕<rt>computer screen</rt></ruby>|
|
||||
|<ruby>词元<rt>Lemmas</rt></ruby>| 与该词相关联的其他 synset (包括那些不一定严格地是该词的同义词,但可以大体看作同义词的);词元直接与其他词元相关联,而不是直接与<ruby>单词<rt>words/rt></ruby>相关联|`code.v.02` 的词元是`code.v.02.encipher`、`code.v.02.cipher`、`code.v.02.cypher`、`code.v.02.encrypt`、`code.v.02.inscribe` 和 `code.v.02.write_in_code`|
|
||||
|<ruby>反义词<rt>Antonyms</rt></ruby>| 意思相反的词 | 词元 `encode.v.01.encode` 的反义词是 `decode.v.01.decode`|
|
||||
|<ruby>上义词<rt>Hypernym</rt></ruby>|该词所属的一个范畴更大的词 | `code.v.01` 的一个上义词是 `tag.v.01`|
|
||||
|<ruby>分项词<rt>Meronym</rt></ruby>| 属于该词组成部分的词 | computer 的一个分项词是 chip |
|
||||
|<ruby>总项词<rt>Holonym</rt></ruby>| 该词作为组成部分所属的词 | window 的一个总项词是 computer screen|
|
||||
|
||||
synset 还有一些其他属性,在 `<你的 Python 安装路径>/Lib/site-packages` 下的 `nltk/corpus/reader/wordnet.py`,你可以找到它们。
|
||||
|
||||
@ -116,7 +116,7 @@ Part Holonyms: []
|
||||
Part Meronyms: []
|
||||
```
|
||||
|
||||
<ruby>同义词集<rt>synsets</rt></ruby>和<ruby>词元<rt>lemma</rt></ruby>在 WordNet 里是按照树状结构组织起来的,下面的代码会给出直观的展现:
|
||||
<ruby>同义词集<rt>synsets</rt></ruby>和<ruby>词元<rt>lemmas</rt></ruby>在 WordNet 里是按照树状结构组织起来的,下面的代码会给出直观的展现:
|
||||
|
||||
```
|
||||
def hypernyms(synset):
|
||||
@ -194,7 +194,7 @@ Synset('soccer.n.01') ( n ) [ a football game in which two teams of 11 players t
|
||||
is 0.05
|
||||
```
|
||||
|
||||
两个词各个 synset 之间<ruby>路径相似度<rt>path similarity</rt></ruby>最大的是 0.5,表明它们关联性很大 (路径相似度指两个词的意义在<ruby>上下义关系的词汇分类结构<rt>hypernym/hypnoym taxonomy</rt></ruby>中的最短距离)。
|
||||
两个词各个 synset 之间<ruby>路径相似度<rt>path similarity</rt></ruby>最大的是 0.5,表明它们关联性很大 ([<ruby>路径相似度<rt>path similarity</rt></ruby>][6]指两个词的意义在<ruby>上下义关系的词汇分类结构<rt>hypernym/hypnoym taxonomy</rt></ruby>中的最短距离)。
|
||||
|
||||
那么 code 和 bug 呢?这两个计算机领域的词的相似度是:
|
||||
|
||||
@ -226,7 +226,7 @@ NLTK 提供多种<ruby>相似度计分器<rt>similarity scorers</rt></ruby>,
|
||||
* jcn_similarity
|
||||
* lin_similarity
|
||||
|
||||
要进一步了解这个<ruby>相似度计分器<rt>similarity scorers</rt></ruby>,请查看 [WordNet Interface][6] 的 Similarity 部分。
|
||||
要进一步了解这些<ruby>相似度计分器<rt>similarity scorers</rt></ruby>,请查看 [WordNet Interface][6] 的 Similarity 部分。
|
||||
|
||||
#### 自主尝试
|
||||
|
||||
@ -408,7 +408,7 @@ tree.draw()
|
||||
|
||||
|
||||
```
|
||||
`sentence = 'Peterson first suggested the name "open source" at Palo Alto, California'`
|
||||
sentence = 'Peterson first suggested the name "open source" at Palo Alto, California'
|
||||
```
|
||||
|
||||
验证这个句子里的<ruby>人名<rt>name</rt></ruby>和<ruby>地名<rt>place</rt></ruby>有没有被识别出来。照例先预处理:
|
||||
@ -488,18 +488,18 @@ NLTK 也可以使用其他<ruby>标注器<rt>tagger</rt></ruby>,比如 [Stanfo
|
||||
使用 Python 库,下载维基百科的 [Category: Computer science page][18],然后:
|
||||
|
||||
|
||||
* 找出其中频率最高的<ruby>单词<rt>unigrams</rt></ruby><ruby>、二元搭配<rt>bigrams</rt></ruby>和<ruby>三元搭配<rt>trigrams</rt></ruby>,将它们作为一个<ruby>关键词<rt>keywords</rt></ruby>列表或者<ruby>技术<rt>techonologies</rt></ruby>列表。相关领域的学生或者工程师需要了解这样一份列表里的内容。
|
||||
* 找出其中频率最高的<ruby>单词<rt>unigrams</rt></ruby><ruby>、二元搭配<rt>bigrams</rt></ruby>和<ruby>三元搭配<rt>trigrams</rt></ruby>,将它们作为一个关键词列表或者技术列表。相关领域的学生或者工程师需要了解这样一份列表里的内容。
|
||||
* 图形化地显示这个领域里重要的人名、技术、日期和地点。这会是一份很棒的信息图。
|
||||
* 构建一个<ruby>搜索引擎<rt>search engine</rt></ruby>。你的<ruby>搜索引擎<rt>search engine</rt></ruby>性能能够超过维基百科吗?
|
||||
* 构建一个搜索引擎。你的搜索引擎性能能够超过维基百科吗?
|
||||
|
||||
|
||||
### 接下来可以做什么?
|
||||
### 下一步?
|
||||
|
||||
<ruby>自然语言处理<rt>NLP</rt></ruby>是<ruby>应用构建<rt>application building</rt></ruby>的典型支柱。NLTK 是经典、丰富且强大的工具集,提供了为现实世界构建有吸引力、目标明确的应用的工作坊。
|
||||
自然语言处理是<ruby>应用构建<rt>application building</rt></ruby>的典型支柱。NLTK 是经典、丰富且强大的工具集,提供了为现实世界构建有吸引力、目标明确的应用的工作坊。
|
||||
|
||||
在这个系列的文章里,我用 NLTK 作为例子,展示了自然语言处理可以做什么。自然语言处理和 NLTK 还有太多东西值得探索,这个系列的文章只是帮助你探索它们的切入点。
|
||||
|
||||
如果你的需求慢慢增长到 NLTK 已经满足不了了,你可以训练新的模型或者向 NLTK 添加新的功能。基于 NLTK 构建的新的<ruby>自然语言处理库<rt>NLP libraries</rt></ruby>正在不断涌现,机器学习也正被深度用于自然语言处理。
|
||||
如果你的需求增长到 NLTK 已经满足不了了,你可以训练新的模型或者向 NLTK 添加新的功能。基于 NLTK 构建的新的自然语言处理库正在不断涌现,机器学习也正被深度用于自然语言处理。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
@ -1,55 +0,0 @@
|
||||
[#]: collector: "lujun9972"
|
||||
[#]: translator: "mcfd"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
[#]: subject: "My top 7 keywords in Rust"
|
||||
[#]: via: "https://opensource.com/article/20/10/keywords-rust"
|
||||
[#]: author: "Mike Bursell https://opensource.com/users/mikecamel"
|
||||
|
||||
在Rust中的前7个关键字
|
||||
======
|
||||
从Rust标准库学习一些有用的关键字。
|
||||
![Rustacean t-shirt][1]
|
||||
|
||||
我使用 [Rust][2] 已经有几个月了,写的东西比我预期的要多——尽管很多已经废弃掉了,但随着我的学习,我改进了所写的代码,并完成了一些超出我最初意图的更复杂的任务。
|
||||
|
||||
我仍然喜欢它,并认为谈论一些在 Rust 中重复出现的重要关键字会很好。我将提供我个人的总结:为什么你需要考虑如何使用它们,以及任何其他有用的东西,特别是对于刚接触 Rust 的新手或来自另一种语言的人(如 Java;请阅读我的文章 [*为什么作为一个 Java 程序员的我喜欢学习 Rust*](https://opensource.com/article/20/5/rust-java)).
|
||||
|
||||
事不宜迟,让我们开始吧。获取更多信息的好地方总是 Rust 官方文档——你可能想从[ std 标准库][4]开始.
|
||||
|
||||
1. **const** – 你可以用 const 声明常量。虽然这不是造火箭,但请一定要用 const ,如果你要在不同的模块中使用常量,那请创建一个 `lib.rs` 文件(Rust 默认的)你可以把所有的常量放在一个命名良好的模块中。我曾经在不同模块的不同文件中发生过 const 变量名(和值)的冲突,仅仅是因为我太懒了,除了在不同文件中剪切和粘贴之外,我本可以通过创建一个共享模块来节省大量的工作。
|
||||
2. **let** – 你并不 _总是_ 需要用 let 语句声明一个变量,但当你这样做时你的代码会更加清晰。此外,如果可以,请一定要添加变量类型。Rust 编译器会尽最大努力猜测它应该是什么类型的变量,但它不一定总能在编译时做到这一点(在这种情况下,编译器 [Cargo][5] 会提示你), 它甚至可能做不到你期望的那样。在这种情况下,对于 Cargo 来说,抱怨你所赋值的函数(例如)与声明不一致,总比 Rust 试图帮助你做错事,而你却不得不在其他地方花费大量时间来进行调试要简单。
|
||||
3. **match** – match 对我来说是新鲜事物,我喜欢使用它。它与其他编程语言中的 "switch" 没有什么不同,但在 Rust 中被广泛使用。它使代码更清晰易读,如果你做了一些愚蠢的事情(例如错过一些可能的情况),Cargo 会很好地提示你。我一般的经验法则是,在管理不同的 option 或进行分支时,如果可以使用 match,那就请一定要使用它。
|
||||
4. **mut** – 在声明一个变量时,如果它的值在声明后会发生变化,那么你需要声明它是可变的(Rust 中变量默认是不可变的)。常见的错误是在某个变量 _没有_ 变化的情况下声明它是可变的,这时编译器会警告你。如果你收到了 Cargo 的警告,说一个可变的变量没有被改变,而你认为它被 _改变_ 了,那么你可能要检查该变量的范围,并确保你使用的是正确的版本。
|
||||
5. **return** – 实际上我很少使用 return,它用于从函数中返回一个值,但是如果你只是在函数的最后一行提供值(或提供返回值的函数),通常会变得更简单,能更清晰地阅读。警告:在很多情况下,你 _会_ 忘记省略这一行末尾的分号(;),如果你这样做,编译器会不高兴的。
|
||||
6. **unsafe** – 如其意:如果你想做一些不能保证 Rust 内存安全的事情,那么你就需要使用这个关键字。我绝对无意在现在或将来的任何时候宣布我的任何 Rust 代码不安全;Rust如此友好的原因之一是它阻止了这种黑客行为。如果你真的需要这样做,再想想,再想想,然后重新设计代码。除非你是一个非常低级的系统程序员,否则要 _避免_ 使用 unsafe。
|
||||
7. **use** – 当你想使用另一个 crate 中的东西时,例如结构体、变量、函数等来自另一个 crate ,那么你需要在你要使用它的代码的代码块的开头声明它。另一个常见的错误是,你这样做了,但没有在 `Cargo.toml` 文件中添加该 crate (最好有一个版本号)。
|
||||
|
||||
|
||||
|
||||
我知道,这不是我写过的最复杂的文章,但这是我在开始学习 Rust 时会欣赏的那种文章。我计划在关键函数和其他 Rust 必知知识方面创建类似的文章:如果你有任何要求,请告诉我!
|
||||
|
||||
* * *
|
||||
|
||||
_本文最初发表于 [Alice, Eve, and Bob][6] 经作者许可转载。_
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/10/keywords-rust
|
||||
|
||||
作者:[Mike Bursell][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[mcfd](https://github.com/mcfd)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/mikecamel
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rustacean-tshirt.jpg?itok=u7LBmyaj "Rustacean t-shirt"
|
||||
[2]: https://www.rust-lang.org/
|
||||
[3]: https://opensource.com/article/20/5/rust-java
|
||||
[4]: https://doc.rust-lang.org/std/
|
||||
[5]: https://doc.rust-lang.org/cargo/
|
||||
[6]: https://aliceevebob.com/2020/09/01/rust-my-top-7-keywords/
|
Loading…
Reference in New Issue
Block a user