Andrew Ducker (andrewducker) wrote,
Andrew Ducker
andrewducker

I am starting to understand why people loathe Java

In C# I can create a dictionary that has ints as keys and strings as the values. I can then look up the value of any string using the int key. Dead simple. If I want an array I can use something like myDictionary.Values.ToArray() and I get all of the values in a string[], because it knows what type everything is. That's what generics are _for_.

Providing I am using Java correctly, I'm creating a HashMap<long,string> (and it has to be a Long, because you can't use primitive types, for some bizarre reason), and then the "put" method does, indeed, mandate that I'm using a Long and a String, but the "get" takes an object, and the toArray returns an array of _objects_. What the fuck? What is the point of specifying types if the compiler is going to just ignore them?

I feel terribly spoiled by working with a language which does what you bloody well tell it to, rather than being a half-assed job to give you the appearance of doing something useful without finishing the job.



Original post on Dreamwidth - there are comment count unavailable comments there.
Subscribe

  • Interesting Links for 02-03-2021

    A journalist, the N word, and the New York Times (tags: journalism racism ) Tomahawk Steakhouse staff told to loan the firm 10% or they could…

  • Interesting Links for 01-03-2021

    A Decades-Long Quest Reveals New Details of Antimatter (tags: physics ) Which character from Hieronymus Bosch's Garden of Earthly Delights are…

  • Interesting Links for 28-02-2021

    Single Covid case puts New Zealand's largest city Auckland back into lockdown (tags: pandemic newzealand ) Do you like it when things in your…

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

  • 26 comments

  • Interesting Links for 02-03-2021

    A journalist, the N word, and the New York Times (tags: journalism racism ) Tomahawk Steakhouse staff told to loan the firm 10% or they could…

  • Interesting Links for 01-03-2021

    A Decades-Long Quest Reveals New Details of Antimatter (tags: physics ) Which character from Hieronymus Bosch's Garden of Earthly Delights are…

  • Interesting Links for 28-02-2021

    Single Covid case puts New Zealand's largest city Auckland back into lockdown (tags: pandemic newzealand ) Do you like it when things in your…