We need to do a lot more to modernise; to get you to that world of cloud and microservices and serverless. Because the reality is EE is the bedrock of mission critical systems; it does power enterprise. And if we look at why it isn’t getting us there it is pretty self evident. Is it open? No, it’s a vendor consortium, last time I checked those aren’t that open. Is it nimble? Well is shipped four years ago, that’s not very fast. We’re going to change everything about this.
將來可以透過 Java EE 來開發免伺服器的雲端服務,不用依靠某廠商 (指的是 AWS?)
// Java 9 URL url = new URL("http://openjdk.java.net"); URLConnection conn = url.openConnection(); Scanner scanner = new Scanner(conn.getInputStream(), "UTF-8"); // Java 18.3 var url = new URL("http://openjdk.java.net"); var conn = url.openConnection(); var scanner = new Scanner(conn.getInputStream(), "UTF-8");
感覺這樣的寫法不是很好,沒有強型別的檢查:(學 javascript 的 ?)
URL url = new Scanner(conn.getInputStream(), "UTF-8"); //complier error
var url = new Scanner(conn.getInputStream(), "UTF-8"); //pass !?
開大絕:
Map<Integer,String> map = Map.of( //
1, "a", //
2, "b", //
3, "c", //
4, "d");
不過我覺得 Intellij 之後的 format 會支援 Map.of 吧
API 已經提供到 10 個 pair 的 of() overload 了,這還不夠嗎?
會放 10 個 pair 以上的 map literal ? 我覺得程式要 refactor 了
Much of the benefit of collection literals can be gained by providing library APIs for creating small collection instances, at significantly reduced cost and risk compared to changing the language. For example, the code to create a small Set instance might look like this:
之前 Sun 某個 Java 傳教士就曾在某個研討會投影片中靠北過了,反正他的大意就是「你們這些人總是覺得演化 Java 時這好哪好,其實才沒你們想的這麼簡單,我們要考慮的情況可多著嘞」…XD
之前有相關 JEP:
不在語法層級支援的原因可能是這一段吧:
In the past, there have been a few proposals floated to change the Java programming language to support collection literals. However, as is often the case with language features, no feature is as simple or as clean as one might first imagine, and so collection literals will not be appearing in the next version of Java.