All of these samples perform essentially the same task: traverse an array of strings and print each value to stdout. Of course, the C++ example is actually using a vector rather than an array due to the evil nature of C/C++ arrays, but it comes to the same thing. Passing over the differences in syntax between these four languages, what really stands out are the different ways in which the task is performed. C++ and Java are both using iterators, while Ruby and Scala are making use of higher order functions. Ruby and C++ both use lowercase variables separated by underscores, while Java and Scala share the camelCase convention. This is a bit of a trivial example, but it does open the door to a much more interesting discussion: what are these idioms in Scala’s case? Scala is a very new language which has yet to see truly wide-spread adoption. More than that, Scala is fundamentally different from what has come before.
Gabriel C. Software surgeon / developer / architect with few years consulting and developing software using OOAD with UML and RUP in JEE and MS technolgies. I've been a software developer and project leader in a offshore development center in Uruguay, technical lead on a project in Chile, architect of a COTS application in Dominican Republic, OOAD/ UML mentor in Nicaragua, architecture and RUP mentor in Puerto Rico, and senior programmer in USA. But I'm still trying to learn what this software stuff is about...
Buildr is a build system for Java applications in Ruby Maven compatible * A simple way to specify projects, and build large projects out of smaller sub-projects. * Pre-canned tasks that require the least amount of configuration, keeping the build script DRY and simple. * Compiling, copying and filtering resources, JUnit/TestNG test cases, APT source code generation, Javadoc etc * A dependency mechanism that only builds what has changed since the last release. * A drop-in replacement for Maven 2.0, Buildr uses the same file layout, artifact specifications, local and remote repositories. * All your Ant tasks belong to us! Anything you can do with Ant, you can do with Buildr. * No overhead for building “plugins” or configuration. Just write new tasks or functions. * Buildr is Ruby all the way down. No one-off task is too demanding when you write code using variables, functions and objects. * Simple to upgrade to new versions. * fast
Scala is clearly an interesting language, well suited for showing off nifty new ideas in language theory and innovation, but at the end of the day, for it to be of any "real" use, it has to be able to meet practicing developers halfway and have some applicability in the "real world." Now that we've looked at some of the core features of the language, can recognize some of Scala's linguistic flexibility, and have witnessed Scala in action creating DSLs, it's time to start reaching out to the environments that real applications use and show how Scala fits. We'll begin this new phase of the series by starting with the heart of most Java™ applications: the Servlet API.