罗塞塔语言包_罗塞塔代码(Rosetta Code)—揭开为世界提供动力的编程语言的奥秘

罗塞塔语言包

It’s no secret that the tech world is dominated by a relatively small pool of programming languages. While exact figures are difficult to obtain (and no doubt vary over time), you could probably name a handful of languages which comprise the vast majority of all programming output over a given period of time.

在相对较小的编程语言库中占据主导地位的技术世界已经不是什么秘密了。 尽管很难获得确切的数字(并且毫无疑问会随时间而变化),但是您可以命名几种语言,这些语言在给定的时间内包含了所有编程输出的绝大部分。

Two interesting sites I visited while researching this article let you visualize programming languages by popularity. IEEE Spectrum lets you interactively adjust the weightings of various metrics, whereas PYPL serves up a neat table giving actual % share figures based on Google Trends data over the last 12 months.

在研究本文时,我访问了两个有趣的站点,使您可以按受欢迎程度直观地显示编程语言。 IEEE Spectrum使您可以交互式地调整各种指标的权重,而PYPL提供了一个整洁的表格,根据过去12个月的Google趋势数据提供了实际的%份额数据。

Now, I refuse to be drawn into any debates over exactly what the best metric of programming language popularity may or may not be (and whether or not that’s an important statistic anyhow). What follows is just a hasty analysis to illustrate a point (any excuse really to use R-Fiddle!)

现在,我拒绝参与有关最佳的编程语言流行度指标到底是什么(无论这是否是重要的统计数据)的争论。 接下来的内容只是仓促分析,以阐明一个观点(任何真正使用R-Fiddle的借口!)

Using the data from PYPL, we can see a couple of clear trends:

使用PYPL的数据,我们可以看到几个明显的趋势:

In order, these are: Java, Python, PHP, C#, JavaScript, C, C++, Objective-C, R and Swift. Combined, they have a Google Trends share of 87.1%.

按顺序,这些是:Java,Python,PHP,C#,JavaScript,C,C ++,Objective-C,R和Swift。 两者合计占Google趋势的87.1%。

2)—语言受欢迎程度遵循幂律分布 (2) —Language popularity follows a power-law distribution)

Using my favorite R package, ‘igraph’, for its trusty power.law.fit() function, I found that the popularity of programming languages follows a power-law distribution:

使用我最喜欢的R包' igraph '的可靠的power.law.fit()函数,我发现编程语言的流行遵循幂律分布:

> pL = power.law.fit(shares)> pL$KS.p$KS.p[1] 0.9873141

That $KS.p value of 0.987 is the p-value associated with a Kolmogorov-Smirnov test statistic, which tells us that we can be pretty damn sure the distribution of popularity (as defined by PYPL) does follow a power-law distribution.

$KS.p值0.987是与Kolmogorov-Smirnov检验统计量相关的p值,这告诉我们可以肯定的是,受欢迎程度的分布(由PYPL定义)确实遵循幂律分布。

Like many other phenomena, the relative popularity of programming languages is unevenly distributed. This can usually be explained by a positive feedback (or ‘snowball-effect’) mechanism — a simplistic version might go that the more popular a language is, the more jobs are available in it, so more people are incentivised to learn it, thus increasing its popularity.

像许多其他现象一样,编程语言的相对流行度分布不均。 这通常可以通过积极的反馈(或“雪球效应”)机制来解释-一种简单的版本可能会成为一种语言,它越受欢迎,提供的工作就越多,因此就有更多的人被鼓励去学习它,因此越来越受欢迎。

那么有什么新消息? (So what’s new?)

It’s not really a surprise that some programming languages are waaaay more popular than others. Everyone already knows that Java, C, C++, C#, Python et al. are by far the most used languages.

某些编程语言比其他编程语言更流行并不奇怪。 每个人都已经知道Java,C,C ++,C#,Python 等。 是迄今为止最常用的语言。

What’s more interesting, in my opinion, is the observation that for every behemoth programming language, there must be dozens of smaller, more niche languages out there in the wilderness.

在我看来, 有趣的是观察到对于每种庞然大物的编程语言,在旷野中肯定有数十种较小的,更特殊的语言。

Sheer curiosity aside, there are good reasons to be interested by this. Anyone who’s dabbled in more than a handful of programming languages knows that different languages suit different purposes. JavaScript is for web development, PHP for server-side programming, R for statistics, Matlab for full-on mathematics. With programming languages, variety is a good thing. Out there, there might just be a language ideally suited for solving that problem you didn’t even know existed.

除了纯粹的好奇心,对此有充分的理由感兴趣。 精通多种编程语言的人都知道不同的语言适合不同的目的。 JavaScript用于Web开发,PHP用于服务器端编程,R用于统计,Matlab用于全面的数学。 使用编程语言,多样性是一件好事。 在那里,可能只有一种语言非常适合解决您甚至不知道存在的问题。

But where to find them? One place to look is Rosetta Code.

但是在哪里可以找到他们呢? 查找的地方之一是Rosetta Code。

编程Safari (A Programming Safari)

I can’t remember exactly how I came across Rosetta Code, but once I found it, I was hooked. It describes itself as a programming chrestomathy site, and features an impressive 647 programming languages in its archives. Go and check it out.

我记不清我是如何遇到Rosetta Code的,但是一旦找到它,我就迷上了。 它自称是编程的主要站点,并且其存档中包含令人印象深刻的647种编程语言。 去检查一下。

The truly awesome thing is that Rosetta Code goes beyond just giving a generic “Hello World!” example for each language. No, instead, it has a collection of over 800 assorted programming tasks, from some as simple as “Odd or Even”, through to more advanced problems, such as maze-solving and web-scraping. Each task page describes the problem to be solved, then gives solutions in a range of programming languages.

真正令人敬畏的是,Rosetta Code不仅提供了通用的“ Hello World!”。 每种语言的示例。 不,相反,它有800多种编程任务的集合,从简单到“奇数或偶数”到更高级的问题,例如迷宫解决和网络抓取。 每个任务页面都描述了要解决的问题,然后提供了多种编程语言的解决方案。

Here, reputation doesn’t matter. As well as C, C++, Java etc., you will find solutions in languages you’ve never heard of before. Some are retro, some are modern; some look familiar, while others are esoteric beyond belief. You could spend longer than you’d care to admit browsing through all the examples — but to help you get started, I’ve compiled a list of some of the lesser-known and/or more interesting languages which caught my attention. Activate nerd-mode, and dive in!

在这里,声誉无关紧要。 以及C,C ++,Java等,您将找到以前从未听说过的语言解决方案。 有些是复古的,有些是现代的。 有些看起来很熟悉,而另一些则深不可测。 您可能花了比您想要花费的时间更长的时间才能浏览所有示例-但是为了帮助您入门,我整理了一些引起我注意的鲜为人知和/或更有趣的语言的列表。 激活书呆子模式,然后潜入水中!

过去的爆炸 (Blast From The Past)

Some languages last forever, or so it seems. As well as C, languages descended from Lisp and Fortran have been around for decades, and others such as BASIC and Pascal may have fallen out of fashion but live on in popular memory.

有些语言会永远存在,或者看起来如此。 与C一样,来自Lisp和Fortran的语言也已经存在了数十年,而其他一些语言(例如BASIC和Pascal)可能已经过时,但仍流行于人们的记忆中。

Time has been less kind to others, though. Here’s a list of some languages with code samples on Rosetta which, to put it one way, are unlikely to get you hired any time soon.

不过,时间对其他人而言并不那么友善。 这是罗塞塔(Rosetta)上带有代码示例的一些语言的列表,以一种方式来说,不太可能很快就让您被录用。

EDSAC订单代码 (EDSAC Order Code)

EDSAC is a famous early computer, designed and built by Maurice Wilkes’ team at the University of Cambridge in the late 1940’s. The construction of EDSAC saw David Wheeler earn the first ever PhD in Computer Science in 1951. Whilst he was at it, he also invented the ‘Wheeler jump’, or closed subroutine — which we commonly refer to today as ‘functions’.

EDSAC是著名的早期计算机,由剑桥大学的莫里斯·威尔克斯 ( Maurice Wilkes )团队在1940年代后期设计和制造。 EDSAC的构建使David Wheeler于1951年获得了计算机科学领域的第一个博士学位。在他任职的同时,他还发明了“ Wheeler jump”或封闭子程序 -今天我们通常将其称为“功能”。

Despite its unshakeable place in history, EDSAC has been out of action since 1958, so don’t rush to learn its custom programming language. Here’s an example from Rosetta Code. It’s the ‘empty program’, or the shortest legitimate program. It doesn’t do very much at all.

尽管EDSAC在历史上处于不可动摇的地位,但自1958年以来它就一直处于停产状态,因此不要急于学习其自定义编程语言。 这是Rosetta Code中的示例 。 这是“空程序”或最短的合法程序。 它根本没有做什么。

T64K  [ set load point ]GK    [ set base address ]ZF    [ stop ]EZPF  [ begin at load point ]

乔治 (GEORGE)

This language, invented in 1957, is one that would have been entered via punched tape into a machine the size of a room. Nevertheless, it was full of features, including loops, conditional statements, subroutines, and matrix data structures. It even reads a little like a more modern language.

这种语言是1957年发明的,可以通过打Kong的胶带输入到一间房间大小的机器中。 但是,它具有很多功能,包括循环,条件语句,子例程和矩阵数据结构。 它甚至读起来有点像更现代的语言。

Sixty years on though, GEORGE is no longer with us. Here’s how it would have been use to calculate the sum of a series:

六十年来,乔治已不在我们身边。 这是用于计算序列之和的方法 :

0 (s)1, 1000 rep (i)   s 1 i dup × / + (s) ;]P

BCPL (BCPL)

‘Basic Combined Programming Language’, or BCPL, is worthy of its place in computing history. As well as apparently giving rise to the tradition of “Hello World!”, BCPL had a profound influence on the design of B, which was itself the forerunner of C. BCPL was the first language to introduce braces “{“ as a way of defining blocks of code — a convention still used in many of today’s most prominent languages. Decent, as legacies go.

“基本组合编程语言”(BCPL)在计算历史中占有一席之地。 BCPL显然引起了“ Hello World!”的传统,但它对B的设计产生了深远的影响,而B本身就是C的先驱。BCPL是第一种引入花括号“ {”作为定义代码块—一种约定,至今仍在许多当今最著名的语言中使用。 体面,随着遗产的发展。

Here’s a “Hello World” program written in BCPL:

这是用BCPL编写的“ Hello World”程序:

GET "libhdr" LET start() = VALOF{ writef("Hello world!")  RESULTIS 0}

PL / I (PL/I)

Developed by IBM in the early 1960’s PL/I (Programming Language One) was widely used in its heyday, but never quite displaced its competitors Fortran and COBOL. PL/I was primarily a mainframe language, and with the advent of the PC and the rising popularity of languages such as C++ and Java, PL/I slipped out of favor.

由IBM在1960年代初期开发的PL / I(编程语言之一)在鼎盛时期得到了广泛的使用,但从未完全取代其竞争对手Fortran和COBOL。 PL / I主要是一种大型机语言,随着PC的出现以及C ++和Java等语言的日益普及,PL / I逐渐失宠。

There are many examples of PL/I on Rosetta Code; here it is generating a Fibonacci sequence:

关于Rosetta代码的PL / I有很多示例 ; 这是在生成斐波那契数列:

/* Form the n-th Fibonacci number, n > 1. */get list(n);f1 = 0; f2 = 1;do i = 2 to n;   f3 = f1 + f2;   put skip edit('fibo(',i,')=',f3)(a,f(5),a,f(5));   f1 = f2;   f2 = f3;end;

SNOBOL4 (SNOBOL4)

SNOBOL was developed in the early 1960’s and became a popular teaching language in the following decade. However, it ran out of steam throughout the 1980’s and 90's, but not before it was able to influence the design of Lua, which makes a top-20 appearance in the PYPL rankings we saw earlier.

SNOBOL开发于1960年代初期,并在随后的十年中成为一种流行的教学语言。 但是,在整个1980年代和90年代,它一直处于蒸蒸日上的状态,但是在它能够影响Lua的设计之前就没了,它在我们之前看到的PYPL排名中排名前20位。

Here’s a SNOBOL4 program that outputs the length of a string:

这是一个SNOBOL4程序,它输出字符串的长度:

output = "Byte length: " size(trim(input))end

焦点 (FOCAL)

FOCAL (‘Formulating On-Line Calculations in Algebraic Language’, since you asked) was introduced in 1968, and was an efficient language that could run on very memory-limited systems. One particular quirk of the language was its apparent phobia of strings. Inputting the string “HELLO” would be interpreted as asking the computer to calculate 8 ^ "LLO” , which FOCAL struggled to work out before spitting out a massive numerical answer.

FOCAL(自您提出要求以来就是“用代数语言来计算在线计算”),它是一种有效的语言,可以在内存非常有限的系统上运行。 该语言的一个特殊怪癖是其明显的字符串恐惧症。 输入字符串“ HELLO”将被解释为要求计算机计算8 ^ "LLO” ,这是FOCAL在吐出大量数值答案之前难以解决的。

Despite its eccentricities, FOCAL was used widely enough during the 70’s and 80’s. Coca-Cola even used their own version, which they imaginatively called COKE.

尽管它很古怪,但FOCAL在70年代和80年代被广泛使用。 可口可乐甚至使用了自己的版本,他们将其想象为可乐。

This example from Rosetta Code shows a FOCAL program that converts temperatures between different units:

Rosetta Code的此示例显示了一个FOCAL程序,该程序在不同单位之间转换温度:

01.10 ASK "TEMPERATURE IN KELVIN", K01.20 TYPE "K ", %6.02, K, !01.30 TYPE "C ", %6.02, K - 273.15, !01.40 TYPE "F ", %6.02, K * 1.8 - 459.67, !01.50 TYPE "R ", %6.02, K * 1.8, !

塞特 (SETL)

SETL was invented in the late 1960’s and was based heavily on set theory, the branch of mathematics that concerns collections of objects. The most recent stable release was back in 2005, but despite its decline from use, SETL has a couple of claims to fame.

SETL于1960年代后期发明,很大程度上基于集合论 , 集合论是与对象集合有关的数学分支。 最新的稳定版本可以追溯到2005年,但是尽管它的使用有所减少,但SETL却声名fa起。

The first compiler of Ada, which was developed by the US Department of Defense, was written in SETL. Also, it is said to have influenced ABC — the language which went on to inspire the design of Python.

由美国国防部开发的Ada的第一个编译器是用SETL编写的。 另外,据说它对ABC产生了影响-后来启发了Python设计的语言。

Here’s how SETL calculates the greatest common divisor of two integers. See any resemblance to Python?

这是SETL如何计算两个整数的最大公约数 。 看到与Python类似吗?

proc gcd (u, v);  return if v = 0 then abs u else gcd (v, u mod v) end;end;

腮腺炎 (MUMPS)

This unfortunately named language has been around since 1966, and is also referred to as M. A key feature is the built in database system, which allows for super-efficient access to stored data.

不幸的是,这种语言自1966年以来一直存在,也被称为M。一个关键功能是内置的数据库系统,它可以超高效地访问存储的数据。

Although no longer in common use, MUMPS lives on the form of GT.M and InterSystems_Cache — which have a niche in hospitals and financial database systems. The European Space Agency has also used InterSystems_Cache for its recent Gaia mission.

尽管不再通用,但是MUMPS仍然以GT.M和InterSystems_Cache的形式存在-它们在医院和财务数据库系统中占有一席之地。 欧洲航天局也将InterSystems_Cache用于其最近的盖亚飞行任务 。

This is how MUMPS can be used to reverse a string:

这是MUMPS可用于反转字符串的方式 :

REVERSE ;Take in a string and reverse it using the built in function $REVERSE NEW S READ:30 "Enter a string: ",S WRITE !,$REVERSE(S) QUIT

故意混淆 (Deliberately Confusing)

What are the hallmarks of a successful programming language? Speed? Versatility? Readability? Nah, forget all that — let’s look at a branch of programming languages out there that are intentionally difficult and/or unintuitive to use.

成功的编程语言的标志是什么? 速度? 多功能性? 可读性? 不,忘了所有这些–让我们来看一下故意难以使用和/或不直观的编程语言的一个分支。

Esoteric languages, or ‘esolangs’, are programming languages used sometimes for experimentation, sometimes for a challenge, and sometimes just as the ultimate nerdy in-joke. If you don’t quite get it, that’s ok — in fact, that’s usually the point.

神秘的语言或“ esolangs”是有时用于实验,有时用于挑战的编程语言,有时甚至是极度讨厌的笑话。 如果您不太了解,那没关系-实际上,这通常就是重点。

Better-known examples include Brainf***, Befunge and the particularly migraine-inducing Malbolge. Here’s a list of a few others, ranging from the amusing to the interesting, to the outright obtuse. Include these on your CV/Resume at your own risk.

较著名的例子包括Brainf *** , Befunge和特别引起偏头痛的Malbolge 。 这是其他一些列表,从有趣到有趣,再到彻底钝化。 将这些内容包括在您的简历/简历中,后果自负。

INTERCAL (INTERCAL)

The original esoteric programming language was invented in 1972, making it as old as C. It was introduced as a parody of programming practices prevalent at the time, but its continued survival to this day suggests it is still as relevant as ever.

原始的深奥编程语言是在1972年发明的,与C一样古老。它最初是作为当时流行的编程实践的模仿而引入的,但它的持续存续至今表明它仍然与以往一样重要。

On top of an obtuse syntax, INTERCAL confuses its users even further by requiring them to use the keyword PLEASE every so often, else the program refuses to run. However, being overly polite backfires — saying ‘please’ too frequently will also result in an error. Of course, this eccentricity was not officially documented, because that’d just be too helpful.

INTERCAL除了使用一种晦涩的语法外,还要求用户经常使用关键字PLEASE使用户更加困惑,否则程序将拒绝运行。 但是,过分客气地适得其反-过于频繁地说“请”也将导致错误。 当然,这种怪癖性没有正式记录,因为那太有帮助了。

Here’s an infinite loop, written in INTERCAL:

这是用INTERCAL编写的无限循环 :

NOTE THIS IS INTERCAL       PLEASE ,1 <- #5       DO ,1 SUB #1 <- #54       DO ,1 SUB #2 <- #192       DO ,1 SUB #3 <- #136       PLEASE ,1 SUB #4 <;- #208       DO ,1 SUB #5 <- #98       DO COME FROM (1)       DO READ OUT ,1(2)    DO ,1 SUB #1 <;- #134(1)    PLEASE ABSTAIN FROM (2)

蜂蜡 (Beeswax)

This is a conceptually interesting language, which takes the movement of bees around honeycomb as inspiration for the movement of pointers across instructions.

这是一种在概念上很有趣的语言,它以蜜蜂在蜂窝周围的移动为灵感来指导指令间的移动。

Beeswax is capable of arithmetic, reading/writing files, and even modifying its own source code. Below is a program that calculates n-factorial (n!) of a user-input integer.

Beeswax能够算术,读取/写入文件,甚至可以修改其自己的源代码。 下面是一个计算用户输入整数的n阶乘 (n!)的程序。

p      <_1FT"pF>M"p~.~d     >Pd  >~{;

厨师 (Chef)

This is perhaps my favorite of the languages I found on Rosetta Code. I’d previously read about it elsewhere, but hadn’t seen anything like the range of examples provided here.

这可能是我在Rosetta Code上找到的语言的最爱。 我以前在其他地方读过它,但是没有看到像这里提供的示例范围之类的东西。

Unlike most programming languages, Chef reads almost completely naturally, as each program is formatted much like a recipe (hence the name!). For completeness, it also refers to variables, instructions and data structures with cooking-related names, such as “mixing bowl”, “refrigerator”, “mix”, “chop” etc. Why not?

与大多数编程语言不同,Chef几乎完全自然地阅读,因为每个程序的格式都非常像配方(因此得名!)。 为了完整起见,它还涉及与烹饪相关的名称的变量,指令和数据结构,例如“搅拌碗”,“冰箱”,“混合”,“剁碎”等。为什么不呢?

Here’s a sample program that calculates the sum and product of an array of numbers.

这是一个示例程序,用于计算数字数组的总和 。

Sum and Product of Numbers as a Piece of Cake. This recipe sums N given numbers. Ingredients.1 N0 sum1 product1 number Method.Put sum into 1st mixing bowl.Put product into 2nd mixing bowl.Take N from refrigerator.Chop N.Take number from refrigerator.Add number into 1st mixing bowl.Combine number into 2nd mixing bowl.Chop N until choped.Pour contents of 2nd mixing bowl into the baking dish.Pour contents of 1st mixing bowl into the baking dish. Serves 1.

高尔夫脚本 (Golfscript)

Familiar to fans of code golf (a fantastically geeky hobby in which participants try to solve programming puzzles in as few bytes of code as possible), Golfscript is a language designed to do a lot with a little.

Golfscript是一种熟悉代码高尔夫的人 (一种怪异的嗜好,参与者试图用尽可能少的代码字节来解决编程难题),Golfscript是一种旨在花一点点钱做的语言。

It certainly achieves this goal, and allows its users to solve complex puzzles very concisely. Its website tells us this brevity is attained through ‘using single symbols to represent high level operations’.

它当然可以实现此目标,并允许其用户非常简洁地解决复杂的难题。 它的网站告诉我们,这种简洁是通过“使用单个符号代表高级操作”来实现的。

Would you use it in a production setting? Maybe, if you were a seasoned code golfer and had no regard for the sanity of any successor to your project. Otherwise… probably not.

您会在生产环境中使用它吗? 也许,如果您是经验丰富的标准高尔夫球手并且不考虑项目的任何后继者的健全性。 否则……可能不会。

Rosetta Code has several nice examples of Golfscript, and since it manages to be so damn concise, I’ve included three of them here:

罗塞塔代码(Rosetta Code)有Golfscript的几个很好的例子,并且由于它是如此简洁,我在这里包括了三个:

[2 4 3 1 2]$   #Sort an integer array
[296,{3/)}%-1%["No more"]+[" bottles":b]294*[b-1<]2*+[b]+[" of beer on the wall\n".8<"\nTake one down, pass it around\n"+1$n+]99*]zip    #99 Green Bottles Lyrics
[{"close"}100*]:d;10,{)2?(.d<\["open"]\)d>++:d;}/[100,{)"door "\+" is"+}%d]zip{" "*puts}/    #100 Doors Challenge

(Hoon)

Hoon is fascinating in that, although some would class it as an esolang, it does actually serve a practical purpose. It can be used to program web services on Urbit, which describes itself as a ‘secure peer-to-peer network of personal servers’.

Hoon的魅力在于,尽管有人将其归类为esolang,但实际上确实有实际目的。 它可以用来对Urbit上的Web服务进行编程,Urbit将其描述为“个人服务器的安全对等网络”。

Take a look at the ‘greatest element’ example below.

看一下下面的“最大元素”示例 。

Hoon is described as Lisp-y, and note the two-character symbols at the start of each line. These ‘runes’ are used in place of reserved keywords, which is a great concept, but does impact readability for those unfamiliar with its logic, and probably qualifies Hoon as somewhat esoteric.

Hoon被描述为Lisp-y,请注意每行开头的两个字符的符号。 这些“符文”用于代替保留关键字,这是一个很棒的概念,但是对于不熟悉其逻辑的人员却影响可读性,并且可能使Hoon有点深奥。

:-  %say|=  [^ [a=(list ,@) ~] ~]:-  %noun  (snag 0 (sort a gte))
> +max [1 2 3 ~]3

皮耶特 (Piet)

By far the most unique language I came across was Piet, named after the 20th Century Dutch artist, Piet Mondrian.

到目前为止,我遇到的最独特的语言是Piet ,以20世纪荷兰艺术家Piet Mondrian的名字命名。

It follows one highly unusual design principle: Program code should be in the form of abstract art. How is this achieved? The solution is nothing short of genius.

它遵循一个非常不寻常的设计原则:程序代码应采用抽象形式。 如何实现的? 解决方案无非是天才。

Integers are represented by the number of ‘codels’ in a contiguous block of color. The pointer starts in the top-left corner, and moves around the image. Every time it encounters a color change, an instruction is executed. The exact instruction is specified by the changes in both hue and brightness.

整数由连续颜色块中“代码”的数量表示。 指针从左上角开始,并在图像周围移动。 每次遇到颜色变化时,都会执行一条指令。 确切的指示由色相和亮度的变化指定。

Mind = Blown.

头脑=吹。

玩数组 (Playing With Arrays)

One thing that caught my attention was the number of array-based languages there are out there. Array-based programming has been around since the early 1960’s, with the invention of APL, and although they’re not exactly mainstream, there are plenty of offshoots still used to various extents today. These languages all have a lot in common, so I’ll spare you too much detail, but they’re interesting in just how concise they can be.

引起我注意的一件事是,那里存在着许多基于数组的语言。 自1960年代初以来,随着APL的发明, 基于数组的编程就已经存在了,尽管它们并不是完全主流,但是今天仍然有很多分支使用。 这些语言都有很多共同点,因此我将为您省去太多细节,但是它们的简洁性很有趣。

Ĵ (J)

J was invented by Kenneth Iverson, who was also the inventor of APL. J is a very terse language, letting you get a lot done with very few lines of code.

J是APL的发明者Kenneth Iverson发明的。 J是一种非常简洁的语言,它使您只需很少的代码行就能完成很多工作。

Below is a K-means clustering algorithm. For comparison, the same example in C runs to 184 lines.

以下是K均值聚类算法 。 为了进行比较,C语言中的同一示例达到184行。

NB.  Selection of initial centroids, per K-means++   initialCentroids     =:  (] , randomCentroid)^:(<:@:]`(,:@:seedCentroid@:[))~     seedCentroid       =:  {~ ?@#     randomCentroid     =:  [ {~ [: wghtProb [: <./ distance/~       distance         =:  +/&.:*:@:-"1  NB.  Extra credit #3 (N-dimensional is the same as 2-dimensional in J)       wghtProb         =:  1&$: : ((%{:)@:(+/\)@:] I. [ ?@$ 0:)"0 1 NB.  Due to Roger Hui http://j.mp/lj5Pnt    NB.  Having selected the initial centroids, the standard K-means algo follows   centroids            =:  ([ mean/.~ closestCentroid)^:(]`_:`initialCentroids)     closestCentroid    =:  [: (i.<./)"1 distance/     mean               =:  +/ % #

(K, q)

These two languages were both developed commercially by Kx Systems. Both are APL-like, array-based languages that have applications in finance and big data. q is wrapped around K, and provides enhanced readability.

这两种语言都是由Kx Systems商业开发的。 两者都是类似APL的,基于数组的语言,在金融和大数据中都有应用。 q包裹在K周围,并提供增强的可读性。

I’ve included a couple of examples of each below. These are super-concise languages, and would no doubt be good for a round of code golf, if that’s what you’re into.

我在下面提供了两个示例。 这些都是超简洁的语言,如果您正在研究这种语言,无疑对于一轮代码高尔夫球会很有用。

/ 1-D Cellular automata in Kf:{2=+/(0,x,0)@(!#x)+/:!3}
/ Anagrams in K{x@&a=|/a:#:'x}{x g@&1<#:'g:={x@
/ Pascal's Triangle in qpascal:{(x-1){0+':x,0}\1}
/ 100 Doors Challenge in q`closed`open (1+til 100) in `int$xexp[;2] 1+til 10

(Klong)

Klong is similar to K and q, but its website claims it is less ambiguous. Judge for yourself — below is a “Middle Three Digits” solution written in Klong.

Klong与K和q相似,但是其网站声称它不太含糊。 自行判断-以下是用Klong编写的“中间三位数”解决方案。

items::[123 12345 1234567 987654321 10001 -10001 -123 -100 100 -12345 1 2 -1 -10 2002 -2002 0] mid3::{[d k];:[3>k::#$#x;"small":|0=k!2;"even";(-d)_(d::_(k%2)-1)_$#x]}.p(mid3'items)

IDL (IDL)

One more array-based language for you. IDL (Interactive Data Language), around since 1977, has been used by organizations including NASA and ESA. In fact, IDL found itself something of a niche in space research, and it was once used to help technicians repair the Hubble Space Telescope.

为您提供另一种基于数组的语言。 自1977年以来,IDL(交互式数据语言)已被包括NASA和ESA在内的组织所使用。 实际上,IDL在太空研究中发现了自己的一席之地,它曾经被用来帮助技术人员修复哈勃太空望远镜。

A more down-to-earth application is this function which generates a Sierpinski triangle.

此函数更实际的应用程序会生成一个Sierpinski三角形 。

pro sierp,n  s = (t = bytarr(3+2^(n+1))+32b)  t[2^n+1] = 42b    for lines = 1,2^n do begin        print,string( (s = t) )        for i=1,n_elements(t)-2 do if s[i-1] eq s[i+1] then t[i]=32b else t[i]=42b  endend

即将来临? (Up-and-Coming?)

Of course, some languages don’t see much use simply due to the fact they haven’t been around very long. Whether or not they catch on depends on a variety of factors, and the reality is that the vast majority won’t see widespread adoption. But you’ve gotta start somewhere, right?

当然,由于某些语言使用时间不长,因此并没有看到太多用途。 它们是否流行,取决于多种因素,而现实是,绝大多数人不会被广泛采用。 但是你得从某个地方开始吧?

Here are a selection of languages from Rosetta’s archives that are all relative newcomers to the show.

以下是Rosetta档案库中的一些语言,这些语言都是该展览的相对新手。

水晶 (Crystal)

This project is still in alpha-testing, so don’t switch over to it just yet — but keep an eye out. Influenced by the writing efficiency of Ruby and the running efficiency of C, Crystal’s authors seem set on producing an all-round best-of-both-worlds language. Time will tell if they’re successful at doing so.

该项目仍处于Alpha测试中,因此暂时不要切换至该项目 ,但请注意。 受Ruby的编写效率和C的运行效率的影响,Crystal的作者似乎着手开发一种全面的世界上最好的语言。 时间会证明他们是否成功。

Below is a ‘quick-sort’ algorithm written in Crystal — why not have a go running it yourself?

下面是用Crystal编写的“ 快速排序 ”算法-为什么不亲自去运行呢 ?

def quick_sort(a : Array(Int32)) : Array(Int32)  return a if a.size <;= 1  p = a[0]  lt, rt = a[1 .. -1].partition { |x| x < p }  return quick_sort(lt) + [p] + quick_sort(rt)end a = [7, 6, 5, 9, 8, 4, 3, 1, 2, 0]puts quick_sort(a)

弗雷格 (Frege)

Functional programming is the new big thing, and Frege is a purely functional language first introduced in 2011. It’s been described as “Haskell for the Java Virtual Machine”. Named after the mathematical logician Gottlob Frege, this language compiles to Java, and is also available to try out online.

函数式编程是新事物,Frege是一种纯函数式语言,于2011年首次引入。它被称为“ Java虚拟机的Haskell”。 该语言以数学逻辑学家Gottlob Frege的名字命名,可以编译为Java,也可以在线试用 。

Below is a solution the “99 Bottles” challenge. It is virtually identical to the same solution in Haskell, which is to be expected.

以下是“ 99瓶”挑战的解决方案。 实际上,它与Haskell中的相同解决方案相同,这是可以预期的。

module Beer where main = mapM_ (putStrLn . beer) [99, 98 .. 0]beer 1 = "1 bottle of beer on the wall\n1 bottle of beer\nTake one down, pass it around"beer 0 = "better go to the store and buy some more."beer v = show v ++ " bottles of beer on the wall\n"                ++ show v                ++ " bottles of beer\nTake one down, pass it around\n"                ++ head (lines $ beer $ v-1) ++ "\n"

Futhark (Futhark)

Although suffering from a lack of comprehensive documentation, the Futhark project nevertheless seems like a promising line of research. The aim is to compile to high-performance Graphical Processing Unit (GPU) code — but not for producing graphical output.

尽管缺少全面的文档,但是Futhark项目似乎是一个很有前途的研究领域 。 目的是编译为高性能图形处理单元(GPU)代码-而不是生成图形输出。

Instead, Futhark’s goal is to harness the power of the GPU to carry out computationally-intensive procedures that would ordinarily take much longer using a more conventional language. Below is an example of a function used to calculate a geometric mean.

相反,Futhark的目标是利用GPU的能力来执行计算密集型过程,而使用更传统的语言通常会花费更长的时间。 以下是用于计算几何平均值的函数的示例。

include futlib.numeric
fun agm(a: f64, g: f64): f64 =  let eps = 1.0E-16  loop ((a,g)) = while abs(a-g) > eps do    ((a+g) / 2.0,     F64.sqrt (a*g))  in a

西德夫 (Sidef)

Sidef is approaching its fourth year of active development, having started out as a project in March 2013. It seems well advanced and very well documented, and has over 600 examples of coding solutions on Rosetta Code.

Sidef即将进入活跃开发的第四年,该项目于2013年3月作为一个项目开始。它看起来非常先进, 文档非常丰富 ,并且有600多个Rosetta Code编码解决方案示例。

Sidef is mostly used for research purposes, and looks to explore both OOP and functional programming. Personally, I really like the look of it. The example below shows it in action finding the intersection of two lines.

Sidef主要用于研究目的,并且希望探索OOP和函数式编程。 就个人而言,我真的很喜欢它的外观。 下面的示例在实际操作中发现了两条线的交点 。

func det(a, b, c, d) { a*d - b*c } func intersection(ax, ay, bx, by,                  cx, cy, dx, dy) {     var detAB = det(ax,ay, bx,by)    var detCD = det(cx,cy, dx,dy)     var ΔxAB = (ax - bx)    var ΔyAB = (ay - by)    var ΔxCD = (cx - dx)    var ΔyCD = (cy - dy)     var x_numerator = det(detAB, ΔxAB, detCD, ΔxCD)    var y_numerator = det(detAB, ΔyAB, detCD, ΔyCD)    var denominator = det( ΔxAB, ΔyAB,  ΔxCD, ΔyCD)     denominator == 0 && return 'lines are parallel'    [x_numerator / denominator, y_numerator / denominator]}
say ('Intersection point: ', intersection(4,0, 6,10, 0,3, 10,7))
> Intersection point: [5, 5]

闪闪发光 (Sparkling)

Like Sidef, this language started out in 2013. Its design has been inspired by features of C, Python and Lua — and a disdain for several features of JavaScript.

像Sidef一样,该语言始于2013年。其设计灵感来自C,Python和Lua的功能,并且对JavaScript的某些功能不屑一顾。

It aims to be a lightweight and extensible scripting language that runs pretty much anywhere. Below is a number guessing game, which you can try and get working in your browser here.

它旨在成为一种轻量级且可扩展的脚本语言,几乎可以在任何地方运行。 下面是一个猜数字游戏 ,您可以在这里尝试在浏览器中进行操作。

printf("Lower bound: ");let lowerBound = toint(getline()); printf("Upper bound: ");let upperBound = toint(getline()); assert(upperBound > lowerBound, "upper bound must be greater than lower bound"); seed(time());let n = floor(random() * (upperBound - lowerBound) + lowerBound);var guess; print(); while true {    printf("Your guess: ");    guess = toint(getline());     if guess < n {        print("too low");    } else if guess > n {        print("too high");    } else {        print("You guessed it!");        break;    }}

诺亚方舟 (Noah’s Ark)

One more category for you — there were loads of potential languages and I couldn’t possibly get through them all to pick out every interesting example. If you spot any I may have missed, please leave a response below!

为您提供的另一种类别–潜在的语言很多,我无法一一列举所有有趣的例子。 如果您发现任何我可能错过的地方,请在下面留下回复!

One thing I did notice was that a lot of languages were named after animals. Is there an explanation for this?!

我注意到的一件事是,许多语言都是以动物命名的。 对此有解释吗?

I won’t go into detail, but here’s a quick run-through to finish up with:

我不会详细介绍,但是以下是快速完成的过程:

猫,小猫 (Cat, Kitten)

Cat is described as a functional language, but appears to be no longer in existence. However, Kitten seems to be currently under development, and calls itself a successor to Cat. Influenced heavily by Haskell, but aims to be more accessible.

Cat被描述为一种功能语言,但似乎已不存在。 但是,Kitten似乎正在开发中 ,并称自己为Cat的继承者。 受Haskell的重大影响,但旨在变得更易于访问。

"Hello world!" writeln    //Cat
"Hello world!" say     //Kitten

眼镜蛇 (Cobra)

OOP language, influenced by Python, C#, Eiffel and Objective-C.

OOP语言,受Python,C#,Eiffel和Objective-C的影响。

class Hello    def main        print 'Hello world!'

> <>(“鱼”) (><> (“Fish”))

Another multidimensional esolang, if you’re into that kind of thing.

如果您喜欢这种东西,那么另一个多维的esolang。

!v"Hello world!"r! >l?!;o

苍鹭 (Heron)

Inspired by C++, Python and Pascal, but no commits since 2012, so appears to be no longer under active development. Its only sample on Rosetta is a lengthy solution to the N-queens problem. For brevity, I’ve inferred a simple “Hello world!” program to show here instead.

受C ++,Python和Pascal的启发,但自2012年以来未提交任何内容,因此似乎不再处于积极开发中。 它在Rosetta上的唯一样本是对N皇后问题的冗长解决方案。 为简便起见,我推断出一个简单的“ Hello world!” 程序显示在这里。

Main() {   WriteLine("Hello world!");}

龙虾 (Lobster)

A game programming language that aims to be readily portable across platforms. Appears to be under active development.

一种旨在跨平台方便移植的游戏编程语言。 似乎正在积极发展中 。

print "Hello world!"

熊猫 (Panda)

The website states that Panda aims to be simple enough that a Panda could program it. I’ve no idea how good Panda’s are at coding, though, so I’m still in the dark about that one…

该网站指出,Panda的目标是使其足够简单,以便Panda可以对其进行编程。 不过,我不知道Panda在编码方面有多出色,所以我仍然对那个熊猫还不了解。

say("Hello world!")

小马 (Pony)

With influences ranging from C++ to Erlang, Pony looks to be an interesting project with thorough tutorial.

借助从C ++到Erlang的各种影响,Pony看起来是一个有趣的项目,它具有详尽的教程 。

actor Main  new create(env: Env) =>    env.out.print("Hello world!")

三文鱼 (Salmon)

Salmon aims to intermix the writing of both low-level and high-level code.

Salmon的目的是混合低级和高级代码的编写。

"Hello world!"!
print("Hello world!\n");
standard_output.print("Hello world!\n");

松鼠 (Squirrel)

Squirrel is a lightweight scripting language that has been embedded in games like Left 4 Dead 2, Portal 2 and CS:GO.

Squirrel是一种轻量级脚本语言,已嵌入到《 Left 4 Dead 2》 ,《 Portal 2》和《 CS:GO》等游戏中

print("Hello world!");

(Phew!)

That was a whistle-stop tour! If you’ve made it this far and enjoyed the ride (or spotted a glaring, glaring error), leave a response underneath — I’ll try and reply asap! Thanks for reading!

那是一次口哨之旅! 如果您走了这么远并且喜欢这个旅程(或者发现了明显的错误),请在下面留下一个答复-我将尽快答复! 谢谢阅读!

如果您想更深入地研究: (If you want to dive deeper:)

  • Rosetta Code

    罗塞塔码

  • PYPL

    PYPL

  • R-Fiddle

    R-小提琴

Thank you for reading!

感谢您的阅读!

翻译自: https://www.freecodecamp.org/news/rosetta-code-unlocking-the-mysteries-of-the-programming-languages-that-power-our-world-300b787d8401/

罗塞塔语言包

你可能感兴趣的:(编程语言,python,机器学习,人工智能,java)