rich

Would any of you care if I dropped TypeScript support from Phaser?

59 posts in this topic

This is a serious question. I have wasted an incredible amount of time due to my decision to use TypeScript, and the problems are still on-going. So I'm curious to know how much it would affect any of you? Do you actually benefit from it supporting TypeScript, or would you be happy enough just using JavaScript?

 

Update: 10th September. After a lot of thought and based on the stack of feedback on this forum I dropped building Phaser in TypeScript and started a rebuild in pure JavaScript. Progress has been fantastic and you can follow it all on the March Towards 1.0 thread in this forum.

Share this post


Link to post
Share on other sites

I told you right from the beginning you shouldn't use TypeScript for a open lib. I would be very happy to see Phaser being continued in "plain" JavaScript and may even drop in and participate a bit in the project.

Share this post


Link to post
Share on other sites

I know im new user but having typecript support was what made my mind to even try html5 development and go with phaser.

 

On the other hand as far as I see problems go often with new releases of typescript, but 0.83 is stable enough to not care about new typescript versions until they hit 1.0 mark and not break backwards compatibility.

 

Plain javascript is just terrible, awfull, horrifying and impossible to make anything worthwhile with. Its even going to be dropped from unity 3d in favour of c# so that says something.

Share this post


Link to post
Share on other sites

I'm not using TypeScript at all and can't wait to see Phaser 1.0, so I'm totally about dropping the support. It will be easier for me to dive in.

Share this post


Link to post
Share on other sites

I've not gotten around to even trying Typescript yet, so like a few others above I'd also be much more likely to try using Phaser if it was in plain Javascript instead of Typescript.

Share this post


Link to post
Share on other sites
I tested TypeScript only because of Phaser - but I did not like it at all (although the basic concept of the language itself is sweet).

 

So, I would not mind at all about Phaser being plain javascript only! 

 

However, I could imagine that this would be a huge step for you. Is the generated javascript code by typescript something you could continue to work with - or do you have to re-write parts of it ?

Share this post


Link to post
Share on other sites

Would you mind to explain how you wasted an incredible amount of time due to TypeScript?

 

I'm using it currently with pixi.js (I made some externs) and I'm in love. I've hesitated a lot with Haxe too. But don't see any reason why I would use pure JS for a complete framework like this!

Share this post


Link to post
Share on other sites

I have 2 projects near end made with Phaser TS. But to be honest I will probably port them to pure JS or CoffeeScript becouse TS starts to annoy me with its bugs and hacks you have to do to make it work (offtop: nodejs nad TS isn't a good couple  :angry:  )

Share this post


Link to post
Share on other sites

I was trying to adapt to typescript since it was a part of phaser and was pretty neat, but I can definitely forget about that if it meant 1.0 were to come even one day sooner.

So no, I wouldn't mind.

Share this post


Link to post
Share on other sites

I would mind a great deal if TS support was dropped from Phaser. I've made a few games with Phaser and had no problems with TS 0.8.3 so far. TS allows for so much more structure and organization and allows me to rapidly develop new games.

Share this post


Link to post
Share on other sites

rich - but what does it mean "to drop support for typescript"? You or someone else can still provide declaration files, and it will work like a charm with type script. Existing users may probably have to make some changes, but they should be reasonably small.

 

I am using CreateJS for my games. Declarations from definitelytyped work like a charm. Well, I had to change them every once in a while, but it was never a showstopper. Same about libs like jquery, node js bindings, etc.

 

As for using plan JS for open library, I bet this is better option. Despite all my love for Type Script, there are other language choices (plain JS, coffee script). Making library independent from them is good of course. And I agree that evolving nature of type script makes it moving target to maintain something for a long term. 

Share this post


Link to post
Share on other sites

Just to say that you never, ever HAD to use TypeScript in order to use Phaser. It has always been perfectly usable from both plain JavaScript and TS.

 

What I'm questioning is the decision to carry on building the framework using TS first. I would definitely still provide a definitions file for TS, so it won't make any real difference unless you were interested in extending the core framework.

Share this post


Link to post
Share on other sites

Just to say that you never, ever HAD to use TypeScript in order to use Phaser. It has always been perfectly usable from both plain JavaScript and TS.

 

What I'm questioning is the decision to carry on building the framework using TS first. I would definitely still provide a definitions file for TS, so it won't make any real difference unless you were interested in extending the core framework.

 

Then totally go with it, as constantly adjusting library to new version of typescript that breaks all your work - is pretty much harsh development cycle, and certainly not healthy.

Share this post


Link to post
Share on other sites

For those asking on twitter: Here is why I'm considering dropping building it in TypeScript:

 

1) It's bugged to hell. Sorry, but it just really is. 0.8.3 was the last stable version they released and even that is relatively easy to break, or get your Visual Studio configs in a mess with.

 

2) It makes integrating other 3rd party libraries considerably more work, as you have to either painstakingly create a lib.d.ts for them or convert them to TypeScript.

 

3) The generated JavaScript is ok and mercifully readable, but does contain quite a lot of redundant calls and hooks. It's also not very intelligent in the way it compiles. If you don't use say physics or particles it still compiles the whole frigging lot into your game anyway. I'd quite like a way to avoid this, but it does make the barrier to entry higher as well. Needs more thought (and no, requireJS isn't the answer, again the whole 'barrier' is there with it).

 

4) I love getters/setters, they make coding so much cleaner - but they also make it ES5 only, which means it dies horribly on IE8 or less. As Phaser is canvas only this doesn't matter too much (as canvas is IE9+) but part of me wishes it did work backwards as well. Maybe just wishful thinking though. The thought of not being able to do:

 

sprite.x = 100

 

.. and have x be a function that can update all kinds of properties in one sweep is really upsetting to me :)

 

5) Currently an un-proven concern; but I'm worried about the impact it may have using TS when trying to integrate with say Firefox OS or CocoonJS.

 

So anyway... these are my thoughts on it at the moment. Feel free to shoot them down / add to them.

Share this post


Link to post
Share on other sites

Plain javascript is just terrible, awfull, horrifying and impossible to make anything worthwhile with.

 

Please try to refrain from comments like this that have no basis in reality, this statement was barely true 15 years ago and is just false today.

 

 

 

@rich, I would be much more likely to contribute to Phaser if it was in JS instead of TypeScript, and I doubt I am the only one who shares that opinion.

Share this post


Link to post
Share on other sites

@rich, I would be much more likely to contribute to Phaser if it was in JS instead of TypeScript, and I doubt I am the only one who shares that opinion.

 

This is a very good point. Although I've been pleased with contributions so far I'm sure that would accelerate them.

Share this post


Link to post
Share on other sites

Then totally go with it, as constantly adjusting library to new version of typescript that breaks all your work - is pretty much harsh development cycle, and certainly not healthy.

I'd have to agree with this. As long as a definition file is included with the framework we can get the best of both worlds.

Share this post


Link to post
Share on other sites

If you can take the generated code and work with it, then you have little to lose. You main gain/lose some contributors. Once Typescript hits version 1.0 or whatever it needs to hit to get stable then you can start to gradually use it again, assuming the benefits are there for you/the project.

Share this post


Link to post
Share on other sites

I really don't see how 5 could be of an issue, given that it outputs normal JS. Can you give an example on "quite a lot of redundant calls and hooks"? Apart from constructor/inhertiance stuff, and arrow functions "this" propagation I haven't seen any big differences yet.

 

Also, Rich, just to make sure all pros/cons are discussed, can I suggest you give your list of reasons why you embraced TS in the first place? 

 

This is why I am building my next game in TS and like it so far (you are guilty with that, btw :) ):
0. If I don't like it, I can easily switch to plain JS. :) I can also give away just JS files to my customers, if they need it for API implementation or customization

1. Easier to write R8/Nitro friendly statically typed code. In the heat of the battle, it is easy to add property in wrong order. Or add hacky extra property and forget about it. 

2. Syntax sugar for classes, modules, interfaces, arrow functions. They are very common in my games, long raw JS syntax lowers my productivity.

3. Reasonably good compile-time dependencies between multiple JS files

 

However, I guess for library 1 is not so much of an issue, as it should be peer-reviewed and not made in the heat of the battle. 2 is subjective: JS people are less likely to contribute to TS, but TS/CoffeeScript guys are get used to the fact that libraries out there is in plain JS. Plus good IDE/editor will help with 2 a lot. And 3 is not unique to TS, for a library something else can be easily introduced.

Share this post


Link to post
Share on other sites

I think I would still build my games in TS. I'm just finding using it to build a library of any reasonable size such a pain in the ass. It was fine for the first few versions but has grown ever more complex. I'm having to write php scripts to rebuild my Visual Studio config files because VS gets in such a mess. I shouldn't have to be doing this! Also I'd love to swap back to use Sublime as it's a much better editor :)

 

However there are downsides too: I love the way you get all the power of ES5 but with 'clean' code. I love the static type compile checks, it catches all those "typo" and "parameter order" errors quickly (WHEN the compiler sodding works that is). Phaser is a pretty big library now, with a lot of dependencies and deep internal hooks - being able to dive into those via F12 in VS is a God-send. I won't get that sort of feature in Sublime and as much as I like WebStorms features, the interface is just so clunky I feel like I code at a snails pace using it.

 

I do wonder if perhaps the solution is to swap back to JS. I mean all the code is written, it won't take much to make that transition, and then use TS for my unit tests! Maybe I'll get the best of both worlds then. Or maybe I should just learn to use the Closure compiler properly :)

Share this post


Link to post
Share on other sites

Let me note one extra issue. IntelliJ Idea only supports 0.8.3, and will only get 0.9.x support in the next version. I assume WebStorm is the same. This definetely adds to the list of issues, I am switching to Visual Studio now. 

Share this post


Link to post
Share on other sites

I'm able to use TS 0.9.x with IntelliJ idea, no issue. Also why did you chose TypeScript over Haxe? Haxe isn't new as TypeScript, it should be more robust (however migrating project from Haxe 2.x to Haxe 3.x is a pain in the ass due to all the other libs you may use, I won't imagine if there were an AS4, finally thanks Adobe... but that's an other story).

Share this post


Link to post
Share on other sites

I'm able to use TS 0.9.x with IntelliJ idea, no issue. 

 

Well - you can edit things for sure and plug in the new compiler. But unless you are on EAP, only TS 0.8.3 syntax is supported in the current version (issue web-8250). This includes syntax highlight, underlining errors and many other features. You will have Idea complaining on bool vs boolean (#1 showstopper), on interfaces that extend classes, on new module import syntax. 

Share this post


Link to post
Share on other sites

@Rich : it's OK if you continue providing d.ts definitions :) as you said it'll make no difference.

my approach when building game engines is : if it have zero extenrnal dependencies or only depend on know libraries that have TS support => use TS

otherwise => use plain JS.

haden likes this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.