Silverfish编程语言

They say, each professional developer must have done at least three pet projects: a sophisticated logging utility, a smart json parser, and an amazing programming language. Once we have both logger and parser accomplished, we finally decided to reveal our desperate success in creation one of the most innovative programming languages named Silverfish.

他们说,每个专业开发人员必须完成至少三个宠物项目:一个复杂的日志记录实用程序,一个智能json解析器和一种出色的编程语言。 一旦记录器和解析器都完成了,我们最终决定展示我们在创建最创新的编程语言之一Silverfish中的绝望成功。

Карасик → На самом деле плотвичка

As we all know, the universe is constantly moving around. Evolution of programming languages is not even close to completion. New languages emerge every year to undergo the laboratory testing on human beings and die in oblivion, sooner or later. The vast majority of innovations in any new language could barely be considered as a result of new development, but as the evolution of well-known approaches or even reinvention of old good wheels.

众所周知,宇宙在不断移动。 编程语言的发展还远远没有完成。 每年都会出现新的语言,经过人类的实验室测试,或早或晚被遗忘。 任何新语言的绝大多数创新都几乎不能被认为是新发展的结果,而是随着众所周知的方法的演进,甚至是对旧的好轮子的重新发明。

While working on Silverfish we were inspired by such successful projects as rust, python, c++, wolfram, and experimental creatures, such as dcastf, glink, whitespace and many others that although have not conquered the world, but remain very valuable and enlightening.

在研究Silverfish时,我们受到诸如rustpythonc ++wolfram和实验生物(例如dcastfglink空白)和许多其他虽然没有征服世界但仍然非常有价值和启发性的生物的成功项目的启发。

So, welcome to our brand new majestic development language, The Silverfish.

因此,欢迎使用我们全新的雄伟开发语言The Silverfish

权利分配语法 (Right Assignment Syntax)

Ages ago when computers were huge and dinosaurs were tiny, the founding fathers made a mistake in sewing up the assignment operator the right-to-left behavior, which is contrary to what would be intuitively expected (unless your mother language is Farsi).

几十年前,当计算机巨大而恐龙很小时,开国元勋们在将赋值运算符缝制从右到左的行为时犯了一个错误,这与直观上的预期是相反的(除非您的母语是波斯语)。

This right-to-left religion left (pun is intended) its stigma on many technologies, making us to perceive:

这种从右到左的宗教在很多技术上都被贬低了(旨在达到双关语),这使我们意识到:

  • Assembly instruction mov confusing students by the order of the arguments for the seventh decade already;

    汇编指令mov通过的论点第七十年已经次序混乱的学生;

  • C standard library functions, such as strcpy, memmove etc drive students bonkers because there is neither logic nor at least some consistency in their argument order.

    C标准库函数(例如strcpymemmove等)使学生大开玩笑,因为他们的论据顺序既没有逻辑,也没有任何一致性。

Still it would be fine if we have always enjoyed the right-to-left paradigm, but the thirst for naturalness spawned:

如果我们一直喜欢从右到左的范例,那还是可以的,但是自然的渴望产生了:

  • command-line utilities cp, ln, etc.

    命令行实用程序cpln

  • the syntax of the functions in the standard C++ library, such as std::copy and its family.

    标准C++库中函数的语法,例如std::copy及其家族。

The dichotomy of directions led to the fact that instead of unstoppably writing code, the developer is forced to pause, walk to the coffee machine for another espresso and lazily move back to the comfortable chair to review hundreds of pages of the respective documentation.

方向的二分法导致这样一个事实,即开发人员没有停下来编写代码,而是被迫暂停,走到咖啡机旁喝另一杯意式浓缩咖啡,然后懒洋洋地回到舒适的椅子上查看数百页相应文档。

Luckily enough, after decades of industry stagnation in regard to this issue, there has been a recent shift. The vast majority of modern tools pick up left-to-right as the default direction as opposed to right-to-left. While the order of arguments in the library functions is still given away to project maintainers’ will, assignment operators that built into the syntax of programming languages survived despite any modern tendency. There came the time to hammer a nail of the righteous wrath to the coffin of prosperous irrationality, which is called, yeah, the assignment operator.

幸运的是,经过数十年的行业停滞之后,最近发生了转变。 绝大多数现代工具都采用从左到右作为默认方向,而不是从右到左。 尽管库函数中参数的顺序仍然由项目维护者决定,但尽管有任何现代趋势,但内置于编程语言语法中的赋值运算符仍然存在。 到了时候,应该将义愤填在钉在繁荣的非理性棺材上了,是的,是赋值运算符。

Silverfish language introduces the right (yes, the right) assignment.

蠹虫的语言介绍了正确的(是 ,右)分配。

42 => answer
foo(42) => answer

Understanding the imperfections of human nature and the inability of the greater part of the community for such radical rebuilding, we did not banish the old assignment operator of the language completely. One can still use it, with the warning prompty spat into the developers’ face.

理解人性的不完善之处以及社区的大部分成员无法进行这种根本性的重建之后,我们没有完全摒弃旧的语言赋值运算符。 仍然可以使用它,警告Swift喷入开发人员的脸庞。

Optional assignment direction: left-to-right and right-to-left:

可选的分配方向:从左到右和从右到左:

LtR vs RtL

By the way, the syntax below is also perfectly valid and can be used for some hacks:

顺便说一下,下面的语法也是完全有效的,可以用于某些黑客:

42 => answer = 42

类型管理; 口译与编译器 (Type Management; Interpreter vs Compiler)

There are unceasing debates getting into the fight, what typing is preferable, static, dynamic, structural, nominative, or else. Silverfish rides all the horses at once, allowing the developer to change the typing from line to line.

争论不断,涉及哪种类型是可取的, 静态的动态的结构的主格的其他Silverfish可一次骑所有马匹,使开发人员可以逐行更改打字。

<typing:dynamic> // dynamic typing :: globally on

fn foo(a, b) // this code is dynamically typed
{
    a + b => c
    return c
}

fn bar(a:i32, b) // dynamically typed, nominative type check
{   
    a + b => c
    return c
}

[typing:static] // local function annotation :: statically typed
fn fubar(a:i32,b:i32) -> i32 // this code is statically typed
{
    a + b => c : i32
    return c

    // other ways to return the value from function
    // a + b => return
    // a + b
}

When we introduced the changeable typing, we at some point discovered that it opens fairly wide approach to optimizations, since the static part can be compiled (the interpreter executes it in jit mode for the native processing instructions.) If the whole application is configured to be fully statically typed, it’s even possible to compile it into an executable file. (Technically we can do it with dynamic code, but in this case we are to deliver the interpreter, the virtual machine and the whole jungle within the code.)

当我们引入可变类型时,我们在某个时候发现它为优化提供了相当广泛的方法,因为可以编译静态部分(解释器以jit模式针对本机处理指令执行它。)如果将整个应用程序配置为完全静态输入,甚至可以将其编译为可执行文件。 (从技术上讲,我们可以使用动态代码来做到这一点,但是在这种情况下,我们将在代码内交付解释器,虚拟机和整个丛林。)

In addition to static and dynamic typing, Silverfish also presents the kinematic typing. This is a brand new kind of typing, recently invented by the academic community. Details of this kind of typing are out of scope of this introductory article, because this topic is worthy of a three-thousand-page book. Just to give an idea, the kinematically typed variable would depend on the types of all the local and global variable in the respective scope, the object tree and the Earth’s axis direction because complete is a composition of portable and relative, as stated in the Holy book:

除了静态和动态打字外, Silverfish还提供了运动学打字 。 这是学术界最近发明的一种全新的打字方式。 这种介绍的细节不在本介绍性文章的讨论范围之内,因为该主题值得一本长达三千页的书。 只是给出一个想法, 运动学类型的变量将取决于相应范围内所有局部变量和全局变量的类型,对象树和地球的轴方向,因为完整可移植的相对的 ,如《圣经》所述。书:

Statics / Dynamics / Kinematics

空格与制表符 (Spaces vs Tabs)

Silverfish offers a beautiful solution to the eternal question, what should be preferred, tabs or spaces. This solution was inspired by whitespace language, which roughly proofs its inviolability and rightness. We gracefully admire the idea of Go authors to use tab-only doctrine to indicate margins and forbid any space-padding in general, but we decide that the arbitrary proclaiming tabs as the truth in the last instance violates the rights of white-spaced minorities, which is contrary to modern society movement toward tolerance and diversity.

Silverfish为永恒的问题(选项卡或空格)提供了一个很好的解决方案。 该解决方案受到空白语言的启发,该语言大致证明了其不可侵犯性和正确性。 我们非常佩服Go语言作者使用仅tab原则来表示页边距并禁止任何空格填充的想法,但是我们决定将任意声明的制表符作为最后的事实侵犯了空白少数群体的权利,这与现代社会向宽容和多样性的运动相反。

In Silverfish, tabs and spaces have different meanings!

Silverfish中制表符空格具有不同的含义!

a + foo(b) => c // tabs
    a + foo(b) => c // spaces

These two expressions look the same, but there is a huge difference. The difference is in the exception handling. Everyone knows that code design like

这两个表达式看起来相同,但是存在巨大差异。 区别在于异常处理。 每个人都知道这样的代码设计

try {
    foo();
}
catch (...) {}

swallowing exceptions is quite popular among developers. We decided to let this design to penetrate into the language core syntax. Now, one can explicitly suppress exceptions by whitespace indentation. The code of Mighty Spacers would run smoothly while the code of Vile Tabbers would raise inevitably.

吞咽异常在开发人员中非常流行。 我们决定让这种设计渗透到语言核心语法中。 现在,可以通过空格缩进显式抑制异常。 强大的垫片代码将平稳运行,而邪恶的泰伯斯代码将不可避免地提高。

错误处理 (Error Handling)

In addition to the aforementioned graceful error handling (aka spaces vs tabs round,) Silverfish has a genuinely elaborated system of dealing with exceptional cases.

除了前面提到的优美的错误处理(又称空格制表符圆), Silverfish还具有处理异常情况的精心设计的系统。

In addition to the classical methods, such as exception handling based on archaic try-catch

除了经典方法外,例如基于过时try异常处理catch

try {
    throw Exception(42);
} catch ex {
    print(ex.value)
    exit(0)
}

and built-in support for unioned result

并内置对联合结果的支持

fn foo() -> result(i32) 
{
    return Exception(42)
}

Silverfish has many contemporary features to handle errors, such as widely discussed in the past, but never actually implemented, tryso clause, which, when an exception is caught, opens the new page in the browser and automatically searches the error on Stack Overflow.

Silverfish具有许多现代功能来处理错误,例如在过去进行了广泛讨论,但从未实际实施过, tryso子句在遇到异常时会在浏览器中打开新页面并自动在Stack Overflow上搜索错误。

tryso {
    throw Exception(42)
}

We are also proud to introduce the tryso_explicit version that instead of performing a passive lookup at Stack Overflow, posts a question with a comprehensive error description. Paid versions of Silverfish would immediately upvote this question from all the community accounts and push the question to IDEs of users of free version.

我们还很自豪地推出tryso_explicit版本,而不是在Stack Overflow上执行被动查找,而是发布带有全面错误描述的问题。 Silverfish的付费版本将立即从所有社区帐户中删除该问题,并将该问题推送给免费版本用户的IDE。

tryso_explicit {
    throw Exception(42)
}

There is also force_retry macro, that enforces the code to be re-executed until it finally runs properly.

还有force_retry宏,它强制重新执行代码,直到最终正确运行为止。

force_retry {
    throw Exception(42)
}
Einstein

Under some circumstances, force_retry might not be a perfect fit; in this cases we have smart_try to the rescue. The latter executes the code only if it looks more or less valid.

在某些情况下, force_retry可能并不完美。 在这种情况下,我们可以通过smart_try进行救援。 后者仅在看起来或多或少有效时才执行代码。

smart_try {
    throw casdcasd sdfsadf Exception(42) // this would never get executed
}

In addition, there is a rather useful core function shallow_throw(N) which throws an exception that gets propagated not more than N levels higher on the call stack.

另外,还有一个相当有用的核心函数shallow_throw(N) ,该函数抛出一个异常,该异常在调用堆栈中传播的高度不超过N级别。

shallow_throw(n) Exception(42)

What would be the real use-case of the above remains unclear to the authors of the language, but they leave it as is in a hope the community would come up with something here.

语言的作者尚不清楚上述内容的真正用例,但他们将其保留原样,以希望社区在这里提出一些建议。

懒惰的互联网计算 (Lazy Internet Computing)

The solution of many computational problems is extremely easy to find in the internet search engines. Therefore, the smart Silverfish interpreter, when encounters a particularly complicated calculation, does take any action upon it directly, but rather googles it for the previously published solution. Thus, the calculation of factorials of large numbers, or Fibonacci numbers, or like this has in Silverfish the complexity O(1). This revolutionary method sometimes even allows Silverfish to predict and produce in the runtime (or compilation time for static variants) exception in the case when the algorithm would never return.

在互联网搜索引擎中非常容易找到许多计算问题的解决方案。 因此,智能Silverfish解释器在遇到特别复杂的计算时,确实会直接对其采取任何措施,而是将其谷歌搜索为先前发布的解决方案。 因此,大数或斐波那契数的阶乘的计算在Silverfish中具有复杂度O(1) 。 在算法永远不会返回的情况下,这种革命性的方法有时甚至允许Silverfish在运行时(或静态变量的编译时)预测并产生异常。

That is, Silverfih is occasionally able to solve the notorious Halting Problem.

也就是说, Silverfih有时能够解决臭名昭著的暂停问题

If Silverfish was unable to find an acceptable solution in the internet, it indeed performs the calculation itself and publishes it back to the internet. Both poor financial resources and considerations of ethical nature prevents us from storing in our datacenters everything calculated by Silverfish worldwide. Instead, Silverfish takes an advantage of decentralized storage, pushing the results to random forum boards. That perfectly works thanks to the aforementioned approach to google this data when needed by another piece of the application.

如果Silverfish无法在Internet上找到可接受的解决方案,则它确实会自行执行计算并将其发布回Internet。 贫乏的财务资源和道德性质的考虑都使我们无法在全球范围内将Silverfish计算出的所有数据存储在数据中心中。 相反, Silverfish利用分散存储的优势,将结果推向随机论坛。 这完全可以通过前面提到的方法在另一应用程序需要时谷歌搜索这些数据来实现。

智能语言 (Smart Language)

They say, the developer’s time is quite expensive. A considerable amount of this time is spent not on writing code and building software architecture, but on non-stop fighting with spelling errors and syntactic inaccuracies. Modern languages in general are very intolerant to human imperfection.

他们说,开发人员的时间非常昂贵。 这段时间中有相当多的时间不花在编写代码和构建软件体系结构上,而是花在不停地拼写错误和语法错误上。 总体而言,现代语言对人类的不完美行为非常不宽容。

Not Silverfish though.

虽然不是银鱼

Clowns

An explicitly designed artificial intelligence module is built into the interpreter. Once stumbled on a syntax or spelling error, it’d predict what the developer had in mind, and run the proper code instead. Performance is not affected at all, especially if the interpreter is tweaked to use all these parallel computing gpu rocket science.

解释器中内置了明确设计的人工智能模块。 一旦偶然发现语法或拼写错误,它就可以预测开发人员的想法,并运行适当的代码。 性能一点也不受影响,特别是如果解释器已调整为使用所有这些并行计算gpu火箭科学。

AI is also trained to give advices in regard to design patterns and architectural issues. It also might be configured to switch mentoring mode on so that it can take over the patronage of novice developers.

还培训了AI,以提供有关设计模式和架构问题的建议。 它还可以配置为打开指导模式,以便它可以接管新手开发人员的支持。

In the upcoming version of the language, the voice assistant would be included to make it possible to generate the code based on the voice commands. Tightly coupled with the suggestion lookup and existing solution search, it is designed to allow performing development for people who had never seen the computer before. The pre-release version is already able to understand voice commands like “I need an accounting system” and “Create me a site by tonight.”

在即将发布的语言版本中,将包括语音助手,以使基于语音命令生成代码成为可能。 它与建议查找和现有解决方案搜索紧密结合,旨在允许对以前从未看过计算机的人进行开发。 预发行版本已经能够理解语音命令,例如“我需要会计系统”和“今晚为我创建网站”。

导入动态库和模块 (Import of Dynamic Libraries and Modules)

The maturity of architectural solutions, artificial languages and software designs, as well as the versatility of typing, allows Silverfish to build generic interfaces for interoperability with other languages that do not require special bindings or wrappers, as used in lua, python and other languages. Binding external libraries is straightforward.

体系结构解决方案,人工语言和软件设计的成熟性以及键入的多功能性,使Silverfish可以构建通用接口,以与其他不需要luapython和其他语言的特殊绑定或包装的语言进行互操作。 绑定外部库很简单。

The import package from python, one might use

从python导入的包,可能使用

import python3:numpy as np

fn main() 
{
    np.arange([42,41,40]) => arr
    np.log10(arr)
}

To import the C standard library:

要导入C标准库:

import clang:string.h as cstring
import clang:stdlib.h as cstdlib

fn main() 
{
    raw_buffer(cstdlib.malloc(40),40) => buf0
    cstring.strcpy(buf0, "HelloWorld")

    println(buf0) // HelloWorld
}

Rigorous readers would surely notice that this kind of import support brings the enormous capabilities of integrating all the existing languages and technologies into Silverfish, and it certainly does. There is no doubt that in the future there will be alpha and omega programming language that will unite everything, and, winning the contest against Disney Studio, will connect all the Sith and Jedi at once, not by clusters.

严格的读者肯定会注意到,这种导入支持带来了将所有现有语言和技术集成到Silverfish中的巨大功能,而且的确如此。 毫无疑问,将来会有alpha和omega编程语言将所有内容统一起来,并且在与Disney Studio的竞赛中获胜后,它将立即将所有Sith和Jedi相连,而不是通过集群。

Brigade

标准协议和RFC支持 (Standard Protocols and RFC Support)

Silverfish comes with a set of libraries supporting all the most common standards and technologies, including but not limited to

Silverfish带有一组支持所有最常见标准和技术的库,包括但不限于

RFC1149 (RFC1149)
fn main() 
{
    rfc1149.datagramm("HelloFriend") => dgramm
    rfc1149.send_bird("c/de Marina 16, this Friday, 7AM to 2PM", dgramm)
}
RFC2795 (RFC2795)
import rfc2795

fn main() 
{
    rfc2795.monkey("Jonh") => john
    rfc2795.monkey("George") => george
    rfc2795.monkey("Stephen") => stephen

    rfc2795.monkey_group([jonh, george]) => jonh_and_george

    "" => sonnet    
    do  
    {
        john_and_george.make_sonnet(66) => sonnet
    } while(stephen.do_critic(sonnet) is false)

    println(sonnet)

    /*

    Tired with all these, for restful death I cry,
    As, to behold desert a beggar born,
    And needy nothing trimm'd in jollity,
    And purest faith unhappily forsworn,
    And guilded honour shamefully misplaced,
    And maiden virtue rudely strumpeted,
    And right perfection wrongfully disgraced,
    And strength by limping sway disabled,
    And art made tongue-tied by authority,
    And folly doctor-like controlling skill,
    And simple truth miscall'd simplicity,
    And captive good attending captain ill:

    Tired with all these, from these would I be gone,
    Save that, to die, I leave my love alone. 

    */
}

结论 (Conclusion)

Here comes the time when we shall be proud to introduce the prototype of the language and publish the source code to the public domain. This landmark event will surely happen and then the IT world would never be the same. Silverfish would not pass unnoticed to the public, for it has all the chances to become one of the most important and long-lived languages in the whole history of the industry, before to give way to new, even better languages.

现在是时候,我们将自豪地介绍该语言的原型并将其源代码发布到公共领域。 这个具有里程碑意义的事件肯定会发生,然后IT界将永远不一样。 Silverfish不会被公众忽视,因为它有机会成为整个行业历史上最重要,寿命最长的语言之一,然后才让步给新的甚至更好的语言。

Silverfish re-interpreted everything in a new way, in the truly spirit of times. We believe that soon we’ll see offers for developers positions in Silverfish, here and there.

银鱼本着真正的时代精神,以一种新的方式重新诠释了一切。 我们相信很快就会在这里和那里看到针对Silverfish的开发人员职位的报价。

There would be Silver Junior Fisher, Silver Middle Fisher, and many recommendative articles on how to interview Silver Senior Fisher here and there.

会有Silver Junior FisherSilver Middle Fisher以及许多有关如何在这里和那里采访Silver Senior Fisher的建议性文章。

So let Silverfish be sailing confidently toward a brighter future. Hurray, comrades!

因此,让Silverfish充满信心地走向更光明的未来。 同志们!

致谢 (Acknowledgments)

The author is grateful to Aleksei Matiushkin (aka chapuza) for the translation and adaptation into English.

作者感谢Aleksei Matiushkin(aka chapuza )的翻译和改编成英文。

provided by Silver Fisher Inc. All rights reserved.

由Silver Fisher Inc.提供。保留所有权利。

Thanks for pay attention

Russian version of this text

此文本的俄语版本

翻译自: https://habr.com/en/post/495372/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值