Java/Suckage: Difference between revisions
From charlesreid1
(Created page with "An enumeration of the things I don't like about Java. ==typing in general== Not necessarily Java-specific, but using a typed language is like wearing a stuffy outfit with a...") |
m (Replacing charlesreid1.com:3000 with git.charlesreid1.com) |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 8: | Line 8: | ||
Trying to do one of the simplest operations imaginable: given a set of integers, find a duplicate. | Trying to do one of the simplest operations imaginable: given a set of integers, find a duplicate. | ||
Link to code: https://git.charlesreid1.com/cs/java/src/master/arrays/find-dupes/FindOne.java | |||
To implement one of the solutions, you have to take the integers passed in and use them to access another array. | To implement one of the solutions, you have to take the integers passed in and use them to access another array. | ||
| Line 13: | Line 15: | ||
Oh, no. Java will have none of that. | Oh, no. Java will have none of that. | ||
* Problems begin with just the very act of initializing data. This is your first warning. | * Problems begin with just the very act of initializing data. This is your first warning. | ||
* Can we do | * Can we do Arrays.asList(1,2,3,3)? Nope. | ||
* Also, we can use generics | * Also, we can use generics <T> - but, not in a static context. | ||
* Also, we can define static methods that take a generic type | * Also, we can define static methods that take a generic type <T>. But no arrays T[]. | ||
* To way to initialize an all-zeros list of Integers. | * To way to initialize an all-zeros list of Integers. | ||
* No way to convert any primitive types to wrappers in one go. | * No way to convert any primitive types to wrappers in one go. | ||
* No way to convert from PT int[] to Object type Integer[] | * No way to convert from PT int[] to Object type Integer[] | ||
Java is like the language that keeps giving, and then saying, "but there's a catch." | |||
[[Category:Java]] | |||
Latest revision as of 03:33, 9 October 2019
An enumeration of the things I don't like about Java.
typing in general
Not necessarily Java-specific, but using a typed language is like wearing a stuffy outfit with a too-tight collar - the compiler.
generic object templating
Trying to do one of the simplest operations imaginable: given a set of integers, find a duplicate.
Link to code: https://git.charlesreid1.com/cs/java/src/master/arrays/find-dupes/FindOne.java
To implement one of the solutions, you have to take the integers passed in and use them to access another array.
Oh, no. Java will have none of that.
- Problems begin with just the very act of initializing data. This is your first warning.
- Can we do Arrays.asList(1,2,3,3)? Nope.
- Also, we can use generics <T> - but, not in a static context.
- Also, we can define static methods that take a generic type <T>. But no arrays T[].
- To way to initialize an all-zeros list of Integers.
- No way to convert any primitive types to wrappers in one go.
- No way to convert from PT int[] to Object type Integer[]
Java is like the language that keeps giving, and then saying, "but there's a catch."