-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README-eof.md.template
16 lines (8 loc) · 2.92 KB
/
README-eof.md.template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
## what i learned while writing this project
I wrote this tool as part of relearning java; java8 is quite an improvement over the old java that i used to work with. It took me some time and practice to get used to java streams. I think that the streams library was very much inspired by Scala futures.
This tool uses the [asm library](https://asm.ow2.io/) to scan class files and to extract annotations. you need to pass an event listener object to the asm library that derives from an event abstract base class and not from an interface in order to specify the aspects that you want to process; now it turns out that java abstract classes are much more versatile than interfaces.
Overall i was surprised at the many changes in the java language that took place during the last decade. I think Scala is loosing a bit of it's edge over java as a result. Now it turns out that they got Kotlin nowadays as a better/functional java, and it sort of wins over Scala due to better interoperability with java: Android picked Kotlin as it's most favoured language, because they just can't switch easily to a newer Jdk and language version, whereas kotlin is adding many of the newer language features that were inspired by scala and its functional programming style, while still maintaining interoperability with existing libraries written in java.
On the downside: kotlin doesn't have a pattern matching feature similar to that in Scala; actually Scala copied this feature from OCaml. Kotlin doesn't have the implicite keyword, this I think is a win because implicit doesn't help to write more readable code.
Overall there are quite a lot of changes in JDK land. Some ten years ago Java seemed to be old and settled in its ways, now suddenly everything looks quite different - when I look at it after a ten years brake
Also I learned that Scala is adding a lot of type information into the bytecode, scala has a type system that has more features than java; this is done by adding its own annotation class: scala.reflect.ScalaSignature - the scala compiler uses this annotation to encode the scala signature in pickled form, so that the annotation value includes binary data. This is a bit of a hack that allows to make the scala language more expressive, as type information about the added features is pushed into this annotation, however it doesn't help with java interoperability. See [link](https://stackoverflow.com/questions/29267199/what-is-a-scalasignature). I think that's an interesting detail of the jdk language wars.
Also interesting that all the newer languages like Scala and Kotlin are all getting rid of Java primitive types like int and long; in both Scala and Kotlin everything is an object. Now this change apparentlty makes it impossible to have compact in memory data structures: without primitive types each class member becomes a reference to a different object! That would result in much more processor cache misses in stuff written in the newer jdk languages.