Closed tsirlucas closed 6 years ago
First of all: Of course, there is a lot of work to do and I am grateful for any help.
This version of the compiler is relatively new and thus still missing language features that a TypeScript programmer might expect, especially strings, arrays and classes (no memory manager or stdlib except built-ins yet). Though, from a WebAssembly point of view, most of the low level operations are supported. Hence, while it should be possible to implement pretty much everything already, it's still more like writing WebAssembly than TypeScript. The compiler tests provide a first expression.
The approach I'm taking is to build everything from the bottom up, that is making sure that the basic building blocks required for the next more advanced building block work as expected. Ideal contributions at the current state would be either improving the compiler tests to uncover and ultimately fix more issues directly or, if that's too boring, to conduct experiments, uncovering issues as well.
Implementing new language features is possible as well, but, as usual, also requires internalizing large portions of the code. Other than that there are quite a few TODOs one could tackle.
Regarding JSON integration: Without working strings it won't be possible to create something that "just works" yet. What could be done, though, is to implement a JSON parser/serializer with the AssemblyScript subset in mind, well knowing that it might still take a while until it actually compiles. That's also what I'm doing with the compiler itself: I know I can't compile it to WebAssembly, yet, but I already can write code using AS notation and imagine how it all falls into place eventually, anticipating that there will be strings and arrays at some point.
Hope this helps to get a first impression. If you have any further questions, feel free to ask.
Just one more question:
Whats exactly the difference between this repo and the original one? I mean, would that JSON integration work with the old compiler?
I keep asking about the JSON integration because I'm trying to migrate a lib to AssemblyScript as experiment... I want to know what are the limitations and benefits in a real-world project today.
Anyway, thanks for the fast answer and great explanation!
The prototype compiler has some, though limited, support for strings. String (or more precisely: class) support there is based on linking your code with a memory management runtime compiled from C (basically dlmalloc) and requires manually free
ing no longer needed memory.
Other notable differences are that the prototype compiler is based on TypeScript (written in TypeScript), while this one here is standalone (written in "portable" AssemblyScript) so it can be compiled to WebAssembly eventually. In the new one I am avoiding using/linking with non-AssemblyScript code. The other issue from above has some thoughts on memory management in the new compiler.
At this point, JSON might not be an ideal test case. Something more compute-heavy might fit better, for example crypto (think bcrypt or similar).
Hey @dcodeIO, thanks again for the answer and explanation!
I'm actually migrating the elasticlunr library to AssemblyScript and it uses the JSON during the indexing process.
I will keep my research and maybe try to isolate the slower but simpler things and migrate them to AssemblyScript. I think this will help me understand how far along the project is and how should I start my studies over the compiler so that I'm able to contribute.
Closing this issue for now as it hasn't received any replies recently. Feel free to reopen it if necessary!
I don't know how the project is running and if you guys need help with anything, but I've noticed that there is some features in TS/JS that we do not have in AssemblyScript like the JSON parser and stringify. Is there some special reason or it's just because no one implemented it yet? I mean, I've read on an issue that you guys don't want to implement Array.push because you don't want to deal with dynamic arrays, etc.
What would be the best approach: Create a PR adding the feature or create a separated lib like a pollyfill?
I'm trying to study the project to understand how could I help, so a contribution guide and a list of what is needed would be nice.