Live data from Hacker News

Preact, a fast 3k React alternative

developit.github.io

31–40 of 142 posts

Re: Preact, a fast 3k React alternative

#31

How does this stack up versus something like riot.js? http://riotjs.com/

RiotJS couldn't keep it to the original size of about 3 KB, it's about 9 KB now. They market it as a "React-like", but it appears that this one is way more "React-like" than RiotJS ever was.

Re: Preact, a fast 3k React alternative

#33

Earlier quoted context omitted.

Well for one 'class Foo extends Bar' will work without any further code to make inheritance work in the way you'd expect, including use of super() etc. Whereas your second example is using non-trivial framework code, that some framework author has to write. See Backbone's extend() for a clear example of what is required [0]. That's work that every framework author is potentially going to implement differently, needle…

The question is whether that ~15 lines of code, written once, is worth the substantial increase in the surface area of the language, especially when overlapping so much with the existing prototypal inheritance mechanism. The choice to use Java/C++-style inheritance is a design pattern that doesn't necessarily reflect the only (or even the best) way to accomplish things.

The language surface area has already increased. The decision has been made.

Re: Preact, a fast 3k React alternative

#34
post #32

[deleted]

It's still best practice for most normal websites that are mostly static content with a bit of jquery and Ajax sprinkled on top.

But for sites that are more like applications people are thinking about the components that make up those applications. These components are self contained and reused so it makes sense to have everything in the same small file.

Re: Preact, a fast 3k React alternative

#35
post #15

We don't need smaller frameworks, we need more modular frameworks. If the framework is modular you can take what you need, and replace the parts you don't like. I'm using mercury [0] in my current frontend project for this purpose. Most of the features of React, none of the commitment. Every single component is interchangeable; the core repository is simply an index.js requiring other modules, which can be depended o…

Mercury fans always say this but I'm never seen anyone swap out random libraries it uses, like dom-delegator. Stuff is still made to be used together, you could swap out dom-delegator if your version had the exact same API, but then what would be the point.

Re: Preact, a fast 3k React alternative

#36

Earlier quoted context omitted.

Well for one 'class Foo extends Bar' will work without any further code to make inheritance work in the way you'd expect, including use of super() etc. Whereas your second example is using non-trivial framework code, that some framework author has to write. See Backbone's extend() for a clear example of what is required [0]. That's work that every framework author is potentially going to implement differently, needle…

The question is whether that ~15 lines of code, written once, is worth the substantial increase in the surface area of the language, especially when overlapping so much with the existing prototypal inheritance mechanism. The choice to use Java/C++-style inheritance is a design pattern that doesn't necessarily reflect the only (or even the best) way to accomplish things.

ES6 classes do not use Java/C++ style inheritance, they are still the same as writing:

  function Foo() {

  }

  Foo.prototype = Object.create(Parent.prototype);

  ....
It's just sugar, nothing more.

Re: Preact, a fast 3k React alternative

#37
post #15

We don't need smaller frameworks, we need more modular frameworks. If the framework is modular you can take what you need, and replace the parts you don't like. I'm using mercury [0] in my current frontend project for this purpose. Most of the features of React, none of the commitment. Every single component is interchangeable; the core repository is simply an index.js requiring other modules, which can be depended o…

I recently found out about incremental-dom[1], a very small library that just does the "dom updating" algorithm. Its very low level and does not rely on keeping around a "virtual dom tree" so its supposedly very interoperable. Does anyone here have any experience with it?

[1] http://google.github.io/incremental-dom/

Re: Preact, a fast 3k React alternative

#38
post #35
post #15

We don't need smaller frameworks, we need more modular frameworks. If the framework is modular you can take what you need, and replace the parts you don't like. I'm using mercury [0] in my current frontend project for this purpose. Most of the features of React, none of the commitment. Every single component is interchangeable; the core repository is simply an index.js requiring other modules, which can be depended o…

Mercury fans always say this but I'm never seen anyone swap out random libraries it uses, like dom-delegator. Stuff is still made to be used together, you could swap out dom-delegator if your version had the exact same API, but then what would be the point.

When I ported my frontend to TypeScript I swapped out the whole observ* suite for my own typed observables. Sure, some of the components are too specific to replace trivially, but then those most likely aren't the ones you're interested in replacing.

Decomposing your code into modules is step one. Making the interface between your modules generic enough to easily replace is the next problem, but if your code is a monolithic blob in the first place that's not going to be possible.

My main issue with modularity in JavaScript is the lack of strict typing, because you won't know if your interface fits correctly until runtime - which is why I've been looking into TypeScript and Elm recently.

Re: Preact, a fast 3k React alternative

#39
post #36

Earlier quoted context omitted.

The question is whether that ~15 lines of code, written once, is worth the substantial increase in the surface area of the language, especially when overlapping so much with the existing prototypal inheritance mechanism. The choice to use Java/C++-style inheritance is a design pattern that doesn't necessarily reflect the only (or even the best) way to accomplish things.

ES6 classes do not use Java/C++ style inheritance, they are still the same as writing: function Foo() { } Foo.prototype = Object.create(Parent.prototype); .... It's just sugar, nothing more.

Being a C++ developer during the day and a web dev at night, this syntactic sugar is actually a breath of fresh air.

Re: Preact, a fast 3k React alternative

#40

Yeah, there's already a company called Preact. =] preact.com

A good one, too. The last startup I worked for was one of their first customers. You fire off events, they machine learn normal behaviour for your customers and feed the intel to your customer success team so you can prevent churn and identify your high-performing customers.
Post reply on HN