Introduction
I have build a super complex server and client structure in my spare time to serve image sharing between my family. And I have a drawing app which is rely heavely on web workers to boost the performance. Since I am a solo developer for all of this, communication and documentation is never a problem. Plain Javascript and webpack works really well. Until a point I have more and more API need to be designed and more and more different message needs to send to worker. How can I make this intuitive and straightforwared? I stopped and thinked about this problem? With my past experiences at Microsoft, I know C# and reflection really well, and Typescript decorator is the saver for this. After going through all more past experiences, I think there must have a better way to solve this. I decide to invent one for myself. I call it API-Anywhere. My ultimate goal is to treat API as a function(which it really is). I will explain it with more details.
Problems
- API Documentation (self explained)
- Async functions running somewhere - web worker, backend server or host app (mobile)
- API Parameter was constraint by interface
- Full IDE integration
- Easy to adopt
- Minimum refactoring
- Support partial migration
Typescript vs Javascript, which one is better?
I think there is nothing wrong with Javascript, though some people thought it is hard to master. Peosonaly, I would like to use Javascript to do the development because when I debug it, I want to see the same code at the break point.
While it has already been compromised by Babel run time generators. There are so many code generated to serve async/await magic.
Typescript is just a syntax sugar for us. We still need to master how javascript works overall and make better use of it.
Because I decide to refactor all my code with API Anywhere achitecture, that means some part of my code will transfer to Typescript. Because I like the idea of decorator which is similar to annotation in Java/C#.