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

Advanced Structural Editing #87

Open
Immortalin opened this issue Sep 6, 2019 · 0 comments
Open

Advanced Structural Editing #87

Immortalin opened this issue Sep 6, 2019 · 0 comments

Comments

@Immortalin
Copy link

Immortalin commented Sep 6, 2019

One of the main strengths of Clojure (and Lisp family languages in general) is first class support for the ability to easily manipulate the source code on the lexer level through defmacro, the read macro etc. On a basic level, you can use it to easily build structural editors á la parinfer and smartparens, on the extreme you can do advanced code generation like https://github.com/webyrd/Barliman

For traditional Rails-variety frameworks like Symphony, to a lesser extent Django, and even ASP.NET Core, the code generation process is one way e.g. run a command to do scaffolding, a bunch of code is generated. However if things go wrong, or if you decide to extend your model, it is back to handwriting code. With Clojure, this can be completely abstracted away. You can easily build a way to dynamically e.g. form inputs from a new updated model state without having to manually write everything. It won't of course be perfect, but it can be potentially a killer feature.

An example would be:

I am building a e-commerce website:

coast scaffold Product image:string, price:decimal, belongs-to: Shop

Then I decided that a single base64 string for Product image is silly, not good for performance, etc. and abstracts images into a separate table and changes the model to has-many: Images.

Now the traditional way would be to jump through all files that mention images:string and delete it, create the migration, and finally create the new Image type, add it into the files, add new UI element, bind UI to controller, test etc. Or you can just re run coast scaffold and override everything.

None of these methods are particularly fun, with Clojure however you can have a GUI or interactive prompt and selectively delete/add elements or code and have the changes be automatically propagated throughout the codebase.

There are CMSes like:

https://strapi.io

that have codebases structured around easy swapping in and out of components, rapidly-changing models, that sort thing. You do not need this sort of trickery in Clojure, it's trivial for Clojure to manipulate the syntax tree and add new code or remove certain existing ones. Rails/Python/PHP/.NET has to regenerate entire files or append code as string (e.g. rails routes generation). Clojure (and most Lisp in general do not suffer from this problem)

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