您自己的编程语言是什么样的?

发布于 2024-07-13 04:26:20 字数 89 浏览 12 评论 0原文

您自己的(我认为是完美的)编程语言会是什么样子? 举一个小例子并解释你的新颖想法!

我对语法真的很感兴趣。

What would your own (I assume perfect) programming language look like? Give a small example and explain your novel ideas!

I'm really interested in the syntax.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(25

素食主义者 2024-07-20 04:26:21

它将是机器可读/可写的,并且将由接受语音指令的智能软件编写。

It would be machine readable/writeable, and it would be written by intelligent software that takes instructions by voice.

三生一梦 2024-07-20 04:26:21

唔。 这是困难的一个。 我的口味倾向于易于人类理解和轻型脚本风格的语言(尽管我确实相信这可以适用于较大的应用程序)。 看代码片段:

function Foo takes x as string, y as boolean //can add returns [return type] if one wishes to be explicit
    //explicit variable declaration
    z as number
    //explicit cast from boolean to number
    z is y as number
    //implicit variable declaration
    bar is 3 * 5
    //function call
    print x
    return z / bar //since we casted z to a number, it returns a number

Hmm. this is a tough one. My tastes run towards the easily human understandable, and light scripting-style languages (though i do believe this could work for larger apps). See code snippet:

function Foo takes x as string, y as boolean //can add returns [return type] if one wishes to be explicit
    //explicit variable declaration
    z as number
    //explicit cast from boolean to number
    z is y as number
    //implicit variable declaration
    bar is 3 * 5
    //function call
    print x
    return z / bar //since we casted z to a number, it returns a number
半衾梦 2024-07-20 04:26:21

我希望看到一个函数能够包含任意数量的引用参数并将它们传递给嵌套函数调用的工具。 在 .net 中,可以通过类似的方式对任何固定数量的通用参数执行此操作(显示两个额外参数版本):

// I forget the C# syntax for delegates, since I normally code in vb
delegate void RefAction<T1, T2, T3>(ref T1 p1, ref T2 t2, ref T3 p3);

Point myPoints[];

void DoSomethingWithIndexedPoint<XT1, XT2>(int index, 
  RefAction<Point, XT1, XT2) theAction, 
  ref XT1 xp1, 
  ref XT2 xp2)
{
  theAction(myPoints[index], xp1, xp2);  
}

我的首选语法如下:

delegate void RefAction<T1, T2, T3>(ref T1 p1, ref T2 t2, ref T3 p3);

Point myPoints[];

void DoSomethingWithIndexedPoint<ref ...>(int index, 
  RefAction<Point, ref ...>, ref ...) theAction, 
  ref XT1 xp1, 
  ref XT2 xp2)
{
  theAction(myPoints[index], ...);  
}

其中“...”将自动扩展由编译器以任何适当的方式。 这样的工具使得在许多情况下使用 Lambda 成为可能,而不必生成闭包实例,并且还可以执行如下代码:

  Interlocked.CompareExchange(SomeObject["George"], SomeValue, SomeOtherValue);

编译器可以将其重写为类似于:

  SomeObject.ActUponProperty("George",
    (ref dest, ref p1, ref p2) => {Interlocked.CompareExchange(dest, p1, p2);},
    SomeValue, SomeOtherValue);

请注意,因为 lambda 表达式不会使用除了作为 ref 参数传递的实例成员或变量之外的任何实例成员或变量,它都可以作为静态函数实现,并且不需要生成闭包。

I would like to see a facility for a function to include an arbitrary number of by-reference parameters and pass them through to a nested function call. In .net, one could do this for any fixed number of generic parameters, via something like (two-extra-parameters version shown):

// I forget the C# syntax for delegates, since I normally code in vb
delegate void RefAction<T1, T2, T3>(ref T1 p1, ref T2 t2, ref T3 p3);

Point myPoints[];

void DoSomethingWithIndexedPoint<XT1, XT2>(int index, 
  RefAction<Point, XT1, XT2) theAction, 
  ref XT1 xp1, 
  ref XT2 xp2)
{
  theAction(myPoints[index], xp1, xp2);  
}

My preferred syntax would be something like:

delegate void RefAction<T1, T2, T3>(ref T1 p1, ref T2 t2, ref T3 p3);

Point myPoints[];

void DoSomethingWithIndexedPoint<ref ...>(int index, 
  RefAction<Point, ref ...>, ref ...) theAction, 
  ref XT1 xp1, 
  ref XT2 xp2)
{
  theAction(myPoints[index], ...);  
}

where the "..."'s would automatically be expanded by the compiler in whatever fashion would be appropriate. Such a facility would make it possible to use Lambdas in many situations without having to generate closure instances, and would also make it possible to do code like:

  Interlocked.CompareExchange(SomeObject["George"], SomeValue, SomeOtherValue);

which the compiler could rewrite as something akin to:

  SomeObject.ActUponProperty("George",
    (ref dest, ref p1, ref p2) => {Interlocked.CompareExchange(dest, p1, p2);},
    SomeValue, SomeOtherValue);

Note that because the lambda expression would not use any instance members or variables other than those passed as ref parameters, it could be implemented as a static function and would not need to generate a closure.

瞎闹 2024-07-20 04:26:20

有点神秘,但这就是我想要的:

Legos!

A little cryptic, but this is what i'd like:

Legos!

苦笑流年记忆 2024-07-20 04:26:20

Jon 说得对,“不同的任务适合不同的语言和范式。” 然而,有一些考虑因素在很大程度上与领域无关。 这些主要涉及语法,但由于代码的阅读次数多于编写次数,我实际上认为语法很重要。

一方面,许多语言都犯了错误,基于 C 的语法是完全任意的。C 实际上有一种非常糟糕的语法。 我只举两个例子。

第一个是没有争议的:分号是不必要的。 采取以下代码; 语法完全明确并且易于编译器解析。 分号和显式续行都不是必需的。

answer = 42
fraction = answer * 2 /
           (answer + 1)
Console.WriteLine(
    "Some funny number: {0}",
    fraction
)

这实际上与 Python 非常相似,但更加宽松:fraction 的定义跨越多行。 这是合乎逻辑的,因为第一行尚未完成。

我必须选择类似 C 语法的另一个要点是它们很大程度上隐式的变量声明。 他们没有明确宣布“我正在声明一个 Foo 类型的变量”,而是羞涩地低声说道“Foo var”。 由于在大多数情况下 Foo 甚至不是保留字,因此此处不会向程序员提供任何视觉提示。 我更喜欢 VB 的显式 Dim var As Foo,尽管这里使用的关键字非常暗淡。

(C++ 实际上让事情变得更糟,因为它引入了许多几乎相同且常常模糊的语法,这些语法意味着从变量初始化到函数声明完全不同的东西)。

我的语言必须具备的另一件事是静态类型。 确实,动态类型它的用途,但它们非常罕见。 即使大多数“脚本语言”也并不真正需要它们。 我认为这经常与具有更多用途的隐式类型相混淆。 再次以 Python 为例。 为什么它不提供静态类型? 它已经是强类型的,静态类型检查只会是随之而来的,并且会减少相当多的调试。 显式变量声明也是如此。 我看不出隐含变量声明有什么优点。

所以我们已经有了一种语言的轮廓:

  • 简洁的语法,避免历史混乱。 尤其:
    • 没有分号
    • 没有像 VB 那样的显式续行
  • 显式变量声明
  • 静态

类型此外,我非常喜欢某些 C++ 概念,例如通用模板、RAII(即避免垃圾而不是收集垃圾)、不变性以及通过迭代器定义的值范围的概念。 我在其他地方说过,我相信迭代器是有史以来最基本的创新之一。 给他们一点口红,你甚至不会认出 C++ 这个丑陋的野兽:

for i in MyVector:
    print(i)

而不是

for (typename vector<T>::const_iterator i = MyVector.begin();
     i != MyVector.end();
     ++i)
    cout << *i << endl;

当然,我知道许多语言都提供了上述语法。 但它们都只提供了 C++ 强大迭代器概念的简化版本(用 C++ 术语来说,大多数语言所知道的唯一迭代器是输入迭代器,它基本上是最不强大的迭代器)。

在这一点上,我可能应该说,所有这些想法的唯一版权都是我的,正在申请专利(特别是 MayOrMayNotBe 运算符 并不真正比较对象引用)。

Jon is right in saying that “[d]ifferent tasks suit different languages and paradigms.” However, there are a few considerations that are largely independent of the domain. These mostly concern syntax but since code is read more often than written, I actually think that syntax matters.

For one thing, and something that many languages do wrong, it's completely arbitrary to base the syntax off C. C actually has an exceptionally bad syntax. I'll just pick two examples.

The first is quite uncontroversial: semicolons are unnecessary. Take the following code; the grammar is completely unambiguous and easy to parse for a compiler. Neither semicolons nor explicit line continuations are necessary.

answer = 42
fraction = answer * 2 /
           (answer + 1)
Console.WriteLine(
    "Some funny number: {0}",
    fraction
)

This is actually quite similar to Python but even more permissive: the definition of fraction spans multiple lines. This is logical since the first line isn't yet complete.

Another bone I've got to pick with C-like syntaxes are their largely implicit variable declarations. Instead of announcing clearly “I'm declaring a variable of type Foo,” all they whisper shyly is “Foo var”. Since Foo isn't even a reserved word in most cases, the programmer isn't offered a single visual hint here. I prefer VB's explicit Dim var As Foo, even thought he keyword used here is, well, quite dim.

(C++ actually makes matters much, much worse by introducing a lot of nearly identical and often ambiguous syntaxes that mean completely different things, from variable initializations to function declarations).

Another thing my language would have to have is static typing. It's true that dynamic typing has its uses but they are surprisingly rare. Even most “scripting languages” wouldn't really need them. I think that this is often confused with implicit typing which has rather more uses. Take (again) the example of Python. Why doesn't it offer static typing? It's already strongly typed, statical type checking would only be consequent, and would cut down on debugging quite a bit. The same goes for explicit variable declaration. I fail to see what advantages implied variable declaration offers.

So there we've already got an outline for a language:

  • Clean syntax, avoid historical clutter. In particular:
    • No semicolons
    • No explicit line continuations à la VB
  • Explicit variable declarations
  • Static typing

Furthermore, I'm a huge fan of certain C++ concepts, such as general-purpose templates, RAII (i.e. avoiding garbage rather than collecting it), immutability and the concept of value ranges defined via iterators. I've stated elsewhere that I believe iterators to be one of the most fundamental innovations ever. Give'em a little lipstick and you won't even recognize the ugly beast that is C++:

for i in MyVector:
    print(i)

rather than

for (typename vector<T>::const_iterator i = MyVector.begin();
     i != MyVector.end();
     ++i)
    cout << *i << endl;

Of course I'm aware that the above syntax is offered by many languages. But they all only offer watered-down versions of C++' powerful iterator concept (to use C++ terminology, the only kind of iterators that most languages know are input iterators, which are basically the least powerful iterators).

At this point I should probably say that the sole copyright for all these ideas is mine, patents pending (in particular for the MayOrMayNotBe operator that doesn't really compare object references).

南风起 2024-07-20 04:26:20

我没有“完美”编程语言的概念,因为需要执行的不仅仅是一项任务。

不同的任务适合不同的语言和范例。

I have no concept of a "perfect" programming language because there isn't just one task to be performed.

Different tasks suit different languages and paradigms.

绿光 2024-07-20 04:26:20

它看起来像 C#。 我很想拥有微软!

It would look like C#. I would love to own Microsoft!

神经大条 2024-07-20 04:26:20

我完美的语言将允许我根据需要增强功能。 如果我需要编写一个没有类的小型直接实用程序,我可以。 如果我需要使用类,我也可以这样做,如果我想编写一个完全面向对象的解决方案,我也可以这样做。 链接器足够智能,可以让我创建小型快速命令行实用程序(没有运行时依赖项)或我能想象到的最大的臃肿 OOP GUI 应用程序。

问题是我喜欢的东西有相反的目标,因此我总是被迫使用完全不同的语言。 我目前使用 PowerShell、VBScript、PowerBasic、Java 和 C#(有时使用 VB .NET、VB 6、C++、Python 和 Perl),没有特定的顺序。

现在,如果我可以使用一种类似 C# 的语言来完成这一切,该语言具有全局函数,在创建这些小型应用程序时没有运行时依赖性,但让我在需要时充分利用 .NET Framework 和 Java SDK 的强大功能,那么我'会很高兴。

My perfect language would allow me to ratchet up the functionality as I need it. If I need to write a small straight forward utility program without classes I could. If I needed to use classes I could do that also, and if I wanted to write a completely object oriented solution I would be able to do that too. The linker would be smart enough to let me create small fast command line utilities (with no runtime dependencies) or the largest bloated OOP GUI app I could imagine.

The problem is that what I like has opposing goals and thus I've always been forced into using completely different languages. I currently use in no particular order PowerShell, VBScript, PowerBasic, Java, and C# (and sometimes VB .NET, VB 6, C++, Python, and Perl).

Now if I could do it all with one C# like language that had global functions with no runtime dependencies when creating those small apps, but let me make full use of the power of the .NET Framework and Java SDK when I needed to, I'd be happy.

梦罢 2024-07-20 04:26:20

完美的编程语言往往出现在科幻小说中。 例如:

  • 奥森·斯科特·卡德的安德系列 - 要创作,你必须去到不同的维度,并在你的头脑中形成一个纯粹的思想。 当你回来时,就是这样。
  • 罗伯特·A·海因莱因 (Robbert A. Heinlein) 在大卫·布林 (David Brin) 的《野兽之数》(Number of the Beast
  • ) 的《地球》(Earth) 中通过副歌声结合眼睛和手指动作进行编程,探索了世界作为神话的概念。

这一切仍然归结为同样的基本困境。 任何不强迫人类学习技能的编程语言往往会限制思想自由。 自然语言也不好,因为它有很多歧义。

我不介意将自由与强大和最少语法结合起来的一种。 我最近开始学习lisp,目前看来还不错。

Perfect programming languages tend to be found in science fiction novels. For example:

  • Orson Scott Card's Ender Series - To create you must go to a different dimension and form a pure thought in your mind. When you return, it is.
  • Robbert A. Heinlein explored the concept of world as myth in Number of the Beast
  • David Brin's Earth has programming through sub vocals combined with eye and finger movements.

It all still comes down to the same basic quandary. Any programming language that does not force the human to learn a skill tends to limit the freedom of thought. Natural language is not good either since it has many ambiguities.

I wouldn't mind one that combines freedom with power and minimal syntax. I've recently started learning lisp, and it seems very good so far.

巴黎盛开的樱花 2024-07-20 04:26:20

Amazon Mechanical Turk 支持大规模并行性。

job = "Upvote this answer"
@price = "$0.01"
fork(10000, job, @price)

Massive parallelism empowered by Amazon Mechanical Turk.

job = "Upvote this answer"
@price = "$0.01"
fork(10000, job, @price)
森林很绿却致人迷途 2024-07-20 04:26:20

我是 C 宏的忠实粉丝,但我认为如果您可以用您正在使用的相同语言编写宏或“元代码”,那可能会很好。 (C 是一个不好的例子;这在脚本语言中可能是好的。)

在这些例子中,我使用大括号来标识元代码。 您将能够通过“预处理器”运行源代码以扩展元代码。 否则它只会在运行时扩展一次。

print "Your product ID is: ", { print '"', generateGUID(), '"' }

或者

lookupTable[] = {
                  /* insert code to generate table here
                   *
                   * This lets you modify the algorithm easily
                   * but speeds up the final program.
                   * 
                   * This would be especially appropriate in
                   * cases where you would otherwise type out
                   * the table as a literal (yuck)
                   */
                }

有时我们必须编写几行非常重复的代码; 现在想不出一个好的例子,但这种想法在这种情况下也会非常有帮助。

I'm a big fan of C macros, but I thought it might be nice if you could write macros or "meta-code" in the same language you're using. (C is a bad example; this could be good in scripting languages.)

In these examples I'm using braces to identify the meta-code. You would be able to run the source through a "preprocessor" to expand the meta-code out. Otherwise it would just be expanded once at runtime.

print "Your product ID is: ", { print '"', generateGUID(), '"' }

or

lookupTable[] = {
                  /* insert code to generate table here
                   *
                   * This lets you modify the algorithm easily
                   * but speeds up the final program.
                   * 
                   * This would be especially appropriate in
                   * cases where you would otherwise type out
                   * the table as a literal (yuck)
                   */
                }

Now and then we have to write several lines of very repetitive code; can't think of a good example right now but this kind of think would also be very helpful in such situations.

等待圉鍢 2024-07-20 04:26:20

这与采用 Eiffel 和 C# 的最佳想法没有太大区别(因为,很明显,我没有知识来想出更好的东西 - 我一开始就没有学过 CS)。

然而,我主要的实际关注点是超越经典的“源代码文本”方法。 我知道这是(或听起来像)IDE 的东西,但为什么我不能有一个可配置的代码视图,其中包含前置条件/​​正文/后置条件等列,而不是“线性”形式 (i):

  function f
  // f's preconditions
  // f's body
  // f's postconditions
  end

  function g
  // g's preconditions
  // g's body
  // g's postconditions
  end

为什么不 (ii) -想象这是一个表格(带边框):

f      f's parameters    f's prec      f's body      f's postc    f's comments
g      g's parameters    g's prec      g's body      g's postc    g's comments

而且,为什么我不能选择样式(i)中函数的“开始”和“结束”方式(大括号、关键字...)? 为什么我无法立即显示或隐藏私有或受保护的成员? 为什么我不能立即看到包含所有继承功能的“平面版本”? 重点

不在于拥有一个可供您编辑的神圣代码文件,然后是多个“酷视图”,而是能够以 (i)、(ii) 以及对您最有用的任何形式编辑和添加代码。

在某种程度上,在这里谈论“IDE”似乎是题外话。 但我认为这迟早会改变我们编写和阅读代码的方式。 这最终将影响语言的演变方式。 未来的目标不仅是增强可读性,而且是“可理解性”和交互性。

It wouldn't be very different from taking the best ideas of Eiffel and C# (because, plainly, I don't have the knowledge to come up with anything better - I haven't studied CS in the first place).

However, my main practical concern would be go to one step beyond the classical "source code text" approach. I know this is (or sounds like) an IDE thing, but why can't I have a configurable code view with columns such as preconditions/body/postconditions instead of a "linear" form (i):

  function f
  // f's preconditions
  // f's body
  // f's postconditions
  end

  function g
  // g's preconditions
  // g's body
  // g's postconditions
  end

Why not (ii) - imagine this is a table (with borders):

f      f's parameters    f's prec      f's body      f's postc    f's comments
g      g's parameters    g's prec      g's body      g's postc    g's comments

And also, why can't I choose how functions "begin" and "end" (braces, keywords...) in style (i)? Why can't I instantly show or hide private or protected members? Why can't I instantly see the "flat version" with all the inherited functions inside? etc.

The point would not be to have one holy code file where you edit and then multiple "cool views", but to be able to edit and add code in both (i), (ii) and whatever form is most useful to you.

In a way, talking about "IDE" may seem off-topic here. But OTOH I think this is going to change the way we write and read code, sooner or later. And this will ultimately influence the way languages evolve. The future goals would be to enhance not only readability but also "understandability" and interactivity.

疯狂的代价 2024-07-20 04:26:20

我想我的应该介于 Brainf*ckLOLCODE 除了还有很多括号

I would imagine mine would be somewhere between Brainf*ck and LOLCODE except with A LOT more parentheses.

今天小雨转甜 2024-07-20 04:26:20

Python 对我来说非常接近理想...我只是想摆脱一些烦恼,比如 self 关键字...但是有了一个好的编辑器,Python 可以很快地做一些令人惊奇的事情...

Python is pretty close to ideal for me... I would just get rid of some annoyances like having the self keyword... but with a good editor, Python can do amazing things very quickly...

蹲墙角沉默 2024-07-20 04:26:20

多媒体。

我希望能够书写一些图形符号,快速绘制连接,然后切换到其他模式,例如在需要精度的地方打字。

我还认为编程语言应该支持那些不会用英语思考的人(是的,甚至是美国人......开玩笑!)。 我已经学了足够多的日语,并尝试学习一些印度尼西亚语 - 我希望看到一种语言支持具有不同语法结构和命令的人们。

我在最近参加的一个关于网络未来的论坛上提出了一个问题,询问一位来访的中国教授,他是否认为中文书面语言比英语更有可能实现可行的语义网络。 他对这个想法很感兴趣。

我读到的很多科幻小说都谈到了未来计算机交互的 UI:

Multi-media.

I want to be able to scribble some graphical symbols, quickly sketch connections and then flip to other modes such as typing where precision is needed.

I also think programmming languages should support people who don't think in English (yes, even Americans ..... joking!). I've studied enough Japanese and tried to pick up some Indonesian - I would like to see a language support people with different grammatical constructs and orders.

I raised a question at a recent forum I attended on the future of the web, asking a visiting Chinese professor if he thought Chinese written language would be more likely to enable a workable semantic web than English. He was intrigued by the notion.

A lot of SF I read talks about future UI's for computer interaction:

  • data wands in David Drake's Lt Leary series (some of which are available free from Baen)
  • multi-modal favourite sets of gestures and vocalisations in Matadora and other casual mentions in Perry's Matador series
  • pen and gesture-based UI including signing to seal the log in Fool's War
嘿咻 2024-07-20 04:26:20

一种没有结构或变量,只有一个函数的语言。

doEverything();//根据已经预测的输入自动生成所有内容

A language that features no structure or variables, just one function.

doEverything();//automatic generation of all content based on already predicted input

幽蝶幻影 2024-07-20 04:26:20

我设想一种语言必须被告知对输入、变量以及执行顺序的精确限制,因此可以编译成快速多线程(或可集群)软件。

这是一个有趣的想法:想象一下“函数”中的所有“语句”都可以按任何顺序执行。 如果某事物依赖于其他事物,则需要显式“调用”该依赖关系。 这将使并行设计成为该语言的一个组成部分。

不幸的是,我没有投入足够的想象力来想出更具体的东西。

I envision a language that must be told precise restrictions on input and variables and execution order, and so can be compiled into fast multithreaded (or clusterable) software.

And here's an interesting idea: imagine that all the "statements" within a "function" could be executed in any order at all. If something depends on something else, you need to "call" the dependency explicitly. This would make design for parallelism an integral component of the language.

Unfortunately I haven't invested enough imagination to come up with anything more specific.

一指流沙 2024-07-20 04:26:20

Clojure 已经非常接近了...

Clojure is getting pretty close...

檐上三寸雪 2024-07-20 04:26:20

我不确定我梦想的语言会是什么样子,但我对 C 风格语言有一点改进。 我已经写了多少次这样的东西:

Node foundNode = null;  // need stupid null value here to keep track if it was not found
foreach (Node testNode in nodes) {
  if (testNode.YesItsMe) {
    foundNode = testNode;
    break;
  }
}
if (foundNode == null) {
  // create new instance
  foundNode = new Node(blabla);
}

我知道有更优雅的功能方法,但有时你仍然会得到这样的代码。 一个简单的“guard”声明在这里会有帮助:

Node foundNode;  // no need to initialize anymore
foreach (Node testNode in nodes) {
  if (testNode.YesItsMe) {
    foundNode = testNode;
    break;
  }
} guard {  // we get here if break was never called
  // create new instance
  foundNode = new Node(blabla);
}

I am not sure what my dream language would look like, but I have a little improvement for C-style languages. How many times have I written something like this:

Node foundNode = null;  // need stupid null value here to keep track if it was not found
foreach (Node testNode in nodes) {
  if (testNode.YesItsMe) {
    foundNode = testNode;
    break;
  }
}
if (foundNode == null) {
  // create new instance
  foundNode = new Node(blabla);
}

I know there are more elegant functional ways for this, but sometimes you still end up with code like this. A simple "guard" statement would help here:

Node foundNode;  // no need to initialize anymore
foreach (Node testNode in nodes) {
  if (testNode.YesItsMe) {
    foundNode = testNode;
    break;
  }
} guard {  // we get here if break was never called
  // create new instance
  foundNode = new Node(blabla);
}
累赘 2024-07-20 04:26:20

我想要一种编程语言,可以让工具很容易正确编写。 提取方法、着色、自动完成、编译等。

我希望在实现这一点的同时仍然易于编写和阅读。

I would like a programming language that makes tools really easy to write correctly. Extract method, colorization, autocomplete, compilation, etc.

I want this to happen while still being easy to write and easy to read.

梦里兽 2024-07-20 04:26:20

我理想的编程语言,代码应该是智能的,它会告诉我另一段代码是否有问题,我们会坐下来交谈,它会告诉我它的问题是什么,这样我们就可以解决它......我称之为“EmotionPeople++”

My ideal programming language, the code would be smart, it would tell me if it had a problem with another piece of code, we would sit down and talk and it would tell me what its problem was so we could work it out... I call it "EmotionPeople++"

将军与妓 2024-07-20 04:26:20

它看起来和Scheme一模一样。 只有它可以编译为 IL 和 Java 字节码以及汇编,这样我就可以使用所有这些库。

It would look exactly like Scheme. Only it would compile to both IL and Java bytecode, and assembly so I could use all those libraries.

夢归不見 2024-07-20 04:26:20

人们设计语言是为了满足特定的目标。
语法和语义应遵循所需的功能。

就我而言,我想要一种具有细粒度并行性的语言,
也就是说,每粒的开销非常低,允许小块
要并行化的代码。

我在 x86 SMP 系统上设计并实现了它,
作为大规模的基础,它已经使用了大约 10 年。
软件分析工具。

要点是让我(我们)指定
并行性很容易:

(|| A B)

并行执行A和B,并让编译器
生成所有使这成为可能的碎片。
我们不关心语法是否正确
是否中缀,所以我们采用 LISP 风格来避免
论据。

一篇描述该语言和一些内容的论文
并行应用程序可以在以下位置找到:
http://www.semanticdesigns.com/Company/Publications/ parallelism-in-symbolic-computation.pdf

这篇论文简要讨论了我们如何没有做到这一点
成功避免语法争论
尽管我们做出了决定。

One designs languages to meet specific goals.
Syntax and semantics should follow desired function.

In my case, I wanted a language with fine-grain parallelism,
that is, very low overhead per grain to allow small chunks of
code to be parallelized.

I've designed and implemented it on x86 SMP systems,
and it has been in use for about 10 years as the foundation for a large-scale
software analysis tools.

The main point was to allow me (us) to specify
parallelism easily:

(|| A B)

does A and B in parallel, and let the compiler
generate all the crud that makes this possible.
We didn't care about whether the syntax was
infix or not, so we went LISP style to avoid
arguments.

A paper describing the language and a number of
parallel applications can be found at
http://www.semanticdesigns.com/Company/Publications/parallelism-in-symbolic-computation.pdf

The paper briefly discusses how we didn't
succeed in avoiding arguments over syntax
in spite of our decision.

怼怹恏 2024-07-20 04:26:20

我将从主要特征开始:

  • 它应该是一种同像语言 对基于宏的元编程提供强大的支持。 这对生产力来说是一个巨大的优势(请参阅 Paul Graham 的超越平均水平
  • 它应该运行在任何平台上,并且对运行分布式代码有很好的支持。 设置机器云应该是一项简单的任务。
  • 它应该是开源
  • 它应该拥有尽可能最大的库和工具生态系统。 实际上,这意味着您需要访问 Java 生态系统,因此它可能需要成为 JVM 语言。
  • 它应该支持类型推断。 生命太短了,不能让编译器为你整理类型细节......
  • 它应该是函数式,并强调数据结构的不变性。 这是高级语言的未来(我并不认为函数式语言很难掌握,但这种语言不适合初学者......)
  • 它应该支持交互式开发,最好是在类似 REPL 的环境,您可以在其中与正在运行的(可能是分布式的)代码环境进行交互。
  • 它应该提供出色的无锁并发支持。 当我们进入大规模多核世界时,基于锁的方法根本无法扩展。 软件事务内存可能是前进的方向。
  • 它应该在性能需要时支持低级编码。 95% 的情况下,高级编码都很棒,但有时您只需要直接操作字节......

目前我发现最接近我的愿望的是 Clojure,它满足了大部分要求。

由于OP指的是语法,我将给出一些代码示例:

适当的变量参数函数,支持大型参数列表:

(+ 1 2 3 4 5)
=> 15

(apply + (range 10000))
=> 49995000

运行时对编译器的交互式访问:

(def function-string "+")

(def function (compile-string function-string))

(function 7 8 9)
=> 24

分布式代码执行(MapReduce风格)。 请注意,这意味着语言/库能够获取本地定义的some-long-running-function并将其透明地分发到集群中的所有节点以便在运行时执行嗯>。

(def my-cluster 
     (create-compute-cluster :nodes 100 :service "Amazon"))

(defn some-long-running-function [input]
  ....)

(def reduction-function 
  (fn [a b] 
    (do-something-to-reduce a b)))

(def lots-of-inputs (range 10000))

(distributed-map-reduce
  my-cluster
  some-long-running-function
  inputs
  reduction-function)
=> (whatever the result of the mapreduce is over the cluster)

正确的类型推断(即编译器计算出 my-function 始终返回一个 String 并相应地进行优化/推断:

(def my-function [name]
   (str "Hello " name "!"))

(my-function "Bob")
=> "Hello Bob!"

(compile-time-type my-function)
=> [java.lang.String :not-null]

I'll start with the key features:

  • It should be a homoiconic language with powerful support for macro-based metaprogramming. This is an enormous advantage for productivity (see Paul Graham's beating the averages)
  • It should run on any platforms, and have great support for running distributed code. Setting up a cloud of machines should be a simple task.
  • It should be open source.
  • It should have largest possible library and tool ecosystem. Practically this means you need to have access to the Java ecosystem, so it would probably need to be a JVM language for this reason.
  • It should support type inference. Life is too short not to have the compiler sorting out the type details for you.....
  • It should be functional with an emphasis on data structure immutablility. This is the future for advanced languages (I'm not disputing that functional languages are hard to master, but this language isn't for beginners....)
  • It should support interactive development, preferable in a REPL-like environment where you can interact with the running (potentially distributed) code environment.
  • It should provide excellent lock-free concurrency support. As we move into the massively multi-core world, lock based approaches simply aren't going to scale. Software transactional memory is probably the way forward.
  • It should support low level coding where needed for performance. High level coding is great 95% of the time but sometimes you just need to manipulate bytes directly.....

Currently the closest I've found to my wishlist is Clojure, which ticks most of these requirements.

Since the OP refers to syntax, I'll give a few code examples:

Proper variable arity functions, with support for large argument lists:

(+ 1 2 3 4 5)
=> 15

(apply + (range 10000))
=> 49995000

Interactive access to the compiler at runtime:

(def function-string "+")

(def function (compile-string function-string))

(function 7 8 9)
=> 24

Distributed code execution (MapReduce style). Note that this implies that the language / library is able to take the locally defined some-long-running-function and transparently distribute it to all the nodes in the cluster for execution at runtime.

(def my-cluster 
     (create-compute-cluster :nodes 100 :service "Amazon"))

(defn some-long-running-function [input]
  ....)

(def reduction-function 
  (fn [a b] 
    (do-something-to-reduce a b)))

(def lots-of-inputs (range 10000))

(distributed-map-reduce
  my-cluster
  some-long-running-function
  inputs
  reduction-function)
=> (whatever the result of the mapreduce is over the cluster)

Proper type inference (i.e. the compiler works out that my-function always returns a String and makes optimisations / inferences accordingly:

(def my-function [name]
   (str "Hello " name "!"))

(my-function "Bob")
=> "Hello Bob!"

(compile-time-type my-function)
=> [java.lang.String :not-null]
肩上的翅膀 2024-07-20 04:26:20

我的最佳语言看起来很像 Nemerle(减去任意限制)。 实际上,这取决于元编程工具; 我应该能够以我认为合适的任何方式任意扩展或修改语言以完美地适应该领域。

给我宏,让我能够按照自己的意愿处理所有代码的 AST,这样我就可以构建我的完美的语言。

My optimal language would look a whole lot like Nemerle (minus the arbitrary restrictions). Really it comes down to metaprogramming facilities; I should be able to arbitrarily extend or modify the language in any way I see fit (period) to fit the domain perfectly.

Give me macros that allow me to work on the AST of all of the code as I wish and I can build my perfect language.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文