??????????Scala vs Java8
???????????? ???????[ 2015/5/27 13:44:30 ] ???????????????
??????????Lambda????????????硣????????????????????????????????????????????JVM??????????Scala??Groovy??Clojure????????????????????????С???????????Java 8??????????????????С?
????Lambda????????????????????JVM?????????????????????????JVM???????????????Lambda????????JVM????????????????????????OO?淶??????????????????????????Щ???????????μ???????????????
????????????????Lambda???????????Takipi???????Scala????????????ò????????Scala??????????????Java 8??????????????????Scala??Java????????Lambda??????????????????????????????????
????????????Щ???????д?????????Lambda??????????????????????б??????????????б??
????Java??
????List names = Arrays.asList("1"?? "2"?? "3");
????Stream lengths = names.stream().map(name -> name.length());
????Scala??
????val names = List("1"?? "2"?? "3")
????val lengths = names.map(name => name.length)
??????????????????????????????????????????
?????????Scala???
????????
????????? javap ???????Scala???????????.class?????????????????????????????????????????JVM??????е????????
????//???????????????У?JVM???????#2???????????????????map?????????
????aload_2
????????????????????????????????????????synthetic?????????????????????????Synthetic???????JVM???????????????????????????Lambda???????????????????????????????????????????????????????
????new myLambdas/Lambda1$$anonfun$1 //?????Lambda????
????dup //???????????
????//?????ù?????.????????????JVM???????????
????invokespecial myLambdas/Lambda1$$anonfun$1/()V
????//??????м???immutable.List CanBuildFrom???????ù??????????μ?list??????????Scala???????????????
????getstatic scala/collection/immutable/List$/MODULE$
????Lscala/collection/immutable/List$;
????invokevirtual scala/collection/immutable/List$/canBuildFrom()
????Lscala/collection/generic/CanBuildFrom;
????//???????????????Lambda???????????????ο??????map??????
????//?????????????????????????????????????????С?????????????????????map????????????
????//map???????????Lambda??????????????????????????list??
????invokevirtual scala/collection/immutable/List/map(Lscala/Function1;
????Lscala/collection/generic/CanBuildFrom;)Ljava/lang/Object;
??????????????Lambda????????????????飿
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11