TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

In search of the perfect JavaScript framework

195 点作者 jsargiox超过 10 年前

23 条评论

danabramov超过 10 年前
<i>&gt;We want to apply values to variables and get the DOM updated. The popular two-way data binding should not be a feature, but a must-have core functionality.</i><p>Strongly disagree. I find one-way bindings and one-way data flow much easier to reason about. A little less boilerplate code is not worth mental overhead, cascading updates and hunting down the source of wrong data in my experience.<p>What <i>is</i> important is <i>not updating the DOM from the code and instead describing it with a pure function</i>. React, Cycle, Mithril, Mercury do it, and it&#x27;s time we get used to this. <i>This</i> is the real timesaver, not two-way bindings.<p>`Object.observe` is the wrong way to approach this problem. If you own the data, why invent a complex approach to watch it, if you could update it in a centralized fashion in the first place? Here is a great presentation on that topic: <a href="http://markdalgleish.github.io/presentation-a-state-of-change-object-observe/" rel="nofollow">http:&#x2F;&#x2F;markdalgleish.github.io&#x2F;presentation-a-state-of-chang...</a>. I strongly suggest you read it (&quot;Space&quot; to switch slides) if these ideas are still alien to you.<p>Even <i>Angular</i> is abandoning two-way bindings. <a href="http://victorsavkin.com/post/110170125256/change-detection-in-angular-2" rel="nofollow">http:&#x2F;&#x2F;victorsavkin.com&#x2F;post&#x2F;110170125256&#x2F;change-detection-i...</a><p>I, for one, welcome our new immutable overlords.
评论 #9015498 未加载
评论 #9015444 未加载
评论 #9015418 未加载
评论 #9015914 未加载
评论 #9016854 未加载
ef4超过 10 年前
&gt; &quot;Abstraction is dangerous&quot;<p>The fact that Javascript people keep saying this with a straight face is getting really absurd.<p>You <i>do</i> realize Javascript is also just an abstraction, right? And that the browsers that run it also abstractions, and the operating systems, and the kernels, and even the hardware itself has multiple layers of abstraction?<p>&quot;Abstraction is dangerous&quot; is just fundamentally wrong. Abstraction is the only way we get anything done.<p>What you really mean to say is that bad abstractions are bad. But stated so clearly, it becomes obvious that it&#x27;s a tautology. Well-designed abstractions that leak as little as possible are essential to everything we do.<p>This stuff matters, because instead of having stupid arguments over &quot;how much&quot; abstraction we want (which really boils down to 99 layers vs 100 layers) we should be debating <i>exactly what</i> abstractions we want.
评论 #9016328 未加载
评论 #9035558 未加载
评论 #9017693 未加载
评论 #9016759 未加载
carsongross超过 10 年前
My theory is that, for much of the web, the perfect javascript framework is <i>no</i> javascript framework.<p>Get rid of all the abstraction, local state, dependency injection, symbol management and so on. Take HTML&#x2F;HTTP seriously and think about REST in terms of HTML rather than JSON.<p>That&#x27;s intercooler.js:<p><a href="http://intercoolerjs.org" rel="nofollow">http:&#x2F;&#x2F;intercoolerjs.org</a><p>Here&#x27;s an image I tweeted trying to explain how to get there mentally:<p><a href="https://pbs.twimg.com/media/B9QNU-ZCQAECP-K.png:large" rel="nofollow">https:&#x2F;&#x2F;pbs.twimg.com&#x2F;media&#x2F;B9QNU-ZCQAECP-K.png:large</a><p>Yes, it&#x27;s a simple model. And no, it doesn&#x27;t work for every app. But many apps would be infinitely simpler and more usable in a browser by using this approach, and almost <i>all</i> apps have some part of them that would be simpler to implement using it.
评论 #9015334 未加载
评论 #9015344 未加载
评论 #9015290 未加载
评论 #9015457 未加载
评论 #9015303 未加载
评论 #9016654 未加载
评论 #9015273 未加载
评论 #9015354 未加载
评论 #9015366 未加载
drawkbox超过 10 年前
As long as your javascript framework is a micro framework and not a monolithic one, the abstraction does not make the project foggy.<p>Building the core and then using micro frameworks or components like react, jquery, etc leads to less walls as swapping is easier as time progresses.<p>You don&#x27;t want to be caught high and dry stuck in years of monolithic to cleanup when the fad dies and at that point having abstracted away everything you need to know.<p>Outside of javascript, .NET WebForms and Drupal are classic examples of too much abstraction in monolithic fashion (those poor bastards stuck there - dead man walking), Angular might be another. The whole time you spent building addendums and machinations to a framework, not building the core of what needs to be known.<p>If the framework changes everything you do and abstracts core logic or the systems you are building doing things without you being aware, it might be easy to start 90% but there are gonna be problems and eventually walls and walls against you.<p>The only thing that should be monolithic and the base is programming languages and platforms. Everything else should be micro components or messaging.
beat超过 10 年前
It&#x27;s a thought-provoking article, but I would also like to see something about React in it. It seems to me that React is a very pragmatic way to get around the global complexity-driven performance issues with DOM manipulation.<p>When we&#x27;re coding, we&#x27;re optimizing for a couple of different things, really. First is real-world performance (represented by slowpoke DOM manipulation). Second is programmer performance (represented by inappropriate abstractions). A lot of things we can do in Javascript to make programming less difficult and complex result in poor real-world performance, and vice versa.<p>But what do I know? I&#x27;m not by any stretch of the imagination a Javascript expert.
hippich超过 10 年前
I yet to find &quot;perfect&quot; JS framework. I bet, it will never happen.<p>Nevertheless, I have a favor to ask any framework developer out there - please, make it disassemblable and usable piece by piece outside of framework.<p>OP was right - sometimes i find some aspect of framework nice, but more often than not it is monolith part of the whole framework, which as a whole I dislike.<p>ps: current combination it seems to fit my mind workflow is Backbone (models + collections) + Ractive.js (Views) + Machina.js (for routing and defining &quot;controllers&quot;&#x2F;states.) Although I am looking to use something else besides Machina.js in next project, as I want to have hierarchy now. And since it is all loosely coupled, I can replace parts.
tel超过 10 年前
The whole &quot;abstraction is dangerous&quot; spiel is so wrong (imo) that I don&#x27;t even know how to respond to anything that follows.<p>The primary complaint appears to be that abstraction eliminates your ability to operationally trace the meaning of a program. This is true, but sacrificing operational denotations only hurts if you replace it with nothing else—<i>and abstractions of general purpose languages are almost always more interpretable than the operational denotation of the base language itself!</i><p>Of course, there are always places for poor abstractions. I am not talking about these. Abstractions which are intentionally opaque, have confusing action-at-a-distance, etc---you&#x27;re bringing down the name of abstraction in general. &quot;Leaky&quot; is insufficiently demeaning.<p>A good abstraction will have its own semantics. These can be equational, denotational, operational, what-have-you but, essentially, these semantics must be easier&#x2F;simpler&#x2F;more relevant than the semantics of the base language they&#x27;re embedded in. Otherwise why abstract?<p>So what does React give you? It gives you, more or less, a value-based compositional semantics. Components have some &quot;living&quot; nature (an operational semantics w.r.t. to state) but they&#x27;re mostly defined by their static nature. Because you can build whole applications thinking only about the static, compositional nature of components you can take massive advantage of this abstraction.<p>Ultimately, <i>you do not want</i> operational semantics for React. This is what gives us React Native, background rendering, and probably what will lead to sensible animations (in time). To define operational semantics, especially ones which have to look like or (worse) be identical to those of Javascript, would destroy almost all possibility of extension. At the cost of making things more complex and harder to reason about.<p>All so that you can just stick to &quot;obvious&quot; Javascript base operations.
djabatt超过 10 年前
Where does react.js fall in this discussion? Or does it? Just reading a lot about react.js this week.
wwweston超过 10 年前
&gt; Abstraction is dangerous<p>True statement. Of course, it&#x27;s <i>more or less</i> true, depending on how much the abstraction you&#x27;re using leaks. Few (if any) abstractions completely encapsulate complexity, almost all will leak. But there&#x27;s a range. Some abstractions elegantly cover a modular portion of your problem space and do it so well you only rarely have to think about what&#x27;s going on under the hood (and will even produce effective clues as to what&#x27;s going wrong when something does go wrong). Some abstractions awkwardly cover only part of a modular portion of your problem space, require a high intellectual down payment to even start to use, have gotcha cases that chew up performance or even break things, and require continual attention to what&#x27;s going on just to keep development going.<p>Most are probably in between.<p>I think this is what JWZ is talking about in his famous &quot;now you have two problems&quot; assessment of regular expressions. I don&#x27;t read him as saying &quot;regular expressions suck,&quot; I read him as saying anything but tools from the high end of the abstraction quality spectrum means now you have two problems: (1) the problem you started with (2) the problem of keeping the model&#x2F;details of how the tool works in your head. Regular expressions are arguably in the (maybe high) middle of the spectrum -- they may not cover your case well (ahem, markup) and they can send your program&#x27;s performance to hell or even halt it if you don&#x27;t know what you&#x27;re doing.<p>Now, they&#x27;re also broadly useful enough in all kinds of development that the benefits go up with the costs and so they&#x27;re probably worth investing in anyway, as part of a suite of other parsing tools&#x2F;techniques. So I&#x27;m not bringing the topic up to bash them.<p>But to take us back to the topic, I might be bringing it up to question the ROI of popular JS frameworks, which, as far as I can tell, are generally not at the the high end of the abstraction quality spectrum, don&#x27;t have the broad usefulness of regular expressions to recommend them, and may not even survive longer than a handful of years.
评论 #9016195 未加载
iEchoic超过 10 年前
The Knockout example in this article is a bit strange - Knockout is not a framework (it is explicit about this) - but besides that, Knockout components actually do allow the &quot;framework&quot; to decide when things are instantiated.
akrymski超过 10 年前
One super simple framework is <a href="https://github.com/techlayer/espresso.js/" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;techlayer&#x2F;espresso.js&#x2F;</a><p>It&#x27;s a bastard child of React and Backbone.
thekingshorses超过 10 年前
I like the direction author is going. I have used similar methodology designing my applications (for mobile), simple, micro libraries, one way data binding.<p><a href="http://hn.premii.com/" rel="nofollow">http:&#x2F;&#x2F;hn.premii.com&#x2F;</a><p><a href="http://reddit.premii.com/" rel="nofollow">http:&#x2F;&#x2F;reddit.premii.com&#x2F;</a><p>* I have bunch of helper functions (UI and non-UI). Each function define in its own file and independent (easy to unit test). Personal library like jQuery but not a jQuery replacement.<p>* App is route based. One route to many controllers. Each controller is a page&#x2F;screen on mobile.<p>* There is only one model (API) that interface with 3rd party library. API layer talks to 3rd party library to get data or gets data from server directly, caches data, etc. Provides sync (Cached data) and async (Cached data or fresh from server) interface to controllers.<p>* There is a app class or I call it a page manager. Responsible for managing pages like ordering, loading, unloading etc (Kind of big and complex 200+ lines of logic).<p>- Decides which page to animate in which direction on mobile (Loading new page or going back).<p>- Order of pages (Back button)<p>- Passes events to its controllers<p>- Decides which pages to keep in DOM, and which to remove.<p>--- If you go from homepage to comments to profile page, all pages are in DOM.<p>--- When you go back to comments page from profile page, profile page will be destroyed and controller will be notified. Same happens when you go from comments to home page.<p>--- If you go to same comments page again, it will be loaded as a new page.<p>* Controller:<p>- Each controller may have multiple CSS and templates<p>- Controller uses its template to render<p>- Using sync API to get data to renders page.<p>- If sync API returns no data, renders empty page with loading, and makes async API call.<p>- Controller are idle when transitioning (animating) from one page to another on mobile. (Very important for smooth animation)<p>- Simple but fat controllers<p>- Controller handles events, UI logic<p>- Self cleaning so that browser can collect garbage when necessary<p>I package app using node&#x2F;gulp. Anything that is not specific to page&#x2F;app related, it becomes part of a helper library. Each app has its own model (Data layer), and controllers. I use micro templates, precompile using node for faster performance.
评论 #9018111 未加载
评论 #9015880 未加载
itsbits超过 10 年前
I don&#x27;t agree with DOM event handling: setting events at every node comes with a cost. And I think you forgot to mention the performance issues with that approach and so now a days almost all frameworks prefer to event delegation.<p>I think author except in 1,2 points didn&#x27;t bother to take side with performance aspects.
RehnoLindeque超过 10 年前
&gt; We all like simple tools. Complexity kills. It makes our work difficult and gives us much steeper learning curve. Programmers need to know how things work. Otherwise, they feel insecure. If we work with a complex system, then we have a big gap between “I am using it” and “I know how it works”.<p>One answer to this problem of opaqueness in abstractions is having a well defined denotational semantics. This makes it clear that something can work in one way &amp; only one way (without the need to dive into library internals). I feel that Elm is doing a pretty good job of tackling this for GUIs and signals.
fiatjaf超过 10 年前
I don&#x27;t think people use frameworks and abstractions because they have a smoothier learning curve, or because they are simpler, but because of DRY. After repeating the same pattern twice, the programmer turns it into a module and abstracts it. After having a lot of modules, the programmer packages them all in a framework. This is good for the author of those modules and the framework, because he understand them, but not always for the outsider who just looks at the complete framework and don&#x27;t know what&#x27;s inside.
mark_l_watson超过 10 年前
A difficult article to write - I would not have tried. There are so many good alternatives and choice depends on the application and available skill sets.<p>I spent time today working in Clojurescript which wraps the Closure library. In the last month I have used Ember.js, Clojure with hiccup, and meteor.js. I really like all of these tools and frameworks. I used to use GWT a lot, and almost committed to Dart. So many good choices.
acdlite超过 10 年前
Bad abstractions are dangerous. Good abstractions are empowering.<p><i>cough</i> React Native <i>cough</i>
mathgeek超过 10 年前
I was slightly disappointed that this didn&#x27;t point to a 404.
closetnerd超过 10 年前
This article reminds me quite a bit about Vuejs. Its got an interface similar to Backbone but with the addition of two way data binding while also allowing you to define web components style tags, attributes.
mperret超过 10 年前
I like the structure of google closure, thoughts?
jcoffland超过 10 年前
Vue.js meets most if not all the criteria outlined in this article. I&#x27;ve been have great luck with vue.js after a nightmare of fighting with writing a big SPA in Angular.
jbeja超过 10 年前
The perfect JS framework won&#x27;t exist until 2079.
rhapsodyv超过 10 年前
I LOVE ExtJS!