Introducing Ampersand.js
blog.andyet.com
blog.andyet.com
Good for folks that are used to the node modules philosophy - Seems like a logical extension of the browserify effort (bringing Backbone into the frontend modules system). I dig it.
* Views have declarative data bindings for updating your html with model data automatically; out of the box, sensible render and remove methods just work; collection rendering is easy.
* Models have explicitly declared properties and types, as well as evented + cached derived/computed properties. You can access model properties without .get('name') and .set('name', value) and events and things just work.
[when IE >= 9]
Honestly though I'm excited by getters and setters. I always disliked calling them explicitly in Backbone—it feels like a hack.
On the other hand, there's something nice to be said about explicit setters (you might not expect events to fire when it doesn't look like a function call).
Still, I'd rather have real looking code than a bunch of xxx.set('propA', yyy.get('propB')) nonsense.
Obviously that will mean some people can't use it, but hey, trade offs right :)
Show me the code, don't hide behind a huge post with buzzwords like "mobile first" and "modular". Show me what it actually does.
The quickstart (called "Learn") is 2 clicks away, well written, and full of code samples:
I hate it when people are lazy. ;-)
But seriously, I agree that the code is what matters, not some blog post. However, I don't know if you could really unpack a framework in a single blog post anyways...
A few inline fragments to contrast with Backbone would be super helpful.
And the clientside code for the example application generated by the cli is here: https://github.com/AmpersandJS/ampersand/tree/master/templat...
It took some browsing of the GitHub repos for me to figure out what this is. But I like it, and will probably use it, so the code is not the issue, just the presentation. :)
Though yes, a better overview would be useful.
Your landing page should contain what your users want to see, not what you want to put there. You might be excited about the motivation behind your project but nobody cares, really.
I clicked on the link and I spent ten minutes reading a wall of text hoping to find good reasons why I should switch from Angular, Backbone or Ember. Instead, I just closed the window without knowing anything about your framework.
> There's plenty of API docs for the core components
Still not a substitute for a user manual, even tiny.
The actual landing page is http://ampersandjs.com (linked in the first sentence of the blog post) and has plenty of technical content like the user manual/guides you wanted (http://ampersandjs.com/learn) and api docs (http://ampersandjs.com/docs).
I don't know what that means, and the reasons for it are "simplicity of tiny modules and npm dependency," which are not exactly convincing by itself, as I can do that just fine with plain Browserify. Then, going to the "Learn" page I get my hands busy.. with something I know nothing about.
This is heavily marketed towards Backbone users, I'm guessing.
You're right that it's basically for Backbone users:
> We <3 Backbone.js at &yet. It’s brilliantly simple and solves many common problems in developing clientside applications.
> But we missed the focused simplicity of tiny modules in node-land.
Read as: "This is like Backbone.js (almost a forked Backbone.js) but better." (better from some perspective, at least)
Yes we'll try and improve the content on the homepage to make it more focussed. Though I guarantee if we didn't talk about the motivation we'd have people saying "why did you make another framework?!"
> Still not a substitute for a user manual, even tiny.
I'm not suggesting we've got it perfect by any stretch, but I'm not sure exactly what you're hoping to see? There's also http://ampersandjs.com/learn with some more detail around the various pieces.
Were does the entitlement come from?
In my opinion that's the best solution to the front-end dev issue.No amount of Backbone based framework ,as good as they are(and I use some) really solve the "how do I build a complex interactive view" problem on the client.
Setting intents and expectations and letting the framework drive the view life cycle solves many issues.AngularJS and React success are a proof of that fact.
So hardest thing to manage in an client app is the view . Backbone never solved that problem.It just had an opinion about the Domain Layer(Backbone models/collections) and the Data Access Layer(ajax).
Didnt try Ampersand but i'm curious as to how it solves that issue.
We support declarative subviews, that might be what you're looking for: http://ampersandjs.com/docs#ampersand-view-subviews
"One of the problems we’ve had at &yet especially when working on large Backbone applications is a sane way to document the type of properties a model is supposed to contain.
Backbone models, by default, don’t enforce any structure. You don’t have to declare anywhere what properties you’re going to store. As a result, people inevitably start saving miscellaneous properties on models from within a view somewhere, and there’s no good way for a new dev starting in on the project to be able to read the models and see exactly what state is being tracked."
I really wish more people would try Dart. Maintaining structure, declaring types, readability... these things can be solved at the language level.
As a developer and a university professor, for the first time in my long career, I can do the following with Dart:
I can use Dart both on the client and on the server;
I can apply both object-oriented and functional way of programming;
I can develop in Dart and deploy applications in JavaScript;
I can be a productive developer with many Dart tools and libraries, and get a very good performance in either Dart applications or their JavaScript versions;
I can start developing a prototype without data types and introduce them when I need to convert the prototype to a deployable application;
I can use Dart for both synchronous and asynchronous programming;
I can use many publicly available packages and reuse their libraries;
I can be a web engineer on the client-side and a software engineer on the server-side, with the same language and many reusable libraries.
This is exactly the project I needed; I will very soon be integrating Ampersand Collections & State into my app. Thanks for this!
To the core team here and anyone making a library: please make sure your documentation is flawless and your example code exemplary. Thanks!
So yes and no, this is a work in progress (what isn't) and we will constantly be pushing to make the docs better. We've been working hard over the last couple of weeks to get this into some form of a publicly releasable state, but yes it's not perfect :)
If you want to help us out, feel free to submit PRs or issues on github. The main site is at http://github.com/ampersandjs/ampersandjs.com while the API references are generated from their individual readmes, all available in that github org.
I appreciate the use of semver, but I don't think the intent is to go through three major versions in as many days...
> I appreciate the use of semver, but...
Oh, we aren't breaking things _that_ quickly! ampersand-state for example has been a repo since February.
I'm really not trying to be annoying, but I'd point out there was a week there in April where ampersand-state jumped from 0.5.0 to 3.0.1. Perhaps it's just that the initial decision to one-dot was premature and now you're locked in by semver?
http://hueniverse.com/2014/05/30/the-fallacy-of-tiny-modules...
Also, it's worth noting that there's no cost in installing a big framework on the server side. It doesn't hurt to have a bit more text on the hard drive that isn't used. Clearly, that's not true on the client where we have to ship code down the pipe.
You'll notice we actually use hapi on the server for the cli app. So I don't believe these to be at odds. It's all about pragmatism and picking the right tool for the job.
No offense but I completely disagree. I don't know what problems does backbone solve.
> But we missed the focused simplicity of tiny modules in node-land. We wanted something similar in style and philosophy, but that fully embraced tiny modules, npm, and browserify.
> So we made Ampersand.js, a well-defined approach to combining (get it?) a series of intentionally tiny, and loosely coupled modules for building JS apps.
So .. what is it exactly? a module system for the client side?
RequireJS[0] has already solved this problem.
After reading the first 10 paragraphs, I still have no idea what is this all about.
Not that I'm against CommonJS. It just requires additional tooling to be "superior" so I don't think you should make such a blanket statement.
1. hasenhj is correct, Backbone has been superseded for "advanced" webapps for at least two years and should not be used for new webapp development
2. I had the same confusion and question about what exactly ampersand is and what "advanced app" problems it sovles
emotional edit: I've used Backbone, Knockout and React in "advanced" (enterprise-scale) production apps, and studied TodoMVC and skimmed the book for Angular and Ember. My original decision to use backbone & knockout in enterprise scale app almost wrecked my first greenfield project, we spent multiple months ripping out Backbone based code. In 2014, Backbone.Model and Backbone.View are very naive ways to approach frontend problems and it is not obvious why until you've been using them a few months. There is an entire ecosystem of blog posts on HN of people attempting to explain why. Any and all of the above dependencies are better than Backbone/Knockout for new webapp development. They of course have the advantage of learning from Backbone, Knockout, YUI, Sencha etc, so it is no surprise that they tackle the hard problems that backbone makes no attempt to solve.
> 4. Strict semver all the things > 5. Tiny module all the things! > The smaller the feature set of the low-level modules, the easier it is to avoid breaking changes. > 6. Expose the simplest API possible.
This is great, but what I would rather see is strict code coverage guidelines on contributions. The whole point behind having micro libraries is that writing unit tests should be easier, because there are simpler dependencies and each simple dependency is easier to mock.
Similarly,
> 7. Optimize for minimal DOM manipulation and performance.
The best way to optimize for performance is to include various performance testing, and never let performance get slower when considering patch contributions.
In short, less marketing fluff, more community process.
7. Yup, we'll keep doing more here. We just announced it! :)
"less marketing fluff" well, it's an intro post attempting to explain something new. And hey, you're reading it so maybe the marketing worked ;) But, point taken.
API reference: http://ampersandjs.com/docs All the codez: https://github.com/AmpersandJS Guides: http://ampersandjs.com/learn/
I'm not saying you should use it, it's what we use and we're sharing it with the world. If you're already happy with your tools, just keep on keepin' on.
Just some hopefully helpful advice.
With regard to "pain in the butt to extend" you could use `extend` and just replace that one method that returns those string, right?
InputView.extend({ getErrorMessage: function () { // return error objects instead? } })
/me shrugs
Forms really are a pain, we tried to create a simple contract between a form-view an it's child field views that was as flexible as possible so you could easily write more input types.
More on that contract here: http://ampersandjs.com/learn/forms#form-input-view-conventio...
But hey, also... easy enough to use something else entirely, it's not like the forms stuff is bundled :)
1. The problem of adding more input types, as well as expressing more functions over existing and additional (unbound) input types, is a classical computer science problem called The Expression Problem.
2. It's really not about 'parents'. It is about workflows. "Can you lift 50 lbs?" may be a dependency for another question.
3. It's simple dependency inversion to use a list of Success and Failure objects to determine the state of a Submit button. This way Submit.Enabled = !list.Any(i => i.Failure). Why should Submit be responsible for knowing the structure of a form, such as fragile parent-child relationships that have no basis in reality.
4. There are really two kinds of dependencies. Layout and workflow. It's too easy to commingle these. Spreadsheets, for example, contain no such visual dependency between cells, only flow.
What does Backbone solve exactly?
props: { name: String, age: Number }
We do need to do some more documentation/cleanup around custom datatypes though for sure.
What a terrible lead-in example for justifying Ampersand.js. If you want structure, why not use a strongly typed language that transpiles to JavaScript? I don't understand how all these micro libraries you created get you any assurance of what you were after.
Can you please explain further why I would use Ampersand.js? Coming from TypeScript, I just see no substantive argument. If I were a Backbone developer who had monolithic dependencies, I could see your argument. I also get AMD modules or CommonJS modules for free with TypeScript.
I realize you are trying to say I am comparing apples to oranges, but the site explicitly mentions Human Javascript approach as inspiration, and Human Javascript is all about choosing your tools. I am pointing out that there is an incredibly powerful tool that works extremely well for large-scale software development.
There are probably good use cases for Ampersand.js. The argument in this article is a really mediocre at best use case.