Live data from Hacker News

In search of the perfect JavaScript framework

dev.opera.com

31–40 of 85 posts

Re: In search of the perfect JavaScript framework

#31
I yet to find "perfect" JS framework. I bet, it will never happen.

Nevertheless, I have a favor to ask any framework developer out there - please, make it disassemblable and usable piece by piece outside of framework.

OP was right - sometimes i find some aspect of framework nice, but more often than not it is monolith part of the whole framework, which as a whole I dislike.

ps: current combination it seems to fit my mind workflow is Backbone (models + collections) + Ractive.js (Views) + Machina.js (for routing and defining "controllers"/states.) Although I am looking to use something else besides Machina.js in next project, as I want to have hierarchy now. And since it is all loosely coupled, I can replace parts.

Re: In search of the perfect JavaScript framework

#32

I like the direction author is going. I have used similar methodology designing my applications (for mobile), simple, micro libraries, one way data binding. http://hn.premii.com/ http://reddit.premii.com/ * I have bunch of helper functions (UI and non-UI). Each function define in its own file and independent (easy to unit test). Personal library like jQuery but not a jQuery replacement. * App is route based. One rout…

I use hn.premii.com all the time. One of the best mobile web apps I have used. Any chance of open sourcing it? Would love to see how you solved some of these problems in detail.

Re: In search of the perfect JavaScript framework

#34

>We want to apply values to variables and get the DOM updated. The popular two-way data binding should not be a feature, but a must-have core functionality. Strongly disagree. I find one-way bindings and one-way data flow much easier to reason about. A little less boilerplate code is not worth mental overhead, cascading updates and hunting down the source of wrong data in my experience. What is important is not updat…

It is a shame to conclude two way data-binding should be a casualty in the maturation of frameworks. Like one way data-binding, it can be misused.

Two-way data binding to properties is generally not good. It increases likelihood of problems as updates to one value have to be observed to adjust other values. It is easy for bugs to slip in and hard to reason about the code.

Two-way data binding to methods is better. Methods that aren't focused on setting one value. In effect not direct data binding. It creates easy to reason about explicit code paths for changing of values. Observation of the change of properties is no longer required.

It is a useful tool and should continue to be seen as such.

Re: In search of the perfect JavaScript framework

#35
post #4

My theory is that, for much of the web, the perfect javascript framework is no javascript framework. Get rid of all the abstraction, local state, dependency injection, symbol management and so on. Take HTML/HTTP seriously and think about REST in terms of HTML rather than JSON. That's intercooler.js: http://intercoolerjs.org Here's an image I tweeted trying to explain how to get there mentally: https://pbs.twimg.com/m…

"No framework"... so here is a framework. Uh hu. Anyhow, move that "use strict;" line into the IIFE. If it's global, you can't merge that file with other files. Some of the code out there breaks in strict mode. That's why it isn't enabled by default.

Well, it's a library, not a framework: you can use it for as much or as little of your app as you like with as little as a single attribute declaration doing something useful for you.

On "use strict", my understanding was that it applies per script:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

Strict mode applies to entire scripts or to individual functions.

Am I misunderstanding?

Re: In search of the perfect JavaScript framework

#36
post #4

Earlier quoted context omitted.

"No framework"... so here is a framework. Uh hu. Anyhow, move that "use strict;" line into the IIFE. If it's global, you can't merge that file with other files. Some of the code out there breaks in strict mode. That's why it isn't enabled by default.

Well, it's a library, not a framework: you can use it for as much or as little of your app as you like with as little as a single attribute declaration doing something useful for you. On "use strict", my understanding was that it applies per script: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... Strict mode applies to entire scripts or to individual functions. Am I misunderstanding?

Many sites have a build process that concatenates multiple JavaScript files into one. If they concatenate other scripts after yours, your "use strict" will apply to all of them.

Since the rest of your script is already enclosed inside a single function, simply move the "use strict" a few lines down so it is the first line in that function. Then it will only apply to your own code.

Re: In search of the perfect JavaScript framework

#37
post #4

Earlier quoted context omitted.

"No framework"... so here is a framework. Uh hu. Anyhow, move that "use strict;" line into the IIFE. If it's global, you can't merge that file with other files. Some of the code out there breaks in strict mode. That's why it isn't enabled by default.

Well, it's a library, not a framework: you can use it for as much or as little of your app as you like with as little as a single attribute declaration doing something useful for you. On "use strict", my understanding was that it applies per script: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... Strict mode applies to entire scripts or to individual functions. Am I misunderstanding?

> Well, it's a library, not a framework: you can use it for as much or as little of your app as you like with as little as a single attribute declaration doing something useful for you.

If it has an entry point, it's not a library, it's an application. If said application does basically nothing on its own and you're supposed to extend it, it's a framework.

http://en.wikipedia.org/wiki/Software_framework

Pay close attention to the 4 bullet points in the first section.

> On "use strict", my understanding was that it applies per script

Yes. However, when you merge scripts, there is only one script at the end.

The site you linked to also mentions this problem.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

"This syntax has a trap that has already bitten a major site: it isn't possible to blindly concatenate non-conflicting scripts. [...] It is thus recommended that you enable strict mode on a function-by-function basis [...]"

Re: In search of the perfect JavaScript framework

#38

>We want to apply values to variables and get the DOM updated. The popular two-way data binding should not be a feature, but a must-have core functionality. Strongly disagree. I find one-way bindings and one-way data flow much easier to reason about. A little less boilerplate code is not worth mental overhead, cascading updates and hunting down the source of wrong data in my experience. What is important is not updat…

It is a shame to conclude two way data-binding should be a casualty in the maturation of frameworks. Like one way data-binding, it can be misused. Two-way data binding to properties is generally not good. It increases likelihood of problems as updates to one value have to be observed to adjust other values. It is easy for bugs to slip in and hard to reason about the code. Two-way data binding to methods is better. Me…

When I was creating a UI library, I tried to pick up on the trend of data-binding, but I found it difficult to use. Now these discussions remind me of it.

I don't even know how the second option is better to be honest. I may research it further.

:-)

Re: In search of the perfect JavaScript framework

#39
post #37

Earlier quoted context omitted.

Well, it's a library, not a framework: you can use it for as much or as little of your app as you like with as little as a single attribute declaration doing something useful for you. On "use strict", my understanding was that it applies per script: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... Strict mode applies to entire scripts or to individual functions. Am I misunderstanding?

> Well, it's a library, not a framework: you can use it for as much or as little of your app as you like with as little as a single attribute declaration doing something useful for you. If it has an entry point, it's not a library, it's an application. If said application does basically nothing on its own and you're supposed to extend it, it's a framework. http://en.wikipedia.org/wiki/Software_framework Pay close att…

Ah, OK. Well, good news: intercooler doesn't have an entry point.

Good point on the concatenation issue, I'll fix it for the next release.

Post reply on HN