Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Locaweb TechTalks 2015 - Seven languages in Seven weeks

Locaweb TechTalks 2015 - Seven languages in Seven weeks

Renan Ranelli

February 06, 2015
Tweet

More Decks by Renan Ranelli

Other Decks in Programming

Transcript

  1. • First of all.... Why does it matter to learn

    programming languages anyway ?
  2. • First of all.... Why does it matter to learn

    programming languages anyway ? • I think you should learn programming languages. • But my opinion probably will not matter for you, so listen to these guys instead:
  3. • Disclaimer: All the languages to be presented are turing

    complete, i.e. you can do everything that can be done with a computer in any of them.
  4. • Disclaimer: All the languages to be presented are turing

    complete, i.e. you can do everything that can be done with a computer in any of them. The book (and this presentation) are by no means an exhaustive exploration of the programming languages. Think of them as food for thought.
  5. We are going to talk about: • Ruby • Io

    • Prolog • Scala • Erlang • Clojure • Haskell
  6. • What I aim to achieve: – I will try

    to explain what composes a language and how the same problem is handled by different languages – I expect to show you that a characterization such as “it is function” or “it is object oriented” is insufficient and most of the times inappropriate – I expect you to be convinced that mutable state can be avoided and that this is key to enabling efficient and sane concurrent programming
  7. We are going to talk about: • Ruby • Io

    • Clojure • Scala • Erlang • Prolog • Haskell Support for OOP Support for FP
  8. • Ruby: – Object oriented, class based, dynamically typed, strongly

    typed – Extremely meta-programmable – Complex syntax, complex evaluation rules – Reads like a novel – We all know and love it ;)
  9. • Io: – Object oriented, prototype based, strongly typed –

    Extremely simple and consistent syntax – Heavy emphasis on message passing, not method call. (actually, “method” is a message that returns an object that can receive the message “call”) – Easy to create DSLs – Excellent concurrency primitives – Crazy amount of reflective power
  10. • Scala – OOP, FP, statically typed, strongly typed –

    Has a powerful type system – Offers advanced FP concepts such as monads and type classes. – You can emulate non-strict evaluation with “call by name” vs “call by value“ paramater passing strategies – Suffers from the Java legacy to a certain extent
  11. • Erlang: – Designed by Ericsson to build telecom software.

    – Alien syntax, derived from Prolog. – Functional, enforces extreme isolation and share- nothing processes. – No threading model. – Amazing support for fault-tolerant, near-real-time distributed application development.
  12. • Clojure: – After Fortran, Lisp is the oldest programming

    language still actively used. – FP, supports OOP, strongly typed, dynamically typed. – Lisp on the JVM with modern constructs and libraries. – Allows meta-programming with macros. – Not so Lispy: no custom reader macros and no automatic tail call optimization. (schemers be mad)
  13. • Clojure: – Although clojure is an strict language, you

    can simulate non-strictness using macros. – It's possible to define the language on-the-fly, i.e., the language is internally reprogramable (heavy influence in ruby and smalltalk) – <code @ clojure-koans/src/koans/17_macros.clj:29>
  14. • Haskell: – Functionally pure programming language. – No exceptions

    and no mutable state (at least the way we are used to) – Extremely powerful type system with parametric types, type class, algebraic data types and type inference. – Offers the full pack of FP crazyness: Monads, Monoids, Functors, Applicatives, Foldables are common language for Haskell programmers. – Much more close to Math, simplifying the way we represent abstract and symbolic constructs.
  15. • Haskell: – Makes it impossible to use mutable state

    – But allows you to simulate it with Monads – <code @ scheme interpreter>
  16. • What does it actually take to learn a new

    programming language? – Syntax – The programming language's primitives? – Type System (strong or weak? Static or dynamic?) – Evaluation rules (precedence, strictness, etc.) – Idioms – Libraries
  17. • Also important: – Meta-programming and extensibility models – Concurrency

    models – Library distribution – Community (of course!)
  18. • Object oriented programming – You can have OOP with

    no classes. – OOP is about “messages and objects”, not “classes and methods”. – You can dispatch using more than one type. – Class based and prototype based object systems are actually equivalent, and you can represent one in the other.
  19. • Polymorphism – Subtype polymorphism is actually pretty poor. Inheritance

    sucks. – Different paradigms will influence heavily the way you compose the behaviors in your program – Class based OOP lends itself nicely to program organization (one class, one file, internal classes in directories) – There is no such parallel in FP
  20. • Functional purity – Buys you a lot, but also

    takes its toll – With a little bit of effort, you can simulate mutable state where its absolutely necessary. – Functional purity brings referential transparency, lazy evaluation, easy concurrency and makes it easier to reason and compose programs. … but – The density of the languages tend to be higher, and the intellectual load is surely higher too. Not that you can't get used to it, but still...
  21. • Concurrency models – One big part of the book

    – Actually a pretty complex topic to discuss here – There is a lot of ways you can work around mutable state, and each one has its idiosyncrasies – The level of isolation impacts heavily the shape of your program organization and architecture
  22. • Pattern matching – Is composed of destructuring + binding

    – Takes various forms – You can simulate algebraic data types in dynamic languages (and that was mind blowing!
  23. • Meta-programming and extensibility – Plays a big role on

    the practical use of the language. – The more extensible the language is, its more likely that you will encounter better and easier apis in the libraries you work with.