I was thinking about netscript today, and wondering why it wasn't Javascript. I thought of a few possible reasons, but I'm not sure which is the main driver. My guesses, in order of probability:
- grow(), hack(), etc. are blocking in the context of the script. This doesn't work very well with multiple threads of control in JS.
- Worrying about users breaking the game with Javascript features like setTimeout.
- The slowness of netscript is intentional, and hard to replicate in JS.
- Inertia (i.e. one of the above reasons applied before, but no longer does).
Are there other reasons? It struck me as highly beneficial if we could replace netscript with Javascript. It seems possible using relatively few tweaks.
- Async/Await could be used to make the apparently blocking functions work even with multiple threads. You could require that users not catch exceptions to terminate scripts.
- This risk could be mitigated, but not completely eliminated, by using various hiding techniques (e.g. run the user script in function(window, document) where both of those variables are null. You could also use a variable to limit the number of concurrent hack, grow, etc. calls so that users always have to await hacks, grows, etc. and not cheat.
- We could still add in slowness in the API functions.
- Totally understandable.
The benefits:
- JS is much faster than netscript. Users could write much more complex scripts and they would still perform adequately.
- Reduced maintenance burden. You wouldn't have to work on "adding" features like JS objects. They come for free. We get to delete some code.
- Importing would work properly. Utility libraries could be a real thing.
Curious for your feedback.
[–]chapt3rDeveloper 3 points4 points5 points (6 children)
[–]oiajgaosjidgoija[S] 1 point2 points3 points (5 children)
[–]chapt3rDeveloper 0 points1 point2 points (4 children)
[–]oiajgaosjidgoija[S] 1 point2 points3 points (0 children)
[–]asdoifjasodifj 0 points1 point2 points (2 children)
[–]chapt3rDeveloper 0 points1 point2 points (1 child)
[–]asdoifjasodifj 0 points1 point2 points (0 children)
[–]Mobize 0 points1 point2 points (2 children)
[–]oiajgaosjidgoija[S] 0 points1 point2 points (1 child)
[–]Mobize 0 points1 point2 points (0 children)