4 ms·
Joe and I are thinking similarly :D I'm going to dump some ideas here. --- # JRFC 27 - Hyper Modular Programming System (moving it over to https://github.co
by _prometheus 12y ago
Joe and I are thinking similarly :D I'm going to dump some ideas here.
---
# JRFC 27 - Hyper Modular Programming System
(moving it over to https://github.com/jbenet/random-ideas/issues/27 https://github.com/jbenet/random-ideas/issues/27)
Over the last six months I've crossed that dark threshold where the desire of building a programming language has become an appealing idea. Terrifyingly, I _might_ actually build this some day. Well, not a language, a programming _system_. The arguments behind its design are long and will be written up some day, but for now I'll just dump the central tenet and core ideas here.
## > Hyper Modularity - write symbols once
### An Illustration
You open your editor and begin to write a function. The first thing you do is write the ([mandatory](https://code.google.com/p/go-wiki/wiki/CodeReviewComments#Doc_Comments) https://code.google.com/p/go-wiki/wiki/CodeReviewComments#Do...) [doc comment](http://golang.org/doc/effective_go.html#commentary http://golang.org/doc/effective_go.html#commentary) describing what it does, and the type signature (yes, static typing). As you write, [your editor suggests](http://npmsearch.com/?q=factorial http://npmsearch.com/?q=factorial) lists of functions [published to the web](npmjs.org) (public or private) that match what you're typing. One appears promising, you inspect it. The editor loads the code. If it is exactly what you were going to write. You select it, and you're done.
If no result fits what you want, you continue to write the function implementation. You decompose the problem as much as possible, each time attempting to reuse existing functions. When done, you save it. The editor/compiler/system parses the text, analyzes + compresses the resulting ASG to try to find "the one way" to write the function. This representation is then content addressed, and a module consisting of the compresses representation, the source, and function metadata (doc string, author, version, etc) is published to the [(permanent) web](http://ipfs.io/ http://ipfs.io/), for everyone else to use.
### Important Ideas
- exporting a symbol (functions, classes, constants, ...) is the unit of modularity (node)
- system centered around writing _functions_ and writing them once (node)
- stress interfaces, decomposition, abstraction, types (haskell)
- use doc string + function signatures to suggest already published implementations (node, Go)
- content address functions based on compressed representations
- track version history of functions + dependents (in case there are bug fixes, etc). (node)
- if a function has a bug, can crawl the code importing it and notify dependents of bugfix. (node, Go)
- use static analysis to infer version numbers: `<interface>.<implementation>` (semver inspired)
- when importing, you always bind to a version, but can choose to bind to `<interface>/<implementation>` or just `<interface>`
- e.g. `factorial = import QmZGhvJiYdp9Q/QmZGhvJiYdp9Q` (though editors can soften the ugly hashes) (node + ipfs)
- all modules (functions) are written and published to the (permanent) web (public or private)
- when importing a function, you import using its content address, and bind it to an explicit local name (`foo = import <function path>` type of thing)
- the registry of all functions is mounted locally and accessible in the filesystem (ipfs style)
- _hyper modular_ means both to "very modular" and "modules are linked and on the web"
Note: this system is not about the language, it is about the machinery and process around producing, publishing, finding, reusing, running, testing, maintaining, auditing, bugfixing, republishing, and understanding code. (It's more about _the process of programming_, than _expressing programs_). This means that the system only expresses constraints on language properties, and might work with modified versions of existing languages.
- lifeisstillgood 12y agoYes. And Yes. I doubt that our conception of these things will be in use in twenty years - but I do think that assisting the process of taking an idea and putting into production (process of programming) is going to be more and more a feature of our world. It allows for bringing up the worst ten percent of code without limiting the top ten. It is far far better than the Java idea of making it hard to shoot your foot off with the language.
- fizixer 12y agoInteresting. I had an idea similar to the first part of your comment, in which 'reinventing-the-wheel', everytime you start to write a new program, is avoided by 'autocompleting your code' based on the vast database of open source projects on the internet. If a programmer starts writing a code that declares some variables and opens a for loop, the smart editor starts searching the open source projects and lists the code chunks with beginnings most resembling what you've typed so far, and then you can pick one of those if you like, or keep writing. I haven't thought of what could be done afterwards though. I tend to think it also has connections with a recent discussion here: https://news.ycombinator.com/item?id=8308881 https://news.ycombinator.com/item?id=8308881
- akkartik 12y ago"The first thing you do is write the (mandatory) doc comment describing what it does, and the type signature. As you write, your editor suggests lists of functions published to the web that match what you're typing." As a concrete example, if I say (picking a syntax at random; underscore denotes where my cursor is): add :: int -> int -> int def add(a, b) """add two numbers""" _ and if the permanent web contains two functions: proj1_add :: int -> int -> int def proj1_add(a, b) """returns sum of arguments""" a+b proj2_sub :: int -> int -> int def proj2_sub(a, b) """returns difference between a and b""" a-b Would you envision your system "matching" both or just the first? If just the first, on what basis do you imagine figuring this out?
- _prometheus 12y agoJust the first. on the strings "sum", "add", and potentially on the symbolic operation `args[0]+args[1]`.