Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💡towards a simpler component-based programming paradigm #16

Open
brodycj opened this issue Mar 23, 2020 · 0 comments
Open

💡towards a simpler component-based programming paradigm #16

brodycj opened this issue Mar 23, 2020 · 0 comments
Assignees

Comments

@brodycj
Copy link
Owner

brodycj commented Mar 23, 2020

I recently finished and published generate-cordova-package which is able to programmatically generate a functional Apache Cordova app or plugin from interactive user input:

  • by programmatically I mean no templates involved, which should help avoid potential copyright issues with using templates from various sources;
  • by functional I mean that the generated app can run on Android, iOS, or macOS, and the generated plugin can be tested with a generated plugin demo app.

The HTML/XML. JSON, and CSS generating components were made with help from simplistic npm library packages; the JavaScript code generating (codegen) components were made to work with an injected types object from babel/types; and the native Java & Objective-C codegen components were made with a bunch of embedded text rendering helper functions. The next steps should be to factor all helper functions into separate source modules then extract them out to separate library packages. Small focus modules as described here: https://blog.sindresorhus.com/small-focused-modules-9238d977a92a

The functions needed to render the HTML/XML, JSON, CSS, JavaScript, and native codegen components are relatively simplistic and could potentially be rewritten in JSX, possibly with simplistic JavaScript objects embedded. Here is a really nice article I found about 2 years ago: https://engineering.hexacta.com/jsx-can-do-that-1b2666c23a32

A major secret seems to be to use RamdaJS to enable the kind of functional programming that can then be done with JSX.

So my idea now is that it should be potentially possible to use a simplistic JSX-like language or paradigm to specify at least how higher-level components should work in JavaScript and lower-level native platform languages such as Java, Objective-C, and likely many, many others. It should be possible to realize the behavior through ways such as code generation or generating JSON or YAML-like configuration files. This would be parallel to the way that systems programmed in languages such as MyHDL could be directly executed, simulated, or synthesized through Verilog or VHDL.

The JavaScript and native codegen components generally use "make" helper functions, which act like constructor functions and make it clear that they are generating code and not rendering from a template. This would be similar to the idea of a language that works completely though using constructor functions, which I had thought of quite a few years ago. (LISP does actually work like this in some cases, using "cons" for example, or a common case when a LISP programmer writes a function that just builds and returns some kind of a list object.)

Working mostly with constructor or "create" functions is pretty similar to the object-oriented "factory" pattern which can often help reduce tight coupling in complex systems. Another programming pattern is if a piece of JavaScript or native code just creates an object then calls a "start" member function to fire it off and forget it.

Another benefit of this simplistic component-based programming paradigm is that it should be possible to specify how a system works with a set of components, regardless of whether it would work by running JavaScript, native CPU code, GPU code, FPGA, etc.

The high-level programming could be done with ideas such as JSX, a YAML-like language, or maybe an idea similar to "config.js" files used by tools like Babel and Webpack.

It would be ideal to find a way to demonstrate this idea with a well-known cross-platform framework such as Apache Cordova or React Native.

@brodycj brodycj self-assigned this Mar 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant