博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
你是远程控吗?
阅读量:7221 次
发布时间:2019-06-29

本文共 1933 字,大约阅读时间需要 6 分钟。

自从Kotlin 成为 Android 开发一级语言,Kotlin确实以其实用,高效赢得了海外很多公司和开发者的认可,比如Square的Jake大神一直在推Kotlin。Kotlin在国外至少有将近2年的应用生产环境的实践(非JetBrains内部实践应用)。在移动开发中,相比iOS程序员,Android程序员总是很幸运,因为我们有很多优秀好用的工具(Android Studio等),选用Kotlin,则是Google 为开发者提供高效的开发工具的一贯作风。

先来晒一晒Kotlin的几大特点:

Kotlin是静态类型编程语言,用于现代多平台应用,100%可与Java™和Android™互操作 [java] view plain copy

Kotlin是非常简介的编程语言

Create a POJO with getters, setters, equals(), hashCode(), toString() and copy() in a single line:

data class Customer(val name: String, val email: String, val company: String)

Or filter a list using a lambda expression:

val positiveNumbers = list.filter { it > 0 }

Want a singleton? Create an object:

object ThisIsASingleton {

val companyName: String = "JetBrains"
}

[java] view plain copy

Kotlin 很安全

Get rid of those pesky NullPointerExceptions, you know, The Billion Dollar Mistake

var output: String

output = null // Compilation error
Kotlin protects you from mistakenly operating on nullable types

val name: String? = null // Nullable type

println(name.length()) // Compilation error
And if you check a type is right, the compiler will auto-cast it for you

fun calculateTotal(obj: Any) {

if (obj is Invoice)
obj.calculateTotal()
}

[java] view plain copy

方便使用 兼容JVM上现有library

Use any existing library on the JVM, as there’s 100% compatibility, including SAM support.

import io.reactivex.Flowable

import io.reactivex.schedulers.Schedulers

Flowable

.fromCallable {
Thread.sleep(1000) // imitate expensive computation
"Done"
}
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.single())
.subscribe(::println, Throwable::printStackTrace)
Target either the JVM or JavaScript. Write code in Kotlin and decide where you want to deploy to

import kotlin.browser.window

fun onLoad() {

window.document.body!!.innerHTML += "
Hello, Kotlin!"
}

几篇社区的博文帮助大家更好的了解kotlin

那么问题来了

你是否已经开始使用准备使用Kotlin?

你觉得Kotlin与JAVA之间的区别有哪些,优势or缺点?

你觉得Kotlin会取代JAVA吗?

转载于:https://www.cnblogs.com/jzy996492849/p/6928908.html

你可能感兴趣的文章
Android 获取SDCard中某个目录下图片
查看>>
设置cookies第二天0点过期
查看>>
【转载】NIO客户端序列图
查看>>
poj_2709 贪心算法
查看>>
【程序员眼中的统计学(11)】卡方分布的应用
查看>>
文件夹工具类 - FolderUtils
查看>>
http://blog.csdn.net/huang_xw/article/details/7090173
查看>>
lua学习例子
查看>>
研究:印度气候变暖速度加剧 2040年或面临重灾
查看>>
python爬虫——爬取豆瓣TOP250电影
查看>>
C++与Rust操作裸指针的比较
查看>>
了解webpack-4.0版本(一)
查看>>
如何培养良好的编程风格
查看>>
Netty Channel源码分析
查看>>
基于 HTML5 WebGL 的 3D 机房
查看>>
Java编程——数据库两大神器:索引和锁
查看>>
springMvc学习笔记(2)
查看>>
吐槽Javascript系列二:数组中的splice和slice方法
查看>>
什么是Javascript函数节流?
查看>>
MQ框架的比较
查看>>