WritheM / Wallace

https://plug.dj/writhem-radio
Other
4 stars 3 forks source link

Port to ES6/7 #56

Closed ylt closed 9 years ago

ylt commented 9 years ago

Typescript ES6 has nicer syntax in terms of it having classes, etc (that are part of es6) along with having types defined. This will reduce the possibility of accidental crash bugs and also is a better fit for documentation tools.

In my own testing I've found jsdoc rather bad and it seems unsuitable for a large projects structured like this, while languages such as Java have plenty of decent tools such as Doxygen, Javadoc, etc.. Javascript is loosely structured, and while the project has been kept to an almost object orientated level, there are a few places where it varies (i.e. plugin events are pretty bad).

Typescript ES6 will beneficial for both the documentation and structure as it'll enforce a clean structure and that types are part of the language and also actively enforced (so will match up with the docs). This is much more useful for documentation as what will work for the implementation should also work for the docs.

Another advantage will be the function decorators, intention is to use these for events as the current approach is fairly primitive. Think I've heard mentions of Sekshi doing this also. For regular events think these will probably will be done in a similar way to http://wiki.bukkit.org/Event_API_Reference#.40EventHandler, commands will be done via annotations also.

@EventHandler(priority = EventPriority.HIGHEST)
@CommandHandler(command = "kick", permission=Ranks.Bouncer)
ylt commented 9 years ago

Actually, fuck it.. Will continue using ecmascript as its more standard, and less hassle to get working in phpstorm.

Just will migrate to ES6 though

goto-bus-stop commented 9 years ago

Babel.js supports Decorators with --optional es7.decorators or --stage 1, which might look a little bit like https://github.com/welovekpop/SekshiBot/blob/annotations/src/modules/MediaStats.module.js#L170-L171 for example!

ylt commented 9 years ago

Yeah, was going to use babel :)