Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This…

    <ul>
    {{range .Query `SELECT id,name FROM contacts`}}
        <li><a href="/contact/{{.id}}">{{.name}}</a></li>
    {{end}}
    </ul>
…reminds me of what we used to do in php3 days. That was convenient, performant and… unmaintainable. Am I missing something ?


Who knows if it will be maintainable or not. Can you articulate why the php3 projects became unmaintainable?


I almost have ptsd from these dark days, I won’t go into details ;-) but there’s plenty of literature about separation of concerns. Having the templates doing the data access takes me back 20 years ago, but I can see why this idea comes back in a web component era.


Check out: https://htmx.org/essays/locality-of-behaviour/

The proposal is that Locality of Behavior > Separation of Concerns. Maybe its true! We'll see. :)


I actually like htmx (I find Unpoly superior so that’s what I use, but it’s the same general idea) and the example given makes sense, but one should not extend locality of behaviour to the point of sprinkling SQL in templates. I don’t think that’s what the htmx folks had in mind in this essay either, their canonical example being the html/css/js trio. But hey… there’s no better experience than first-hand experience, you will find soon enough if it works for you.


I agree that it's taking the idea of LoB to an extreme that wasn't intended (at least not explicitly) in the essay. But I still don't see why it's a bad idea considering that SQL-level abstractions (views, procedures, etc) are available. What value does adding a layer of application-level abstraction provide? So I have to name and call a function that calls the sql; to what end?


There’s plenty of literature (and debate !) about mvc/mvt (and its numerous variants and interpretations) in the context of web apps. It’s interesting that you challenge the consensus though.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: