Hacker News new | ask | show | jobs
by joeldrapper 478 days ago
> another layer of abstraction that new hires need to understand. Another DSL to learn.

The thing about Phlex is it’s actually one less thing to learn. Instead of learning Ruby and ERB and how to use them both with HTML — and all the context switching that goes with using three languages in one file, you only need to know Ruby and HTML semantics (elements, methods, attributes, text, comments, doctype).

> Another syntax/LSP/docs to add to the IDE, or editor.

If you’re writing an app in Ruby, you’ll already have Ruby LSP set up in your editor. There is no other syntax. I would strongly advise against using Phlex if not already writing an application in Ruby, though I have heard of someone using Phlex to generate PHP.

> Another leaky abstraction that has to be debugged, monitored, performance-tested.

I don’t know what you mean by “leaky abstraction”. I consider Phlex to be an air-tight abstraction around the parts of HTML I’ve ever had to use in the last 15 years of programming. There are a couple of things you can’t do without using `raw` — mainly CDATA and other non-HTML5 doctypes.

If I saw a convincing argument for supporting those parts of HTML, I would.

The real leaky abstraction for HTML is string templating, where none of the HTML semantics are validated and XSS vulnerabilities abound.

2 comments

> The real leaky abstraction for HTML is string templating

With actual XML and JSON (or csv etc) I would agree: for that you need a serializer, not a string templating env.

But for HTML, especially when used to build GUIs, string templating makes sense - to me -.

What I meant with "leaky abstraction" is that when I write a web-app, my goal is to write certain HTML, the actual strings, to a browser. I'll have my developers console open, inspect DOM/source and then modify the code of the app until the DOM/source matches what I want or need it to be. The closer my "code of the app" is to this actual DOM/source, the less I need to think through layers.

I prefer to just "move this UL out of the DIV and next to the H2¹" rather than manipulating the structure in a tree of objects. To each their own, I guess, but I rather prefer to stay "as close to the metal" as possible, especially if that metal isn't complex or difficult.

¹ I realized I wrote my HTML elements in capitals. I am that old; and I don't anymore, but old habits creap in, I guess :)

> you only need to know Ruby and HTML semantics (elements, methods, attributes, text, comments, doctype).

If you know those things then you basically know ERB. And to your point the Ruby LSP works with ERB.