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

Compiler construction 您自己的编程语言是什么样子的?,compiler-construction,programming-languages,syntax,language-design,Compiler Construction,Programming Languages,Syntax,Language Design,您自己的(我假设是完美的)编程语言是什么样子的?举个小例子,解释你的小说想法 我对语法很感兴趣。我没有“完美”编程语言的概念,因为要执行的任务不止一个 不同的任务适合不同的语言和范例。完美的编程语言往往出现在科幻小说中。例如: 奥森·斯科特·卡德的《恩德系列》——要创造,你必须进入一个不同的维度,在你的头脑中形成一个纯粹的思想。当你回来的时候,它是 Robbert A.Heinlein在《野兽的数目》中探讨了世界作为神话的概念 大卫·布林的《地球》通过人声与眼睛和手指动作相结合的方式进行编程

您自己的(我假设是完美的)编程语言是什么样子的?举个小例子,解释你的小说想法

我对语法很感兴趣。

我没有“完美”编程语言的概念,因为要执行的任务不止一个


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

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

  • 奥森·斯科特·卡德的《恩德系列》——要创造,你必须进入一个不同的维度,在你的头脑中形成一个纯粹的思想。当你回来的时候,它是
  • Robbert A.Heinlein在《野兽的数目》中探讨了世界作为神话的概念
  • 大卫·布林的《地球》通过人声与眼睛和手指动作相结合的方式进行编程
这一切仍然归结为相同的基本困境。任何不强迫人类学习技能的编程语言都会限制思想自由。自然语言也不好,因为它有很多歧义


我不介意一个结合了自由、力量和最小语法的游戏。我最近开始学习lisp,到目前为止它看起来非常好

我的最佳语言看起来非常像Nemerle(减去任意限制)。实际上,它可以归结为元编程工具;我应该能够以我认为合适的任何方式(句号)任意扩展或修改该语言,以完全适合该领域


给我宏,让我可以随心所欲地处理所有代码的AST,我就可以构建我的完美语言。

大规模并行性由


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


做任何事()//根据已经预测的输入自动生成所有内容

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

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


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

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

我非常喜欢C宏,但我认为如果你能用你正在使用的同一种语言编写宏或“元代码”,那就太好了。(C是一个不好的例子;这在脚本语言中可能很好。)

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

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


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

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

我想我的功能应该介于和之间,除非有更多的功能。

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

问题是我喜欢的东西有相反的目标,因此我总是被迫使用完全不同的语言。目前我没有使用特定的PersBeSk、VBScript、PowerBasic、java和C++语言(有时还有VB.NET、VB 6、C++、Python和Perl)。 现在,如果我能用一种类似C语言的语言来完成这一切,在创建那些小应用程序时,它具有全局功能,没有运行时依赖性,但在需要时让我充分利用.NET Framework和Java SDK的强大功能,我会很高兴。

已经非常接近……

多媒体

我希望能够涂鸦一些图形符号,快速绘制连接,然后切换到其他模式,例如需要精确输入的模式

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

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

我读过很多关于未来计算机交互用户界面的讨论:

  • David Drake的数据棒(其中一些可用)
  • 佩里《斗牛士》系列中最受欢迎的多模态手势和发声以及其他随意提及的动作
  • 基于笔和手势的UI,包括签名以密封登录

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


      我不确定我的梦想语言会是什么样子,但我对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);
      }
      
      我知道有更优雅的函数方式可以实现这一点,但有时您仍然会得到这样的代码。一个简单的“守卫”声明将有助于:<
      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)
                         */
                      }
      
      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);
      }
      
      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);
      }
      
      answer = 42
      fraction = answer * 2 /
                 (answer + 1)
      Console.WriteLine(
          "Some funny number: {0}",
          fraction
      )
      
      for i in MyVector:
          print(i)
      
      for (typename vector<T>::const_iterator i = MyVector.begin();
           i != MyVector.end();
           ++i)
          cout << *i << endl;
      
        function f
        // f's preconditions
        // f's body
        // f's postconditions
        end
      
        function g
        // g's preconditions
        // g's body
        // g's postconditions
        end
      
      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
      
      (|| A B)
      
      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
      
      // 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], ...); } Interlocked.CompareExchange(SomeObject["George"], SomeValue, SomeOtherValue); SomeObject.ActUponProperty("George", (ref dest, ref p1, ref p2) => {Interlocked.CompareExchange(dest, p1, p2);}, SomeValue, SomeOtherValue);
      (+ 1 2 3 4 5)
      => 15
      
      (apply + (range 10000))
      => 49995000
      
      (def function-string "+")
      
      (def function (compile-string function-string))
      
      (function 7 8 9)
      => 24
      
      (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)
      
      (def my-function [name]
         (str "Hello " name "!"))
      
      (my-function "Bob")
      => "Hello Bob!"
      
      (compile-time-type my-function)
      => [java.lang.String :not-null]