当前位置:网站首页>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
边栏推荐
- MySQL
- leetcode:701. 二叉搜索树中的插入操作【bst的插入】
- Strongly connected components of digraph
- Basic concept and implementation of overcoming hash
- Appuyez sur l'apprentissage de l'esprit de frappe - reconnaissance des coordonnées de fond multithreadées
- Daily topic: movement of haystack
- 12_ Implementation of rolling automatic video playback effect of wechat video number of wechat applet
- Top ten regular spot trading platforms 2022
- 看疫情之下服装企业如何顺势而为
- [Androd] Gradle 使用技巧之模块依赖替换
猜你喜欢

Cut point of undirected graph
![1696C. Fishingprince plays with array [thinking questions + intermediate state + optimized storage]](/img/bf/ab6838e34a3074130eac0a9992e77c.png)
1696C. Fishingprince plays with array [thinking questions + intermediate state + optimized storage]

leetcode 2097 — 合法重新排列数对

JS inheritance and prototype chain

Soft exam information system project manager_ Real topic over the years_ Wrong question set in the second half of 2019_ Morning comprehensive knowledge question - Senior Information System Project Man

Excel if formula determines whether the two columns are the same

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

Detailed explanation of Q-learning examples of reinforcement learning

Excel removes the data after the decimal point and rounds the number

力扣 204. 计数质数
随机推荐
Arduino DY-SV17F自动语音播报
【面试题】1369- 什么时候不能使用箭头函数?
无向图的割点
[Arduino experiment 17 L298N motor drive module]
【FPGA教程案例6】基于vivado核的双口RAM设计与实现
Test shift right: Elk practice of online quality monitoring
What are the trading forms of spot gold and what are the profitable advantages?
Draw love with go+ to express love to her beloved
【FPGA教程案例5】基于vivado核的ROM设计与实现
Delete duplicate elements in the ordered linked list -ii
MySQL basic usage 02
[androd] module dependency replacement of gradle's usage skills
对非ts/js文件模块进行类型扩充
软考信息系统项目管理师_历年真题_2019下半年错题集_上午综合知识题---软考高级之信息系统项目管理师053
Kivy tutorial how to create drop-down lists in Kivy
Kivy教程大全之如何在 Kivy 中创建下拉列表
Matlab Doppler effect produces vibration signal and processing
On Fibonacci sequence
How is the mask effect achieved in the LPL ban/pick selection stage?
Excel calculates the difference between time and date and converts it into minutes