当前位置:网站首页>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
边栏推荐
- leetcode 6103 — 从树中删除边的最小分数
- uniapp组件-uni-notice-bar通告栏
- 1696C. Fishingprince plays with array [thinking questions + intermediate state + optimized storage]
- MySQL
- 【面试题】1369- 什么时候不能使用箭头函数?
- 看完这篇 教你玩转渗透测试靶机Vulnhub——DriftingBlues-9
- MySQL - database query - basic query
- C#应用程序界面开发基础——窗体控制(3)——文件类控件
- 【系统分析师之路】第五章 复盘软件工程(开发模型开发方法)
- Basis of information entropy
猜你喜欢
给你一个可能存在 重复 元素值的数组 numbers ,它原来是一个升序排列的数组,并按上述情形进行了一次旋转。请返回旋转数组的最小元素。【剑指Offer】
[Arduino experiment 17 L298N motor drive module]
12_ Implementation of rolling automatic video playback effect of wechat video number of wechat applet
攻克哈希的基本概念与实现
【面试题】1369- 什么时候不能使用箭头函数?
Using tensorboard to visualize the model, data and training process
【FPGA教程案例6】基于vivado核的双口RAM设计与实现
leetcode:701. Insertion in binary search tree [BST insertion]
一位苦逼程序员的找工作经历
[untitled]
随机推荐
leetcode:871. Minimum refueling times [Pat has done before + maximum stacking + greed]
The R language uses the ctree function in the party package to build conditional inference decision trees, uses the plot function to visualize the trained conditional inference decision tree, and the
How wide does the dual inline for bread board need?
R language ggplot2 visualization: use ggplot2 to display dataframe data that are all classified variables in the form of thermal diagram, and customize the legend color legend of factor
The latest analysis of tool fitter (technician) in 2022 and the test questions and analysis of tool fitter (technician)
Leetcode 2097 - Legal rearrangement of pairs
Concise analysis of redis source code 11 - Main IO threads and redis 6.0 multi IO threads
C#应用程序界面开发基础——窗体控制(4)——选择类控件
dotConnect for PostgreSQL数据提供程序
Androd gradle's substitution of its use module dependency
电话网络问题
[system analyst's road] Chapter V double disk software engineering (development model development method)
异步、郵件、定時三大任務
Expérience de recherche d'emploi d'un programmeur difficile
[androd] module dependency replacement of gradle's usage skills
信息熵的基础
2022 cable crane driver examination registration and cable crane driver certificate examination
Basic concept and implementation of overcoming hash
Kivy tutorial - example of using Matplotlib in Kivy app
数学知识:Nim游戏—博弈论