delete this account! Posted October 13, 2017 Share Posted October 13, 2017 I'm just starting out with Phaser and not sure why I shouldn't use TS. It seems better to me. Not sure if there are any benefits over using JS. Link to comment Share on other sites More sharing options...
mattstyles Posted October 13, 2017 Share Posted October 13, 2017 There are many pros and cons of moving away from JS, the top-most of which should be that you are now writing source that your target platform can not execute, this adds complexity and that isn't always good. Off the top of my head I can think of a few others: * Writing TS may give you the illusion of safety i.e. if a codebase is littered with <any> declarations there may be an issue that authors don't understand how it works or, even worse, that they are using it as a loophole to circumvent typing in certain places * I fear way too many devs (as in, 1 developer is too many) are taking the approach, 'oh, I don't need to write unit tests as I am using TS', this is terrible. Don't be that person. * JS is a dynamic language, as such, you aren't constrained by a type system, maybe you like certain patterns that a type system prohibits. * TS adds complexity and will likely slow you down, this argument is easy to counter as you could argue that eventually it'll help you speed up when your codebase gets larger you'll be able to know the structure of objects and functions you're using at a glance, this documentation advantage is superb for a type system, although good commenting could get you to this point without the extra complexity * You might not like the transpiled output, maybe its slower for some things? * TS adds a whole level of pain when using other modules (interoperability, a big strength of JS is the availability of modules via things like npm) * TS has only recently added a dev mode that checks types at runtime, not sure how well this works yet but static type safety only gets you a little way to the point of writing safer code, to be truly valuable it should really be doing this at runtime (JS types can change at any point and thats a language feature, all you can do is try to check that they don't, some of this can be done statically but not all) * It is a potential barrier if you want other devs to work on your project * TS requires a build step, some people dont want this of JS development These are just a couple of cons to using TS and some are equally applicable to writing ESNext code too whilst some of these issues have been solved (i.e. the transpiled output will be excellent, it might be a little slower than a different solution but it will be very high quality; whilst it might be a barrier, it might also draw people in to your project). There are of course many pros to a type system too so I won't make a judgment on where I sit with whether I think its worth it for JS development, thats up to you. I wouldn't really consider one superior over the other (and you can add flow, or using esnext, or purescript or Elm or Haxe etc to that list too), it depends on what developers want out of their codebase and what they value when writing code. Link to comment Share on other sites More sharing options...
8Observer8 Posted October 14, 2017 Share Posted October 14, 2017 I is more difficult for me to make workflow for writing tdd-tests in TS + Gulp in VSCode. I have some problems with Sinon for making Mocks. It is very simple in JS. I spent a very long time for making workflow for build all TS script to one bunld.min.js. And for making breakpoints in client and node.js server in TS with Multi-target debugging in VSCode But I like TS because I like C#, C++ and Python. JS is difficult for me for learning because it does not look like other languages. I like compilation errors, unlike run-time errors. Link to comment Share on other sites More sharing options...
Recommended Posts