Hacker News new | past | comments | ask | show | jobs | submit login
Frameworkless JavaScript (moot.it)
278 points by pauljonas on Jan 9, 2014 | hide | past | favorite | 188 comments



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.

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.

Asking developers to learn your company's proprietary paradigm is asking them to invest time and effort developing a skill that they often can'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.

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.


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.

Yes, but choose wisely. :)

Back in the late '90s I worked for a company that had their own home-grown Java Web application framework. It was conceptually clean, ran fast, and was fun to work with. URLs mapped to classes and methods; example.com/foo/bar basically located and loaded the Foo class and invoked the bar method. Domains were used to select "skins": XSLT files transformed the output. Internally it was URLs and XML all-around, making it easy to grab and verify data.

(I realize that describing an application framework using the words "Java", "XML", and "XSLT" might cause some to flinch. Believe it or not this was a really, really sweet tool. I was lucky to work with some very smart people who wrote very good code. We took some liberties with how XML was handled for some interesting parsing advantages. Not a fan of XSLT, but I learned some useful coding techniques.)

Teaching this to bright and motivated developers was not hard. It ran on relatively low-powered commodity hardware and customers loved it. Everyone was happy.

Then the company was acquired, and the new bosses decided that they didn't want to have to train new devs on some hand-rolled framework. J2EE and EJB become the new frontier.

Yes, it was easier to find devs who already knew about EJBs, WAR files, and so on. Was it worth it? No. In this case they would have been better served keeping the old framework. It was just better.

If your company is using custom tools and you are concerned that this will make it harder to bring on new developers consider how your tools tack up against what's publicly available. Maybe the better choice would be to open-source what your're using, or just take the hit of training people when they get hired.

If you make things too easy for run-of-the-mill developers you may end up with run-of-the-mill developers.


I worked somewhere with a similar brilliant framework. It was so much easier, etc., etc. Similar sort of genius auto-loading thing. XML/XSLT. Could slap stuff together fast.

I could make those XSLTs sing man. I made a pivot table out of XSLT, no shit. It was amazingly fast compared to the IE7 javascript engine. Orders of magnitude on masses of data, it actually was amazing.

Know how many times Ive used my crazy mad XSLT skills since?

Never.

In reality, your framework sucked. Just like ours did. The lack of just being able to google stuff slowed everyone down massively. The lack of extensive code examples slowed everything down. Doing the easy stuff was amazingly fast. Want to do something creative or complicated? NO!! That custom framework held back the talented programmers in so many ways.

And because every problem was novel and usually caused by some restriction in the framework you learnt solutions and patterns that you never, ever used again.

And when they left your company, those talented developers suddenly found themselves 3-5 years behind people who would previously have been their equal. They had effectively learnt a completely useless programming language.


The same applies to people who learned EJBs and J2EE in 2002 too, right? I remember doing Java web development circa 2006 and the new hotness in the Java world was JSF and Spring. And anyways, Java web development was dying then and all the cool kids were moving to RoR and Django. I remember arguing vociferously against the choice of JSF in my company and advocating for Rails; I finally quit in 2007, and the CEO called me up in 2009 and saying "Yeah, we made a mistake. Where should we go now?" They finally went out of business around 2011.

I think the lesson is that tech is a harsh industry to be in regardless of which tech you choose, and you should count on your skillset being obsolete in 3-5 years regardless. And your goal should be to learn the latest and greatest as quickly as possible, grab all the riches and other goodies around you while you can, and bank them for the lean years when the industry completely shifts around you and you have to learn something else.


I think the lesson is that tech is a harsh industry to be in regardless of which tech you choose, and you should count on your skillset being obsolete in 3-5 years regardless.

Also key is to not let what you're told to do at work decide what you're going to learn. Even if your current company is using whatever is the latest and hottest framework you need to be learning other languages, other ways of doing things.

Here's an anecdote: I did some consulting work for an Indian-owned company in the US. I was helping out with some Rails stuff. It was a curious case of out-sourcing reversal. They had a hard time finding devs in India to do Rails because those developers felt that Java and EJB would be better for their resumes so that was the work they went for.


>In reality, your framework sucked. Just like ours did. The lack of just being able to google stuff slowed everyone down massively. The lack of extensive code examples slowed everything down. Doing the easy stuff was amazingly fast. Want to do something creative or complicated? NO!! That custom framework held back the talented programmers in so many ways.

No, that's like your experience man. Mine has been different, and I've worked with stuff from Portlets, Struts and Webwork (remember those?) to Django and Express.js


> And when they left your company, those talented developers suddenly found themselves 3-5 years behind people who would previously have been their equal.

Domain specific knowledge doesn't cause this. If you are limited by how much of it you have or don't have then you have a long way to come as a programmer... having used a language or framework before is only really useful so that you don't get snagged by gotchas or weird and wonderful eccentricities of the framework or language.

In reality getting employed is more difficult without experience on a CV, but if you are intelligent and can get an interview its not usually a problem - smart people know, or can be taught quickly, the lack of value specific experience has in most contexts (i.e. anything where you aren't just urgently crunching something out of the door). :)


In reality, your framework sucked. Just like ours did. The lack of just being able to google stuff slowed everyone down massively. The lack of extensive code examples slowed everything down. Doing the easy stuff was amazingly fast. Want to do something creative or complicated? NO!! That custom framework held back the talented programmers in so many ways.

Well, at the time it was alta-vista not google we turned to. :)

The code was pretty straight-forward Java (about the most clever thing was use of forName and assorted reflection), so finding stuff was not a problem. We had many examples; examples as part of the rather good documentation was important for us.

We tried to avoid doing anything complicated. That was part of the point. Negative lines of code was a win.

It was easier to work with and figure out and extend than the alternatives at the time, and arguably still cleaner and more light-weight then what came after.

When the time came to move to some standard Java thing is was no easier (and often harder) to find decent examples or docs.

And because every problem was novel and usually caused by some restriction in the framework you learnt solutions and patterns that you never, ever used again.

No, not at all.

I really don't get this broad dismissal of all in-house frameworks. Is it so far-fetched to think that a small group of smart developers with business domain knowledge can build fast, lean, code? Maybe I was just lucky to have experienced this, but I don't think it's so rare.

The code was good, clean, Java. We ran into some issues because of garbage collection (we were really pushing things for speed and memory) for some related code but roadblocks due to our basic tools were rare.

Somehow we avoided over-engineering stuff. It actually worked, and worked well.

And when they left your company, those talented developers suddenly found themselves 3-5 years behind people who would previously have been their equal. They had effectively learnt a completely useless programming language.

Again, no, not at all. They had little trouble picking up EJBs or whatever was the Java-du-jour, if they needed, but unlike devs who only knew how to piece together beans and JSPs (basically plug-and-play coders) they knew how to handle things when stuff didn't work as expected or as the docs insisted. They could actually program because they actually knew the language.

Contrast this to people who learn, say, only Rails, and Rails conventions, and write very little custom Ruby code. They're at the mercy of the framework because they're married to a particular tool rather then being immersed in the underlying language. Ideally if one picks a framework one should also really learn the underlying language, but given a choice in hiring I'll go with the one who knows the language over one who knows a framework.

Perhaps not every case of using your own custom tools, well-designed for the task at hand, is the same, or does not work out well for every type of programmer.

I have worked places where they used poorly-conceived in-house tools, and it was not good. But that's not the case everyplace, and a business can get a competitive advantage using tools streamlined for their domain.


To back you up: Backbone and Rails are two examples of popular frameworks that grew out of in-house frameworks. So no, it is not far fetched at all to to think "that a small group of smart developers with business domain knowledge can build fast, lean, code".


Exactly right! Same with PHP (originally "Personal Home Page" scripts for an talented individual) and Djanjo (two talented hackers at small newspaper). Most of today's popular web framework had humble beginnings while many of those promoted by big tech companies have fallen by the wayside.

http://www.php.net/manual/en/history.php.php http://en.wikipedia.org/wiki/Django_(web_framework)#History


Makes me wonder how many other good frameworks there are out there they just never get released for one reason or another.

I've had people tell me about in-house tools they use, and some sound quite good.

One reason some companies do not release their source is because part of their business is in the licensing of the code. If a client could just take it and have others work on it because it was fundamentally OSS they'd lose that.


XSLT gets a bad rap, I guess because it is verbose and rather special-purpose. I do wish that version 2 were more widely deployed.

But hey, XSLT 1.0 runs in like, every browser in the world, and is practically designed for emitting DOM. I wonder why it's not used more often.


Last I heard, browser vendors are waiting to be able to drop XSLT.

XSLT is a functional language with a very weird syntax, and a very domain specific default mode - transforming XML trees in streaming mode. XSLT was the translation of SGML's DSSSL [1] into an XML syntax, DSSSL is (was?) a subset of Scheme.

XSLT is actually a pretty good tool for streaming "push" templating - writing a stylesheet that generically specifies how to handle certain kinds of elements. It really sucks at "pull" templating, i.e. writing the result and indicating where data from the input should go, how most templating languages work.

It turns out "pull" templating matches the mental model of most people much better, is easier to understand, and is in particular useful for ye olde typical website. On top of that, it inherited XML with all its baggage, and is forever coupled to that one particular data model.

I'd still use XSLT if I had to format something like a book, or a massive manual. Put for formatting programmatic results in a web app, I never would.

[1] http://www.jclark.com/dsssl/


It turns out "pull" templating matches the mental model of most people much better, is easier to understand, and is in particular useful for ye olde typical website.

And for that I found I was happier using a streaming parser and writing event handlers to grab data as it went by and formatting as needed in my handler code.

XSLT might be a good fit if your logic depends on whole-document handling. For example, you need to know how many foo elements there are in order to generate a TOC. Or something where you're explicitly working of irregularities and optional data so you need to have the whole XML doc at hand and apply your transformations "all at once" so to speak.


I've had that question myself more than a few times. If you find any good reads on that question, I'd love to see them!


The other big benefit of popular frameworks to businesses is that they're more likely to reach maturity faster with more people using, fixing, and contributing to them. With frameworks, bugs, security holes, and performance issues - especially the hard-to-find edge cases and gremlins - once solved are solved forever (more or less), whereas every time you start your own new framework you have to deal with that again.

It's probably best for a business, if you want to give your employees experience architecting a framework instead of just using one, to standardize on something like Angular.js/Ember/React/etc and then encourage/incentivize your employees to become contributors to it. Almost best of both worlds - benefit from using the framework, and employees get valuable experience, resume builders, and connections. Only thing they miss in that scenario is architecting a framework from scratch, which is something only your early employees would have gotten to do anyway.


This is very true. I once went to work at a .NET company which had built their own ORM and web UI binding framework. It was very nice back in the .NET 1.1 days but ASP.NET MVC, Entity Framework, the .NET base class library and the javascript community gradually overtook us. After a while it became more of a liability than a benefit. We'd never really documented it very well. New people ended up duplicating features and some of the quirkier bugs just never got fixed. Recruiting and retaining staff got hard and we ended up in a local minimum where each new screen was quicker to do in the in-house framework, but overall we were always falling behind.

It helped us to begin with, but my view is you have to factor in what the abandonment cost might be when the industry standard starts pulling ahead of you, and that could be big. As soon as it looks like the industry is settling on a standard way of doing something, start skating to where that puck will be.


Indeed. Having seen JS job listings that include rhetoric like "work with our hand-rolled pseudo-framework! it's sort of like Backbone but with a special socket layer baked in specifically for our app!" I can't run away fast enough.


In my experience writing web apps for many years (frontend and backend), you either (1) start off with an existing framework, (2) write your own, or (3) end up with a mess.

You really shouldn't be doing (2) unless you've had several go-arounds with (1). (3) is, of course, undesirable.


The problem with frameworks is that you can't do dead-code elimination with them. The solution to this is to use a *-JavaScript compiler of some kind. This lets you use bits and pieces from all sorts of different places without paying the heavy price of including all the dead code.


These types of posts are popping up more and more these days. I like to call them "JavaScript luddite" posts: posts that worship single-digit kb apps with zero dependencies as universally good ideas.

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.

"API first" -- just layer your API on top of whatever you'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.

"Small size" -- cry me a river. Yes, byte size is important but it'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've pretty much blown away any JS savings you would have had.

Another thing: usually multiple server round-trips matter more than bytes down the wire.

"Full control" -- this is a legit reason. Some of the bullet points are indicative of the state of client-side JS tooling though which are fixable.

"Special needs" -- moot's engineering challenges were not unique, they just didn't like the trendy frameworks. This is totally OK, but not a good reason to tell everyone that code reuse is bad.

"Technology lock-in" -- somewhat of a legit reason, but more of a commentary on monolithic architectures than anything else.


>These types of posts are popping up more and more these days. I like to call them "JavaScript luddite" posts: posts that worship single-digit kb apps with zero dependencies as universally good ideas.

So something like "the UNIX way". And that's wrong because?

>Abstraction is an important part of what we do as SW engineers.

Which is why we should be able to handle it and craft it properly, and not outsource it to some ready-made one-size-fits-all framework.

There are other outlets for code reuse, and they are called libraries.

>"Small size" -- cry me a river. Yes, byte size is important but it's not more important than code reuse and all the benefits that come with it (security, dev speed, support etc).

Code reuse? Ever heard of libraries?

In fact adopting a framework makes pretty sure that it will be hard to reuse both best-of-breed third party libraries (because frameworks favor their built-in stuff) and it also makes it pretty sure that your code will not be reusable outside of it, e.g when you move to a better framework. E.g. all those Ember objects will be tied to Embder, and the logic will be tied to Ember logic of doing things.

>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.

Beside the point, for one his app is not his blog, and second, a one-page style app can function while some image is loading, but not while the main JS files are.

>"Special needs" -- moot's engineering challenges were not unique, they just didn't like the trendy frameworks.

Moots might not have been, but your startups better be, else you're doing commodity work churning out stuff. In which case, yes, use a framework.


> "Small size" -- cry me a river. Yes, byte size is important but it's not more important than code reuse and all the benefits that come with it

I would disagree with this within reason. Code reuse affects YOU the developer. Byte size, however, affects your USERS. Things that impact your users are far more important than things that affect your development zen. Obviously the two are not entirely independent and a balance must be reached, but the user is the important person here, not the developer.


Code reuse or the lack thereof also affects the users, because there is more potential for bugs. Reinventing the wheel may be warranted, the end result may actually be more stable depending on who works on that wheel reinvention, but lets not kid ourselves - every line of code written increases the potential for bugs and there's nothing that affects the user experience more than a broken app.

Besides, bytes count is important, but it's only a problem because people aren't using tree-shaking optimizers, like Google Closure. E.g. when importing a library like JQuery, you're paying for a lot of crap in it that you don't need. A smart tree-shaker is able to detect unused branches and eliminate everything you don't use.

And it's a solvable problem. Google Closure in "advanced" optimizations mode is amazing. Unfortunately the popular libraries are not written for Closure's advanced optimizations and thus are incompatible. This is where compilers can help us. ClojureScript for example compiles to Google Closure optimized Javascript. There's also a fork of an older version of TypeScript that does the same thing. Google's Dart does tree shaking too. Maybe we'll also see EcmaScript 6 compilers that will do it too.

We don't need to sacrifice code reuse because of bytes count. I mean, sure, if you don't find a library that matches your architectural needs, wheel reinvention is fine. But optimizing for bytes count is a stupid reason to do it and we only feel the need for it because our tool-chains are primitive.


Tree-shaking optimizations aren't a magic bullet. I argued for about a year and a half to get Google Search to use JQuery, but it turned out to be a complete non-starter because the way the JQuery library is constructed is not amenable to compilation or static analysis. JQuery often dynamically assigns methods to the JQuery object by building a base function and then customizing it with some data-driven properties, then splitting a string to get the method names. For example, .width() and .height() are the same method, but one returns .offsetWidth while the other returns .offsetHeight; this distinction is encoded into a closure when the JQuery object is created.

It's a really cool programming technique that unfortunately kills the possibility of statically analyzing the library.

The other interesting thing is that this technique actually makes the JQuery codebase significantly smaller than defining separate methods for each function that appears in the API. So it optimizes for byte-size of apps that use all JQuery functionality, at the cost of apps that use only a little bit of JQuery functionality. And I think this trade-off is why people continue to like no-framework approaches: it is possible for the application author to know what functionality from a library they will need and write code accordingly, but it is not possible for a library author to know what functionality a particular application will need and optimize for that. When you make your library more amenable to tree-shaking compilers, you increase the byte-size of it in the absence of those compilers (through reduced code-sharing or dynamism in your own codebase), which makes you look worse in head-to-head comparisons. When you build your library to be small and clever but assume it'll all be used as one unit, you impose a tax on people who just want some of the functionality and not all of it. And when you use no library at all, then you often end up reinventing parts of the functionality of a JS library poorly, in a less optimized form, and as your app grows it becomes both slower and less productive than if you'd just used one of the leading frameworks.


I think lodash is doing this the right way: https://npmjs.org/browse/keyword/lodash-modularized


+1

We ensure that React is advanced mode compatible and people routinely get pissed at me because I'm a stickler for bytes. But that's because React is a shared core library where it's our job to be small and fast.

When you're building an app, the trade-offs and priorities are different.


> E.g. when importing a library like JQuery, you're paying for a lot of crap in it that you don't need.

Although a plus of something like jQuery, if you get it off google's cdn, is that probably most users will already have it sitting on their disk so you they won't actually need to download it. It gets cached by default for up to a year.


Sure, didn't mean to pick on JQuery, it was a random example and indeed, Google's CDN link is so popular that many users have it cached.


Comparing images and javascript in terms of payload size is apples and oranges. Images do not block the rendering of a page, are trivial to decode and display, and do not have long execution paths for the duration of their life.


If your argument is "byte size", images matter. There's no getting away from that.

This Marco Polo, Columbus-esc view of "rediscovering the basics" is on ego, not efficiency. You're not discovering new territory by rebuilding the wheel, passing it off as "efficiency".

Bandwidth costs would be the only point I could possibly side with - but as mentioned, you add a JPG or any resource for that matter, and the benefits are gone.

If you are going to go about the busy work of rebuilding the wheel, ask yourself, is there a single user's life you are improving? If you have sacrificed the user experience at all - to save 10kb - then you've disserviced them, while patting yourself on the back needlessly. 10k barely changed my experience on a 14.4-33.6kb modem, so I am unsure of how to make the argument today.


I think you completely missed my point. "Byte size" in javascript is an analogue for slow app execution (page rendering and code paths), not slow downloading or bandwidth costs.

Also, I'm not suggesting we "re-invent the wheel" or code everything from scratch. I'm an advocate for composing your app from small modules. Modern js is incredibly good at this.


"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."

Boom Baby!

Sorry, I just love how you picked up on that. Yeah, lets complain about size of our code, but hey look at my pretty high-res image!

"The lady doth protest too much, me thinks".

Anyway, at the end of the day its about creating an experience that gets the job done (and ultimately get more $$$ in your pocket). Many of the problems I see (here and in the office) are debates on which framework is the best for this and that. Though those are good debates to have, one shouldn't sacrifice the end goal for the "proper" software solution.

Jobs said it best here... http://www.youtube.com/watch?v=FF-tKLISfPE


I recently built a little library for generating slopegraphs in SVG. I could have used d3 and maybe saved a little bit of code but for something straight forward and purposeful like this I think the no dependencies thing works well.

I have also worked on projects that tried to build a framework for everything on their own. Good learning experience but not the best for code stability or predictable dev cycles.


"Small size" -- cry me a river. Yes, byte size is important but it's not more important than code reuse and all the benefits that come with it

Code reuse and security depend on developer's skill. You can have both in a home-brew microframework or have neither while using something more popular. Code size, on the other hand, is something you cannot get rid of, once you commit to a certain solution.

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.

This wouldn't be true if he had more JavaScript in his app. The argument doesn't make any sense.

I sense zero respect for people on slow internet connections from you. Yes, it is a real problem. Yes, modern framework-rich development makes the problem worse.


You hould get your hands on a 1st-gen iPad and browse using only that for a few weeks, to get a feel of how clunky js frameworks slow the web down.


The very next post on this blog is all about ... drum roll ... a custom framework that the moot team built, after deciding to not use any frameworks.

https://moot.it/blog/technology/riotjs-the-1kb-mvp-framework...

Sadly, this behavior is very common among those who have a hard time adopting existing libraries/frameworks. In the end, they almost always re-invent their own obscure wheel that does the same job.


I think it's important to distinguish frameworks from libraries. With libraries, your code is the caller; you can compose things as you like, including with your own code for cases not covered by the library. But with frameworks, your code tends to be the callee; you must conform to (and are thus limited by) the assumptions the calling code has baked-in by the framework authors. My sense is that the pain from this inverted directionality is what drives these bespoke frameworks.


The irony doesn't escape me, but for what it's worth, here is a previous HN discussion about their framework you mentioned:

https://news.ycombinator.com/item?id=6653024

A complaint I remember was that "there isn't much to see here except jQuery"


Of course. Not using any framework (external or built in-house) would mean that the team didn't find any useful abstractions that could be layered on the raw JavaScript. Very unlikely.


Obligatory XKCD http://xkcd.com/927/


Boooooo.


I've just gone through a similar process of reviewing and discarding a number of JavaScript frameworks. I've settled on React, and I can't recommend it enough!

React handles mostly the V in MVC, and does an admirable job of it. It even provides a cross-platform event abstraction, which would've saved the author some trouble.

http://facebook.github.io/react/

http://facebook.github.io/react/blog/2013/06/05/why-react.ht...

http://facebook.github.io/react/blog/2013/11/05/thinking-in-...

Now, how about CSS? So far, I'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't enough examples of real pages built with these tools.

Thoughtbot, if you're listening, why not publish at least the Sass sources of these webpages?

http://bourbon.io

http://neat.bourbon.io

http://bitters.bourbon.io


Hey, we're listening. The source code to all of those sites is actually already public, in the gh-pages branch of each of their respective repos:

https://github.com/thoughtbot/bourbon/tree/gh-pages

https://github.com/thoughtbot/neat/tree/gh-pages

https://github.com/thoughtbot/bitters/tree/gh-pages

I hope that helps! -Chad


The biggest cause of bugs before we used React is the fact that the "state" of the app is leaking all over the place. Symptoms were things like looking for dom nodes that didn't exist, events that triggered on code that was no longer active, bugs due to the app being in a state extremely complex to reproduce with crazy conditions all over the place, race conditions...

React does many things to mitigate those problems and those classes of bugs nearly dropped to 0.

- The code you write is declarative: you say how you want the dom to look like. This means that you no longer have two pieces: creation and retrieval that need to be kept in sync.

- React manages the life cycle of the components. When the component is no longer being rendered, it is properly destroyed, all the listeners are destroyed ...

- The render function is pure. This means that it is easier to write and unit test.

- The code is organized into small, composable and unit testable modules. By having a lot of small components it makes writing complex bug-free code easier.

- Each component has a very well defined interface. It cannot use anything else without it being obvious. This prevents the creation of big chunks of interdependent modules that are impossible to separate.

- There is a single point for state update. This makes the high risk pieces of code stand out.

In the end, we found that React actually helped us write more reliable app compared to framework-less Javascript code.


Mutable state can be a huge time sink. It's why I'm putting more and more time into functional programming, since I think that Haskell (and Clojure) is closer to what programming in the future will be like.

I think many programmers don't respect how much complexity is reduced when state isn't leaking all over the place.

Of course there will always be times when you need state, but many times its worth jumping through a few hoops to make things work without state.

EDIT: If programmers learn C so they can think lower level, they should learn Haskell so they can think in terms of side effects, composability, and the advantages of pure functions. Just a reminder, pure functions can be created in any language though some (Clojure, Haskell) enforce purity.


I had the same thought while reading the article. React seems great for people who don't need many libraries to develop complex web apps.


What do you use for the models and routing?


I haven't decided yet. I'm looking at using just the necessary parts of Backbone. Spine was also promising, but seems abandoned.


So you are basically saying that something is great without having worked with it on a production-grade project... Not saying React is a bad library, quite frankly it's the opposite, but your reasoning is surprising. In the future, avoid advising things you have not played extensively with.


+1 react, I also believe it would satisfy OP's need. React is going to take over the world in the next 5 years


React is a view + template, not a framework.

From the React site: "React as the V in MVC".

It's perfectly normal to combine react with something like Backbone as more complete solution.


React components are controllers too. "componentDidMount" == controller event. They are lightweight controllers, though.


@Touche True. It's perfectly reasonable to add a model/data layer to React as a final/complete solution. In such a situation a heavy weight controller can be skipped.


I would recommend http://enyojs.com/


Not using a JS Framework? Congratulations, you've just built your own ad hoc JS Framework.

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.


Congratulations, you've just built your own ad hoc JS Framework.

We used to call that part of software development “design”, and learning basic design skills and becoming familiar with the common strategies and techniques were prerequisites for being a useful developer. Perhaps losing that baseline is an unfortunate side effect of having readily available black box code to do many common jobs in the Internet age and being able to get moderately good results just by joining up those boxes. I don’t think this is a good thing, though. The idea that learning to find your way around a design when you start working on a new project might be considered difficult and not just something everyone routinely does is not a happy one.


In my experience, using a framework and learning design aren't mutually exclusive. Learning a framework often requires studying its source code and grokking how it works, there's simply no better documentation.

Granted that may not be quite at the level of designing your own complete framework from scratch, but imho it's the happiest middle ground between personal skill development and standing on the shoulders of giants that FOSS has enabled.


>Not using a JS Framework? Congratulations, you've just built your own ad hoc JS Framework. 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.

That's the framework party line. Not necesarilly true. For one, somebody not familiar with, say, Angular would still have to get to know Angular (a huge task in itself) and then your application code too.

Why not just have them understand the application code only? Since it's tailored to your application it also omits needless features and workarounds for framework issues.


I've never seen a non-trivial application that is "application code only".

Most frameworks weren't built out of thin air, but because of real application needs. Sure they have more than is necessary, but it is often the case in any non-trivial application that you end up writing a bunch of custom common "framework" code which duplicates the work that readily available frameworks (that you avoided using) had.

Any new developers then have to learn your new "lightweight templating language", "lightweight database mapper", "lightweight MVC layer", and what have you (which now you have to support even though it's not core to what your application does, but is just a support layer).

Though I guess the best part is most of these frameworks being discussed came about because an internal team wasn't happy with what was available and decided to roll their own, which eventually became big enough to release as a standalone unit.


>Sure they have more than is necessary, but it is often the case in any non-trivial application that you end up writing a bunch of custom common "framework" code which duplicates the work that readily available frameworks (that you avoided using) had.

There are trivial apps (no need of framework, small enough), medium apps (can use a framework maybe) and serious non-trivial large apps, apps you bet your company on.

The latter are often better to NOT base into a framework. If they do anything novel, and they want to do, they'd hit framework limits. The framework will impose its logic upon your code, whether it fits or not, and you'll have all the baggage of assorted layers it offers you'll feel obliged to use.

>Any new developers then have to learn your new "lightweight templating language", "lightweight database mapper", "lightweight MVC layer", and what have you

That's totally orthogonal. That you don't use a framework, doesn't mean you can handpick any of the popular template language libs, database mapper libs etc. Instead of being constrained by the set the framework authors chose.

That is: libs, instead of frameworks.

>Though I guess the best part is most of these frameworks being discussed came about because an internal team wasn't happy with what was available and decided to roll their own, which eventually became big enough to release as a standalone unit.

That's not ironic in the slightest though. It reinforces what I said: since those teams evaluated whats available and they didn't fit their needs and rolled their one to solve their particular problems they way they want to solve them, what makes third companies think those "hand-rolled" frameworks are a good fit for THEIR needs?

The message to take away, when a company rolls her own framework is not "frameworks are good, I should use theirs", but "they saw it fit to roll their own stuff. Perhaps I should too".

After all, if you're a startup your competitive advantage is your code. You shouldn't constrain it to fit anything external.

Now, if you are a consultant or web designer delivering cookie cutter projects for a company, or an enterprise developer doing some CRUD, by all means use a framework. Especially if you aren't doing anything very creative or original in the first place.


This sentiment, expressed collectively, commoditizes the entire profession.

How can you expect to ask for raises if all devs are basically interchangeable? If we've eradicated all notions of design, and follow prescriptive rules of structuring and solving problems that anybody can Google and follow, then what avenues are left to express technical ability? What differentiates you?


This sentiment, expressed collectively and somewhat unsympathetically, portrays the entire profession as prioritizing job security over true excellence.


Or one could say that it reveals the fatal flaw in our current system of capitalism:

Automation is desirable because it increases efficiency and lowers costs.

Automation is undesirable because it eliminates jobs and automatons are not consumers.


That was Marx main argument for the inevitability of a socialist revolution: That capitalism will eventually become efficient enough to on one hand create enough goods to make it possible to totally eradicate poverty, but on the other hand become efficient enough to substantially reduce employment.


Indeed.

But excellence should mean using the right design for a program, not the Good Enough one advocated by today's fashionable framework. I'm more concerned about collective effects (such as negating the need for analysis and design).

This is yet another instance of Worse is Better.


What is worse? What is better? Often shipping something that is 'Good Enough' is better than getting the 'right' (perfect?) design for a program.

In the post, it is clear that moot has a set of concerns that a typical business software developer doesn't have.

So, pick the right tool for your business situation, which may include a framework, or not. But I have to say, as a developer, the times when I thought I had to start from scratch and been right were far fewer than the times I wanted to start from scratch and been wrong.

That may be a testament to my skill, the problems I work on, or both.


I find the difference to be that each developer is now more productive and can add more function in less time.

The profession isn't commoditized, the lower end of the profession gets better, and those with the skills move up a notch and do more and more challenging things.

I used to build single-page javascript apps in pure javascript (pre-jQuery), and it was a pain. Once jQuery came along, things were easier. I actually don't think I'd have too much trouble going back and using just jQuery, but I don't think I'd be as productive as I am with backbone, angular or knockout.


I want to believe you, but I also see that a significant portion of the industry is still on CRUD, and people still get really excited about CRUD frameworks.


I don't know why you were downvoted. I (think) I agree with you.

I'm assuming you mean they are on CRUD as in most projects are what I call 'simple I/O'. Data goes into a database, data comes out of a database, and the job of the developer is just to make that happen.

For the most part, that is true, but I don't think you can blame that on the 'industry', that's the 'market'. The majority of the market didn't/doesn't need anything more than that.

However, if you have the skills, there are lots of jobs out there in data-analytics, robotics, etc. etc. (depending on where you are) that probably wouldn't have been available if we were ALL neck deep building every CRUD app from scratch. The frameworks make average people right faster and better code.

Hell, they help me write better and faster code. I'm no coding genius, but I've built apps in rails, and it is faster than when I was building everything by hand in PHP.

I haven't been doing much CRUD lately, seems like Front-End has taken the majority of my time in the last few years, but that's part of the 'craft' of being a developer. I actually find front-end more challenging and rewarding than CRUD (these days) simply because frameworks have made CRUD so easy.


And yet I haven't seen a convincing web CRUD framework. Have you?

I never did desktop development so don't know about there, but some must have been good.


Isn't that basically what Rails and Django are? Or are you asking for something client-side?


It doesn't commoditize the entire profession, only the 50% of it that is common to every web site or app you ever build. The other 50% is where the artistic license, craftsmanship, business sense, empiricism, and other value-adds of your team comes in.


"then what avenues are left to express technical ability"

I dunno, maybe actually solving problems for clients instead of playing endless rounds of "my JS is smaller than yours"?


This is not about code golf, this is about the widespread automatic use of frameworks in lieu of an analysis/design/build-one-to-throw-away phase.


Calmly, Chicken Little, calmly! Perhaps the sky is not falling after all...


Nope, it isn't. But clinging to frameworks in lieu of actual program design can hamper your ability to design something that doesn't fit neatly into a predefined box.


Frameworks tend to arise in languages with poor composability. Composable languages favour large numbers of small libraries which can be mixed and matched in many creative ways. Composability favours design.


Of course. But no one seems to be suggesting otherwise, that I can see, and for the relatively common case in which one needs quickly to prototype and roll out something which does "fit neatly into a predefined box", a framework is often just the thing.


You touch on the one things that frameworks are actually good for: prototyping. Unfortunately they're never just used for that purpose. The prototype and all the framework cruft is then called "the product" and used as such.

And sure, then you have people who can come in and "hit the ground running" but they're little more than overpaid glue sticks. They don't understand true software engineering. They just know how to glue framework code together.


"And sure, then you have people who can come in and "hit the ground running" but they're little more than overpaid glue sticks. They don't understand true software engineering. They just know how to glue framework code together."

Is it possible that some of us have an idea about what we're doing, but have to do enough different projects that learning a common framework has enough of a benefit to outweigh writing bespoke code for everything?

I don't feel the need to write a whole language for every problem I need to solve, and I don't generally think of the language functions I don't use on a given project as "cruft".


Who said anything about writing a whole language? Just know the language you're writing in well enough that you can build something better without a framework than you can with.


Well, sure. When I need something like URL routing, or object-relational mapping, or templating, why not reinvent it from scratch every time? Or, failing that, why not handle things like that with a collection of favorite libraries, each of which has its own calling conventions, its own requirements, and its own attitude toward the world? Reconciling all those differences certainly won't take a significant amount of time, and I'm always happy to spend my efforts on tooling instead of on whatever project inspired the need for tooling in the first place.

More seriously, I can understand where you might be coming from with the implication that frameworks are a crutch for developers who don't bother to learn, or aren't capable of learning, the language in which the framework is implemented; I've had to clean up the wreckage left behind by Ruby on Rails hacks, too.

But what's important to keep in mind is that the Rails dev community is extremely atypical in its extremely low average level of basic programming capability, and the Rails framework is likewise anomalous in the degree to which it forgives such incompetence. These traits, I stress, are not common to frameworks in general or to the developers who employ them, and consequently it is very much a mistake to use the Rails ghetto as a basis for extrapolation to more or less anything else. It's your mistake to make, of course, and if you insist upon it, then I won't go to any further effort on your behalf. But you can't say no one tried to warn you.


Prototypes always end up in production, framework or not.


I've seen this happen over over to the point where work prototypes are not terribly removed from production code.

I prototype slower, but nobody cares.


I just try to write production quality prototypes these days. Django is a godsend for writing maintainable solid agile database applications.


What if, instead of needing a framework, we just wrote tiny modules of functionality and composed them into an application?

This is how the nodejs guys are doing this via npm and I must say, it's staggering. The core node "framework" has a tiny API, and the heart of it is simply require().


Exactly. If this kind of thing seems like your cup of tea check out component[1].

[1]: https://github.com/component/component


This, entirely. You can effectively construct your own framework by combining other pre-established routers, models, and views (plus whatever other modules you might want). You still get many of the benefits of using frameworks (testing, docs), but it's much more flexible and has the potential to be leaner. You still need to establish best practices and a relatively consistent application design, but these are things you'd want to do anyway... even if using Backbone, or whatevs.


Yes exactly! Modules like in Node.js or libraries as in PHP are a lot more flexible and IMHO better than frameworks.

I coded single page HTML5 apps in JS and Node.js/PHP and avoided any frameworks. A few helper functions are enough and I got a codebase that is easy to read, refactore and the overall code size is small and the execution is fast.


I don't use any 3rd party code for my current work as of now. So yes I have built my own "toolkit". Maybe a vector rendering library wil be required at some point, but I started off on bare bones to see how far you get.

It's not that I am generally against 3rd party code, JavaScript is just a bit special in that case. The quality of JavaScript libraries is just so outright bad that I don't have any use for most of them. I have a personal policy to only include code that satisfies my personal quality standards, if a codebase makes me cringe I will not use it but rather write my own.


Every non-trivial app will add enough custom code to a framework that new developers have a learning curve.


Whereas had they decided to use Backbone or AngularJS I wouldn't have to invest tons of effort...? Regardless of framework (or lack there of), effort will be needed for those utilizing the API.


On top of that, their new knowledge of said framework is not transferrable to their next job.

If someone works on a popular framework, it makes it easier to get the next job.


It's SO much effort to spend a weekend studying a code base and playing with it. Get over yourself.


I'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:

    (function () {
        'use strict'
        var n;

        $(document).ready(function () {
            // Event listeners here
            $('#some-id').on('click', n.Product.respond_to_some_click);
        }

        // Sometimes I omit the n variable and just pollute the global namespace because I'm BA like that.
        n = {

        Product: {
            respond_to_some_click: function() {
                // Do some stuff
            }
        },

        Cart: {
        },

        Whatever: {
        }

        }

    }());
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't wait to get it ripped to shreds and see how I can improve :)


This approach is fine for small projects but you'll run into organizational problems once your application's complexity grows. For example, how many event listeners are you going to pile into that $(document).ready callback before you decide to break things up? How do you organize your code if/when you separate your listeners.

Another aspect your code doesn't address is fetching/posting data from/to the server, which leads to many more tangles, especially once you start duplicating code between models, etc.

Anyway, this isn't a criticism by any means. If such a lightweight approach is working well then you're doing it right. I'm just pointing out that things can get hairy as your app needs to do more and more.


In my current project I have 20 listeners in the ready function. I can see how it would get pretty nasty if I got up to the 100+ range. I think that would be settled by tacking on a listeners method to each of the models:

    ...
    $(document).ready(function () {
        n.Product.listeners();
        n.Cart.listeners();
    });
    ...
Ooo... I like that, maybe I'll implement that...

Regarding the fetching/posting data, I have an ajax method on the applicable model. Fortunately, I'm writing the server app as well so I got to make some decisions on that end that simplify the approach (e.g. everything goes through POST, all data comes back as JSON.) I suppose that makes the AJAX acronym imprecise... AJAJ?


I hope that you realize that when you've divided your listeners to Product and Cart objects, you've created a "lightweight" Model representation. Next thing you probably need is to fetch those Products and Carts from the server, and you add fetch()-function to them. Soon you'll realize that you've rewritten for example Backbone's Model class. With the exception that your solution has probably more bugs.


That's a good point. However, it's till tempered by the fact that I haven't added ~40kb to the app to get it.


Why not have a hashchange listener going to a hash-parsing router function, and make #some-id an anchor to a hash link with slash-separated parameters, or just use Backbone's router to handle your request? Then you don't need to keep track of a bunch of element id references.


Launching a massive project with that exact same structure soon. No problems at all. Feels so flexible.


Suggesting that frameworks are too complicated because they "add tens of redundant methods, adding complexity for the end user" is ridiculous. The number of methods in something doesn'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't need to worry about it. That's pretty much the point of a framework. Further though, using an established framework improves things through the "many eyes" principle - if tens of thousands of people have used a piece of code, chances are it's going to be pretty damn bulletproof and it'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.

Specifically in the case of moot.it, perhaps as a thing that's dropped into a website to provide a discussion forum having tight code is a bonus, but if you're writing something for other people to extend then using a well known framework as a starting point is a very, very obvious choice.


> if you're writing something for other people to extend then using a well known framework as a starting point is a very, very obvious choice.

This is precisely why we chose to build on top of Backbone.js. It has huge market saturation and easily understandable principles, but could benefit a lot from some of the killer features of Angular and Ember.

Rarely does a framework do everything you need. In the eventuality that you create another app you'll want a custom platform to build off of. It simply makes sense to base that custom platform on top of something stable and vetted by the community.


I think the 'redundancy' here is more just unnecessary complexity.

Eg, the primary value of Angular is binding DOM -> data. As a developer, I want to specify:

- The template for the DOM

- The data

That's all. I don't care about $scope.$apply, a second module system (even if it's better) or anything else I have to read about.

Ractive.JS (The Guardian's framework) does this. It's just mustache templates you bind to data, and when the data changes, the relevant parts of the DOM do.

The 'how to' fits in a tweet, it's backed by a major media company and the lib is 32 kilobytes.


Ractive.JS doesn't need $scope.$apply because it uses it's own model system. AngularJS doesn't use it's own model system, the model is a plain old JavaScript object. The author of 'Frameworkless JavaScript' criticizes the Ember way of using a "complex model system".

$scope.$apply exist because of limitations in JavaScript. Apparently this will be fixed in ES6, so ES6-version of AngularJS theoretically won't need $scope.$apply.

Ractive.JS's data-binding looks similar to Ember.js, which also has it's own model system to learn (learning complex frameworks was criticized in the article).


Ractive uses POJSOs. Each binding has a POJSO (ie, an Object, nothing magical, no new inheritance system or unrelated class-based OO system) and a template (in mustache format). That's all.

You can make the binding live specifying 'magic: true' which requires ES5 (a reasonable requirement for modern web apps).


I stand corrected. I thought you needed ES6 for that, but apparently ES5 is nearly enough.

I didn't read about Ractive.js's magic mode. It's not automatic data-binding either, according to the docs[1]:

'Magic mode only works with properties that Ractive already knows about.'

1. http://docs.ractivejs.org/latest/magic-mode

AngularJS works with properties that it doesn't know about, if you use $apply.$scope.


The thing is it's better set things manually so the boundary between your DOM data and other parts of the application become clear. There's no chance of mistaking this.set('keypath', data) with something else.


I don't think the model should care about the view. It should be possible to change the model without caring about view, or even knowing if a view exists. A view should be able to use the model, but the model shouldn't care.


It's just data for ractive.js to display on the DOM. There's no assumption on whether this is a Model, a View Model or whatever pattern you adopt for your app.


+1 Damn right. I love Ractive.js. I could train my developers by pointing them to the interactive tutorial and they can pick it up in two hours or so. There's very few concepts to learn.

We use it with jQuery, PubSub and TypeScript.


+1 for ractive. If all one needs is data binding , Ractive is enough. Angular is too complexe and too heavy in my opinion(though i like its expression language).


Amen, I agree 100% with this blog post.

I work on a popular web application that's built on AngularJS, and these are the exact same conclusions that I've come to.

* Code size is a huge issue for us. When something goes wrong, it's terrible to have to dig deep into mountains of code.

* I haven'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't really matter.

* I might be "hubris" 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.


This has been discussed before. https://news.ycombinator.com/item?id=6653024

A massive discussion between Backbone.js developer and the developer of Riot.js kicked off. It's an interesting read that's for sure.

You can find the library here https://github.com/moot/riotjs


Oh, so they wrote their own framework but the site doesn't use a framework.. now I get it.


The blogpost explains why they didn't use an off-the-shelf framework. (Spoiler: "We wanted control.")

That they can generalize their homebrew abstractions into a new framework only shows that they didn't use an off-the-shelf framework.


It is refreshing to see this post. As someone who has tried, and not really taken to, all three of those frameworks I sympathize.

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.


Moot's customers are not the people viewing the discussions; their customer is the developer integrating their code into a website. A framework might be important to them.

If their argument was "We didn't like any of the frameworks so we built moot without one" that'd be great, but they're making the case that all developers would be better off without, and that's pretty damn dubious.


I fail to see where the article proselytized against JS frameworks for anyone. They highlighted their specific needs and explained why each of the big 3 JS frameworks didn't fill that need. Can you point out where I missed this "all developers would be better off without..." tone?


My thoughts exactly. Moot's specific use case militates strongly against any of the frameworks discussed in the linked article, but it's specious to infer from that that frameworks are never of value, and especially questionable to do so in an article whose trailing "Read next" link points to an article about the framework Moot themselves invented.


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/free CDNs that host many of these libraries:

backbone -- http://cdnjs.com/libraries/backbone.js/

rainbow -- http://cdnjs.com/libraries/rainbow/

socket.io -- http://cdnjs.com/libraries/socket.io/


CDNs are not magic and there's a lot more than bandwidth to consider: you still have the overhead of doing DNS lookups, additional server connections and response latency before bandwidth enters the picture and the client overhead of decompressing, parsing and processing the response, where CSS will block rendering until it transfers and JavaScript will not only block rendering but also further loads until it finishes executing. Latency is almost always far more important to the user experience than the actual bandwidth and, particularly if you have many users on wireless networks, with blocking resources the concern isn't the average or best-case latency but the worst-case.

Libraries are still usually a reasonable trade for the reasons you mentioned but it puts a solid limit on your site's performance. If most of your users won't execute most of that code, it makes sense to reconsider – for example, if you could replace most of your jQuery usage with APIs like e.g. querySelector/querySelectorAll and your site only supports IE8+, it's quite reasonable to question whether you're getting enough benefit to be worth that download or whether there's a way to defer anything which isn't used all of the time. For example, much as I love LeafletJS, I'll toss in a rel=prefetch header for it but won't load the script until I need to display a map.


I find this specious: What modern web app isn't minifying/concatenating it's Javascript and CSS source? All of your concerns are easily remedied via a proper build procedure. And we're talking about, in relative terms, miniscule amounts of data for the web. 33 kb? C'mon now.


> I find this specious: What modern web app isn't minifying/concatenating it's Javascript and CSS source?

In that case, you should learn more about web performance: minification is a useful tool but it's not magic. If you add code to a bundle, you're almost certainly transferring too much data for the initial request — which increases the time before anything can run — and making caching less efficient because any change to your JavaScript invalidates the entire cached object; if you serve it separately, caching works better but you'll incur the latency cost multiple times. Every site has to balance these factors against user capabilities and the site performance targets.

To illustrate why you're being entirely too cavalier, consider Ilya Grigorik's excellent Velocity 2013 presentation detailing exactly what it takes to reliably deliver a rendered webpage in 1 second on mobile:

https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&c...

Note that his performance target is roughly 14KB transfer to deal with the way 3G performs in the real world. If you were thinking about including jQuery, you just blew that budget twice over: a fully compressed, gzipped copy of jQuery 2.0.2 is 29KB. If you concatenated everything, you not only blew your transfer budget but you ensured that none of your JavaScript, even the parts which are entirely self-contained, executes within that performance target.

The point isn't that CDNs aren't useful (they're great), asset packaging isn't good (it's a key tool), or even that jQuery is bloated, but rather that good engineers make decisions based on their performance goals and actual measured user performance rather than flippantly saying “We use a CDN so the site will be fast!” (contra: healthcare.gov) or “everything is minified, so it'll be fast”.


The magic of CDNs is caching. So, if you are using, for instance, the URL "//code.jquery.com/jquery-2.0.3.min.js" on your site, and the user has already visited a bunch of sites which are using that URL for their jQuery (highly likely), it means that there is no re-download because the browser already has the DNS and JS cached. Perhaps one extra hit to check for a 302 (and sometimes not even), so the thing about CDNs is the idea that when people hit your site, they already have the libraries you are using locally.

In this regard, you should exclude well-used resources that are on a CDN from your packaging/build process.


How likely is this? Everyone says "highly likely", but it's unclear what that actually means. 20% chance? 80% chance?

I wonder if someone has looked at the number of websites using the same CDN and calculated this probability. I'd be very interested in the results.


> So, if you are using, for instance, the URL "//code.jquery.com/jquery-2.0.3.min.js" on your site, and the user has already visited a bunch of sites which are using that URL for their jQuery (highly likely), it means that there is no re-download because the browser already has the DNS and JS cached.

Have you actually measured this? I've found that the results are lot murkier because not every site uses the same CDN or the same version of jQuery, so a user might have a bunch of different copies cached and still need to load the version you use, and many browsers – particularly on mobile – still have very small cache size limits so the fact that they downloaded jQuery yesterday doesn't mean it's still cached when they visit your site again today. This becomes increasingly dubious for any library less popular than jQuery.

This also doesn't help as much as you think for latency: by the time the browser is requesting that copy of jQuery, it already has your site's DNS resolved and almost certainly has at least one connection already established to your webserver. Restarting those processes for another server adds a non-trivial amount of latency – more so for HTTPS — which is acceptable if you're going to be making many requests but might take longer than simply transferring something like jQuery over an existing connection, particularly for wireless users or anyone using SPDY. This is fine for something which doesn't block rendering or which can stream but for something like CSS/JS in the critical path you really need real world monitoring to see how well your CDN is actually performing.


Ok, but trade that off against the latency for sending cookies and whatnot, and I think the difference is likely trivial.

If we look at the headers for jQuery 2.0.3, we get Expires:Thu, 31 Dec 2037 23:55:55 GMT, which means that it will not expire.

You make a good point in the fact that mobile won't have so much room to cache, however, I'd imagine this will increase as devices get more space and whatnot - in Android 4.4 with the latest Chrome Beta, I tried a few sites I'm using CDN on and got 304 for pretty much all CDN'd stuff:

http://files.blackflags.co.uk/officenumbers.herokuapp.com.ha...

So what I'm saying really is I think that whilst you have good arguments, I think that things are continuing to get better and better :)

That said, once everyone's on LTE, perhaps we don't even have to care ;)


> So what I'm saying really is I think that whilst you have good arguments, I think that things are continuing to get better and better :)

Yeah, I don't want to come across as a complete downer on this – the situation is easily better than it's ever been with CDNs becoming not just available but cheap, distributed DNS a turnkey service, etc. etc. Working on a global website for awhile has definitely reminded me that performance / reliability work hits diminishing returns unless you have have near-Google budget.

> That said, once everyone's on LTE, perhaps we don't even have to care ;)

Didn't we used to say that about 3G? ;)

https://docs.google.com/presentation/d/1IRHyU7_crIiCjl0Gvue0... does look appealing, though


Frameworks never reduce headaches or save developer time. They only push those things towards the end of the project when you can least afford it.


The cost of hosting might not matter, but increased page weight means increased bounce rate, especially among users with slower connections.


Unfortunately, the title is misleading. It should be titled "Angular, Ember and Backbone are too heavyweight so I created riot.js".


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.

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.


>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, you 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.

For one, your app can have a structure even with your self-coded solution. That's the job of the programmer, not of the framework. Besides, the framework's structure is not tailored for you app. It's the one-size-fits-all structure its developer likes to think in.

Second, while using a framework might has some benefits for a slightly larger team, when you go even big it loses the benefits again. In fact a lot of the big companies are using their own framework (which they self-coded).


How disappointing, the article is called "Frameworkless JavaScript", but the author uses jQuery for the application. Yeah, I get it, jQuery a library...

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.

That being said, I also like clean, minimal JS code.


I think the focus on file size comes from the fact that moot is supposed to be embedded on sites, much like Disqus.


Really interesting post for sure.

I'm not really seeing the size advantage here. All of the mentioned frameworks are cached on popular CDN's and I just don't think you're really getting much of a win out of creating your own, smaller files.

Also, I'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'll have to ask internally every time I have trouble figuring something out.

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.

Anyway, a great read for sure!


It's not just the download size and CDN utility in caching JS on the client side for reuse -- on older machines or devices with less than shiny new execute power, all that code make for a sluggish UX experience. Maybe not in seconds, but even a hundred milliseconds can make for a huge difference, even if it's not readily apparent.


If the code is already cached on the device, which I'm assuming it is in most cases. What is it that is slowing down the UX experience?


Cached doesn't mean free. Every byte of JS still has to get parsed even if it won't ever be used.

I really like how this demoscene-like mentality of being efficient with our computing power by only applying the minimal, needed complexity has started to get a more mainstream following. The traditional approach of piling on more complexity in the form of abstractions and other things is simply not sustainable. "The fastest way to do something is to not do it at all."


I think the author is getting flak for having his own "framework" while writing an article about being frameworkless.

But the "framework" riot.js has just one important function called "observable." It's 60 lines of code that sets up an event system. I have a similar custom event system in my projects and I do not use frameworks. It's not something people will need to Google or ask their coworkers much about. Backbone on the other hand... anyone unfamiliar with it will need to spend a significant amount of time learning it.


>Why not Angular?

The author points out that they just want two-way databinding, and don't want the entire overhead of Angular. Most of the Angular overhead is directives that you probably would use /anyways/, and are actually just written in Angular.

Ostensibly, you could fork Angular, take out all the custom directives, and end up with a much smaller starting codebase.

But then you'd end up re-implementing a lot of the default Angular directives (like ng-loop), and likely have a buggier application for it.


This sounds like every project that I've ever been on. My co-workers could have written a series of these types of posts:

* MVCless GWT

* Makeless Builds

* Eclipseless Java IDEs

* Hibernateless ORMs

* Freemarkerless Templating

I've seen this story many many times. I'll give you one guess as to how many of these *less solutions were worth the effort put into them.


Is the answer 42?


Great post, needs to be said sometimes that custom code is always going to be smaller and do just enough.

I'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 & rendering data. I do use Backbone but only the Views, but the overall architecture of the front end is clean, simple, and minimal.


You sir/madam, are doing it right.


What'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't satisfied with what's out there, rolls their own stuff, and lo and behold it can be generalized to other applications.

I wouldn't be surprised to see a Moot framework in the next year or so!



>> First, it's about the same size as Moot as a whole (91kb)

I am feeling a bit of a fool to ask that but... what's the obsession with the code size when it comes to client side JS?

Bandwidth? Well, unless you are running at Google'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).

Performance, since more code - more stuff to execute - will take longer? It's good to have performance in mind and maybe benchmarks will tell you that it's X times faster but what will it be once translated to seconds?


As I said here (https://news.ycombinator.com/item?id=7032169) it's usually because of front-end performance. Users are very concerned with performance, and loading a 150kb library doesn't help.

The extra kilobytes translate into seconds at an alarming rate if you're not on Google Fiber, and I've found that in rural NH Bootstrap usually takes 3 seconds to load vs. Min takes 300ms to load. Min (http://minfwk.com) is a 995 byte CSS framework I made to deal with the slow loading times of other CSS frameworks.


it all comes down to load times. because users will leave if a page takes a long time to load, the less code you have to transfer over the wire, the better. it is different from server side code because it must be transferred and executed by the user.

also, this applies heavily to mobile. not everyone has high-speed internet connections or wifi on their phones, so the less data transfer you have, the faster your page will load, and the less likely your user will leave before it's done loading.


They want small JS files so their designers can have a 2MB background image...


Bandwidth concerns cut both ways. I typically worry less about my server being able to serve it, than I do about the client having to receive it.

For desktop users it's less of an issue, but site size matters a great deal to mobile users.

At least that's where I tend to worry about it, not sure if this is the common reason.


Every app has its own framework/DSL.

What a "framework" that isn't your app gives you is the ability to have a common language to describe and build your app's framework/DSL.

The larger the team, the more important a framework becomes. The smaller the team, the easier it is to have "less framework" that you aren't totally defining yourself.

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.

Then again, sometimes reinventing the wheel is fun.


By no framework, I think don'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.

There are non MVC frameworks that focus on UI/DOM/CSS. I based this on Enity/System more w/ events management, I call it module buss. Don't have time to evagelise it ( http://github.com/puppetMaster3/ModuleBU ) Don't use MVC, code is just all over place, there are other patterns. I know this is shocking.


Love HN. "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."


This article criticizes the time spent learning a new framework. However, it doesn't seem to note that creating a new bulletproof JavaScript framework will likely take a lot of more time.


I wonder why Google's Closure Compiler hasn't taken off more in the open-source world. At the cost of some mandatory comments to help the compiler, it's able to analyze and remove unused library code from your application.


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'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's size.

This inspired me to create Min, a 995 byte CSS framework: http://minfwk.com


  if(frameworkLess == MadeYourOwnFramework){
   this.author = aHipster
  }
On second thoughts, the message seems more like "Go frameworkless, with our new framework."


Re: hipster-- I don't think that word means what you think it means.


How on earth is using JQuery considered "frameworkless"?


jQuery is considered a library and not a framework.


The authors of the recent book "Single Page Web Applications", 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.


> Goals for a web application should not be in imperative DOM manipulation, object oriented practices, or in "pure" MVC. A successful application aims to be simple, and there is no room for academic jargon.

I highlight this particular pair of sentences because I believe it is very important... I've had too many discussions over why code is 'bad' when what people mean is "doesn't precisely fit this particular idea of how to implement a particular paradigm". What they really mean is that they have a philosophical objection.

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 /better/ than shoehorning it into an object (singleton).


tl;dr They are realtime. They don't want full blown Rest frameworks for just reactive views. So, no AngularJS or EmberJS.

What about Knockout.js? It's just 16kb.


Exactly, I'm just waiting for a greenfield project where I can try Knockout + React.


Unless I'm blind, this post contains everything except usage examples or source code for your framework. I'd be interested in seeing it for myself, not only in hearing how cool it is.



Framewoks shouldn'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.

That's why a simple thing like http://aurajs.com/ is so good and beautiful.


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't become the app.

That's sort of the big lesson I've learned over the years working with Rails, where too many projects become "Rails apps" rather than apps that use by Rails.


What a joke! He complains about frameworks being too bulky but unquestionably uses jQuery without questioning it the same way.


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 "Someone is writing...".


When I'm working on a deadline it's super easy to just grab x, y & z framework and use the bits I need from each. And in the end, I've added what... 150kb of scripts?

Unless I'm targeting users with bad connections, what's the problem?


Hehe. The answer is in the question. Mobile browsing is what... a third of the web nowadays?


Doesn'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 "Plain Old Java Object".


So you'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.

For one, you can'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...

This is exactly what MVC frameworks try to help you with, and with good reason. And I'm not even talking about the dozens of other well-tested and carefully designed features you'll probably end up duplicating. Taking everything into consideration, I really don't think smaller file sizes justify all that.


So when OP says none of the popular framework works for him, he doesn'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.


On the other hand, if you're on a budget and don't have the money to implement your own solution to single-page web apps, you've gotta make some compromises.

And that's where a framework comes in.


I've always thought the opposite while working on my own projects with limited budget...

I don't have enough time to learn all these js framework idiosyncrasies, and learn the way a framework wants me to do things. I know how to separate data from the application code, and use events to communicate between parts of my app. That seems much simpler to me than trying to learn a framework.


New document: "Building modular applications with Riot.js"

https://news.ycombinator.com/item?id=7036274


Reasonable argument for preferring small optional packages v. shipping the kitchen sink with a big package. But hubris to roll your own everything.


I don'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 :)


Backbone + Marionette (http://marionettejs.com) reduces the amount of boilerplate.


Is this the same guy who wrote head.js?


No.


I'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 'component' system built from simple jQuery plugins.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: