Ruby is dying. What languages are cool now?
-
Upload
michal-konarski -
Category
Software
-
view
1.602 -
download
0
Transcript of Ruby is dying. What languages are cool now?
![Page 1: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/1.jpg)
Ruby is dyingWhat languages are cool now?
Michał Konarski
u2i.com
![Page 2: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/2.jpg)
Seriously, is Ruby dying?
![Page 3: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/3.jpg)
Ruby Go
https://blog.whoishiring.io/hacker-news-who-is-hiring-thread-part-1/
Who is hiring?
![Page 4: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/4.jpg)
But let’s look from a different angle...
![Page 5: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/5.jpg)
http://www.tiobe.com/
TIOBE Index
![Page 6: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/6.jpg)
Well, not exactly.
But what languages are cool now?
![Page 7: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/7.jpg)
Let’s look at six of them
![Page 8: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/8.jpg)
Swift
![Page 9: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/9.jpg)
Swift
● designed by Apple● released in 2014● created for iOS, macOS, tvOS● multi-paradigm● statically, strongly typed● compiled
![Page 10: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/10.jpg)
namespacesgenerics
closures
tuplesoperator overloading
native collections
type inference
pattern matching
multiple return types
Read-Eval-Print-Loop (REPL)
Swift features
![Page 11: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/11.jpg)
Nothing really outstanding.
So, what’s the story behind Swift?
![Page 12: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/12.jpg)
“We absolutely loved Objective-C, but we had to ask ourselves a question -
what would it be like if we had Objective-C without the baggage of C?”
Tim Cook
![Page 13: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/13.jpg)
It’s mainly because Objective-C is bad.
And they had nothing else.
![Page 14: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/14.jpg)
@interface Foo : NSObject@property (readonly) int bar;- (instancetype)initWithBar:(int)bar;+ (instancetype)fooWithBar:(int)bar;@end
@implementation Foo- (instancetype)initWithBar:(int)bar { self = [super init]; if (self) { _bar = bar; }
return self;}
+ (instancetype)fooWithBar:(int)bar { return [[self alloc] initWithBar:bar];}@end
How bad is Objective-C?
http://www.antonzherdev.com/post/70064588471/top-13-worst-things-about-objective-c
![Page 15: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/15.jpg)
Swift is easier to read
Objective-C
if (myDelegate != nil) {if ([myDelegate respondsToSelector:
@selector(scrollViewDidScroll:)]) {[myDelegate scrollViewDidScroll:myScrollView]
}}
Swift
myDelegate?.scrollViewDidScroll?(myScrollView)
![Page 16: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/16.jpg)
Why also Swift is better?
● no need to have two separate files (code and headers)● it’s safer (runtime crash on null pointer)● it has automatic ARC (Automatic Reference Counting)● it’s faster● it requires less code● it has namespaces
![Page 17: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/17.jpg)
It’s not only a language
XCode 8
https://developer.apple.com/xcode/
![Page 18: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/18.jpg)
It’s not only a language
Swift Playgrounds
http://www.apple.com/swift/playgrounds/
![Page 19: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/19.jpg)
![Page 20: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/20.jpg)
● sponsored by Mozilla● announced in 2010● first release in 2012● stable release in 2015● statically, strongly typed● multi-paradigm● compiled
![Page 21: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/21.jpg)
“The goal of the project is to design and implement a safe, concurrent, practical systems
language”Rust FAQ
![Page 22: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/22.jpg)
There are not such languages?
Apparently not.
![Page 23: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/23.jpg)
Current languages are wrong
● there is too little attention paid to safety
● they have poor concurrency support
● they offer limited control over resources
● they stick too much to paradigm
![Page 24: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/24.jpg)
So let’s create a new high-low level language!
![Page 25: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/25.jpg)
Rust is a high level language!
● generics ● traits● pattern matching● closures● type inference● automatic memory allocation and deallocation● guaranteed memory safety● threads without data races
![Page 26: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/26.jpg)
Rust is a low level language!
● no garbage collector● manual memory management● zero-cost abstractions● minimal runtime● as fast as C/C++
![Page 27: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/27.jpg)
Guaranteed memory safety? How?
![Page 28: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/28.jpg)
Ownership
fn foo() {
let v1 = vec![1, 2, 3];let v2 = v1;println!("v1[0] is: {}", v1[0]);
}
error: use of moved value: `v
![Page 29: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/29.jpg)
You can’t have two references to the same object!
![Page 30: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/30.jpg)
Ownership
stack heap
[1, 2, 3]v1
v2
![Page 31: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/31.jpg)
There are more such mechanisms.
![Page 32: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/32.jpg)
Future of Rust
● currently two big projects: servo and rust● other smaller projects: redox, cgmath, Iron, rust-doom● it changes very quickly● it has a good opinion in the community● it will be hard to replace C/C++● It has a steep learning curve
![Page 33: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/33.jpg)
Go
![Page 34: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/34.jpg)
Go
● designed in Google in 2007● first release in 2009● stable release in 2016● statically, strongly typed● multi-paradigm, concurrent● compiled
![Page 35: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/35.jpg)
Standard languages (Java, C++)
● are very strong: type-safe, effective, efficient● great in hands of experts ● used to build huge systems and companies
![Page 36: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/36.jpg)
Standard languages (Java, C++)
● hard to use● compilers are slow● binaries are huge● desperately need language-aware tools● poorly adapt to clouds, multicore CPUs
![Page 37: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/37.jpg)
Simpler languages (Python, Ruby, JS)
● easier to learn● dynamically typed (fewer keystrokes)● interpreted (no compiler to wait for)● good tools (interpreters make things easier)
![Page 38: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/38.jpg)
Simpler languages (Python, Ruby, JS)
● slow● not type-safe● hard to maintain in a big project● very poor at scale● not very modern
![Page 39: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/39.jpg)
What if we had a static language with dynamic-like syntax?
![Page 40: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/40.jpg)
A niche for a language
● understandable● statically typed● productive and readable● fast to work in● scales well● doesn't require tools, but supports them well● good at networking and multiprocessing
![Page 41: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/41.jpg)
Features of Go
● syntax typical for dynamic languages● type inference● fast compilation● garbage collector● memory safety features● built-in concurrency● object oriented without classes and inheritance● lack of generics● compiles to small statically linked binaries
![Page 42: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/42.jpg)
Interfacestype Animal interface { Speak() string}
type Dog struct {}
func (d Dog) Speak() string {return "Woof!"
}
func SaySomething(a Animal) {fmt.Println(a.Speak())
}
func main() {dog := Dog{}SaySomething(dog)
}
![Page 43: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/43.jpg)
Built-in concurrency!
![Page 44: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/44.jpg)
Goroutines
func main() { go expensiveComputation(x, y, z) anotherExpensiveComputation(a, b, c)
}
![Page 45: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/45.jpg)
Channels
func main() { ch := make(chan int)go expensiveComputation(x, y, z, ch) v2 := anotherExpensiveComputation(a, b, c) v1 := <- chfmt.Println(v1, v2)
}
![Page 46: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/46.jpg)
Future of Go
● it’s popularity constantly raises● it’s backed by Google● it’s used by Docker, Netflix, Dropbox, CloudFare,
SoundCloud, BBC, New York Times, Uber and others● it’s seen as a good balance between Java-like languages
and Python-like● it easy to learn and powerful● it runs well in cloud environments● might be a good choice for microservices approach
![Page 47: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/47.jpg)
![Page 48: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/48.jpg)
● created by José Valim● released in 2012● functional● dynamically, strongly typed● compiled to Erlang VM byte code
![Page 49: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/49.jpg)
Erlang? Processes!
![Page 50: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/50.jpg)
Elixir = Erlang with Ruby syntax
![Page 51: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/51.jpg)
Elixir features
● massively concurrent● scalable● fault-tolerant● great performance● functional, but practical● nice Ruby-like syntax● metaprogramming via macros
![Page 52: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/52.jpg)
Ruby has Rails.
![Page 53: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/53.jpg)
Elixir has Phoenix.
![Page 54: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/54.jpg)
Controllers in Rails
class PagesController < ApplicationController def index @title = params[:title] @members = [ {name: "Chris McCord"}, {name: "Matt Sears"}, {name: "David Stump"}, {name: "Ricardo Thompson"} ] render "index" endend
http://www.littlelines.com/blog/2014/07/08/elixir-vs-ruby-showdown-phoenix-vs-rails/
![Page 55: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/55.jpg)
Controllers in Phoenix
defmodule Benchmarker.Controllers.Pages do use Phoenix.Controller
def index(conn, %{"title" => title}) do render conn, "index", title: title, members: [ %{name: "Chris McCord"}, %{name: "Matt Sears"}, %{name: "David Stump"}, %{name: "Ricardo Thompson"} ] endend
http://www.littlelines.com/blog/2014/07/08/elixir-vs-ruby-showdown-phoenix-vs-rails/
![Page 56: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/56.jpg)
Future of Elixir
● new Erlang for the masses● fits highly concurrent niche● attracts Ruby developers● no big company behind● used by Pinterest● will fly on the wings of Phoenix?
![Page 57: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/57.jpg)
![Page 58: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/58.jpg)
● created by data scientists● released in 2012● dynamically, strongly typed● compiled
![Page 59: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/59.jpg)
Compiled one for fast stuff.Interpreted one for visualisation.
Data scientists’ two languages problem:
![Page 60: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/60.jpg)
Julia features
● solves scientists’ two language problem● familiar syntax● extensive scientific library● user-defined types● multiple dispatch● built-in parallelism ● good performance (comparing to C)
![Page 61: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/61.jpg)
Single dispatch (Ruby)
a.do_something(b, c)
Only a decides which method to choose.
![Page 62: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/62.jpg)
Multiple dispatch
julia> f(x::Float64, y::Float64) = 2x + y;
julia> f(2.0, 3.0)7.0
julia> f(2.0, 3)ERROR: MethodError: `f` has no method matching
Here everything decides!
![Page 63: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/63.jpg)
Future of Julia
● R, MATLAB and C competitor ● unifies scientific software stack● not mature enough yet● small, but growing number of libraries
![Page 64: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/64.jpg)
![Page 65: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/65.jpg)
● created by Google● released in 2011● optionally typed● interpreted● translated to JavaScript
![Page 66: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/66.jpg)
Let’s replace JavaScript!
![Page 67: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/67.jpg)
Dart vs JavaScript
● class-based (not prototype-based)● normal foreach● named parameters● operator overriding● string interpolation● optional typing● false is false● easy DOM operations
![Page 68: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/68.jpg)
Looks familiarclass Point { num x; num y;
Point(this.x, this.y); distanceFromOrigin() { return sqrt(x * x + y * y); }}
main() { var p = new Point(2, 3); print(p.distanceFromOrigin());}
![Page 69: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/69.jpg)
Cascade operator
querySelector('#button') ..text = 'Confirm' ..classes.add('important') ..onClick.listen(
(e) => window.alert('Confirmed!'));
![Page 70: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/70.jpg)
Future of Dart
● 2016 AdWord UI built in Dart● no Dart VM in browsers● fragmented community● client-side future is dim● backend future looks much better
![Page 71: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/71.jpg)
![Page 72: Ruby is dying. What languages are cool now?](https://reader034.fdocuments.in/reader034/viewer/2022050614/58a39d881a28abb1348b6421/html5/thumbnails/72.jpg)
Sources
● developer.apple.com/swift● rust-lang.org● golang.org● elixir-lang.org● julialang.org● dartlang.org