Hacker News new | ask | show | jobs
by joeldrapper 476 days ago
> I'm not sold on some of its design like the distinction between views and components

There is no distinction in Phlex. The distinction is only made in generated code in Phlex-Rails where it felt like a sensible way to fit with the existing mental model. Views are technically just components, but they are expected to be HTML documents composed of components and rendered directly from controller actions. You wouldn’t want to render a view inside another component because you’d get another doctype and `<html>` tag. So they are sort of “entry points”.

> There's a little metaprogramming in SGML::Elements I dislike

Many crimes are committed in the name of performance. For example, we have a different code path for standard elements with attributes and content, standard elements with attributes but no content, standard elements with content but no attributes and standard elements with no attributes or content. Not to mention void elements.

This allows us to reduce the number of string concatenation operations required during rendering and is why it renders ~1.5gbps of HTML per core.

I’ve considered having an API-compatible minimal version of Phlex that would be much easier to take on and maintain yourself if it didn’t make all these performance optimisations.

1 comments

You know, you've told me that about views and components before, and I keep forgetting. I am so used to getting burned by software that has two names for things because a couple months or years later, ah yes, now that you mention it there is this one tiiiiny distinction that happens to be why the app is on fire now.

It would be great if you could expand your explanation of the metaprogramming into a comment in the code. When I read it, I didn't immediately recognize the technique and its tradeoffs, so it seemed like an odd decision rather than an informed one.

Having two versions of phlex would be a strong negative to me. I don't like to see dev teams spread themselves out, it's one more choice I'd have to make when adopting, if switching between them I have new risks that they've slipped out of sync in some way, and it's altogether another odd decision that has to be explained.

What I was trying to say about the code is that I share the previous commenter's experience of "welp I guess if we want that bug fixed we have to click 'fork' on github... while we write up our plan to migrate away". Having had that experience several times, Phlex looks like an acceptable risk.