1

What would the ideal web framework look like?

 2 years ago
source link: https://dev.to/siddharthshyniben/what-would-the-ideal-web-framework-look-like-p5m
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Cover image for What would the ideal web framework look like?

What would the ideal web framework look like?

Aug 26

・1 min read

It seems like every week there is another ground-breaking new web framework. Some of them are interpreted, some compiled. Some of them are based on HTML tags, some component driven, and so on.

So, what would the "ideal" framework look like, maybe using ideas of existing frameworks? Of course, no framework is perfect for use everywhere, but what would come close?

Discussion (13)

pic

CollapseExpand

I'll start

My "ideal" framework would be a framework which is compiled: it would have components in a file with script and style tags (like Vue/Svelte). As usual, components can be imported, other JavaScript/CSS can be imported, and styles and scripts are scoped, etc. and the compiled output will be HTML (Yes, actual HTML, not just a boilerplate), CSS and JavaScript. AFAIK there is no framework like this, and the closest is Svelte, but Svelte doesn't generate HTML.

Comment button Reply

CollapseExpand

Svelte is able to generate HTML. It is called server-side rendering in Svelte and it's possible to do it in the build step.

I have done it for an old version of my work-in-progress website framework. Since then I've switched framework, because Svelte didn't meet my requirements recarding actually the same feature.

I've tried to make my own JavaScript framework like Svelte / Vue with the features I need, but I didn't really succeed. Maybe I'll try again some time.

Comment button Reply

CollapseExpand

Take a look at RiotJS. Now at version 6. It's compiled and has been around considerably longer than Svelte

Comment button Reply

CollapseExpand

Author

Aug 26

RiotJS seems nice, I'll try it out. Thanks!

Comment button Reply

CollapseExpand

and the compiled output will be HTML (Yes, actual HTML, not just a boilerplate)

Can you clarify what you mean by this? I'm not sure I understand it.

Comment button Reply

CollapseExpand

Author

Aug 26

Consider this component:

<script>
    let name = 'world';
</script>

<main>
    <h1>Hello {name}!</h1>
</main>

Enter fullscreen modeExit fullscreen mode

If you run this through Svelte, you get this HTML as output:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset='utf-8'>
    <meta name='viewport' content='width=device-width,initial-scale=1'>

    <title>Svelte app</title>

    <link rel='icon' type='image/png' href='/favicon.png'>
    <link rel='stylesheet' href='/global.css'>
    <link rel='stylesheet' href='/build/bundle.css'>

    <script defer src='/build/bundle.js'></script>
</head>

<body>
</body>
</html>
Enter fullscreen modeExit fullscreen mode

It's basically a boilerplate. In my "ideal" framework, the h1 element would be there in the HTML (maybe statically embedded, if the framework is really good). This could speed up a little bit

Thread

Thread

I see what you mean now - Something that outputs closer to Static Site Generators without being fully static 😊 That would be amazing!

Comment button Reply

CollapseExpand

This might be controversial, but:

My ideal framework would be the lack of one. For me the web itself should change to support modern apps, and remove the need for any frameworks. As the web was never intended for most of the use we're giving it today.

What I mean is, that the technology/language should already provide what you need to build modern apps without needing a framework on top of it.

Needless to say that this is almost imposible, the web can't change as drastically. So we will need too keep with good old js+html+css+framework+libraries.

What would it look like or how would it work? I have no clue

Comment button Reply

CollapseExpand

Author

Aug 26

Exactly

But as you said, this would be impossible. We would have to literally relearn web development.

Comment button Reply

CollapseExpand

Not only re-learn it, but re-build it and re-implement it everywhere

Comment button Reply

CollapseExpand

It depends on what you're building (obv). For me its Rails 6 + Turbo + Stimulus + ViewComponent (from GitHub).

I get to leverage all the meta-programming superpowers of ruby and solve a lot of view complexity on the backend. The front end becomes a lot more fun, because I don't have to worry about html generation in the browser.

In many cases clever use of Turbo & Stimulus will outperform purely JS based frameworks, because the html does not need to be constructed by the browser.

Comment button Reply

CollapseExpand

Maybe the best for me would be single-file component based (like Vue.js) framework with asynchronous rendering (like Crank.js), full build-time rendering (SSR) with partial hydration (like Elder.js) and support to seamlessly integrate with server (like Inertia.js).

Comment button Reply

CollapseExpand

you could try imba.io

not quite a framework but it looks interesting

Comment button Reply


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK