Kotlin真的会取代JAVA吗?

Kotlin真的会取代JAVA吗?原文链接Kotlin真的会取代JAVA吗?发布时间:2017-05-3113:36:061019人关注59人参与自从Kotlin成为Android开发一级语言,Kotlin确实以其实用,高效赢得了海外很多公司和开发者的认可,比如Square的Jake大神一直在推Kotlin。Kotli

大家好,欢迎来到IT知识分享网。Kotlin真的会取代JAVA吗?

原文链接

Kotlin真的会取代JAVA吗?

自从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

-hello Kotlin

-用Kotlin写Android程序

-使用Kotlin&Anko,扔掉XML开发Android应用

那么问题来了

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

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

你觉得Kotlin会取代JAVA吗?

 

原文链接

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/33542.html

(0)
上一篇 2023-12-16 21:00
下一篇 2023-12-17 11:45

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

关注微信