2 Replies - 22104 Views - Last Post: Yesterday, 01:51 AM

#1 macosxnerd101  Icon User is online

  • Games, Graphs, and Auctions
  • member icon

Reputation: 11307
  • View blog
  • Posts: 42,583
  • Joined: 27-December 08

Week 31- Scala

Post icon  Posted 21 September 2010 - 09:39 PM

Posted Image

This week's challenge is Scala, a statically typed hybrid functional-Object Oriented language. In Scala, every value is expressed as an Object. It also has features for inheritance, and a composition-based replacement for multiple inheritance. Scala also provides functional programming features including functions as values, anonymous functions, higher-order functions, nested functions, and currying. It also supports the algebraic pattern matching familiar to many other functional languages.

Scala is a compiled language, designed to run on the JVM. As such, it is compiled to Java Bytecode, and can interact with all standard Java libraries.

The Scala Website
DIC Functional Programming Forum

Is This A Good Question/Topic? 0
  • +

Replies To: Week 31- Scala

#2 Dogstopper  Icon User is online

  • The Ninjaducky
  • member icon

Reputation: 2929
  • View blog
  • Posts: 11,201
  • Joined: 15-July 08

Re: Week 31- Scala

Posted 02 November 2010 - 08:29 PM

For now, I wrote the famed Hello World Application!

object HelloWorld {
	def main(args: Array[String]) {
		println("Hello World");

I sort of like the idea of a compiled object. In this case, HelloWorld is a Singleton object/class mix instead of a class. Supposedly, this idea gets rid of static variables in Java entirely. I'm not crazy about the syntax for method definitions, but I'll get over it.
Was This Post Helpful? 0
  • +
  • -

#3 g4143  Icon User is online

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 18
  • Joined: 30-April 09

Re: Week 31- Scala

Posted Yesterday, 01:51 AM

Scala is a language that should give the legions of Java programmers coding joy-gasms but for one reason or another they mostly have rejected the language(Scala). Here's a short example of the possibles with Scala.

The code reads the command line args and tries to open and read valid files.

import scala.io.Source

object testit {

  def main(args: Array[String]): Unit = {
        getFileContents(filename) match {
          case (sc, Some(s)) => s.foreach(println)
          case (f, None) => println(s"Open/Read failed with: $f")
  def getFileContents(filename:String):(String, Option[Iterator[String]]) = {
      match {
        case util.Success(s) => ("Success", Some(s))
        case util.Failure(f) =>  (f.getMessage(), None)

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1