为什么不用kotlin

The world of software development has evidenced drastic changes in the development platforms and programming languages since 2010. A huge support for the mobile development community has been provided by the pioneer tech companies such as Google, Apple etc.

自2010年以来,软件开发领域已证明开发平台和编程语言发生了翻天覆地的变化。先锋技术公司(例如Google,Apple等)为移动开发社区提供了巨大的支持。

Demands of modern developers gave rise to the more powerful and more advanced high level programming languages like Kotlin and Swift. Every modern programming language tried to satisfy the requirements of developer in order to produce much faster, reliable and flexible software systems.

现代开发人员的需求催生了更强大,更高级的高级编程语言,例如Kotlin和Swift。 每种现代编程语言都试图满足开发人员的需求,以便生产出更快,更可靠和更灵活的软件系统。

Hence, the languages offer lots of similarities wrapped up in different flavours. As Iphones and Android smartphones has covered majority of the market. Kotlin (Android) and Swift (IOS) became the two highlights in the world of mobile development.

因此,这些语言提供了许多相似之处,并包含了不同的风味。 由于Iphones和Android智能手机已经覆盖了大部分市场。 Kotlin(Android)和Swift(IOS)成为移动开发领域的两个亮点。

Lets talk about how close the two famous programming languages are in design and detail.

让我们谈谈两种著名的编程语言在设计和细节上的接近程度。

可变分配 (VARIABLE ASSIGNMENT)

Both of them resembles each other in syntax. Swift uses let to initialize constants where as Kotlin uses val for the same purpose.

两者在语法上相似。 Swift使用let来初始化常量,就像Kotlin使用val一样。

Variables in Swift
Swift中的变量
Variables in Koltin
Koltin中的变量

条件声明 (CONDITIONAL STATEMENTS)

Conditional statements were introduced by E.W. Drijkistra as he felt the need to replace the classic go-to statement making the control flow much more readable. There after languages like C/C++ revolutionised the conditional statements. Now, Swift and Kotlin has offered much more simpler syntax.

EW Drijkistra提出了条件语句,因为他认为有必要替换经典 语句使控件流更具可读性。 之后,诸如C / C ++之类的语言彻底改变了条件语句。 现在,Swift和Kotlin提供了更简单的语法。

如果别的 (IF-ELSE)

if-else in Swift
Swift中的if-else
if-else in Kotlin
如果在Kotlin

Unlike Kotlin, Swift offer intelligent syntax but allowing developers to eliminate the need to write Enum name while accessing its type.

与Kotlin不同,Swift提供了智能语法,但允许开发人员在访问Enum名称时无需编写Enum名称。

开关盒 (SWITCH- CASE)

switch-case in Swift
Swift中的开关盒
when conditional in Koltin
有条件的在Koltin

But on the other hand, Kotlin succeeds in offering conditional expression which can be very handy in reducing LOC (lines of code) and make code much more compact.

但是另一方面,Kotlin成功地提供了条件表达式,这在减少LOC(代码行)并使代码更加紧凑方面非常有用。

功能 (FUNCTIONS)

Degree of ease to write functions in any language gives you an idea of extent of simplicity of syntax. Both of the languages provide similar syntax for defining functions.

使用任何语言编写函数的容易程度使您对语法的简单程度有所了解。 两种语言都提供了用于定义函数的相似语法。

Functions in Swift
Swift中的函数

Unlike Java or C, functions in Kotlin and Swift are considered as first level citizens ie. they can be passed as an argument and can be returned from a block of code.

与Java或C不同,Kotlin和Swift中的函数被视为第一级公民。 它们可以作为参数传递,也可以从代码块中返回。

Functions in Kotlin
Kotlin中的功能

空安全操作员 (NULL SAFETY OPERATORS)

Both of the language offer null safety by allowing the users to create optional datatypes that can be nullable but should be unwrapped before invocation.

通过允许用户创建可选的数据类型,这两种语言都提供了空安全性,这些数据类型可以为空,但应在调用之前解开。

When we considering unwrapping of optionals, it can be done in two ways :

当我们考虑展开可选对象时,可以通过两种方式完成:

  1. Safe unwrapping ( ?. )安全展开(?。)
  2. Forced unwrapping ( !. )强制展开(!。)
Null safety in Kotlin
Kotlin的零安全

Swift offers two other types of unwrapping also

Swift还提供了其他两种类型的展开功能

3. Implicit unwrapping

3.隐式展开

4. Conditional unwrapping

4.有条件的展开

Null safety in Swift
Swift中的零安全

Such operators allow the developer to avoid NPE (NullPointerException) to a major extent and force the team of developers to code in a controlled manner.

这种运算符使开发人员可以在很大程度上避免NPE(NullPointerException)并迫使开发人员团队以受控方式进行编码。

封装 (ENCAPSULATION)

In designing softwares , developers majorly consider two kind of high level encapsulations :

在设计软件时,开发人员主要考虑两种高级封装:

  • Abstraction ( such as Abstract classes, Interfaces, Protocols )

    抽象(例如Abstract类,接口,协议 )

  • Concrete definition ( such as Classes, Structures )

    具体的定义(例如类,结构 )

摘要 (ABSTRACTION)

Interface and protocol are somewhat analogical in Kotlin and Swift respectively. Both of them offers standardisation in code design.

接口和协议分别在Kotlin和Swift中有点类推。 两者都提供了代码设计的标准化。

Interface in Kotlin
Kotlin中的界面
Protocol in Swift
Swift中的协议

In Swift, you can explicitly define the exposed setters getters for a property of protocol.

在Swift中,您可以为协议的属性显式定义暴露的setter获取器。

混凝土定义 (CONCRETE DEFINITION)

Classes and structures are used to wrap characteristics and behaviour together in order to replicate real world objects. Defining such concrete definitions is similar in both languages

类和结构用于将特征和行为包装在一起,以便复制现实世界的对象。 两种语言中定义此类具体定义的过程相似

Properties of OOPS (Object Oriented Programming) can be exploited using such encapsulations.

OOPS(面向对象编程)的属性可以使用此类封装加以利用。

Explaining such properties in detail is not relevant in this article. Hence, the most famous OOPS property ‘ Inheritance ‘ can describe the grammer of both the languages.

在本文中,详细解释此类属性并不重要。 因此,最著名的OOPS属性“ 继承”可以描述两种语言的语法。

Inheritance in Swift
Swift中的继承
Inheritance in Kotlin
Kotlin的继承

集合 (COLLECTIONS)

Developer spend 50% of their time in developing and using data structures in a language. Designer of any computer language keep this in mind that process of populating and consuming the data structures in any language should be versatile and offer as much functionality as possible.

开发人员将其50%的时间用于开发和使用一种语言的数据结构。 任何计算机语言的设计师都牢记这一点,即以任何一种语言填充和使用数据结构的过程都应该是通用的,并应提供尽可能多的功能。

Following snippets demonstrate the four fundamental operations CRUD over a standard data structure ‘ List ’ :

以下代码片段演示了对标准数据结构“ List ”的四个基本操作CRUD

  • Create

    çreate

  • Read

    [R EAD

  • Update

    更新

  • Delete

    d elete

Working with list in Swift
在Swift中使用列表
Working with list in Kotlin
在Kotlin中使用清单

Kotlin appears to offer much more operations over data structures if the developer can utilise Java streams in a right manner

如果开发人员可以正确地利用Java流,那么Kotlin似乎可以提供更多的数据结构操作

扩充功能 (EXTENSIONS)

Sometimes, developer need to extend the functionality by adding features to a certain existing structure. Kotlin and Swift take care of this requirement by adding extensions which enhance the project scalability to a large extent.

有时,开发人员需要通过向某些现有结构中添加功能来扩展功能。 Kotlin和Swift通过添加扩展来满足此要求,这些扩展可以在很大程度上增强项目的可伸缩性。

Extension in Kotlin
Kotlin扩展

Swift allows extension block rather than just methods which allows developers to add data variables and make extensions much more versatile.

Swift允许扩展块,而不仅仅是允许开发人员添加数据变量并使扩展更加通用的方法。

Extension in Swift
Swift中的扩展

先进的数据操作 (ADVANCED OPERATIONS ON DATA)

Various operations are generally performed over collection of data. Modern day language try to offer concise and powerful advanced operations that allow the developer to avoid iterating over the data explicitly by writing a chunk of code with nested loops. Such advanced operations are :

通常对数据收集执行各种操作。 现代语言尝试提供简洁而强大的高级操作,使开发人员可以通过编写带有嵌套循环的代码块来避免显式地遍历数据。 这样的高级操作是:

  • Filtering筛选
  • Sorting排序
  • Mapping制图
  • Reducing (Conversion)减少(转化)
Advanced operations in Swift
Swift中的高级操作
Advanced operations in Kotlin
Kotlin的高级运营

参考资料 (REFERENCES)

  • https://kotlinlang.org/docs/reference/

    https://kotlinlang.org/docs/reference/

  • https://swift.org/documentation/

    https://swift.org/documentation/

  • http://nilhcem.com/swift-is-like-kotlin/

    http://nilhcem.com/swift-is-like-kotlin/

结论 (CONCLUSION)

You can observe in few scenarios that Koltin offer a little more power to the developers to write much more concise code as it is designed few years after the Swift. Kotlin and Swift can be considered few of the most evolved programming languages that comprise of best features from languages like Javascript, C++, Java etc.

您可以在几种情况下观察到Koltin为开发人员提供了更多的功能,使其可以编写更多简洁的代码,因为它是在Swift之后的几年设计的。 Kotlin和Swift可以被认为是发展最快的编程语言中的少数几种,这些语言包含了Javascript,C ++,Java等语言的最佳功能。

Due to the similarity in syntactic structure, developers can migrate from Swift to Kotlin and vice versa in order to expand their domain of programming skills.

由于语法结构的相似性,开发人员可以从Swift迁移到Kotlin,反之亦然,以扩展他们的编程技能领域。

“ In a bigger picture, both languages are designed to have much similar syntax. It looks like the prototype for modern day high level programming languages have been defined which we can expect to observe in upcoming languages. “

“从更大的角度看,两种语言都设计为具有非常相似的语法。 看起来已经定义了现代高级编程语言的原型,我们可以期望在未来的语言中观察到它们。 “

If you have any suggestions, feel free to reach me on

如果您有任何建议,请随时与我联系

LINKEDIN : Mohit Malhotra

链接人 Mohit Malhotra

MAIL : Mohit Malhotra’s Inbox

邮件 Mohit Malhotra的收件箱

Thanks for reading.

谢谢阅读。

您还可以阅读 (YOU CAN ALSO READ)

* 使用新一代Java (* Working with New Generation of Java)

* 使用新一代Python (* Working with New Generation of Python)

* 有关C ++中动态多态的一切 (* Everything About Dynamic Polymorphism in C++)

翻译自: https://medium.com/swlh/why-kotlin-and-swift-are-siblings-fe2db11aab50

为什么不用kotlin


http://www.taodudu.cc/news/show-4406974.html

相关文章:

  • springCloud与它的好兄弟微服务
  • spring Cloud与它的好兄弟分布式
  • Conclusion for Inheritance and Object Oriented Design
  • C++进阶_Effective_C++第三版(六) 继承与面向对象设计 Inheritance and Object-Oriented Design
  • object-oriented javascript【目录】
  • Java SE 008 理解面向对象程序设计 (Inside Object Oriented Programming)
  • 【论文阅读】Oriented R-CNN for Object Detection
  • Java中 \n \f \r \t 含义
  • bamlss简介
  • 7-1 找第k小的数(反思),a++和++a的区别,运算符优先级,递归分制思想
  • STM32 学习笔记1-智能小车-基于PWM 调速 的电机设置
  • CodeForces 603C/604E Lieges of Legendre SG函数
  • Postgres安装及MIMIC IV数据库的载入(Windows 10)
  • 香港电影中的演员:F字头(持续更新中)
  • F#基础教程 定义mutable记录类型
  • 基础平台项目之集成Jquery.pagination.js实现分页
  • Lieges of Legendre CodeForces - 603C (博弈论,SG找规律)
  • Dubbo系列之微服务框架整合教程
  • Bootstrap系列之treeview实现菜单树
  • SpringBoot系列之配置文件占位符使用
  • Zxing系列之设置二维码图片背景透明教程
  • ctrl+c失效
  • java.lang.IllegalStateException: No value for key [DynamicDataSource@e5f43124] bound to thread
  • INTRODUCING F#
  • (附源码)ssm基于jsp高校选课系统 毕业设计 291627
  • 仿佛来自虚空,Grothendieck的故事2
  • Flutter 打包iOS包出现 ld: bitcode bundle could not be generated because
  • RHCE-8-管理变量和事实/任务控制
  • iOS12-Swift5-Xcode10 Buildtime错误:/xx/Pods/Target Support Files/Pods-xx/Pods-xx.d
  • csa作业

为什么不用kotlin_为什么Kotlin和斯威夫特是兄弟姐妹?相关推荐

  1. java中使用kotlin_在Kotlin中使用libGDX

    java中使用kotlin 最近,我一直在阅读有关不同语言的信息,以及它们可以为已经拥挤的软件开发人员带来什么,并且一种语言对我来说很突出:Kotlin. ( https://kotlinlang.o ...

  2. Android_Kotlin原生开发_认识Kotlin_了解Kotlin和JVM虚拟机关系_认识Kotlin的重要性_更强大的跨平台特性_不需要JVM虚拟机也可跨平台---Kotlin工作笔记001

    1.谷歌支持Kotlin作为android第一开发语言,因为java是已经被oracle收购了,可能会对Google收费. 2. 可以看到java语言写的android程序,实际上回编译成字节码,在j ...

  3. 详解操作系统之进程间通信 IPC (InterProcess Communication)

    进程间通信(IPC,Inter-Process Communication),指至少两个进程或线程间传送数据或信号的一些技术或方法. 进程是计算机系统分配资源的最小单位(严格说来是线程).每个进程都有 ...

  4. 苹果这一次太强硬!如果你的 App 拒绝支持这些技术,将在2020年4月30日后全面下架!...

    点击"开发者技术前线",选择"星标????" 在看|星标|留言,  真爱 来源 | 开发者技术前线 , 作者 | 开发者前线   编辑 | 可可 苹果近期在开发 ...

  5. java:数字转string 报空指针_超干货详解:kotlin(4) java转kotlin潜规则

    前言 以一个java老鸟的角度,如何去看 kotlin. Java源代码应该如何用Kotlin重构. 如何正确学习kotlin并且应用到实际开发中.本文将会探究. 本文分两大块,重难点和潜规则. 重难 ...

  6. java 可选参数_超干货详解:kotlin(4) java转kotlin潜规则

    往期推荐 如果面试时大家都说真话... 这400道面试题,决定了你去BAT还是TMD 前言 以一个java老鸟的角度,如何去看 kotlin. Java源代码应该如何用Kotlin重构. 如何正确学习 ...

  7. 《Kotlin项目实战开发》第5章 函数与函数式编程

    第5章 函数与函数式编程 凡此变数中函彼变数者,则此为彼之函数. ( 李善兰<代数学>) 函数式编程语言最重要的基础是λ演算(lambda calculus),而且λ演算的函数可以传入函数 ...

  8. MVVM+ViewBinding+Kotlin入门

    本篇博客不作原理性分析,仅对还没有接触过MVVM,viewbinding,甚至说是kotlin的同学一个入门练习项目,通过此篇博客,可以对MVVM架构,以及最近比较火的ViewBinding有一个初步 ...

  9. kotlin学习教程

    kotlin的方法 可以直接调用 不用 new? 2.kotlin关于字符串 用 $拼接变量 3.kotlin 类 方法 变量 可以同级的,同级的 方法 和 变量(常量) 是 生成了 一个新的 xxx ...

最新文章

  1. GROMACS运行参数之md.mdp文件详解
  2. 基于SSM实现网上购物商城系统
  3. Gamma阶段项目展示
  4. 使用CSDN的Markdown编辑器
  5. 项目管理过程组和知识领域 简介重点记忆
  6. 解决nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
  7. 关于单元测试的思考--Asp.Net Core单元测试最佳实践
  8. 【转】深度解析 Qt 中动态链接库
  9. 我是怎么找电子书的?
  10. 简单谈谈MySQL优化利器-慢查询
  11. MYSQL数据库管理与应用
  12. easyar no matched package name
  13. excel转tsv格式
  14. 32位eclipse使用64位jdk问题
  15. 20 多个国外优秀Android开源 App
  16. 关于《奇点临近》读后的总结与感想
  17. 字符串切片反转字符串_如何反转字符串
  18. mysql 报错1366
  19. 计算机专业英语BD,计算机专业英语
  20. 可视化网盘系统的设计与实现过程记录

热门文章

  1. HTML-浮动(float)
  2. 重学C++笔记之(十三)友元、异常和其他
  3. laravel 5.3 更换语言包
  4. PL_SQL模块学习之十六、记录
  5. 高一到高三计算机笔记,高一到高三学习计划
  6. Comparator.comparing的使用
  7. Linux各种安装软件包的方式
  8. 了解HTML标记语言
  9. 谈谈Android里的Context的使用!!!
  10. 数据库索引结构(方法),一张图搞懂MySQL索引