Proposed levels of skill for the scala programming language, can be used as a base for a curriculum
Related links:
- the scala style guide.
- a scala basic exam
- examples of scala abuses
- sample training curriculum Artima
trait Companion[T] { | |
type C | |
def apply() : C | |
} | |
object Companion { | |
implicit def companion[T](implicit comp : Companion[T]) = comp() | |
} | |
object TestCompanion { |
/** Use with a default value, for example: | |
* runningScalaVersion getOrElse "2.8.0" | |
*/ | |
lazy val runningScalaVersion = { | |
val matcher = """version (\d+\.\d+\.\d+).*""".r | |
util.Properties.versionString match { | |
case matcher(versionString) => Some(versionString) | |
case _ => None | |
} | |
} |
class DynamicImpl(x: AnyRef) extends Dynamic { | |
def _select_(name: String): DynamicImpl = { | |
new DynamicImpl(x.getClass.getMethod(name).invoke(x)) | |
} | |
def _invoke_(name: String)(args: Any*) = { | |
new DynamicImpl(x.getClass.getMethod(name, args.map(_.asInstanceOf[AnyRef].getClass) : _*).invoke(x, args.map(_.asInstanceOf[AnyRef]) : _*)) | |
} | |
override def typed[T] = x.asInstanceOf[T] | |
override def toString = "Dynamic(" + x.toString + ")" | |
} |
Proposed levels of skill for the scala programming language, can be used as a base for a curriculum
Related links:
/** | |
* An answer from Jason Zaugg on the scala-internals mailing list | |
* | |
* Implicit parameters can have defaults. | |
*/ | |
scala> implicit def OptionalImplicit[A <: AnyRef](implicit a: A = null) = Option(a) | |
OptionalImplicit: [A <: AnyRef](implicit a: A)Option[A] | |
scala> implicitly[Option[Ordering[Int]]] |
Scala is a wonderful language, with a specification of a size comparable with that of Java. Overall, the specification is simpler than C++. Why then do some feel intimidated by its expressiveness?
Scala can generate complex constructs. There are some features of the language that, if not used properly, can negatively influence one's perception of its simplicity and generate a waste of many an hour of a frustrated developer.
Newcomers from simply typed, object-oriented, structured languages do not have a full grasp of all the features of scala and their effects or benefits, and they may be very surprised if others on their team use them.
One thing to have when starting or using scala is a readily available bible. I recommend "Programming in Scala", the .pdf version, an easily searcheable language reference.
The scala style guide is very good. Here we will describe the advanced features of the language, which are aimed at library-developers and should not b