scala for c# developers

29
Scala for C# Developers Omer van Kloeten

Upload: omervk

Post on 10-May-2015

3.566 views

Category:

Technology


5 download

DESCRIPTION

From the Scalapeño 2013 conference: http://scalapeno.underscore.co.il/ It’s no secret that in Israel, C# is one of the leading languages for development. This stems from various reasons, ranging from the power of the language to the ubiquity of Microsoft’s technologies in government and defense organizations. When it first came out, C# was Microsoft’s answer to Java and the two were on-par. Since then, C# has grown leaps and bounds and Java, while still sitting on top of the powerful JVM with a huge, open ecosystem created over nearly two decades, was left behind. Developers looking to stop paying the Microsoft-tax were faced with a language that simply did not meet their expectations. Scala is the one of the answers to this growing need for a new, modern language for the JVM. This lecture introduces the language, comparing its idioms to those of C#, and introduces you some of the tools and frameworks to get you started with it.

TRANSCRIPT

Page 1: Scala for C# Developers

Scala for C# DevelopersOmer van Kloeten

Page 2: Scala for C# Developers

Hi!

CTO at

Eight years working in C#

Two years suffering Java

Two years enjoying Scala newBrandAnalytics AppMyDay

Page 3: Scala for C# Developers

What is Scala?

JVM Language

Academic roots

Released 2003

Maintained by TypeSafe

Continuously updated

Page 4: Scala for C# Developers

Why should I care?

CLR vs. JVM

The Hummus Manifesto

Java is old, Scala is the new hotness

Learn, learn, learn

Page 5: Scala for C# Developers

Who uses Scala?

Page 6: Scala for C# Developers

Similar Backgrounds

Trying to replace Java

Benevolent Dictators Design-by-committee sucks!

Strongly and statically typed

Object-functional

Page 7: Scala for C# Developers

Imperative vs. Functional

Imperative C# Functional LINQ…

…But In Reality

Page 8: Scala for C# Developers

Functional First

Functional C# Functional Scala

Slight differences Underscores… underscores everywhere! Strict (immediate) vs. Non-Strict (lazy)

people.view().filter…

Lots more than we can cover here…

Page 9: Scala for C# Developers

Syntax Doesn’t Matter, Right?

C#

class Foo: Bar, IBaz

class Foo<TBar>

interface IFoo

int foo(string s) { return 42; }

...

Scala

class Foo extends Bar with Baz

class Foo[TBar]

trait Foo

def foo(s: String) = 42

...

Page 10: Scala for C# Developers

Syntax Doesn’t Matter, Defaults Do

C#

Private by default

Non-virtual by default

Scala

Public by default

Virtual by default

Java mentality

Page 11: Scala for C# Developers

Immutable By Default

val and var C#’s readonly

lazy val .NET’s Lazy[T]

Collections

Page 12: Scala for C# Developers

Tuples and Case Classes

Tuples First-class citizen Completely typed

Page 13: Scala for C# Developers

Tuples and Case Classes

Tuples First-class citizen Completely typed

Case classes Easy, immutable types

Page 14: Scala for C# Developers

Everything Is An Expression

Page 15: Scala for C# Developers

Pattern Matching: Basics

Page 16: Scala for C# Developers

Pattern Matching: Unapply

Page 17: Scala for C# Developers

Pattern Matching: Collections

Page 18: Scala for C# Developers

Pattern Matching: Summary

switch/case on steroids

First-class language construct

Statically checked for comprehensiveness

Page 19: Scala for C# Developers

What Scala Doesn’t Have

A fast compiler

C#’s value types Built-ins Structs Enums

Partial types and methods

Getters and Setters Well, no, but…

Native for or foreach support

Page 20: Scala for C# Developers

Wait, what?!

Well, kinda… ...is translated to:

Page 21: Scala for C# Developers

Language Topics Not Covered :(

Streams

Type inference

Tail recursion

Multiple inheritance

Operators

Implicits

Structural Type Definitions

Companion objects

Parallelization and concurrency

Monads

Macros

Reflection

More underscores!

Page 22: Scala for C# Developers

Tooling and Libraries

Almost twenty years of Java Scala wrappers

Great community Engineers Scientists

Page 23: Scala for C# Developers

Tooling: IDEs

Scala plugin

JetBrains of ReSharper fame

Scala over Eclipse

TypeSafe Maintainers of Scala

NetBeans, Sublime, etc.

Page 24: Scala for C# Developers

Tooling: REPL

Page 25: Scala for C# Developers

Tooling: Build System

Maven

Better than Ant

Bloated

Written in Java for Java

SBT

Simple Build Tool

Irony

Written in Scala for Scala

Page 26: Scala for C# Developers

Frameworks

Web Frameworks Play! Framework Lift Scalatra

Object-Relational Mappers Slick Squeryl

Unit Testing Specs2 ScalaTest

AND

EVERYTHING

FROM JAVA!

Page 27: Scala for C# Developers

Where Do I Start?

Base stuff: Download and install latest JDK (from

oracle.com) Go to http://scala-lang.org/downloads,

download and install the MSI

IntelliJ IDEA: Go to http://jetbrains.com/idea/download,

download and install the Community Edition

Demo

Page 28: Scala for C# Developers

Where Do I Start?

Twitter’s Scala School

A Tour of Scala

Another Tour of Scala

Functional Programming Principles in Scala

Scala By Example (PDF)

Programming in Scala (Book)

Page 29: Scala for C# Developers

Thank youQuestions?@omervk