当前位置:网站首页>Vim 9.0正式发布!新版脚本执行速度最高提升100倍
Vim 9.0正式发布!新版脚本执行速度最高提升100倍
2022-07-03 01:03:00 【Python数据之道】
出品 | OSC开源社区(ID:oschina2013)
将 Vim 9.0 版本献给 Sven Guckes,他于 2022 年 2 月去世。Sven 是 Vim 的核心维护者,他注册了 vim.org 域名并创建了第一个 Vim 网站,我们将以此纪念他。
经过多年的逐步改进,Vim 现在推出了一个重要版本,向前迈出了一大步。除了许多小的补充改进之外,该版本的重点是 Vim 脚本语言的一个新的变化:Vim9 Script。
上一个版本是 2019 年 12 月发布的 8.2 版。由于最新的源代码总是会在 GitHub 上提供,因此许多用户已经安装了后来的补丁版本(有超过 5000 个),这些变化也已经被许多用户试用过了。在 8.2 的基础上,许多错误得到了修复、安全问题得到了解决,代码覆盖率得到了极大的提升。这个版本比以前的任何版本都更可靠。
Vim9 Script
Vim 的脚本随着时间的推移而不断发展,同时保留了向后的兼容性。这意味着过去的错误选择往往无法改变,与 Vi 的兼容性也限制了可能的解决方案。因此执行速度相当慢,每次执行时都要对每一行进行解析。
Vim9 Script 的主要目标是极大地提高性能。这是通过将命令编译成可以有效执行的指令来实现的,执行速度有望提高 10 到 100 倍。
Vim9 Script 的次要目标是避免 Vim 特有的结构,使其更接近于常用的编程语言,如 JavaScript、TypeScript 和 Java。
性能的提高只能通过不 100% 向后兼容来实现。例如,通过创建一个 "a:" 字典使函数参数可用涉及到相当多的开销,在 Vim9 函数中,这个字典不再可用。
对于那些有大量传统脚本的开发者来说也不用过于担心,这些脚本依然可以像以前一样使用。目前没有计划放弃对传统脚本的支持,变化不会像 Python 2 到 Python 3 那样剧烈。
有趣的功能
为了从加速中获益,一个函数必须用 def 来定义,必须指定参数和返回类型。这不仅是为了使执行速度更快,也有助于在函数被编译成字节码时及早发现错误。变量需要用 var 来声明的,并且也有一个类型,可以是明确的,也可以是从分配的值中推断出来的。
行的延续不需要使用反斜杠,这是在传统脚本中使用的机制。
函数调用不需要 call,赋值不需要 let,表达式的求值不需要 eval。这使得 Vim9 Script 看起来更像大多数编程语言。
将一个大的脚本分割成小块如今也变得简单多了。在一个脚本中, export 被用来使特定的函数和变量对其他脚本可用,然后在需要使用导出的项目的地方使用 import。结合自动加载机制,这为实现大型插件带来了一种灵活而强大的方式。
现在注释以 # 开头。以前的双引号语法来自古老的 Vi,会干扰字符串的使用。在许多其他语言中,例如 Python 和 shell 脚本,都知道 # 的含义。
未来的工作
在 Vim9 Script 的计划之一是添加类,虽然可以用字典来模拟,但这还远远不够理想。大多数程序员都熟悉类,在 Vim9 Script 中也应该加入这样的东西,目前关键字已经被保留。
更多详情可查看:https://www.vim.org/vim90.php
边栏推荐
- Top ten regular spot trading platforms 2022
- 【系统分析师之路】第五章 复盘软件工程(开发模型开发方法)
- Test shift right: Elk practice of online quality monitoring
- Niu Ke swipes questions and clocks in
- Assets, vulnerabilities, threats and events of the four elements of safe operation
- How wide does the dual inline for bread board need?
- 每日一题之干草堆的移动
- Leetcode 6103 - minimum fraction to delete an edge from the tree
- MySQL basic usage 02
- MySQL foundation 07-dcl
猜你喜欢

攻克哈希的基本概念与实现

Excel calculates the difference between time and date and converts it into minutes

Cut point of undirected graph
![[FPGA tutorial case 6] design and implementation of dual port RAM based on vivado core](/img/fb/c371ffaa9614c6f2fd581ba89eb2ab.png)
[FPGA tutorial case 6] design and implementation of dual port RAM based on vivado core

leetcode:701. 二叉搜索树中的插入操作【bst的插入】

Basic concept and implementation of overcoming hash

1696C. Fishingprince Plays With Array【思维题 + 中间状态 + 优化存储】

Top ten regular spot trading platforms 2022
![leetcode:871. Minimum refueling times [Pat has done before + maximum stacking + greed]](/img/2c/8ec3926243fac8db9ed45d8053f3af.png)
leetcode:871. Minimum refueling times [Pat has done before + maximum stacking + greed]

Androd Gradle 对其使用模块依赖的替换
随机推荐
Dotconnect for PostgreSQL data provider
Type expansion of non ts/js file modules
测试右移:线上质量监控 ELK 实战
[my advanced journey of OpenGL learning] collation of Euler angle, rotation order, rotation matrix, quaternion and other knowledge
Excel if formula determines whether the two columns are the same
How is the mask effect achieved in the LPL ban/pick selection stage?
Is there anything in common between spot gold and spot silver
Specified interval inversion in the linked list
Every k nodes in the linked list are flipped
1696C. Fishingprince Plays With Array【思维题 + 中间状态 + 优化存储】
【无标题】
MongoDB系列之MongoDB常用命令
力扣 204. 计数质数
The industrial scope of industrial Internet is large enough. The era of consumer Internet is only a limited existence in the Internet industry
[untitled]
Machine learning terminology
Do not log in or log in to solve the problem that the Oracle database account is locked.
Esp32 simple speed message test of ros2 (limit frequency)
Compare version number
MySQL foundation 05 DML language