do we really need new languages?

26
QUALITY. PRODUCTIVITY. INNOVATION. endava.com Do we really need new languages? Moldova ICT Summit 2016

Upload: moldovaictsummit2016

Post on 15-Apr-2017

127 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Do we really need new languages?

QUALITY. PRODUCTIVITY. INNOVATION.

endava.com

Do we really need new languages?

Moldova ICT Summit 2016

Page 2: Do we really need new languages?

2

2

“Programs must be written for people to read, and only incidentally for machines to execute.”

Harold Abelson, SICP

Page 3: Do we really need new languages?

3

3

Evolution, beginning

QUALITY. PRODUCTIVITY. INNOVATION.

Machine language • Flat

Assembler • Procedural

C • Structural

C++/Java • OPP

Page 4: Do we really need new languages?

4

4

Evolution, beginning

QUALITY. PRODUCTIVITY. INNOVATION.

Trololo!!!How about

FP?Alonzo ChurchParent of Lambda Calculus

Page 5: Do we really need new languages?

5

5

FP advantages

QUALITY. PRODUCTIVITY. INNOVATION.

• Expressions• Immutability • Declarative programming• No need to track order• You know it from school*

*math classes

EZ

Page 6: Do we really need new languages?

6

6

What we have today

QUALITY. PRODUCTIVITY. INNOVATION.

In mobile development we use mostly Java and Objective-C

So what’s wrong guys,Don’t you like my

OOPs?

Alan KayFather of OOP

Page 7: Do we really need new languages?

7

7

Huston, we have a problem!

QUALITY. PRODUCTIVITY. INNOVATION.

• State is root of all evil*• Statements (you have to track ex order)• There is no OOP

Oh my...

Page 8: Do we really need new languages?

8

8

…and what should we do?

QUALITY. PRODUCTIVITY. INNOVATION.

Update our languages!

Page 9: Do we really need new languages?

9

9

It’s not so easy

QUALITY. PRODUCTIVITY. INNOVATION.

We want to keep backward compatibility

Not so fast boy!

James GoslingAuthor of Java

Page 10: Do we really need new languages?

10

10

So what to do?

QUALITY. PRODUCTIVITY. INNOVATION.

That’s easyInvent new language!

Kotlin, Swift, Scala, Go…

Page 11: Do we really need new languages?

11

11

Kotlin vs Java

QUALITY. PRODUCTIVITY. INNOVATION.

Laconic Kotlindata class Country(val name: String? = null)

Java public class Country { private String name;

public Country(String name) { }

public String getName() { return name; } public void setName(String name) { this.name = name; } }

Page 12: Do we really need new languages?

12

12

Kotlin vs Java

QUALITY. PRODUCTIVITY. INNOVATION.

Kotlin - type inferenceval myMap = HashMap<String, List<String>>()

JavaMap<String, List<String>> myMap = new HashMap<String, List<String>>();

// Or:

Map<String, List<String>> myMap = new HashMap<>();

Page 13: Do we really need new languages?

13

13

Kotlin vs Java

QUALITY. PRODUCTIVITY. INNOVATION.

Kotlin - extensions functionsfun String.encodeSpaces(): String { return this.replaceAll(" ", "_")}

Javapublic final class StringUtils { public static String encodeString(String str) { return str.replaceAll(" ", "_") }}

Page 14: Do we really need new languages?

14

14

Kotlin vs Java

QUALITY. PRODUCTIVITY. INNOVATION.

Functional Kotlinfun <T> lock(lock: Lock, body: () -> T): T {

lock.lock()

try {

return body()

}

finally {

lock.unlock()

}

}

Page 15: Do we really need new languages?

15

15

Kotlin vs Java

QUALITY. PRODUCTIVITY. INNOVATION.

Safe Kotlin

var a: String = "abc"a = null // compilation error

var b: String? = "abc"b = null // ok

if (b != null && b.length > 0) print("String of length ${b.length}")else print("Empty string")

Page 16: Do we really need new languages?

16

16

Kotlin vs Java

QUALITY. PRODUCTIVITY. INNOVATION.

● Function literals and inline functions● Smart casts● String templates● Class delegation● Type inference● Range expressions● Default arguments● Named arguments● More

Page 17: Do we really need new languages?

17

17

Kotlin vs Java

QUALITY. PRODUCTIVITY. INNOVATION.

http://kotlinlang.org http://try.kotlinlang.org

Page 18: Do we really need new languages?

18

18

Swift vs Objective-C

QUALITY. PRODUCTIVITY. INNOVATION.

Swifthello = “Hello”world = “World”str = ”\(hello) \(world)!”

Obj-CNSString *hello = @”Hello”;NSString *world = @”World”;NSString *str = [NSString stringWithFormat:@”%@ %@!”, hello, world];

Page 19: Do we really need new languages?

19

19

Swift vs Objective-C

QUALITY. PRODUCTIVITY. INNOVATION.

Obj-Cfor(int i = 0; i < 10; i++) {

if (i % 2 == 0) {[array addObject:@i];

}}

Swiftfunc isEven(Int) -> {

return number % 2 ==0}array = Array(1..10).filter(isEven)

Page 20: Do we really need new languages?

20

20

Swift vs Objective-C

QUALITY. PRODUCTIVITY. INNOVATION.

• It’s not binded to C• Say “bye-bye nil”• Simpler code• Optionals• No [], namespaces…• It’s Open Source

Page 21: Do we really need new languages?

21

21

Swift vs Objective-C

QUALITY. PRODUCTIVITY. INNOVATION.

Page 22: Do we really need new languages?

22

22

How new languages help us to build better products

QUALITY. PRODUCTIVITY. INNOVATION.

• Readability• Predictability• Testability• Expressivity

Robert MartinUncle Bob

My style, boy!

Page 23: Do we really need new languages?

23

23

More benefits?

QUALITY. PRODUCTIVITY. INNOVATION.

• Write less code• More joy from work• Think less• More time for coffee• Less possibility to be fired• On step closer to nirvana

Î-mi place atmosfera

de aici!

Guido Van RossumAuthor of Python

Page 24: Do we really need new languages?

24

24

What if I’m not a mobile developer?

QUALITY. PRODUCTIVITY. INNOVATION.

C/C++ Rust

Java Scala

C# ???

Python Go

Erlang Elixir

Ruby Crystal

Java Script Dart

Page 25: Do we really need new languages?

25

25

Conclusion

Make it by yourself =)

Do we really need new languages?

Page 26: Do we really need new languages?

26

Thank you

QUALITY. PRODUCTIVITY. INNOVATION.

Vlad DrahneaSoftware Engineer

[email protected]

Stefan PopaSoftware Engineer

[email protected]