Pages

Thursday, May 12, 2022

Java

 


I still find it frustrating that what C lets you do with an array of structs requires something this:

ArrayList<ArgTypes> argumentList = new ArrayList<ArgTypes>();
argumentList.add(new ArgTypes("-f", ArgValueTypes.DOUBLE, feedRate)); 
argumentList.add(new ArgTypes("-xs", ArgValueTypes.DOUBLE, xStart));
argumentList.add(new ArgTypes("-xe", ArgValueTypes.DOUBLE, xEnd));
argumentList.add(new ArgTypes("-ys", ArgValueTypes.DOUBLE, yStart));
argumentList.add(new ArgTypes("-ye", ArgValueTypes.DOUBLE, yEnd));

You should not need to execute code for a static array.

And while it is profoundly type unsafe, I miss union.  Unsafe types are dangerous, but fun.

C has a small number of primitive types and operators and a swarm of library functions to do just about everything reasonable; Java has the NATO of classes that once you learn them can make the Galactic Empire run in fear 

1 comment:

  1. C# and Java are very similar languages, but C# has made constant improvements in this kind of syntactic sugar. It doesn't make the generated code work any better, but it does make it easier to write, read, and maintain.

    ReplyDelete