Locaweb TechTalks 2015 - Seven languages in Seven weeks

Locaweb TechTalks 2015 - Seven languages in Seven weeks

4569aec00cb223b3fbf484f9e7ba1256?s=128

Renan Ranelli

February 06, 2015
Tweet

Transcript

  1. 1.
  2. 3.

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

    programming languages anyway ?
  3. 4.

    • 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:
  4. 8.
  5. 9.

    • 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.
  6. 10.

    • 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.
  7. 11.

    We are going to talk about: • Ruby • Io

    • Prolog • Scala • Erlang • Clojure • Haskell
  8. 12.

    • 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
  9. 13.

    We are going to talk about: • Ruby • Io

    • Clojure • Scala • Erlang • Prolog • Haskell Support for OOP Support for FP
  10. 15.

    • 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 ;)
  11. 18.

    • 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
  12. 21.

    • 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
  13. 24.
  14. 25.
  15. 26.

    • 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.
  16. 29.

    • 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)
  17. 30.

    • 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>
  18. 32.

    • 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.
  19. 35.

    • Haskell: – Makes it impossible to use mutable state

    – But allows you to simulate it with Monads – <code @ scheme interpreter>
  20. 37.

    • 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
  21. 38.

    • Also important: – Meta-programming and extensibility models – Concurrency

    models – Library distribution – Community (of course!)
  22. 39.

    • 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.
  23. 40.

    • 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
  24. 41.

    • 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...
  25. 42.

    • 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
  26. 43.

    • Pattern matching – Is composed of destructuring + binding

    – Takes various forms – You can simulate algebraic data types in dynamic languages (and that was mind blowing!
  27. 45.

    • 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.