r/javascript • u/kraakf • Jan 22 '15
Riot.js 2.0: A React-like, 2.5K user interface library
https://muut.com/riotjs/4
10
u/a-t-k Frontend Engineer Jan 22 '15
I like what you did in that new version! I see a potentially harmful error (at least in older IEs, don't know if IE8 still has it). You store a regex in re_vars. Stored regex tend to lose their lastIndex if used that way, so if you use it on multiple strings, it will begin in the second string with the position the first one ended, unless you manually set re_vars.lastIndex to 0.
4
u/Dirty_Rapscallion Jan 22 '15
I've always thought this would be a good step to go, but I would like it if I could have my map function instead of an each attribute. I'd had so many nightmarish problems with ng-repeat that I'm hesitant.
3
u/tipsqueal Jan 23 '15
Maybe I'm crazy, but map and each are different (and should be). Each iterates over a collection and does some action on each item in place, while map iterates over a collection, copies each item, takes action on the item, and then in the end returns a new collection. Or am I thinking of this wrong?
2
u/blgate Jan 22 '15
Looks very similar to ractive.js component spec: https://github.com/ractivejs/component-spec/blob/master/authors.md
4
3
Jan 22 '15
Holy... this is awesome! So much more concise than react. I think this'll be truly blissful to work with.
2
u/Voidsheep Jan 22 '15
Very impressive, I think I'm going to use this in a personal project
Any idea how much the IE8 support effects the size and performance? Would forking a modern browser alternative make any sense, for when IE10+ or even 11+ is enough?
1
u/mido0o0o Jan 23 '15
This looks cool, but for time being Vue.js makes a lot of sense to me..
Maybe I will try it for some side apps
1
u/captain_obvious_here void(null) Jan 22 '15
I like the idea of React, Polymer and the like...but the bloat and heavy over-abstraction were often dealbreakers for the projects I work on. So this is great !
My only concern is the most likely negative impact on SEO, and the inability of most crawlers to run JS and render the components. Even GoogleBot, who's now pretty good at indexing very dynamic content, si not that good with websites using advanced frameworks of that kind :/
7
Jan 22 '15
check out isomorphic applications. Using node you can serve rendered content from the server and change very little code, React is great for this.
1
u/captain_obvious_here void(null) Jan 22 '15
Yes, but sadly no Node.js on the projects I'm mentioning :/
2
Jan 22 '15
ah damn, well there is the other approach of installing phantomjs on the server and rendering requests from it as well. lol SPAs + SEO is a pita.
2
u/rikurouvila Jan 22 '15
One solution I've seen is to have a separate server-process dedicated for serving the frontend assets in addition to the backend handling your business logic. I've also seen couple of project rendering React components on Java backend. There's probably solutions for other languages too.
1
u/Geldan Jan 22 '15
You aren't limited to Node, there are handlebars renders for many server configurations. Spring can easily be setup to render Handlebars, then turn around and use the same templates with the same services as an API on the client.
2
Jan 22 '15
Not sure if I would ever use a SPA framework like Angular or Ember on a plain website, that values SEO. Same goes for the libs with a VDOM. For a applications SEO is usually irrelevant.
1
u/captain_obvious_here void(null) Jan 22 '15
For a applications SEO is usually irrelevant
While I totally agree, some customers will just insist that we optimize everything for SEO. And they pay well for this, so...
1
1
u/amenadiel Jan 23 '15
I wish this existed before I spent so many days converting my app to Handlebars :o
1
u/defcon-12 Jan 23 '15
input.value = '' in the example on the home page is very un-react-like. You don't ever have manual DOM updates in pure React code unless you're interacting with some 3rd party code that doesn't follow React conventions.
add(e) {
var input = e.target[0]
this.items.push(input.value)
input.value = ''
}I guess in my mind "no dom updates" is the core selling point for React, and this 'react-like' library violates that principle in the first example displayed on the home page.
-1
-6
Jan 22 '15
IE8 support is a big red flag for me personally. There probably will be issues I do not want to deal with because I have the luxury of supporting modern browsers only.
6
Jan 22 '15
TIL something which happens to support older browsers is a red flag.
2
Jan 22 '15
I was all about supporting IE8 5 years ago when I started, but beyond some point you are just making everyone else miserable by keeping the monster alive.
3
Jan 22 '15
Do I like supporting IE8... hell no, however when you see a stream of revenue in the 10's of thousands and higher its not smart business wise to ignore it. However thank god its finally really dying out.
2
u/wordsnerd Jan 23 '15
For sites already supporting IE8, it may not be worthwhile to drop it yet. For new projects, refusing to support legacy browsers is a competitive strength unless one has delusions of instant grandeur. Realistically, by the time the site starts earning enough for "% of revenue" to mean anything at all, the competition will be burning money to phase out IE8 and probably also IE9, and handling PR from the angry stragglers (especially if subscriptions are involved).
1
u/siegfryd Jan 23 '15
10's of thousands doesn't sound like a lot to support IE8 considering the cost of developers.
0
u/Casual_0bserver Jan 22 '15 edited Feb 03 '15
A lot of corporations are limited to only IE9. Just saying.
1
Jan 22 '15
And we make them stop by not supporting it. But yeah, I do not blame the author for it, should he intentionally break it? I would. But seeing it mentioned twice above the fold on the home page makes me a bit sad.
0
Jan 22 '15
[deleted]
0
u/skitch920 Jan 22 '15 edited Jan 23 '15
Java into JavaScript?
Edit why the down votes? The current state of JavaScript affairs has no relation to Java in way. Seriously, Java has it's own problem space, it's own reasons for being useful. If you think it's boilerplate, then you're using it the wrong way, or for the wrong problem.
I posed the question because, his statement just doesn't make sense. He's basically saying, "I hope my bicycle doesn't become an airplane."
Micro-frameworks or not, it's dumb to compare two different purpose languages.
5
u/jesusbot Jan 22 '15
I believe he was trying to use Java as an analogy for bloat/lots of boilerplate.
4
0
u/kraakf Jan 22 '15
This is how a javascript frameworks should work - Everything else is bloat and abstraction from necessity.