What would the ideal web framework look like?
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.
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)
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.
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.
Take a look at RiotJS. Now at version 6. It's compiled and has been around considerably longer than Svelte
RiotJS seems nice, I'll try it out. Thanks!
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.
Consider this component:
<script>
let name = 'world';
</script>
<main>
<h1>Hello {name}!</h1>
</main>
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>
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!
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
Exactly
But as you said, this would be impossible. We would have to literally relearn web development.
Not only re-learn it, but re-build it and re-implement it everywhere
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.
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).
CollapseExpand
you could try imba.io
not quite a framework but it looks interesting
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK