微軟重磅開源新語言Bosque,超越結構化編程

微軟重磅開源新語言Bosque,超越結構化編程

前言

微軟科學家Mark Barron根據是自己發表的論文《Regularized Programming with the BOSQUE Language》,設計出全新的編程語言 Bosque,Bosque的靈感源於TypeScript語法、 ML、NodeJS/JavaScript的語義。

Bosque理論

Mark Barron指出上世紀 70 年代興起的結構化程序設計和抽象數據類型使得開發者可以屏蔽掉底層硬件架構的特徵,專注於編寫功能代碼,同時開發也變得更加不易出錯。而作者在此基礎上,提出了一種新的程序設計思想——Regularized Programming(規範化/正則程序設計),通過避免低級循環動作的迭代處理、用代數數據轉換操作符豐富語言等設計,超越結構化程序設計

Bosque特性

1、我們熟悉的循環機制在 Bosque 中它被取消了,不需要“for”、“while”、“do while”循環,取而代之的是引入了函子(仿函數,Functors)來取代:

//Functor (Bosque) 
var a = List[Int]@{...};
//Pre: true
var b = a.map[Int](fn(x) => x*2);

//Post: List[Int]::eq(fn(x, y) => y == x*2, a, b)te

2、構建對象

微軟重磅開源新語言Bosque,超越結構化編程

意外複雜性(Accidental Complexity)

Bosque消除了主要的不確定複雜性來源。

該論文《Regularized Programming with the BOSQUE Language》基於一系列分析、運行時與編程器開發的經驗與驗證,以及針對開發人員的採訪,確定了開發過程中會出現的 5 個主要不確定複雜性來源:

  • 可變狀態和框架/Mutable State and Frames;
  • 循環、遞歸和不變量/Loops, Recursion, and Invariants;
  • 不確定性為/Indeterminate Behaviors;
  • 數據不變違規/Data Invariant Violations;
  • 平等和別名/Equality and Aliasing

環境需求

Windows

  • The LTS version of node.js for Windows (x64)
  • Typescript (install with: npm i typescript -g)

構建&測試

npm install && npm run-script build && npm test 

命令行執行

node bin/test/app_runner.js FILE.bsq

開發工具VSCode

This repository provides basic Visual Studio Code IDE support for the Bosque language (currently limited to syntax and brace highlighting). The installation requires manually copying the full bosque-language-tools/ folder into your user .vscode/extensions/ directory and restarting VSCode.

關於Bosque

論文

https://www.microsoft.com/en-us/research/uploads/prod/2019/04/beyond_structured_report_v2.pdf

源碼

https://github.com/Microsoft/BosqueLanguage

關於我

大家好,我是Wooola,10年JAVA老兵,擅長微服務,分佈式,併發,工作流。請大家多多關注我。


分享到:


相關文章: