Martin Ordersky总结的Scala编程六境界

2019-01-22  本文已影响5人  Leesper

Level A1: Beginning application programmer

  1. Java-like statements and expressions: standard operators, method calls, conditionals, loops, try/catch
  2. class, object, def, val, var, import, package
  3. Infix notation for method calls
  4. Simple closures
  5. Collections with map, filter, etc
  6. for-expressions

Level A2: Intermediate application programmer

  1. Pattern matching
  2. Trait composition
  3. Recursion, in particular tail recursion
  4. XML literals

Level A3: Expert application programmer

  1. Folds, i.e. methods such as foldLeft, foldRight
  2. Streams and other lazy data structures
  3. Actors
  4. Combinator parsers

Level L1: Junior library designer

  1. Type parameters
  2. Traits
  3. Lazy vals
  4. Control abstraction, currying
  5. By-name parameters

Level L2: Senior library designer

  1. Variance annotations
  2. Existential types (e.g., to interface with Java wildcards)
  3. Self type annotations and the cake pattern for dependency injection
  4. Structural types (aka static duck typing)
  5. Defining map/flatmap/withFilter for new kinds of for-expressions
  6. Extractors

Level L3: Expert library designer

  1. Early initializers
  2. Abstract types
  3. Implicit definitions
  4. Higher-kinded types

As I wrote above, the skill sets required from application programmers and library designers are really quite different. But if I should throw them into the same baskets, I would group like this:

A1, A2/L1, A3/L2, L3

上一篇下一篇

猜你喜欢

热点阅读