My first main language was Java. However, over the years I’ve dropped Java in favor for Python, JavaScript, bash, etc. I still have advanced reading knowledge of Java, but since I haven’t coded in it for so long, my writing knowledge is intermediate at most. The other day, while looking at some old code written in Java, I got inspiration to re-write it as a learning experience to reacquaint myself.
It was at that point that I stopped to think that if I wrote this in Java, it would be nice, but when the renewed inspiration had hit me, I wanted to implement it as a web app (it was a game), so other people could play it.
So now here’s the dilemma: Do I re-write (and heavily refactor) the code I’ve previously written in Java, and then in JavaScript (for the web version), or do I just forget about Java altogether and re-write it in JavaScript?
EDIT: I have no problem writing in Java first and then JavaScript, but I’m more likely than not going to need Java anymore for a long while. What I’m trying to ask is whether or not I should rewrite the old code in Java first, to practice a skill I may not need in the future. The actual languages are less important than that question.
6
Consider your end result – an online game, written in JavaScript.
As such, by all means, take inspiration from your old codebase and plan ahead.
The way I would approach this would be to figure out what refactoring I would do and use both the old codebase and the refactoring plan as a blueprint for a new codebase using JavaScript.
My point is that if you are going to refactor to Java, then directly port to JavaScript, you will hit problems when porting from Java to JavaScript (idioms, how the different environmentw work, assumptions not relevant to Java etc…). Ditching the intermediary step you know that the JavaScript will not be a direct port and will be already ahead in regards to issues with a direct port.
Since this is a personal project designed for your enjoyment, you should aim for that – you don’t have to refactor the whole codebase. If you start and feel that it is not constructive to your goals (rekindling the fun in programming), stop and go ahead with the re-write in JavaScript, without having done a whole lot of work that you find tedious.
6
Using an old language sounds all rosy; sometimes we almost have a nostalgic appreciation for languages we used earlier in our lives. Like a house we lived in when we were young. This is my analogy and answer.
The things that caused me to move out of my parents house when I was 18 aren’t easily remembered. But if I moved back in, the rosy appreciation and nostalgia would wear off quickly. I would remember the shower near my room with poor pressure. The limey poorly softened well water. The inability to bring a girl over without my dad engaging them in a philosophical expose about their purpose in life.
And just as a side note… Java is to you as PHP is to me. I also moved to Python. Using a tool you don’t HAVE to use causes your task to be missing a key component. I call it the “Bridge of Necessity”. This bridge caries us across rivers that we lack the courage, motivation, or ambition to cross ourselves. Always approach a project with a bridge of necessity. Often I make promises to friends like “In a week I will have this cool demo to show you”. This forces me to get off my ass and program the cool thing I was spouting off about or otherwise be a liar. You don’t want to be a liar do you, DO YOU?
🙂
1
Even if you don’t use the “old” language directly, you will always find practical uses of it, either indirectly (ideas used originally in that language pushed in newer languages) or directly (in the case of Java you can see already how many languages are built on top of the JVM and encourage interoperability with existing Java libraries — Scala, JRuby, Clojure, etc.). Using another JVM language means that you don’t even need to rewrite your code: Just reuse it and write only the new parts in your favorite language.