16 comments

  • Phlex is an amazing project. Makes frontend fun again. I&#x27;ve built my own UI library using DaisyUI and Tailwindcss that we use in all our Rails projects: <a href="https:&#x2F;&#x2F;github.com&#x2F;inhouse-work&#x2F;protos" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;inhouse-work&#x2F;protos</a><p>It cannot be overstated how nice it is to move away from erb and into pure ruby. Private methods as partials is a game changer for refactoring your UI.
    • freedomben22 hours ago
      I increasingly wonder if I&#x27;m the only one left who genuinely likes erb :-D<p>Not a fan of the rails erb helper methods though, so maybe it doesn&#x27;t count. I almost exclusively use it outside of rails now
      • barefootford22 hours ago
        I don&#x27;t know if I&#x27;m a fan but I&#x27;ve almost never had erb be the problem in a Rails app. The LLMs can work with it easily. Don&#x27;t need to bring in extensions to work with major text editors. Sticking with ERB for now.
      • GenericCanadian21 hours ago
        I found using partials between projects to be a headache. I wanted a way to standardize my UI for accessibility across all projects and not have to re-implement the same standards over and over. It&#x27;s nice to be able to package the UI up into a gem and keep it maintained everywhere.<p>It&#x27;s got a nice path for incremental adoption, so there is no need to go all-in unless you want to. Personally my Rails projects are all 95%+ ruby now.<p>Another nice knock off effect is that the LSP and integration with my IDE (neovim) is much nicer with Phlex components than it is with ERB.<p>I also think personally I don&#x27;t like &quot;magic&quot; spaces like ERB where its hard for me to follow the code path. How does ERB manage multiline blocks with html in them? Hard to understand, harder to explain. To me it feels like there is less to worry about in Phlex where I&#x27;m thinking more in Ruby, less in the specifics of the view context.
    • jherdman23 hours ago
      Have you had much luck with slots? I have a project using View Components that leverages slots. I&#x27;ve tried migrating to Phlex, but the lack of explicit slot support has been a bit frustrating.
      • GenericCanadian21 hours ago
        Slots are pretty easy in Phlex. Have a look at the README in the repo I linked for an idea. I just create `with_column` or `with_header` methods that take a block and store it.<p>To create them declaratively (not needing to call them in a set order) you just create a module that defines `before_template` and calls `vanish`: <a href="https:&#x2F;&#x2F;www.phlex.fun&#x2F;miscellaneous&#x2F;v2-upgrade.html#removed-deferredrender" rel="nofollow">https:&#x2F;&#x2F;www.phlex.fun&#x2F;miscellaneous&#x2F;v2-upgrade.html#removed-...</a>
  • budu1 day ago
    The RubyUI team is doing a fantastic job. This gem is now one of the first ones I add to a new project. Thanks for your work!
  • bdcravens1 day ago
    Looks interesting, but I wish there was a way to alias the component names, since every component class, some of which have common names, take root in the global namespace. (though I suspect that easily enough done manually)
    • joeldrapper23 hours ago
      They’re not in the root namespace. They are instance methods (on the instance of the component) that start with a capital letter. <a href="https:&#x2F;&#x2F;www.phlex.fun&#x2F;components&#x2F;kits.html" rel="nofollow">https:&#x2F;&#x2F;www.phlex.fun&#x2F;components&#x2F;kits.html</a>
    • a-priori1 day ago
      It&#x27;s basically a code generator for adding standard Phlex components to your project, so once you&#x27;ve added a component to your application you can modify it any way you want.
      • damir15 hours ago
        And little by little we get closer to being Lisp-like...
  • anonygler15 hours ago
    I used a rendering library like Phlex back in 2010. I hated it back then and I still don’t like it.<p>They claim it’s faster than ERB but only show micro benchmarks. This is basically a form of lying.<p>This approach stinks for a lot of reasons:<p>- it adds a ton of pressure on the garbage collector. - the backtraces suck to debug. Ruby is better now than in 2010, but it’s still lame. - your templates are largely static. Yet when it lives as code you can’t cache any of it. An efficient ERB generator is just cached strings concatenations. Very efficient in Ruby.<p>Finally, Rubyists hate this and it’s why the community is slowly dying. Almost all your frontend should be in JS&#x2F;JSX at this point. Even the static stuff.
    • joeldrapper5 hours ago
      This is nonsense. You can cache it like anything else. But you probably won’t need to because it’s so fast.
  • drumpkid1 day ago
    I’m impressed by this project’s progress. It’s more than just a render library. Although they claim it’s 12x faster than ERB, but I couldn’t find their benchmark.
    • fidrelity1 day ago
      I believe it&#x27;s referencing this: <a href="https:&#x2F;&#x2F;github.com&#x2F;KonnorRogers&#x2F;view-layer-benchmarks" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;KonnorRogers&#x2F;view-layer-benchmarks</a>
      • byroot1 day ago
        Can&#x27;t believe this still has to be debunked. No Phlex certainly isn&#x27;t 12x faster than ERB. It&#x27;s noticeably slower than ERB, e.g.: <a href="https:&#x2F;&#x2F;github.com&#x2F;KonnorRogers&#x2F;view-layer-benchmarks&#x2F;commit&#x2F;80a3ffd90d5d08b0361a875dfd7d01517476039a" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;KonnorRogers&#x2F;view-layer-benchmarks&#x2F;commit...</a><p>In some extreme scenarios with tons of very small partials, it can win against <i>Action View</i> because the Action View partial lookup is significant overhead.
        • joeldrapper23 hours ago
          In my experience, it’s not an extreme scenario to render several thousand components in a single view.<p>I think you’re looking at this from the perspective of having maybe a partial for your header and another for your footer. The way you build views in Phlex is you would have a component not just for the header but also the nav, each item in the nav, and each icon in each item.<p>We can argue about whether that level of abstraction and reuse is worth it, but the fact is ActionView gets very slow when you build views like that composing thousands of partials — and for people who want to build views like that, it matters.<p>Still, I think these “12× faster” comparisons are silly. If ActionView was just as fast at rendering thousands of small components, I’d still pick Phlex for the developer experience. I enjoy writing Ruby, not toggling between Ruby and HTML.
        • tenderlove23 hours ago
          It says on the website it&#x27;s 12x faster so it must be true!<p><a href="https:&#x2F;&#x2F;rubyui.com" rel="nofollow">https:&#x2F;&#x2F;rubyui.com</a>
          • joeldrapper23 hours ago
            It probably is (or at least was) faster than ActionView if you use lots of small partials, but it is not faster than ERB since it is not compiled. It generates HTML at about 1.6gbps per core on my laptop so probably fast enough for most things.
      • mrinterweb14 hours ago
        There were a few things off about the benchmarks so I made a pull request with some updates. The 12x claim is WAY off. <a href="https:&#x2F;&#x2F;github.com&#x2F;KonnorRogers&#x2F;view-layer-benchmarks&#x2F;pull&#x2F;22" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;KonnorRogers&#x2F;view-layer-benchmarks&#x2F;pull&#x2F;2...</a>
  • daviding1 day ago
    Interesting stuff. Unsure about the Phlex approach but could be worth a go.<p>Didn&#x27;t have any luck with the Date Picker component demo page (no pop up or validation?), and that&#x27;s my usual go-to for seeing how these libraries are doing.
  • alexmccain614 hours ago
    RubyUI looks interesting, but I wonder how well it scales in large apps. Moving away from ERB makes sense for maintainability, but does it introduce any trade-offs in terms of memory usage or debugging? Would love to hear from people using it in production.
  • jspash12 hours ago
    Just curious why the decision was made to go with PascalCase for the DSL? Is this meant to help React devs feel at home? Seems very un-Rubylike.
    • joeldrapper5 hours ago
      It’s because that’s how constants are named in Ruby. The method names match the constant names of the component classes.
      • dragonwriter5 hours ago
        methods aren&#x27;t constants and the normal ruby idiom if there was a reason for method names to correspond to class&#x2F;constant names in a different module would be for the method names to be the constant name converted from PascalCass to snake_case, rather than the method names being in the format of constant names.
  • dzonga1 day ago
    this looks dope. has anyone built anything substantial with phlex ?
    • allknowingfrog7 hours ago
      I haven&#x27;t done anything with RubyUI, but I&#x27;ve been using Phlex for the past couple of months and I never want to go back. It&#x27;s everything I wanted HAML or Slim to be. Everything is code. You create classes and functions instead of views and partials. Everything you know about managing and abstracting code suddenly applies to your UI rendering.<p>Paired with Tailwind, this is the fastest application development I&#x27;ve ever done.
    • joeldrapper23 hours ago
      I believe Clearscope is the largest app using Phlex views exclusively, with 454 components and counting. There’s a list of some other users here. <a href="https:&#x2F;&#x2F;www.phlex.fun&#x2F;project&#x2F;community.html#who-s-using-phlex" rel="nofollow">https:&#x2F;&#x2F;www.phlex.fun&#x2F;project&#x2F;community.html#who-s-using-phl...</a>
    • timwis1 day ago
      Yep! <a href="https:&#x2F;&#x2F;magicnotes.ai" rel="nofollow">https:&#x2F;&#x2F;magicnotes.ai</a> It’s pretty neat once you get over the initial weirdness. Unlocks a lot of potential. But because it’s new, there are fewer conventions, so you have to come up with them and be consistent.
    • aliosm23 hours ago
      I’m using Phlex&#x2F;RubyUI primarily in my project <a href="https:&#x2F;&#x2F;baheth.ieasybooks.com" rel="nofollow">https:&#x2F;&#x2F;baheth.ieasybooks.com</a> and it is amazing in both performance and developer experience.
  • ajmaia8 hours ago
    Our team was already using the pre-release version in the current project, a brand new Rails 8 monolith. Its being very useful!
  • cbeltrao10 hours ago
    Awesome project!
  • desireco421 day ago
    Looks really good and I am happy to see many interesting in Ruby world...
  • justinko18 hours ago
    If I can&#x27;t copy&#x2F;paste HTML, not interested.
    • joeldrapper5 hours ago
      There is an experimental feature that allows you to use ERB templates like ViewComponent. <a href="https:&#x2F;&#x2F;github.com&#x2F;phlex-ruby&#x2F;phlex&#x2F;pull&#x2F;867" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;phlex-ruby&#x2F;phlex&#x2F;pull&#x2F;867</a>
  • luispimenta10 hours ago
    nice
  • ramesh311 day ago
    Really gorgeous components. I cant say I understand who would use this or why... but this is a good thing.
  • the fact that this mentions Tailwind already signifies that its target audience is 10 year olds<p>edit: yeah, after reading more, this is an affront against nature. forget about separation of content and presentation, now you can even throw your backend into the dumpster fire!