I'm trying to make a browser MMO game as a hobby project.
Currently, the server-side code is written in ASP.NET Core (this was not my choice; the game started as an academic project and the prof imposed C#), while browser-facing client-side code is written in (almost) vanilla JS¹.
While writing JS code I was sadly paying almost no attention to code quality and I soon found myself unable to work with my own client-side code. Adding simplest features or fixing simplest bugs was taking disproportional amounts of time and - when finally done - was making the whole code even more messy.
Now I know that in such cases the general piece of advice is to first make a working prototype and only then think about rewriting, but I allowed myself an exception for JS code, figuring out that I dug myself in such a deep hole that it would likely take less time to rewrite JS code from scratch than to try to work with it.
Still, I don't rewrite the whole JS code from scratch. Instead, whenever a need arises to make some adjustments to existing code, I try to cut a relatively large piece of code that contains the parts in need of adjustments, I rewrite this piece from scratch, append this work to the new, rewritten code, then put some bindings between the new and old code. This way, I hope, the new code will eventually take over the whole bulk of old code, so that only new code will exist. While this is a lot of work (each time I rewrite significantly more than strictly necessary to make X work), I think it is worth it because I hope that the new code, while imperfect, will at least prove to be manageable - and this is more than can be said about the old code.
OK, I'm done with the (longish) introduction, onto the actual question.
Since I am notoriously able to devote far less time to this hobby project than I'd like to, I did not manage to finish rewriting client-side code before ASP.NET Core 3.0 came out, and Blazor with it. Blazor is the new ASP.Net way to write client-side code.
Now I feel that my situation is kind of... awkward. I feel like it had been justifiable for me to use JS before Blazor came out, but once Blazor came, I should be using Blazor... I feel like my efforts to rewrite JS code in JS became obsolete even before I could finish this task!
Am I correct that it is important to use a consistent technological stack? Or is it fallacious of me?
Because, according to this thinking, I basically have 2 choices:
- Decide to continue using ASP and C# - then consistency demands to rewrite client-side code in Blazor;
- Decide to continue using JS - but then consistency demands that I no longer use ASP and C# for server-side development, instead I should rewrite server side code to Node.JS.
Both options require some very significant effort, perhaps more than they're worth it.
Well, there is a third option: Write any new client-side code in Blazor, while leaving old code intact until need arises to modify it.
But even now the bindings between old JS code and new JS code are, I feel, awkward and ugly: both bulks are significantly different architecturally, still there is much overlap with their responsibilities, so they have to call each other. The parts where new code must call or be called by old code are written in a way that is somewhat contrary with the whole design of new code, especially since both new and old code is - by design - written in such a way that hints this is a consistent module to manage the entirety of the website - but this is not true for neither old nor new code at the moment. But - I was willing to tolerate this situation for then, since - as I said - I hoped that new code would eventually capture and replace the entirety of old code.
Now to ask to port JS code to Blazor step-by-step is to ask that not two, but THREE such bulks of code should coexist, sharing their responsibilities, calling each other in counter-intuitive places, etc...
I feel between a rock and a hard place.
Or... Am I wrong that I want the technological stack to be concise? Maybe there's really nothing wrong in having server-side code in ASP .Net Core and C#, while having client-side code in vanilla JS?
¹ (that is: I use no framework like Angular, React, Vue, etc - not even JQuery). Reasons are: (1) I wanted to avoid being overwhelmed by the quantity of libraries, frameworks, etc to learn; (2) I thought that it would anyway be a sound idea to first learn JS and only then learn frameworks