PhaserEditor2D Posted September 20, 2017 Share Posted September 20, 2017 Hi, In Phaser Editor we are about to replace the current JavaScript intelli-sense engine by the one used by VSCode (Salsa). Salsa works well for JavaScript ES6 but for ES3 it lacks important features like type inference of prototype inheritance. But, is not the time to forget ES3 and start coding in ES6? If you want to target older browsers you can compile the ES6 code into ES3 just before to publish the game (as probably you are doing now to create the .min files), but in the meantime, you can code and test in ES6. ES6 is very nice for Phaser games development, especially when you want to create custom objects, like sprites, just compare these codes: ES6: class MySprite extends Phaser.Sprite { constructor(game) { super(game, "dude"); } update() { // custom behavior } } ES3: MySprite = function (game) { Phaser.Sprite.call(this, game, "dude"); } MySprite.prototype = Object.create(Phaser.Sprite.prototype); MySprite.prototype.constructor = MySprite; MySprite.prototyte.update = function () { // custom behavior } The ES6 code is way more clear and simple. Actually, the ES3 way is so confusing that probably I wrote it wrong ;-) Link to comment Share on other sites More sharing options...
pixelburp Posted September 20, 2017 Share Posted September 20, 2017 I use ES6 almost exclusively now, it's so much easier and more development friendly than all the hacky ways of the past. I'd suggest anyone serious about learning JS should lean towards ES6+ and let things like BabelJS handle the backwards compatability, rather than struggle with prehistoric JS versions. PhaserEditor2D 1 Link to comment Share on other sites More sharing options...
Skeptron Posted September 21, 2017 Share Posted September 21, 2017 I don't see any valid reason to stick with versions lesser than ES6 now. Even Phaser 3 has moved to it. PhaserEditor2D 1 Link to comment Share on other sites More sharing options...
8Observer8 Posted September 22, 2017 Share Posted September 22, 2017 You can use ES6 features by using TypeScript. It will be compiled to ES3 or ES5. VSCode is friendly with TypeScript. Phaser has build in support for TypeScript. PhaserEditor2D 1 Link to comment Share on other sites More sharing options...
msickle Posted September 22, 2017 Share Posted September 22, 2017 No one I know uses ES6 for any job. No one bothers learning it at all. So I also don't use it in hobby game coding. Just my take. Link to comment Share on other sites More sharing options...
pixelburp Posted September 22, 2017 Share Posted September 22, 2017 2 hours ago, 8Observer8 said: You can use ES6 features by using TypeScript. It will be compiled to ES3 or ES5. VSCode is friendly with TypeScript. Phaser has build in support for TypeScript. I've used TypeScript a little and while at first the typing was a great way to catch edge cases and enforce stricter code, the actual code became a bit of a mess to maintain, having to type evvvvvvverything. I think it's a bit excessive. I haven't looked at something like FlowJS, so dunno if that reduces the code smell but it seems quite popular ATM. 2 hours ago, Bobomite said: No one I know uses ES6 for any job. No one bothers learning it at all. So I also don't use it in hobby game coding. Just my take. Conversely, almost all the JS devs I know use ES6, and that seems to reflect in the broad trend with devs generally (see something like https://stateofjs.com/2016/flavors/ for last years trends; very interesting to see how Coffeescript has effectively died a death after briefly being championed for a while) TBH there's not a lot to 'learn' anyway, it's just an extension to the existing syntax to introduce saner & smarter options to how you code your applications or games. The "class" sytax alone is enough reason to start using it - the old way of doing JS classes is insanity. Equally, it's ridiculously easy to set up something like BabelJS or Browserify to convert your ES6 into whatever JS version you wish to support - TBH at this point, there's no good reason for any JS Dev not to learn ES6. Hobby coding is the perfect environment to learn these things too - no project deadlines or management pressure to interfere with a chance to properly upskill. I'd recommend it, because those not 'bothering' may find themselves struggling to stay relevant or hirible; not trying to sound harsh looking at the state of recruitment there's an increasing focus on devs familiar or experienced with ES5 => ES6 :-) PhaserEditor2D 1 Link to comment Share on other sites More sharing options...
PhaserEditor2D Posted September 22, 2017 Author Share Posted September 22, 2017 4 hours ago, 8Observer8 said: You can use ES6 features by using TypeScript. It will be compiled to ES3 or ES5. VSCode is friendly with TypeScript. Phaser has build in support for TypeScript. Yes, we are going to include TypeScript too, for those who prefer static type checking. Link to comment Share on other sites More sharing options...
nkholski Posted September 22, 2017 Share Posted September 22, 2017 I wouldn't do anything but very basic stuff without any kind of transpiler anymore, and I would definitely not do anything with phaser without it. Thanks to node and transpilers we don't have to think about browser compatibility or being stuck with aged standards. ES5 is valid ES6 and Typescript so there is nothing new to learn, just new possibilities. With babel or typescript you can focus on your codebase without any worries about deploying the code. Node and projects such as babel has (partly) liberated us from browser hell :-) The same goes for+ css and transpilers such as sass. PhaserEditor2D 1 Link to comment Share on other sites More sharing options...
Recommended Posts