1

With the danger of fragmentation due to the fork in Node, how can I make sure a "Node" project will run across both Node and its fork?

The hope is that they will join together again once Joyent and the creators of io.js resolve their differences but one cannot hope that this will definitely be the case. So as a node contributor it would make sense to bet on both options and having your codebase require less maintenance if the fork does become a long term one.

marco-fiset
  • 8,721
  • 9
  • 35
  • 46
Nikos
  • 129
  • 4
  • [Sharing your research helps everyone](http://meta.programmers.stackexchange.com/questions/6559/why-is-research-important). Tell us what you've tried and why it didn’t meet your needs. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer. Also see [ask] – gnat Jan 14 '15 at 14:53
  • @gnat I havn't used io yet and don't intend to unless I'm required to support it. I don't have research yet on what appears to be a moving target unless you use it. I want to hear from those that have to support both. – Nikos Jan 14 '15 at 15:27
  • 3
    I don't think anyone other than the maintainers of those projects can provide an answer to this question, and even that is doubtful. –  Jan 14 '15 at 16:39
  • @Snowman can you create a tag for io.js? – Nikos Jan 15 '15 at 15:33

2 Answers2

9

The same way you always do when trying to make a program "platform independent":

  • you try to use only features available on both platforms

  • you provide different implementations for functions where this not possible, and switch between the implementation by detecting which platform you are using

  • and the most important step: you test it on both platforms

Doc Brown
  • 199,015
  • 33
  • 367
  • 565
0

The likely problem is if you adopt IOjs your code (if you are using newer features) will only work there. It will not work on node (v10x)...unless you stick to es5.

chovy
  • 117
  • 2
  • I am not following how this answers the question from the OP: how do I make sure the code will run in both projects? – Adam Zuckerman Jan 15 '15 at 00:36
  • As I said. Use es5 only. – chovy Jan 15 '15 at 01:23
  • 1
    Are you saying to use EcmaScript 5? If so, I think you might have missed the point of the question. – Adam Zuckerman Jan 15 '15 at 01:51
  • @AdamZuckerman why do you think that? The question was how to ensure a project will run on both forks, this answer suggests sticking with ES5. Assuming the major difference between forks is the supported edition of ES, this does seem like the most likely problem someone might encounter for now. More fragmentation could happen down the road of course, but this answer identifies the *most likely problem right now* based on the major difference in the forks. – Hey Jan 15 '15 at 02:24
  • So your answer is to use the language that the framework was written in to insure compatibility with the two frameworks? The question from the OP is asking about keeping their code compatible with both frameworks by making calls to the two different frameworks as if they are the same, not about the choice of language. – Adam Zuckerman Jan 15 '15 at 02:50
  • @AdamZuckerman was that comment addressed to me? I don't know what frameworks you're referring to; nobody else here has mentioned any frameworks. I also don't know what you mean by "choice of language." Do you consider ES5 and ES6 to be two different languages? The point of this answer is that if no ES6-specific features are used, both host environments should behave the same way, assuming the critical difference between the host environments is the supported edition of ES. – Hey Jan 15 '15 at 06:31
  • 2
    @Hey: "nobody else here has mentioned any frameworks" - nobody but the OP in the headline of the question? I give you a hint - http://readwrite.com/2015/01/13/io-js-fork-node-js-version-1-0 – Doc Brown Jan 15 '15 at 07:38
  • @DocBrown so we're calling Node a *framework* now? Seems like a bit of a stretch. Express is a framework, Koa is a framework, Flatiron is a framework. I have *never* seen Node called a "framework" outside of the comments above and the article you just linked. Node is a *platform* on top of which frameworks are built. – Hey Jan 15 '15 at 08:46
  • This isn't just splitting hairs either. To suggest Node is a framework and then go on to talk about "the language that the framework was written in," as if the host environment itself were written in JS, suggests those comments are pretty misguided. – Hey Jan 15 '15 at 08:51
  • 1
    @Hey: the term (as many other terms in software development) is not used strictly used. I think it is pretty clear what AdamZuckerman meant in his comment. So can you confer that the *only* difference between IO.js and Node.js is the version of the programming language (es6 instead of es5)? From looking at the changelog of IO.js, I was under the impression there were some other differences level of the provided libraries or modules. – Doc Brown Jan 15 '15 at 08:55
  • @DocBrown I haven't been keeping up with io, but my understanding was that they plan on submitting new features back to Node for inclusion. Naturally the projects might grow apart. At this stage in the game I think this answer is accurate. It doesn't say the *only* problem is the discrepancy between ES editions, it just says that's the *likely* problem. It doesn't say if you only use ES5 features your code will definitely work in Node, it just says if you use features that are not in ES5, they won't work there. It might not be a spectacular answer, but I don't think it misses the point. – Hey Jan 15 '15 at 09:16
  • Also, I don't think it's at all clear what AdamZuckerman meant by his last comment. "So your answer is to use the language that the framework was written in to insure compatibility with the two frameworks?" <- this makes no sense to me, sorry. That's why I asked for clarification. – Hey Jan 15 '15 at 09:27
  • @Hey, to use a car analogy, this would be like an auto maker splitting into two companies, where one company uses wheels with a 16" diameter and the other uses a 15" diameter. Wheel cover makers would have to make their covers in multiple sizes to accommodate both manufacturers. Chovy's comment was the equivalent of saying, "Use an air hammer to tighten the lug nuts." – Adam Zuckerman Jan 15 '15 at 15:39
  • 1
    @AdamZuckerman that analogy doesn't fit, though. It's more like they used to make 15" wheels, after the split, the newer company makes 15" and also 16" wheels. Chovy's answer is like saying stick with 15" wheels and you can still get them from both companies. – Hey Jan 15 '15 at 18:56
  • boy. if i knew i'd have created this much a !@#$ storm I'd have kept my mouth shut! – chovy Jan 15 '15 at 19:20