1. 程式人生 > >宣告式(程式設計)語言是解釋型語言

宣告式(程式設計)語言是解釋型語言

宣告式語言包包括資料庫查詢語言(SQLXQuery),正則表示式,邏輯程式設計,函數語言程式設計和組態管理系統。

宣告式程式設計透過函式、推論規則或項重寫(term-rewriting)規則,來描述變數之間的關係。它的語言執行器(編譯器直譯器)採用了一個固定的演算法,以從這些關係產生結果。

https://baike.baidu.com/item/宣告式程式設計/9939512

 

 

Aren’t We Just Hiding the Implementation?

Eventually, every piece of our code must be implemented somewhere. In declarative languages, the implementation is up to whoever interprets the code:

  • SQL is handled by a database engine.
  • A browser will interpret HTML.
  • A YAML configuration file could be handled by a build server.

When we apply some declarative techniques to our imperative languages, it’s up to us to provide the implementation. Even the LINQ extension methods are implemented in C#, they’re just not in our own codebase. So we’re actually just abstracting away implementation details. Then the question is: how far do we go with this abstraction? You will need to find what works best for you, but a good starting point for me is that public methods (i.e. your public API) should contain a minimum set of statements, and these should all be easily readable. The contents of your public method should tell you what is happening, not how.

 

https://blog.ndepend.com/declarative-programming-depth/