rawify/BitSet.js

Q: TypeScript Definition file?

Closed this issue · 4 comments

kabua commented

Do you have a TypeScript Definition file? If not, I have a good start on one.

Also, any plans on porting to TypeScript? If so (or not) my guys are thinking about porting it anyway. If they end up porting it, would you like a pull request?

I had a TypeScript definition file in the making, but wanted to add one to all of my projects at once - so I didn't finish it yet. What benefit are you expecting from porting the whole lib to TS instead of adding a definition file?

kabua commented

That's the exact same question I asked my guys. I got back "If we write everything with TypeScript, we should continue write everything with TypeScript, because otherwise it will be a mess in code and a lot of 'any' types in our typescript code. I believe that all this code is important, that's why I think we should continue use TypeScript everywhere, then we will be protected from ridiculous bugs"

I like TypeScript a lot actually, we are in the process of porting very important modules to it. In the process we have found some dumb bugs that somehow slipped through the cracks. However, I don't think the realized that you wrote it and there is an npm package for it. So I didn't see the need. I've just sent you a pull request that contains our current definition file - if you are interested.

PS. very useful utility class. Thanks for writing and maintaining it.

Cheers!

Thanks, I'm glad you like the library! :)

I totally agree with sticking to one language instead of making a mess of several languages and TS seems like a good fit these days. However, since TS is transpiled to JS and TS can use JS dependencies, I don't see the value of translating external libraries to a higher level to get it translated to JS again, other than the 'any'-type problems. But aren't they solved with the type definition file already? If not, that could be a good point, considering a TS version.

One last maybe abstract concern is that I spend a large amount of time optimizing the library for code-size and performance and am not sure if the TS transpiler can generate an equivalent quality. I use several hacks here and there but since they are all well tested, it's okay. In the end that's the purpose of a library, to make one thing as good as possible.

If you translate the library anyway and if the generated JS code is of a similar quality, I would consider adding your TS version.

Robert

kabua commented

I agree, if you already have good clean optimized JS code no need to port it. Just add a TS type def file and call it good.

For larger works, i.e. enterprise development, a typed based language has a better ROI.

There is an interesting parallel here, modern day languages like C#, Java and others follow the same pattern:
C# -> IL -> Machine code
Java -> IL -> Machine code.

And TypeScript is no different:
TS -> JS -> (C++ ->) Machine code.

Most people don't write in IL even though it is totally possible. Normally IL is used for ease of transportation from source machine to the run-time machine. IMHO, JavaScript is becoming more and more a IL language.