Skip to content

Instantly share code, notes, and snippets.

@pederbl
Created May 23, 2012 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pederbl/2774396 to your computer and use it in GitHub Desktop.
Save pederbl/2774396 to your computer and use it in GitHub Desktop.
new self documenting language
def pay_employees
pay employees
where
employees {
Person.where(employee: true)
}
pay(persons) {
persons.each { |person| person.pay }
}
end
end
***
The fundamental idea behind this new language is to make writing code more like writing essays. The most
interesting and summarizing statements should come at the top much like a research essay should have its
thesis in the first paragraph and the purpose of all subsequent paragraphs should be to support the thesis
with examples and logic.
Code is hard to read because abstractions are at the function level and the execution order prevents the
coder from placing the most interesting statements of each function at the top as he would when writing
an essay. Variables increase the difficulty to understand code because they depend on the conditional
paths through the code and may even have different meanings within the same function as a coder might
reuse a variable for subsequent logic.
To address this issue developers sometimes try to write documentation that should help others (and
themselves) to understand the code. But, documentation is fundamentally problematic because its boring, its
time consuming and there is no way to make sure the code actually does what the documentation specifies.
Another way to address this issue is to split functions into many. But, there is a code readability and
namespace pollution cost to having new function unless its scoped and within a function the execution order
of scoped functions must be in the opposite order than what is desired (low-level -> high-level instead of
thesis -> supporting logic/examples).
The understandability of code is critical since both correctness and maintainability are among the most
critical properties of any software system and both of these are primarily dependent on understandability
of the code.
My inspiration for this new language mainly comes from Ruby, Lisp and Haskell. All of them are lacking in some
important aspect to make code readable for the masses.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment