The web has evolved a lot since the days of Tim Berners-Lee, but we are still using some of the initial concepts. From a technical view, HTML is superfuous: We can access the HTML-DOM-API directly to build the DOM. From a programmers view, there are good reasons to rethink the whole concept.
What´s the advantage? Much more than you would think:
- Element creation gains some programmatical "intelligence": You can create new elements on the fly using conditions If -> create element A, else -> create element B.
- Most Elements have been "pimped" a bit to be more accessible: Simply apply an array to a list using ul(["Milk","Butter","Tea"]) to create a populated list.
- No need to use a virtual DOM, direct access is blazing fast on current browswers.
- No need to use a Shadow DOM, as CSS properties can be fully encapsulated to prevent side effects.
You will find more useful aspects using the DML-approach. After a few days you will ask yourself how you did it before?
Scope of use
- Build complete web applications with DML from sratch (Which is prooved by the DML homepage and other applications). This is easier if you have some experience to use object oriented design patterns.
- DML also integrates seamlessly with other frameworks, as it does not presuppose a certain workflow.
- If you like them: DML is ideal to create webcomponents
- DML can also integrate existing webcomponent libraries into your workflow. Just write some short wrappers.
The core of the DML-libary is free (Open Source under the CC0-1.0 License), a complete introduction and reference can be found here. There are some more advanced modules available for professional use (e.g a charting library with an unlimited number of axis on each side of a diagram).
The homepage itself was created using DML too. It provides lot´s of "living" examples that can be changed to immediately see the effects. Please try out yourself!
What about SEO?
It is true: DML creates dynamic websites, bypassing the traditional HTML-part (though you can still use HTML). Some search engines will not be able to read the content of your site then (beside Google, that can render and index dynamic pages too). But this is not different from React or Vue, that have a similar approach. DML is still a very young project, so server side rendering is not yet implemented.
Top comments (15)
I think the need for static HTML is overrated. In 2021 it's totally okay to have a Website being dynamically rendered.
List of examples (to be continued)...
There are some new examples to show, how short things can be with DML:
ToDo (Official) : Todo (100% lighthouse :-))
ListUpdated : ListUpdated
Counters : Counters
Simple TopBar : TopBar
Simple List demo : SimpleList
Binary is live here Binary
Clock is live here Clocks
Eckehard, I can't make webcomponents work, could you show an example by completing one of your script ?
very nice you put the examples online, thank you much for that!!!
As mentioned, the DML-class was not intended to be used as a webcomponent, so I did not check out how to pass parameters to WC. There are also some strange effects which may require some investigation. As you may see, the clocks are not inside the div.
Here is the index.html:
Thank you Eckehard
Here is the live version ClockWC
I would like to import dml.js in a main app.js
In order to tree shake the bundle.
I encountered some errors like : 'function p' already declared.
Is this in your project ?
yes, p() is one of my functions. I should think about building a new class where all this functions are part of like dml.p(), dml.print to avoid naming conflicts. Or supply dml as a module, which will have the same effect.
DML currently is a script without import/export, which is really a shortcoming. Thank your for the hint, maybe I find some smart solution for that....
Thank you Eckhard,
I really believe in DML ant its potential :-)
Yes, first commercial projects we have done using DML have been very promising.
But there is one issue I could not solve til now:
Using scripts instead of ES-modules is quite convenient, as it let´s you use all your functions without effort. BUT: it adds all defintions to the global namespace, which earlier or later will result in name clashes. Additionally, DML currently contains lot´s of constants and functions just for convenience, giving a total of about 170 names in your namespace, and most of them are rarly ever used.
There are several solutions discussed here using ES-modules, which is the right way to do, but has drawbacks too:
Don´t know if this has some negaive impact?!?
Here, all constants are grouped in JSON-object "css", which can be import as an entity. Now we use div("",css.bold) instead of div("",_bold), which is not really bad, but does not really improve the readability. As it makes the intention clearer, maybe this could be an advantage.
which would allow more fine grained import, but I assume, most of the time we would import all modules anyway.
Is there a better solution?
I would really appreciate if there was a way to use the library inside a scoped context, so all definitions live only inside this context, similar to the revealing pattern.
We CAN implement such a pattern using classes:
Using named inport currently seems to be the most appealing and correct way, but it seems to have very little advantage over the current "script"-approach (beside the possibility to avoid name clashes). If there is any better solution, any suggestion is very welcome.
I also believe named import is the best solution, and let tools like Rollup do tree shaking for production.
But, I also think you could, at the same time deliver DML_core.js (and co.) which would benefit those who want don't want to deal with node.
DML was created to write complex web applications. Not all sources have been published yet, but the basic modules are open source now. As you may have seen from the examples, DML makes it very easy to create object oriented web modules. We found the we got less problems with DML than with WebComponents and things grow very fast.
DML was inspired by the concept of Delphi components. As far as I can see, it works pretty well. We will present more modules in the near future to let you estimate the real power of this concept.
Some more details about functional templates are given here. DML enables the use of OO-concepts for web design, which is important to handle larger applications. I will demonstrate the use of classes in a later post.
Thank you for your work.
Waiting for more posts :-)
The library is under constant development, but the basic paradigm and routines are fairly stable now. So I would be happy to see, what others can do with it. For my own projects it is a real timesaver and I cannot even think to use HTML the "traditional way" anymore.
DML itself is released under an open source license, but it is intended to allow also commercial development of new components, that are not necessarily free. For now I would be happy to find people to contribute to the project (or even help to find bugs or make things better).
As I have demonstrated in my last post, that it is very easy to create useful new elements or own Webcomponents.
Please check out the documentation with lots of "living" examples. More demonstations are about to come...
Thank you Eckehard, I will investigate more :-)