当前位置:网站首页>Understand kotlin from the perspective of an architect
Understand kotlin from the perspective of an architect
2022-07-05 12:09:00 【CrazyCodeBoy】
Kotlin summary
Kotlin It's a kind of Java Static type programming language running on virtual machine . It's mainly JetBrains The programming language developed by the development team . although Kotlin And Java Syntax is not compatible , but Kotlin Designed to be compatible with Java Code works with each other , And can be reused as Java Set framework, etc Java Referenced method library . It's easy stay Android Substitute... In the project Java Or the same Java Use it together .
Google stay 2019 Year of Google I/O It was announced at the meeting that Kotlin Be selected as Android Develop preferred language .
Kotlin There are many characteristics of :
- Simple and easy to use : Kotlin There are a lot of extensions available in , Make our code more concise , The developed framework is easier to use
- Security : Avoid errors of the whole class such as null pointer exceptions
- Interoperability : make the best of JVM、Android And the browser's existing library
- Tool friendly : You can use any Java IDE Or use the command line to build
Study Kotlin Meaning to architects Kotlin
Should I study now Kotlin Well ? And learning Kotlin What does it mean to architects ?
- Study at the right time : at present Kotlin Has become a Android The official preferred language for development , Now learn Kotlin It was at the right time ;
- Follow the trend , For the sake of the future : Now, all major Internet companies, including the first and second tier, are going Kotlin Turn up , Now learn Kotlin Not only to follow the trend , For the sake of the future ;
- Improve development efficiency : In terms of development efficiency Kotlin Development is better than Java Much higher ;
- Lead the team to carry out technological innovation : Improve the team's pursuit of cutting-edge technology and improve the team's technical atmosphere , Meet the small partner's needs ( money 、 grow up 、 platform ) The pursuit of growth ;
Kotlin Design concept
The above picture is from Kotlin The boss of the language design team Andrey Breslav stay 2018 year KotlinConf Speech at the meeting , It contains his right Kotlin Introduction of some design concepts , Interested students can search the full version of this video on the tubing .
stay KotlinConf 2018 At the conference Andrey Breslav According to the Kotlin Did not create some original design concepts that are not currently available or familiar to the public , It absorbs the essence of many other languages , And provide powerful IDE Support , It is really convenient for developers to apply it to practical projects .
- It is not only concise but also readable : Mainly refers to Kotlin Support hiding, such as getter、setter etc. Java Template code , And there are a large number of standard libraries and flexible overloading and extension mechanisms , Make the code more intuitive ;
The above figure is used respectively when setting the control click event Java and Kotlin The comparison of implementation , It can be seen that Kotlin The implementation saves some template code , It not only looks simple, but also allows developers to focus on the implementation of specific logic , More readable .
It is not only expressive but also reusable :Kotlin Some commonly used functions such as :Android Some extensions of are encapsulated into libraries , For the convenience of developers , In terms of reusability, it is better than Java It's worse than that ;
The pursuit of interoperability is greater than originality : Why do you say that , stay Kotlin The beginning of development , A lot of people think Kotlin Nothing more than from other languages copy Over here , I think so because you look like a higher-order function , Closure , Expand ,Lambda Expressions are not Kotlin Pioneering , From the existing language
From the past ;Kotlin The designer's idea is not to pursue originality , Instead, it pursues better interoperability ,Kotlin To surpass Java Must realize and Java Interworking of ( Interoperability ), Instead of starting a new stove .Powerful tools to support NPE Protection makes soundness stronger : Everybody knows Kotlin yes JetBrains Developed by our team , and JetBrains Also famous IntelliJ IDEA The author of , And we develop Android So AS It's also Google And JetBrains The product of cooperation , It can be said that in terms of tools AS by Kotlin Development Android It provides powerful support including compiler checking .
Kotlin Construction process
Above, Kotlin and Java Build process comparison :
- *kt Will be Kotlin The compiler program compiles into .class Bytecode file , And then filed into .jar, Finally, the final cause program is output by the packaging tools of each platform
- The picture above is not difficult to understand *kt It will eventually be compiled as Java Bytecode file , Then why do we need one in the last step Kotlin At runtime ? Presumably, many friends will have doubts about this
- This is because , We use it Java To write the program, all implementations will have Standards Java Class library to support , such as :
java.lang.*,java.util.*, but Kotlin The class library in is not standard Java Class library , therefore ,Kotlin The application needs to rely on Kotlin Run time to support these Java The standard class library has no implementation .
- This is because , We use it Java To write the program, all implementations will have Standards Java Class library to support , such as :
How to learn effectively
- First go through the above
Kotlin And Java Similarities and differencesYesKotlinI have an impression of the difference in - Follow this course Kotlin Explain and learn an article
- Make good use of tools (
A gentleman is not different , Good and false in things)- Official documents :https://kotlinlang.org/docs/reference/
- The ultimate tool : Make good use of AS Of
convert java file to kotlin fileTools - I know you Google
The ultimate tool (Practice)
If you encounter some code and don't know how to use Kotlin When it comes to implementation , Try the following tools :
public interface BrightnessListener {
String[] onViewBrightness(String... args);
}
Use the following steps to convert the above Java Document conversion Kotlin:
AS->Code->convert java file to kotlin file
Or copy the above code to kotlin Use... In documents AS The automatic conversion function of :
interface BrightnessListener {
fun onViewBrightness(vararg args: String?): Array<String?>?
}
Kotlin It can be understood as Java The grammar sugar of , We can use AS Provide tools to view us Kotlin Code Java Look like , in other words IDE We will Kotlin How does the code turn Java Code :
AS->Tools->Kotlin->Show kotln Bytecode
Reference resources
边栏推荐
- Linux Installation and deployment lamp (apache+mysql+php)
- Automated test lifecycle
- Redis cluster (master-slave) brain crack and solution
- 【yolov3损失函数】
- What is the difference between canvas and SVG?
- Network five whip
- Yolov5 target detection neural network -- calculation principle of loss function
- pytorch-softmax回归
- Principle of redis cluster mode
- 【yolov5.yaml解析】
猜你喜欢

Error modulenotfounderror: no module named 'cv2 aruco‘

Embedded software architecture design - message interaction

Redis集群(主从)脑裂及解决方案

石油化工企业安全生产智能化管控系统平台建设思考和建议

Sentinel sentinel mechanism of master automatic election in redis master-slave

简单解决redis cluster中从节点读取不了数据(error) MOVED

Matlab boundarymask function (find the boundary of the divided area)

Use and install RkNN toolkit Lite2 on itop-3568 development board NPU

codeforces每日5题(均1700)-第五天

Mongodb replica set
随机推荐
Pytorch MLP
Understanding the architecture type of mobile CPU
liunx禁ping 详解traceroute的不同用法
Want to ask, how to choose a securities firm? Is it safe to open an account online?
Why do you always fail in automated tests?
Codeforces Round #804 (Div. 2)
The most comprehensive new database in the whole network, multidimensional table platform inventory note, flowus, airtable, seatable, Vig table Vika, flying Book Multidimensional table, heipayun, Zhix
石油化工企业安全生产智能化管控系统平台建设思考和建议
【使用TensorRT通过ONNX部署Pytorch项目】
Mongodb replica set
JS for loop number exception
【云原生 | Kubernetes篇】Ingress案例实战(十三)
全网最全的新型数据库、多维表格平台盘点 Notion、FlowUs、Airtable、SeaTable、维格表 Vika、飞书多维表格、黑帕云、织信 Informat、语雀
跨平台(32bit和64bit)的 printf 格式符 %lld 输出64位的解决方式
Reading notes of growth hacker
【yolov5.yaml解析】
13. (map data) conversion between Baidu coordinate (bd09), national survey of China coordinate (Mars coordinate, gcj02), and WGS84 coordinate system
一次生产环境redis内存占用居高不下问题排查
手机 CPU 架构类型了解
redis的持久化机制原理


