Idea Dump
—
Over the past 3 years or so I've been researching and applying programming language ideas that have interested me. Not with any particular goal in mind, just for my own enjoyment, and as an opportunity to learn and to carve out a small space to write software for myself without getting as caught up with the hype cycles and churn in the industry.
Over this time I've documented my ideas and thought processes. I like to revisit these notes from time to time, and while they are rough and informal, I think they're interesting and can be actually better quality than what I end up when I attempt to write a "real" post.
So below I've picked a few to share. Might make some more posts like this in the future.
Things the best languages should do elegantly
Not a list of things I think every language should have, just things I would look for when considering the efficacy of a language.
Explicit data flow
js + html fails by using event hooks setup imperatively react/vue are a bandade
A good language makes it impossible to bury triggers or transfers of data
State over time
mutable variable and reassignment are not good enough, this defies explicit data flow
A good language provides careful semantics for handling state over time
Lists of stateful entities
A good lanugage implements a particle system elegantly
Modular stateful entities with logic
locality of behavior is an imporant principle as well as modularity.
React/vue have good solutions for this, but are isolated views on to the web they enable creation of components which can be declaratively included within other components, embedding state and logic. Components handle input events from the top down, bubbling events up and delegating statefulness to the parent and propagation of state through children.
A good language provides a general solution to modular stateful code
UI
A good lanuage enables elegant creation and management of UI
Idea - program log + hashes
Idea: Real Easy TDD
TDD is "test driven development" a simple priciple, to write a test first, see it fail, then make the change.
But there's a big problem. Test failures are not guaranteed Even if you check in the failing test to version control, the previous test failure will not necessarily be ensured with something like continuous integration.
And more likely, you will just make the change and write the test in one commit.
Solution? Keep all your old code to run new tests against. version control keeps your old code, but it doesn't really make sense to use this to run multiple versions in CI.
What if instead, every function is referenced to by it's hash. The program is simply a hash itself, a function to be run grouping together all your other hashes.
Tests run against these hashes. New versions of your program are simply new functions made up of different functions, although this doesn't exclude the possibility of retaining old functions for testing purposes.
So when adding a test, you indicate at what hash the test should fail at (before your change) and then after you change it, you register that this hash should pass the test.
Then the test runs twice, once with the old hash and one with the new. Then the test results are cached forever, since they ran against a hash, which is guarenteed to run the same forever.
Idea: Event Sourcing Event Aggregation Programs
Event sourcing is nice. Except when your event protocol changes, and you need to either run a migration, or do some crazy defaulting to ensure old event versions still work fine
What if instead, the event interpreter was an event itself?
So when the interpreter changes, an event is emitted to indicate this, This means in order to determine the current state of anything managed by the event sourcing system, all you must do is push that entitiy's events through the most recent program event at the time it was emitted.
Benefit: No need for namespaces
Namespaces are for separating names that might collide.
Namespaces do not however enable coexisting copies of the same code at different versions.
Using hashes however elliminates the need for namespaces. You may have aliases for your code for reference, but importantly: they are not required internally for your code to run.
This means your system may operate fine with multiple versions of the same program installed simultaneously without any issues, even running at the same time.
How?
Need some kind of program which allows you to "check in" data which can be hashed and held onto.
This repository can hosted so it can be pulled down by others
Then apart from this, you can have your version control, which simply holds links to versions in the repository.
The way programs are hashed is first by breaking it down to a symbolic representation, then by looking at the internal references, and breaking it apart.
Every chunk of code is hashed separately, and a dependency tree is made.
for instance, if your code looks like this:
def foo(): print('foo')
def bar(): print('bar')
def foobar(): foo() bar()
Then foo, bar and foobar will be hashed separately Then foobar, rather than holding onto the named references, will hold the hashes of foo and bar.
So when foobar is pulled down, all it's dependencies are packaged with it.
Web alternative
Someone creates something. They publish to a given network. Could be a number of personal computers, or family computers, or anyone.
As soon as you publish a work, it can be pulled in by someone else in that network. Others can be notified too, but ultimately once released, it can be asked for and provided by anyone on that network.
Each computer on the network is able to access this data, and may cache it or discard as needed.
Programs can also be published. Programs, when run, can take in data you have access to, plus user provided data, including clicks and keypresses on your computer, and create new piece of data that you can publish on a network.
Programs have zero access controls by default, and may be granted access via whitelisting. Think how websites can allow or block push notifications, geolocation, etc. But instead, these programs don't even have access to push or pull resources from the web.
Programs are the replacement for website applications. They are desktop applications, where you have full control of your data, and can plug it in whatever way you wish.