In this first chapter we will go through what makes Ember.js great and why you would want to use it for your next big web project.
What is Ember.js?
Ember.js is a framework for front-end development, which means that it helps you create the design and logic that the website user interacts with.
To understand what problems Ember solves and how it makes web development easier and much more enjoyable, let's first go through some basic web history.
The changing nature of the web
In the early 90's, designing a website was very straightforward and uncomplicated. This was back when the web only consisted of text documents. To create these documents, the only thing you needed was a markup language called HTML, and some CSS that you could sprinkle onto make it look nicer.
Microsoft's website in the good ol' times (1994)
All the interactions on a site back then consisted of linking from one HTML page to another. Every time you clicked a button or a link, the website made a request to the server and your computer then proceeded to download en entirely new HTML document in order to show the new page. This might sound inefficient, but since everything consisted of only text and images back then, it worked just fine. However, this was soon about to change.
As people wanted more and more advanced websites, the simplicity of HTML and CSS soon became very limiting. This is when JavaScript was introduced in 1995 as a Turing-complete language specifically tailored for web development.
Initially, JavaScript was generally considered to be an "ugly language", yet it had the potential to make websites behave much more like a native application rather than just a static document viewer.
Over the course of many years, some great technologies like jQuery, AJAX and Backbone.js helped bring JavaScript to the mainstream and cemented the view that it was indeed the right way to do things.
Google Maps was one of the early websites to showcase what JavaScript was really capable of.
Even though JavaScript and its libraries solved a lot of the previous pain points, it also created a bunch of new problems. Now that you could load new data into your website without reloading the whole page, how would you efficiently manage state, and make sure that all the necessary elements were updated when new data was loaded?
As the user experience on websites became more complex, the JavaScript behind the scenes doing all the work was often referred to as "spaghetti code" because it was so unmanageable.
This is where Ember comes in. The founders of Ember realized early on how the web was changing and understood the need for a front-end framework that would enforce some best practices that were commonly agreed on.
Yehuda Katz and Tom Dale, the initial creators of Ember.js
Today, Ember has established itself as being a great framework for developers who want to build "ambitious applications", and some big companies have taken the leap to use it in their stack.
If you want to know more about the motivations for a pure front-end framework, Tom Dale gave an excellent talk at Cascadia.js in 2013:
Why Ember instead of XX?
If you're an experienced web developer, you probably know that there are tons of other frameworks to choose between already, notably Backbone.js, Angular.js and React.js. Why would you want to choose Ember instead of these?
First of all, let me say that I have used most of the well-known JavaScript frameworks and libraries that exist today and that they all have their strengths and weaknesses, including Ember. The wisest thing to do is, not surprisingly, "use the right tool for the right job". So what are some things that Ember is especially good at?
You should consider using Ember.js if...
-
You want to get started quickly and get a product out fast without writing lots of boilerplate code (it's the optimal front-end framework for startups!)
-
You're planning on building an ambitious and complex application with a lot of logic on the front-end side.
-
You care about having good URLs when the user navigates through your app.
-
You don't want to spend time arguing about what the file structure of your project should be or what build tool to use. You'd prefer to just have it set up beforehandand start getting productive.
On the other hand, you should probably not use Ember.js if...
-
You're just building a very simple static site, without much interaction or state. In this case, Ember will probably just feel bloated.
-
Your website requires that the initial page load is blazing fast. As your Ember apps get bigger, you will currently have to sacrifice some initial loading time in order to have a faster and more interactive experience once everything is loaded (although this is constantly being improved thanks to addons like Ember FastBoot and Ember Engines)