3 ms·
I don't know Matestack specifically but in general the problem of DSLs is that they can quickly turn into giant pain in the ass once you need to do something th
by masa331 6y ago
I don't know Matestack specifically but in general the problem of DSLs is that they can quickly turn into giant pain in the ass once you need to do something they aren't prepared for. And this has bitten me enough times already(ActiveAdmin, Thor,...).
The other problem is that if you use this you only learn the specific DSL which isn't portable. But if you use and learn the basic technologies under it - HTML, CSS, and pure JS now that is something you can use elsewhere even if you throw Ruby away completely. And the knowledge of the basics is really really important and useful.
Anyways, what is a problem with writing good old .html.erb templates? I don't think there is any.
And for the reactivity thing - the most easiest and fastest(10 minutes at max to install and enable) is to just turn on Turbolinks[1] and include this little plugin[2][3] for persistent scroll position where you want. Now when when you click marked with `data-turbolinks-scroll = "false"` Turbolinks fetches the page, replaces the current page with it, and you are still at the same scroll position. No need for SPA or JS heavy FE or anything.
[1] https://github.com/turbolinks/turbolinks https://github.com/turbolinks/turbolinks
[2] https://medium.com/@kosovacsedad/how-to-turbolinks-5-scroll-position-persistence-6e4435a60b2e https://medium.com/@kosovacsedad/how-to-turbolinks-5-scroll-...
[3] https://gist.github.com/sedadkosovac/661d0fd369069cad010f164b3fcd8c20#file-turbolinks_scroll_persistence-js https://gist.github.com/sedadkosovac/661d0fd369069cad010f164...
- jonnymoe 6y agoCore contributor here: I think you're right when talking about DSLs ONLY introdrucing a high level of abstraction. But Matestack's first layer only maps HTML tag rendering to Ruby method calls, which actually doesn't add any abstraction and thus gives you the same level of flexibility when implementing things. The advantage of doing things in pure Ruby (even without any abstraction layer) is simply that it's now possible to utilize Ruby's languange features to create clean and readable UI code within a proper Ruby class - which means you can use class inheritance and modules for UI code structuring. That could be a big thing if you're into writing Ruby code ;) On top of that Matestack offers components (used via a DSL) with a higher level of abstraction in order to hide implementation complexity of - for example - rerendering a specific part of the UI. The idea behind these components is to drastically reduce the amount of code and effort you have to invest in order to implement typical UI requirements. And yes it's true: When using these components you loose some flexibility on how exactly things will work but you gain development speed and productivity. If the components don't perform as desired, you simply create your own component in pure Ruby or pure Vue.js and do whatever you want - e.g. consuming a JSON API and perform client side rendering. Without this customization path I would totally agree with what you said here: "the problem of DSLs is that they can quickly turn into giant pain in the ass once you need to do something they aren't prepared for" Matestack tries to enable you to use components with high level of abstraction next to components with low level of abstraction next to your very own components... and they are all meant to live happily side by side :D
- masa331 6y agoWell i don't find plain HTML unreadable or messy. Same with JS. And i never experienced any productivity issues writing it. As i'm thinking about it only DSL i find useful is Nokogiri's XML builder. That can save me some time sometimes. Good luck with Matestack anyways. It's just not for me i think