Nilesh Trivedi
12/29/2022, 12:59 PMb
and height h
. It's common to think of these as "independent" variables and define quantities like the following as "dependent":
• perimeter(b, h) => 2*(b+h)
• area(b, h) => b*h
• diagonal(b, h) => sqrt(b^2+h^2)
But if I were to ask, what are the base and height of a rectangle whose area is a
and diagonal is d
, our programming languages have no tooling to do this (except the symbolic manipulation libraries for computer algebra). All the required information is there but we have privileged b
and h
over area
and diagonal
and thus, we now need to figure out the formula for side lengths and program it as the function sides(a, d)
I should be able to describe a structure, and auto-generate all possibilities functions (including for currying and partial applications, and while we are at it, all the partial derivatives with respect to each other) so that i can just declare what is known and what I want to calculate. A rectangle can then be represented with any set of variables that make everything else determinable. I should get access to all possible constructors like new Rectangle(area: a, diagonal: d)
.
And I want to see this be available for all programming tasks, not just algebra/math. For creating a graph, is the constructor new Graph(Node[], Edges[])
really the privileged one? Why not build languages in a way that I automatically get new Graph(AdjacencyMatrix)
and graph.getNodes()
and graph.getEdges()
.Nick Smith
12/31/2022, 7:20 AMAlex Cruise
01/03/2023, 8:20 PMAlex Cruise
01/03/2023, 8:21 PMKonrad Hinsen
01/06/2023, 10:55 AMSteve Dekorte
01/20/2023, 7:08 PMguitarvydas
01/22/2023, 2:06 PM... function-name (...) {...}
In Ohm-JS, you can say this, whereas in a CFG-based parser generator you need to over-specify all of the niggly bits of C syntax. In Ohm-JS, this results in a few minutes of work and only a few lines of code. The Ohm-Editor assists in developing the micro-grammar.
In YACC and CFG-based approaches, though, you’re looking at a gargantuan job (days, weeks, months, ...) and you simply don’t bother to write such a quickie parser. You either don’t bother with the whole idea, or you use something like REGEX which fails on a number of edge-cases for this kind of thing. REGEX can’t search recursively for matching brackets, Ohm-JS can. Using REGEX, you might get away with a partial solution, or, the project might grow larger as you hit unexpected speed bumps. You either persevere or you just give up.
For the record, the grammar plus the accompanying code fabricator specification for the above simple example are shown in the appendix.
### DaS Comes For Free
When you can build totally isolated building blocks, you can draw sensible diagrams of how the building blocks should be snapped together to solve a problem.
Later, you can steal (cut/copy/paste) chunks of previous solutions and use them as building blocks for new problems.
DaS: Diagrams as Syntax.
DaS is not diagrams as an Art Form. DaS is diagrams as programming languages. For example, instead of writing {...}
, you draw a rectangle.
Programming languages were created by culling the English language and by choosing only the words and phrases that could be compiled to executable code.
Can we cull diagrams in the same way to invent new programming languages?
EE’s have done this and they call the resulting diagrams “schematics”.
Building construction engineers have done this and call the resulting diagrams “blueprints”.
## Don’t We Already Use Building Blocks?
“Code Libraries” look like building blocks, but, contain subtle bits of coupling that discourage building-block-iness.
For example, the very common idiom of a function call f(x)
introduces at least 3 kinds of coupling:
1. The name f
is hard-wired into the caller’s code. The calling code cannot be cut/copy/pasted into some other solution without also dragging in the called code, or, by futzing with the source code.
2. The function call f(x)
waits for the callee to return a value. This is also known as blocking. Function call notation works fine on paper, where functions can be evaluated instantaneously. It’s different when you map function call syntax onto hardware that has propagation delays wherein functions take finite amounts of time to “run”. This subtle difference in behaviour leads to hidden gotchas. A glaring example of the impact of such a difference can be seen in the Mars Pathfinder disaster[^pathfinder].
3. The function return v = f(x)
hard-wires a routing decision into the callee’s code. The callee must direct its response back to the caller. This is called “returning a value”. Again, this doesn’t look like a problem when you just want to build fancier calculators, but, this hard-wired routing decision discourages simple solutions to non-calculator problems, like machine control.
[^pathfinder]: https://www.rapitasystems.com/blog/what-really-happened-software-mars-pathfinder-spacecraft
When you don’t have complete isolation, you don’t have building blocks. Imagine a LEGO® set where all the pieces are joined together with a single, long sewing thread glued to each LEGO® block. Or, you have two real-world objects, e.g. one apple and one orange. You cut the apple in half. What happens to the orange?
As humans, we are used to the idea that objects are completely isolated. Programs don’t work that way. We have to stop and think hard when writing programs.Nick Arner
01/25/2023, 12:44 AMJonas
01/28/2023, 6:51 PMIvan Reese
01/28/2023, 9:43 PMSteve Dekorte
02/01/2023, 8:38 PMMariano Guerra
02/03/2023, 3:47 PMJim Meyer
02/09/2023, 11:34 AMKalvin
02/16/2023, 1:04 AMIbro
02/20/2023, 12:41 PMOleksandr Kryvonos
02/21/2023, 10:20 AMEli Mellen
02/22/2023, 2:25 PMJarno Montonen
02/22/2023, 2:43 PMJarno Montonen
02/23/2023, 12:32 PMJason Morris
02/28/2023, 6:11 AMNiall McCormack
03/01/2023, 9:03 PMguitarvydas
03/03/2023, 7:50 PMhttps://www.youtube.com/watch?v=bFeJZRdhKc▾
https://www.youtube.com/watch?v=5YjsSDDWFDY&list=PLcGKfGEEONaDO2dvGEdodnqG5cSnZ96W1&index=28▾
Jared Forsyth
03/06/2023, 6:54 PMIvan Lugo
03/16/2023, 2:05 PMMariano Guerra
03/18/2023, 12:11 PMMariano Guerra
03/21/2023, 9:14 AMwtaysom
03/24/2023, 7:17 AMNick Smith
03/27/2023, 4:51 AMJarno Montonen
03/27/2023, 7:30 AMIbro
03/27/2023, 2:32 PMIbro
03/27/2023, 2:32 PM