QWv3 – Dev blog 26

Send help! I’m currently stuck in compiler hell!

My original development plan was to produce the alpha version then move onto the warm-ups viewer then the editor mode stuff then, finally, the language strings editors. However, in a moment of law studies induced delirium (it’s the excuse I’m sticking with), I bypassed the warm-ups viewer and went onto the editor mode changes. This has caused me to be stuck in compiler hell for the past few months.

What is compiler hell?

When you write Java code it needs to be ‘compiled’. This means that there is a piece of software, called a compiler, that takes your code and converts it to a format that can be run by the Java ‘Runtime-Environment’ (JRE). Essentially it translates the code into a more digestible format. In theory this makes the code faster and easier to run. The main issue is that the JRE is ONLY able to run this digested format. It can’t take the normal code I produce and just ‘run it’ and, importantly, when you ‘compile’ the code, if it finds anything it doesn’t like it spits out an error, crosses it’s arms and then refuses to do anything else. Think of it as a 3 year old bouncer on the door to that fancy restaurant you really want to go to that won’t let you in unless everything about you is perfect.

The practical upshot of this is that if, like me, you are converting your code from one technology (Java Swing) to another (JavaFX) when you start making changes the compiler spits out a metric tonne of errors and you have to slowly and methodically grind your way through. Carefully fixing each one and hoping you haven’t got the fix wrong thus causing more errors.

I made a single line change yesterday and the error count jumped up from 384 to 566. The errors are also quite difficult to read, for example:

D:\development\github\quollwriterv3\src\main\java\com\quollwriter\ui\fx\components\Viewer.java:171: error: titleProperty() in Viewer cannot override titleProperty() in Stage
public StringProperty titleProperty ()
^
overridden method is final
D:\development\github\quollwriterv3\src\main\java\com\quollwriter\ui\fx\sidebars\EditorsSideBar.java:459: error: incompatible types: incompatible parameter types in lambda expression
() ->
^
D:\development\github\quollwriterv3\src\main\java\com\quollwriter\editors\ui\EditorProjectViewer.java:40: error: EditorProjectViewer is not abstract and does not override abstract method getMainSideBar() in AbstractViewer
public class EditorProjectViewer extends AbstractProjectViewer
^
D:\development\github\quollwriterv3\src\main\java\com\quollwriter\editors\ui\EditorProjectViewer.java:168: error: getMainSideBar() in EditorProjectViewer cannot override getMainSideBar() in AbstractViewer
public EditorProjectSideBar getMainSideBar ()
^
return type EditorProjectSideBar is not compatible with SideBar
D:\development\github\quollwriterv3\src\main\java\com\quollwriter\editors\ui\EditorProjectViewer.java:167: error: method does not override or implement a method from a supertype
@Override

And these are just some of the more intelligble ones, when you get into generics and functions the errors become even stranger. You get used to it after a while but it does make your head hurt after a few hours.

I haven’t had a ‘clean’ compile, i.e. zero errors, for over two months now. The number of errors was so unmanageable I’ve had to tell the compiler to only show ten at a time. I can then laboriously trudge my way through them, fixing a few then recompile, fix a few then recompile and on and on. Worse still some errors can hide other errors or fixing one error can lead to a slew of others appearing. In coding terms, it’s akin to cleaning the public toilets outside that dodgy kebab shop at 2 am while the patrons are busy using them.

But, I am getting there although things are compounded by the fact I have to also implement the existing functionality in JavaFX, this requires carefully examining the current code then translating it to the new paradigms (and having to do it all in my head since I don’t have reference pictures to call on).

Currently I’m at 304 errors in total, earlier I was at around 260. I’m not sure how long this visit to hell will go on for, hopefully not too much longer… I really hate compilers.

3 thoughts on “QWv3 – Dev blog 26

  1. alucardnoir

    “When you write Java code it needs to be ‘compiled’. ” And here I was, thinking all code not written in assembly needed to be compiled. I guess that’s why I’m not a programmer.

    1. Don’t get me started on compilers. The real problem with a compiler it is that it is there for the benefit of the platform designer you are writing the code for. It doesn’t help the code writer at all. Consider that most of the code that I’m currently wading my way through won’t actually be run for weeks or even months, or in some cases, at all. And you can’t be selective either, you can’t just focus on one part of the code at a time and ignore the rest because of dependencies. An example of code that doesn’t need to be compiled (before deployment) is Javascript and that is, arguably, the most successful programming language the world has ever seen. Compilers are needed, but not by the code writer. This is the reason why scripting-type languages such as Javascript are becoming more popular, the time I’m spending crossing my T’s and dotting my I’s for the Java compiler is time I could and should have been spending on functionality.

      1. alucardnoir

        The troll in me wants to yell: Everything should be written in ASSEMBLY then! The emotional side of me wants to yell: Everything should be written in C anyway. The rational side of me is though keeps getting hung up on: “This is the reason why scripting-type languages such as Javascript are becoming more popular, the time I’m spending crossing my T’s and dotting my I’s for the Java compiler **is time I could and should have been spending on functionality.”**

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: