Where I think Meteor is doing wrong with Blaze

haha, thanks and cheers mate

yea, people are working on it. Make a Blaze Components interface that can also transpile to react. We don’t need to wait around for MDG for anything. Blaze Components by @mitar basically is the interface, plus a few tweaks. And @timbrandin is already working on tools to transpile Blaze as it is. I outlined the plan in depth above. But here it is again:

We’ll have our own extremely thin wrapper over React that modifies React ever so slightly so you call: this.props('key') instead of this.props.key (Blaze Components will share the same interface)–that way the same code in Blaze can call a reactive function under the hood; and in React, the former simply calls the latter under the hood. And obviously, that’s just one example of the things that must be done, but it exemplifies the idea.

That’s my proposal at least, and I’m currently working on it (along with a matching Flux clone [based on Alt] that can similarly work with either underlying renderer). Any ideas are welcome; I’ll share my work when when I have some.

I appreciate the work you are clearly putting in, and I hope you find some way to make it financially viable for you to maintain your solution so people can depend on it long term. So don’t get me wrong but the first word in your response should not have been yes.

This thread was started by @mitar and in my opinion his original post was not primarily about finding practical solutions for keeping Blaze moving forward (clearly he wrote Blaze components without MDG). It was primarily about the erosion of trust by effectively dropping development of a core piece of their tech stack. That trust has now been eroded even further because the community has raised the concern but hasn’t been able to get any official response on it for over 16 days. At this point I think whitehouse.gov needs less attention on a topic to get an official response from the fricken president than we need to get a official response from MDG.

10 Likes

I wholeheartedly agree with mitar. I myself was attracted to Meteor because it claimed to be a platform where all the pieces to build things were there, rather than being another Frankenstein project assembled from multiple open source projects. I’ll be the first to leave if MDG loses its vision.

2 Likes

@arnpham as somebody building and maintaining a Blaze production app I share your frustration. However, I am hopeful about Meteor embracing more external technologies (react, npm, webpack, etc.)

The JS world is changing at a dizzying pace, and as an individual it feels impossible to keep up with all the new technologies as they roll out in rapid succession. MDG is a well-funded, insanely smart group whose full-time job it is to stay on top of the changes and curate them all into a convenient, performant, reliable, and coherent platform.

Meteor 1.0/1.1 shows that they have great taste. 1.2 shows that they are adapting to the shifting landscape (perhaps not quickly enough). All of it—from Blaze to DDP to Galaxy—shows that they they have the muscle to go deep and build out any piece they need to in order to uphold their vision.

If 1.3 and beyond can thread the needle of incorporating new technologies without leaving existing users completely in the cold, I think it will be a real achievement. In that light it doesn’t surprise me that MDG is taking their time to figure out thoughtful response.

3 Likes

I guess I don’t see the problem with having more choice in view layers. Could you elaborate more on this? I feel like i’m missing a valid viewpoint.

My outlook is that having 2 view libraries to choose from means you’ll have more packages in atmosphere. One might be for Blaze UI’s and another might be for React UIs.

For the packages that do things other than views… for example a Router, the package author just needs to de-couple the view from what they’re doing. FlowRouter and simple:rest are a great examples of decoupled packages!

The next version of Autoforms could do this too by building the core that is ignorant to the kind of UI then create two adapters for each view library. Then you end up with modular packages like autoform-core, autoform-adapter-react, autoform-adapter-blaze.

To make the user experience better provide a wrapper package like autoform-react and autoform-blaze to make installing these easier (as it could require many sub packages).

I honestly think the choice of view layers will strengthen the community by forcing developers to think modular and build composable packages going forward.

4 Likes

I love where you’re going with this. Meteor packages will need to decouple themselves away from the presentation layer. It is clear that Meteor is moving towards a “pick your own presentation layer” paradigm. If the community doesn’t abstract packages from their presentation logic, then we will be drawing lines between sets of packages that we can and can’t use.

For autoform, @aldeed has already said that React support is not on the roadmap. He doesn’t seem to convinced that people will stick with React. Fortunately, since collection2 and simpleschema are cleanly abstracted from the presentation layer, and the majority of autoform is Blaze templates, it could be easily ported to React (with enough time and resources). But then you’d also have to port all the autoform add-ons written in Blaze.

2 Likes

Also once we get SQL support we’ll have a similar issue with persistence layers. A popular pattern to solve this is the Repository pattern. So for example if a package wanted to add a ‘Post’ then the package could just use Repo.insert('post', {title: 'foo'}) and then an adapter layer could handle what an ‘insert’ is in the DB you’re using (like Mongo, Rethink, Postgres,).

I’m working on a ‘rails-like’ opinionated library (of several small packages) for doing a REST API in Meteor and it has a similar concept of repositories.

1 Like

I actually think it’s pretty likely a lot of people will stick with React, but autoform is currently tightly coupled with Blaze so I’d rather see a new package for the React version of autoform. And also I would not rule out something else springing up unexpectedly and displacing React. It is still the wild west of UI components.

7 Likes

Why you’re looking to React only? How about upcoming Angular2?
React, React, React… Why only React?
I just played with Angular2 a few weeks ago and I feel that we will have another portion of hype when new Angular will be production ready. Also for me to move to Angular2 from Blaze looks as much easier solution than to move into React. It’s actually closer to what Blaze2 was supposed to be, isn’t it? @Urigo, what’s your opinion about that?

Why you don’t care about your early adopters?
Many people who started with meteor year or two ago have already their apps up and running. There are many very popular packages e.g. autoform made by @aldeed which will not have React/Angular2 etc. support, so to move there from Blaze will be huge job.

Blaze is easy
@sashko, @dgreensp I think you should agree that to start with Blaze is much easier that with React. It also requires less code as well. So blaze is just awesome to start. And if somebody wants to add one or a few React components, Meteor already supports that.

So why to deprecate it?
There was many reasons already told and I feel that anyway for now main reason is that MDG at the moment don’t have enough resources to work on it. 20M wasn’t given to them for thank you, investors are actually waiting for return on investment, so concentration on Galaxy is totally understandable. I just don’t think that to go easy(?) way and deprecate Blaze instead of make it better is right solution.

I do have some experience with React. I use it in one medium size Django project. I also used to play with React in a few small Meteor apps and thinking about React in new bigger one. But the main reason is not because I love React. Sure, React is good piece of software, I just don’t like their approach and Blaze feels more natural for me.

What I miss in Blaze:

  • State. In our team we even had to implement our own state solution (using reactive vars and stuff).
  • Arguments to templates. We really needed them for our components and had to cheat putting data into @context and passing arguments directly into template data context: +myComponent context=event arg1="abc" arg2="some_arg". Each template then starting with {{#with context}}. Not so elegant solution :confused:
  • OO style component model. Yes, it’s something @mitar is trying to add into Blaze with his BlazeComponents, but to have this out of the box would be really awesome.

I like @slava position on this topic:

I still find Blaze to be much faster to write code in. I do think though, Blaze has too many weird concepts that were mixed together due to the legacy to Handlebars.

It is important to remember that Meteor had many UI front-ends: LiveTemplates, LiveUI, Spark, Blaze. At first, they were a more “dynamic” use of Handlebars library. Since then, Blaze was completely rewritten and there is nothing left from Handlebars other than the weird syntax and semantics: dynamic and overriding data context, no arguments to templates, no OO component model, weird interactions with the this variable in Template helpers, that leads to yet another thing Template.current() which exists only because the data context access is borrowed from Handlebars.

I think Blaze2, if it happens, would need to be cleaned up and be backwards incompatible. I would be excited for a better components model and a more structured way to interact with the scoped variables.

Source: https://crater.io/posts/biSDc8kgfvqqFMa4M/ama-with-slava-kim-august-18th-at-1pm-edt-10am-pdt

For me, if 3 things I mentioned earlier will be solved, Blaze becomes default solution for any size of Meteor projects. And if Blaze additionally would support event handlers directly in template (as React and Angular2 do) that would be totally awesome.

P.S. I really like that MDG made big effort of separating core from blaze and now we can choose what to use Blaze, React or Angular.

2 Likes

This is really interesting. I would be curious to see if you gave both React and Blaze to a developer who has never used either… which would be harder to use. IMHO the one you’re most comfortable with is always easier.

The reason this stuck a chord was that i’ve not worked in Blaze for the last 8 months and I recently made a small chatroom app in Blaze and I awkwardly fumbled around trying to get data into it and to get a reactive quark working. This is mostly because i’ve been using React 5 days a week and have been thinking about the UI in a different way.

Just an observation. Perhaps Blaze isn’t really ‘that’ easy once you get past the hello world stuff?

4 Likes

State. In our team we even had to implement our own state solution (using reactive vars and stuff).
Arguments to templates. We really needed them for our components and had to cheat putting data into @context and passing arguments directly into template data context: +myComponent context=event arg1=“abc” arg2=“some_arg”. Each template then starting with {{#with context}}. Not so elegant solution :confused:
OO style component model. Yes, it’s something @mitar is trying to add into

I really think you’ve pretty much described the core advantages/features of React right there. Just sayin’

10 Likes

Well, you may not have to make a new package. I think “Sideburns,” which is now called “Blaze React” will impress:

I’ve been doin a lot of work on it along with @timbrandin, and things are looking good.

There are a lot of similarities between Blaze and React where it counts. And the path to resolving the differences is requiring less hacks than you would think. In addition, it’s gonna fit even more nicely with @mitar 's “Blaze Component” package (which is what people should have been using instead of Blaze for a long time now–side note: the conversation really should be Blaze Components vs React).

Anyway, anyone who would like to contribute, email me at james@faceyspacey.com. we need as much help as possible to get it done quickly, as it’s a side project for both of us (obviously).

2 Likes

I haven’t tried sideburns, but I’m aware of it. But the issue is not so much the handlebars template syntax as it is the component scope. I haven’t researched enough yet to be sure, but I think a bunch of the things that autoform does with dynamically inheriting and examining parent scope will break down if react is managing the component scope. Maybe it will take less work than I think, in which case great.

What scope are we talking about? Just data “scope” or “instance scope”? are you using just Template.parentData(level) or have your rolled your own solution to make an unofficial Template.parentInstance(level)?

It is. Here’s an example of a Template.parentData(level) method in React:

http://jsfiddle.net/v755xkxx/

Basically when the props of a parent component change, the entire child component is re-rendered as well, which means that if you have access to the parent component passed down via a prop, you can simply get the parent’s props, i.e:


<MyComponent parent={this}  />

var MyComponent = React.createClass({
  parentData: function(level) {
    var parentData = this.props;
    
    for(var i = 0; i < level && parentData.parent; i++) {
      parentData = parentData.parent.props;
    }
    
    return parentData;
  },
  render: function() {
    	return <div>{this.parentData(1).count}</div>;
  }
});

The “heuristics” don’t seem to be so fine-grained that it will figure out whether it needs to re-render a child component based on whether it passed down one of the props being accessed. So in the above example you won’t end up with the parent component’s count property having changed, but the child component still rendering the old value because it doesn’t know to update itself since it wasn’t passed count as a property. It doesn’t need it to be passed to itself to get a chance to re-render. And that seems to be the same story all the way up the chain.

However I’m still wary there could be edge case instances I’m missing. If anyone would be willing to point them out it would be awesome.

FINAL NOTE: there’s also a “context” feature React offers that’s lesser known, but that they plan to expand upon:

here’s a quick example:
http://jsfiddle.net/Ljpd0d0m

So that behaves a lot more like how context is passed down naturally in Blaze. In short, there’s a lot more similarities between React and Blaze than you might think. And there’s lots of ways to hook into React. I get the feeling that a lot of different view frameworks will end up using React under the hood, given it opens the doors to React Native and likely what will be the largest reactive component ecosystem of them all…Clojurescript’s Om already transpiles to React. You can use React in combination with Cycle.js, which is basically the purest functional reactive approach in plain javascript (i.e. without having to switch to a transpile-to-javascript language like Elm, Om, etc). So all these guys are using or able to use React as their renderer. While there is an order of magnitude more similarities with their already-functional approach and React–they can basically just render all components functionally as “dumb” components–I think with the various features such as “contexts” and ultimately what might be a less strict system under the hood than you might think, it will be possible for even Blaze to partake, and perhaps more importantly @mitar’s Blaze Components, which together will give Meteor/Blaze developers everything they are lusting after that React provides.

2 Likes

Very well put. Trust, reliability and incremental steps for the installed base make the product stronger.

2 Likes

For us it is: Consistency, predictability, trust, security, ease of use across multiple platforms

2 Likes

You are doing this already. Many of the tutorials and answers are already written for Angluar and React. It is already freezing :wink:

2 Likes

I can’t believe I was naive enough, one year ago, to choose Meteor and Blaze for my startup.

Now my application is so large and connected to Blaze through dependencies, I cannot upgrade to whatever UI tech is the flavor at the moment.

Blaze it seems now will never be upgraded/enhanced. And amazingly on something so important as the front end to our applications, MDG will not provide official guidance.

Now I’m stuck without Blaze upgrades/enhancements, stuck with what appears to be a dead end tech, and stuck with dead packages in some cases. This is a mess for the ones that actually have larger running production applications.

We trusted MDG; we trusted them to make the right technology choices and at least enhance/support it for a while. Some, like myself, have invested countless hours on Blaze, I’m sure others have too. I’ve bet my small company on Meteor and Blaze, and now we find (through anecdotal evidence) that Blaze is abandon-ware.

What was so awful about Blaze tech to make MDG turn it into abandon-ware? Why not continue investing Blaze tech as a hedge as something MDG can control? Does MDG not care about the needs and expectations of the users of their tech?

And what if Angular2 walks all over React when it arrives?

5 Likes