TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Frameworkless JavaScript

278 pointsby pauljonasover 11 years ago

48 comments

cdataover 11 years ago
As a JavaScript developer who spent much of his early career writing framework-less JavaScript (as many of us did in the not too distant past), the sentiment behind this post really rings true to the way I feel about programming for a client like the browser. Modern frameworks are all young and imperfect in their own ways, every byte counts and JavaScript is certainly powerful and expressive enough to get you by without a framework.<p>On the other hand, now that I have had the experience of leading teams of JavaScript developers, I know first hand the value of building a project on top of a common base that is readily familiar, well documented and easy to pick up by outsiders. The reality I have experienced is this: as your project and team grow, not everyone you work with will hit the ground with the architectural ambition to contribute to or absorb a new paradigm. Many developers will come to the table with useful domain experience related to a specific framework, or a desire to learn a tool that will be useful to them in a future job.<p>Asking developers to learn your company&#x27;s proprietary paradigm is asking them to invest time and effort developing a skill that they often can&#x27;t even use in a side project if they wanted to; putting aside questions of commoditization of the profession, I think that this can be a potential enthusiasm killer for your team mates.<p>The ability to think beyond the framework and self-solve problems with code is a great skill to engender in a team. That said, the pursuit of that skill often must be balanced with the business need of crafting a product.
评论 #7032294 未加载
评论 #7031463 未加载
评论 #7031921 未加载
评论 #7033482 未加载
评论 #7033625 未加载
peterhuntover 11 years ago
These types of posts are popping up more and more these days. I like to call them &quot;JavaScript luddite&quot; posts: posts that worship single-digit kb apps with zero dependencies as universally good ideas.<p>This type of thinking is going to hold back frontend web development as a whole unless we address it. Disclaimer: I am on the React team.<p>&quot;API first&quot; -- just layer your API on top of whatever you&#x27;re using to implement it. Abstraction is an important part of what we do as SW engineers. This post describes a particularly leaky abstraction, which is easily fixed.<p>&quot;Small size&quot; -- cry me a river. Yes, byte size is important but it&#x27;s not more important than code reuse and all the benefits that come with it (security, dev speed, support etc). By the way, the Retina image on the blog post was 46kb over the wire which is bigger than all the JS in his app. The lesson to be learned here is that if add a single image you&#x27;ve pretty much blown away any JS savings you would have had.<p>Another thing: usually multiple server round-trips matter more than bytes down the wire.<p>&quot;Full control&quot; -- this is a legit reason. Some of the bullet points are indicative of the state of client-side JS tooling though which are fixable.<p>&quot;Special needs&quot; -- moot&#x27;s engineering challenges were not unique, they just didn&#x27;t like the trendy frameworks. This is totally OK, but not a good reason to tell everyone that code reuse is bad.<p>&quot;Technology lock-in&quot; -- somewhat of a legit reason, but more of a commentary on monolithic architectures than anything else.
评论 #7034154 未加载
评论 #7032884 未加载
评论 #7032477 未加载
评论 #7036359 未加载
评论 #7032571 未加载
评论 #7035471 未加载
评论 #7035904 未加载
mjacksonover 11 years ago
The very next post on this blog is all about ... drum roll ... a custom <i>framework</i> that the moot team built, after deciding to not use any frameworks.<p><a href="https://moot.it/blog/technology/riotjs-the-1kb-mvp-framework.html" rel="nofollow">https:&#x2F;&#x2F;moot.it&#x2F;blog&#x2F;technology&#x2F;riotjs-the-1kb-mvp-framework...</a><p>Sadly, this behavior is very common among those who have a hard time adopting existing libraries&#x2F;frameworks. In the end, they almost always re-invent their own obscure wheel that does the same job.
评论 #7032855 未加载
评论 #7032544 未加载
评论 #7033260 未加载
评论 #7033985 未加载
评论 #7032741 未加载
mietekover 11 years ago
I&#x27;ve just gone through a similar process of reviewing and discarding a number of JavaScript frameworks. I&#x27;ve settled on React, and I can&#x27;t recommend it enough!<p>React handles mostly the V in MVC, and does an admirable job of it. It even provides a cross-platform event abstraction, which would&#x27;ve saved the author some trouble.<p><a href="http://facebook.github.io/react/" rel="nofollow">http:&#x2F;&#x2F;facebook.github.io&#x2F;react&#x2F;</a><p><a href="http://facebook.github.io/react/blog/2013/06/05/why-react.html" rel="nofollow">http:&#x2F;&#x2F;facebook.github.io&#x2F;react&#x2F;blog&#x2F;2013&#x2F;06&#x2F;05&#x2F;why-react.ht...</a><p><a href="http://facebook.github.io/react/blog/2013/11/05/thinking-in-react.html" rel="nofollow">http:&#x2F;&#x2F;facebook.github.io&#x2F;react&#x2F;blog&#x2F;2013&#x2F;11&#x2F;05&#x2F;thinking-in-...</a><p>Now, how about CSS? So far, I&#x27;ve reluctantly chosen Bourbon + Neat + Bitters, which are nice, but not ideal. I appreciate the Sass and semanticism (semanticness, semanticitivity) of it all — no more Bootstrap-like class names in my HTML! However, there aren&#x27;t enough examples of real pages built with these tools.<p>Thoughtbot, if you&#x27;re listening, why not publish at least the Sass sources of these webpages?<p><a href="http://bourbon.io" rel="nofollow">http:&#x2F;&#x2F;bourbon.io</a><p><a href="http://neat.bourbon.io" rel="nofollow">http:&#x2F;&#x2F;neat.bourbon.io</a><p><a href="http://bitters.bourbon.io" rel="nofollow">http:&#x2F;&#x2F;bitters.bourbon.io</a>
评论 #7031136 未加载
评论 #7031648 未加载
评论 #7031152 未加载
评论 #7031060 未加载
评论 #7031457 未加载
评论 #7031493 未加载
评论 #7031100 未加载
评论 #7031319 未加载
syncover 11 years ago
Not using a JS Framework? Congratulations, you&#x27;ve just built your own ad hoc JS Framework.<p>Suddenly, anyone who joins moot will have to invest tons of effort in your custom framework instead of being able to hit the ground running.
评论 #7031217 未加载
评论 #7031399 未加载
评论 #7030955 未加载
评论 #7031634 未加载
评论 #7031261 未加载
评论 #7031368 未加载
评论 #7030989 未加载
评论 #7032527 未加载
评论 #7032466 未加载
Arnorover 11 years ago
I&#x27;ve used Backbone for a couple projects. Then I used Angular because I liked the two way binding and easy access to history. Still, I generally find that these frameworks get in the way for most of my projects. I tend to use the following structure:<p><pre><code> (function () { &#x27;use strict&#x27; var n; $(document).ready(function () { &#x2F;&#x2F; Event listeners here $(&#x27;#some-id&#x27;).on(&#x27;click&#x27;, n.Product.respond_to_some_click); } &#x2F;&#x2F; Sometimes I omit the n variable and just pollute the global namespace because I&#x27;m BA like that. n = { Product: { respond_to_some_click: function() { &#x2F;&#x2F; Do some stuff } }, Cart: { }, Whatever: { } } }()); </code></pre> This structure keeps things pretty well organized without a real need for a framework. So far this has been a really comfortable alternative to a heavy framework. I can&#x27;t wait to get it ripped to shreds and see how I can improve :)
评论 #7031518 未加载
评论 #7034834 未加载
评论 #7031444 未加载
onion2kover 11 years ago
Suggesting that frameworks are too complicated because they &quot;add tens of redundant methods, adding complexity for the end user&quot; is ridiculous. The number of methods in something doesn&#x27;t always add to the complexity - in a lot of cases a framework vastly reduces the difficulty of using something by abstracting away the hard stuff so the user doesn&#x27;t need to worry about it. <i>That&#x27;s pretty much the point of a framework.</i> Further though, using an established framework improves things through the &quot;many eyes&quot; principle - if tens of thousands of people have used a piece of code, chances are it&#x27;s going to be pretty damn bulletproof and it&#x27;ll have a swathe of documentation backing it up (as official docs, blog posts, StackOverflow questions, etc). No startup can even dream of competing with that.<p>Specifically in the case of moot.it, perhaps as a thing that&#x27;s dropped into a website to provide a discussion forum having tight code is a bonus, but if you&#x27;re writing something for other people to extend then using a well known framework as a starting point is a very, <i>very</i> obvious choice.
评论 #7031015 未加载
评论 #7033449 未加载
akamakaover 11 years ago
Amen, I agree 100% with this blog post.<p>I work on a popular web application that&#x27;s built on AngularJS, and these are the exact same conclusions that I&#x27;ve come to.<p>* Code size is a huge issue for us. When something goes wrong, it&#x27;s terrible to have to dig deep into mountains of code.<p>* I haven&#x27;t yet interviewed a developer who truly has a deep knowledge of AngularJS out of the box. There are lots of people who have shipped little projects with it, but at the end of the day, we hire smart guys and train them. Framework knowledge doesn&#x27;t really matter.<p>* I might be &quot;hubris&quot; to write your own framework for a small throwaway client project, but when you are heavily invested in your own product, every option is on the table. We borrowed time at the beginning by using Angular, and we are slowly paying it back, one frustrating problem at a time.
jbrooksukover 11 years ago
This has been discussed before. <a href="https://news.ycombinator.com/item?id=6653024" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=6653024</a><p>A massive discussion between Backbone.js developer and the developer of Riot.js kicked off. It&#x27;s an interesting read that&#x27;s for sure.<p>You can find the library here <a href="https://github.com/moot/riotjs" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;moot&#x2F;riotjs</a>
评论 #7030959 未加载
binarymaxover 11 years ago
It is refreshing to see this post. As someone who has tried, and not really taken to, all three of those frameworks I sympathize.<p>Stick with what works for you. Shipping code on your own terms is the end goal. The customer viewing the page does not care one iota what framework you are using.
评论 #7030924 未加载
sheetjsover 11 years ago
While I agree with the salient point in the article, I disagree with the emphasis on the size of the script. If using a framework reduces headaches and saves developer time, it will be significantly less expensive to use the framework than to roll and host your own solution. ALSO, there exist cheap&#x2F;free CDNs that host many of these libraries:<p>backbone -- <a href="http://cdnjs.com/libraries/backbone.js/" rel="nofollow">http:&#x2F;&#x2F;cdnjs.com&#x2F;libraries&#x2F;backbone.js&#x2F;</a><p>rainbow -- <a href="http://cdnjs.com/libraries/rainbow/" rel="nofollow">http:&#x2F;&#x2F;cdnjs.com&#x2F;libraries&#x2F;rainbow&#x2F;</a><p>socket.io -- <a href="http://cdnjs.com/libraries/socket.io/" rel="nofollow">http:&#x2F;&#x2F;cdnjs.com&#x2F;libraries&#x2F;socket.io&#x2F;</a>
评论 #7031232 未加载
评论 #7031270 未加载
评论 #7031246 未加载
crabasaover 11 years ago
Unfortunately, the title is misleading. It should be titled &quot;Angular, Ember and Backbone are too heavyweight so I created riot.js&quot;.
js4allover 11 years ago
You are going a dangerous way. As long as your team and code base are small, a self-cocked solution has its advantages. But when you use one of the frameworks, your app gets a structure that other developers can easily understand, because they know the concept. They easily find points where to debug and where to breakpoint.<p>Using a proprietary framework has none of these advantages. Every new developer needs more time to find his way into the code and that time multiplies as your team grows. Just think about this before starting a new project.
评论 #7031442 未加载
nkuttlerover 11 years ago
How disappointing, the article is called &quot;Frameworkless JavaScript&quot;, but the author uses jQuery for the application. Yeah, I get it, jQuery a library...<p>File size seems like the biggest concern, but really, how important is that on a dynamic page that needs to load exactly once? And using a CDN it might already be cached anyway.<p>That being said, I also like clean, minimal JS code.
评论 #7031028 未加载
jon_kupermanover 11 years ago
Really interesting post for sure.<p>I&#x27;m not really seeing the size advantage here. All of the mentioned frameworks are cached on popular CDN&#x27;s and I just don&#x27;t think you&#x27;re really getting much of a win out of creating your own, smaller files.<p>Also, I&#x27;m always wary of companies that want to re-invent the wheel as opposed to using open-sourced, well-documented projects. If I start at your company and you use Backbone, not only is there a good chance I can come in with a good understanding of your code -- but I can easily check on Google for any questions I have. If I start at a company that has built their own, closed-source, custom JS framework -- I&#x27;ll have to ask internally every time I have trouble figuring something out.<p>It may be necessary for your product, but to me it always raises a flag when people create their own proprietary version of something that already has been done.<p>Anyway, a great read for sure!
评论 #7031193 未加载
评论 #7034418 未加载
warfangleover 11 years ago
&gt;Why not Angular?<p>The author points out that they just want two-way databinding, and don&#x27;t want the entire overhead of Angular. Most of the Angular overhead is directives that you probably would use &#x2F;anyways&#x2F;, and are actually just written in Angular.<p>Ostensibly, you could fork Angular, take out all the custom directives, and end up with a much smaller starting codebase.<p>But then you&#x27;d end up re-implementing a lot of the default Angular directives (like ng-loop), and likely have a buggier application for it.
fogusover 11 years ago
This sounds like every project that I&#x27;ve ever been on. My co-workers could have written a series of these types of posts:<p>* MVCless GWT<p>* Makeless Builds<p>* Eclipseless Java IDEs<p>* Hibernateless ORMs<p>* Freemarkerless Templating<p>I&#x27;ve seen this story many many times. I&#x27;ll give you one guess as to how many of these *less solutions were worth the effort put into them.
评论 #7034511 未加载
splatcollisionover 11 years ago
Great post, needs to be said sometimes that custom code is always going to be smaller and do just enough.<p>I&#x27;m also working on a real-time socket.io app and find that I can keep most of the data model logic on the server, and the front-end is focused on user interactions &amp; rendering data. I do use Backbone but only the Views, but the overall architecture of the front end is clean, simple, and minimal.
评论 #7031325 未加载
dougk16over 11 years ago
What&#x27;s interesting to note, for all those disparaging this approach, is that this is how all those other JS frameworks came into being in the first place...developer isn&#x27;t satisfied with what&#x27;s out there, rolls their own stuff, and lo and behold it can be generalized to other applications.<p>I wouldn&#x27;t be surprised to see a Moot framework in the next year or so!
评论 #7031957 未加载
gedrapover 11 years ago
&gt;&gt; First, it&#x27;s about the same size as Moot as a whole (91kb)<p>I am feeling a bit of a fool to ask that but... what&#x27;s the obsession with the code size when it comes to client side JS?<p>Bandwidth? Well, unless you are running at Google&#x27;s scale, some extra bandwith is much cheaper than the time spent on writing your own solutions to well known and solved problems (and some of the problems you were not aware of yet).<p>Performance, since more code - more stuff to execute - will take longer? It&#x27;s good to have performance in mind and maybe benchmarks will tell you that it&#x27;s X times faster but what will it be once translated to seconds?
评论 #7032334 未加载
评论 #7032458 未加载
评论 #7031900 未加载
评论 #7031728 未加载
programminggeekover 11 years ago
Every app has its own framework&#x2F;DSL.<p>What a &quot;framework&quot; that isn&#x27;t your app gives you is the ability to have a common language to describe and build your app&#x27;s framework&#x2F;DSL.<p>The larger the team, the more important a framework becomes. The smaller the team, the easier it is to have &quot;less framework&quot; that you aren&#x27;t totally defining yourself.<p>That said, the real benefit in most frameworks is the solved problems. They might not solve them in the most optimal way, but is reinventing the wheel adding the most value in most cases? Nah, probably not.<p>Then again, sometimes reinventing the wheel is fun.
puppetmaster3over 11 years ago
By no framework, I think don&#x27;t use an MVC framework, it does not add value. (I wrote a book on MVC framework). Great is the enemy of good, they are bad for you.<p>There are non MVC frameworks that focus on UI&#x2F;DOM&#x2F;CSS. I based this on Enity&#x2F;System more w&#x2F; events management, I call it module buss. Don&#x27;t have time to evagelise it ( <a href="http://github.com/puppetMaster3/ModuleBU" rel="nofollow">http:&#x2F;&#x2F;github.com&#x2F;puppetMaster3&#x2F;ModuleBU</a> ) Don&#x27;t use MVC, code is just all over place, there are other patterns. I know this is shocking.
moron4hireover 11 years ago
Love HN. &quot;I, not knowing your exact requirements and constraints, know better than you what is best for your project. You are a fool for having defied us. At last, my intellectual superiority is proven.&quot;
nawitusover 11 years ago
This article criticizes the time spent learning a new framework. However, it doesn&#x27;t seem to note that creating a new bulletproof JavaScript framework will likely take a lot of more time.
oesmithover 11 years ago
I wonder why Google&#x27;s Closure Compiler hasn&#x27;t taken off more in the open-source world. At the cost of some mandatory comments to help the compiler, it&#x27;s able to analyze and remove unused library code from your application.
owenversteegover 11 years ago
It seems that a large motivation to not use JS frameworks is their large size. Of course, the same can be said for CSS - the frameworks are quite large. Unfortunately, since most developers don&#x27;t interact with CSS as much, people typically ignore the fact that Bootstrap and Foundation are 130kb and 150kb respectively - at the same time they complain about a 24kb JS library&#x27;s size.<p>This inspired me to create Min, a 995 byte CSS framework: <a href="http://minfwk.com" rel="nofollow">http:&#x2F;&#x2F;minfwk.com</a>
WalterSearover 11 years ago
<p><pre><code> if(frameworkLess == MadeYourOwnFramework){ this.author = aHipster } </code></pre> On second thoughts, the message seems more like &quot;Go frameworkless, with our new framework.&quot;
评论 #7033813 未加载
kinofcainover 11 years ago
How on earth is using JQuery considered &quot;frameworkless&quot;?
评论 #7034621 未加载
spikelsover 11 years ago
The authors of the recent book &quot;Single Page Web Applications&quot;, Mike Mikowski and Josh Powell, took a similar approach - avoiding frameworks and using jQuery and just a few JavaScript libraries. Mike gave good talks on their philosophy at a couple of the HTML5 Dev Confs (available on YouTube). Made a lot of sense to me.
jherikoover 11 years ago
&gt; Goals for a web application should not be in imperative DOM manipulation, object oriented practices, or in &quot;pure&quot; MVC. A successful application aims to be simple, and there is no room for academic jargon.<p>I highlight this particular pair of sentences because I believe it is very important... I&#x27;ve had too many discussions over why code is &#x27;bad&#x27; when what people mean is &quot;doesn&#x27;t precisely fit this particular idea of how to implement a particular paradigm&quot;. What they really mean is that they have a philosophical objection.<p>This effect has even poisoned programming languages... look at static class in C# - really thats a hack around having omitted free standing variables and functions with no associated object - something completely against the spirit of OO but ultimately necessary, practical and &#x2F;better&#x2F; than shoehorning it into an object (singleton).
asattarmdover 11 years ago
tl;dr They are realtime. They don&#x27;t want full blown Rest frameworks for just reactive views. So, no AngularJS or EmberJS.<p>What about Knockout.js? It&#x27;s just 16kb.
评论 #7034633 未加载
terabytestover 11 years ago
Unless I&#x27;m blind, this post contains everything except usage examples or source code for your framework. I&#x27;d be interested in seeing it for myself, not only in hearing how cool it is.
评论 #7031012 未加载
fiatjafover 11 years ago
Framewoks shouldn&#x27;t do everything for you, they should provide you the bases for separation of code, and them you should implement anything you want on the top of it. Angular and Ember force you to do their way -- and charge a byte price for it.<p>That&#x27;s why a simple thing like <a href="http://aurajs.com/" rel="nofollow">http:&#x2F;&#x2F;aurajs.com&#x2F;</a> is so good and beautiful.
bphoganover 11 years ago
Seems to me that the smartest thing to do is write your application independent of any framework. That way you insulate your stuff from the framework and it doesn&#x27;t become the app.<p>That&#x27;s sort of the big lesson I&#x27;ve learned over the years working with Rails, where too many projects become &quot;Rails apps&quot; rather than apps that use by Rails.
jsnkover 11 years ago
What a joke! He complains about frameworks being too bulky but unquestionably uses jQuery without questioning it the same way.
Aardwolfover 11 years ago
As nice as the frameworkless javascript of that website may be, I had to turn off javascript to properly read the content of that website, because otherwise it made the page title flash in a distracting way to say &quot;Someone is writing...&quot;.
deevusover 11 years ago
When I&#x27;m working on a deadline it&#x27;s super easy to just grab x, y &amp; z framework and use the bits I need from each. And in the end, I&#x27;ve added what... 150kb of scripts?<p>Unless I&#x27;m targeting users with bad connections, what&#x27;s the problem?
评论 #7035951 未加载
CmonDevover 11 years ago
Doesn&#x27;t matter which kind of icing you put on a bad cake, but it can make it look a bit better. Does author suggest we just eat a very small bad cake with no icing on top? Also POJO historically stands for &quot;Plain Old Java Object&quot;.
pkaover 11 years ago
So you&#x27;re mixing view logic (rendering DOM elements, listening to events) with controller logic, and from my experience this is exactly the type of stuff that leads to an unmaintainable mess when your codebase grows.<p>For one, you can&#x27;t test your controllers unless you mock the DOM (and nobody is ever gonna waste time doing that). And what happens when you decide to create a mobile version of your app with a new set of touch optimized views? Duplicate all controllers? Then you decide to split a view into two or more independent views. Rewrite that controller logic again. And so on...<p>This is <i>exactly</i> what MVC frameworks try to help you with, and with good reason. And I&#x27;m not even talking about the dozens of other well-tested and carefully designed features you&#x27;ll probably end up duplicating. Taking everything into consideration, I really don&#x27;t think smaller file sizes justify all that.
yeukhonover 11 years ago
So when OP says none of the popular framework works for him, he doesn&#x27;t want to be locked in with another framework, he created his own MVC framework Motto. That sounds contradicting. You now locked into your own framework.
ulisesrmzrocheover 11 years ago
On the other hand, if you&#x27;re on a budget and don&#x27;t have the money to implement your own solution to single-page web apps, you&#x27;ve gotta make some compromises.<p>And that&#x27;s where a framework comes in.
评论 #7034348 未加载
tipiiraiover 11 years ago
New document: &quot;Building modular applications with Riot.js&quot;<p><a href="https://news.ycombinator.com/item?id=7036274" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=7036274</a>
etanazirover 11 years ago
Reasonable argument for preferring small optional packages v. shipping the kitchen sink with a big package. But hubris to roll your own everything.
dikeiover 11 years ago
I don&#x27;t have time to write my own framework and teach my team to use it, so I use Backbone and tell them to google it :)
akbar501over 11 years ago
Backbone + Marionette (<a href="http://marionettejs.com" rel="nofollow">http:&#x2F;&#x2F;marionettejs.com</a>) reduces the amount of boilerplate.
mcmireover 11 years ago
Is this the same guy who wrote head.js?
mrcwinnover 11 years ago
No.
andylover 11 years ago
I&#x27;ve built apps with Backbone, Marionette, Angular, and React. All very interesting and innovative. But for me none of them beats the productivity of a &#x27;component&#x27; system built from simple jQuery plugins.