[fpc-pascal] Food for thought - language string improvement

Graeme Geldenhuys mailinglists at geldenhuys.co.uk
Mon Jul 10 12:14:27 CEST 2017

On 2017-07-10 07:30, Michael Van Canneyt wrote:
> If that is all, on the language side, I am a happy man :)

I did mention that it was purposely a small list

> Let me give you a counter example why I think Java plainly sucks.
> I get very depressed when I see things like this:

You do realise that you don't have to write code like that. ;-) It's 
like me showing you bad examples of Object Pascal code - there are even 
dedicated websites that does just that. :-) Just because the language 
allows for such code, doesn't mean you have to write code like that.

Saying that, I personally agree that your code example is hard to read 
at first, and I simply try avoid writing Java code like that.

Some more examples of why I like Java.

* This language feature I disagreed with for many years, until I
recently understood how Java works. Defining local variables when and 
where you need them in the code. Read up on the scope of variables to 
understand  it fully, but local variables scope is based on code blocks. 
So if you define a new variable inside { and } - it is only valid inside 
that block. The IDEs fully support this obviously and wouldn't even 
suggest such variables (code completion) outside such code blocks.

* Targeting older Java versions, even though you are using a newer 
version to compile the code.

* String support, and more specifically, Unicode string support is a
breeze to understand and use.

* The backwards compatibility, to use 10-15 year old BOM class files
without the original source code. They simply just work - as if you just 
compiled them. On the flip side, both Eclipse and IDEA can decompile 
class files back to .java files too - and they do an impressive job at 
that (that's obviously more useful if the original class file code 
wasn't run through a obfuscater).

* Try/Catch blocks where you can catch multiple exception types - 
without needing nested code blocks like Object Pascal. You can even add 
a finally block in there too - again without nested blocks.

* I seem to have grasped Generics in Java much easier than in FPC or
Delphi. I don't fully know why that is. Maybe the syntax, more examples 
etc? Not sure.

This list just scratches the surface obviously. And then, like you 
mentioned, the absolute massive and very impressive supporting libraries 
and frameworks.


fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal

My public PGP key:  http://tinyurl.com/graeme-pgp

More information about the fpc-pascal mailing list