Code Watch: Two years with Scala
October 22, 2012 —
(Page 1 of 3)
For the past two years, my day-to-day programming language has been Scala. Scala is a hybrid language that combines the approaches of object-orientation and functional programming. You can treat Scala as a "Java.next" with minimal changes in your object-oriented mindset (the only thing that springs to mind is that Scala's "companion objects" might seem like unnecessarily clunky replacements of Java's "static" functionality). Even just as a drop-in replacement, I think most programmers would prefer Scala to Java: type inference saves finger-typing, and fields and class structure are a little clearer.
Scala is also a functional programming language. I've talked about functional programming many times over the years, but it continues to have an undeserved air of mystery around it. The low bar for a language to be "functional" is the support of functions as "first-class constructs." Essentially, wherever you can have a value (on the right-hand of assignments, as the input or output of functions, etc.), you can have instead an anonymous block of code (if you like Greek, you can call them "lambda functions"). This turns out to be so convenient that every mainstream language either already supports or is moving toward such support; every language is, or will be soon, a "functional programming" language.
The greatest practical benefit of first-class functions is that, multiple times per day, instead of writing a for loop that iterates over elements of a collection to transform, filter or accumulate something, you just pass a small function to common collection-class functions such as (in the Scala world), map, filter and foldLeft. I cannot imagine a programmer not preferring the use of such functions: They are both clearer and more concise than loops.
But first-class functions do not guarantee understandable code, as anyone who's tried to maintain a complex JavaScript Web page (with all those element.click(function(){}) tangles of first-class event handlers) can attest. Instead, the major task-by-task benefit of functional programming is not a language feature, but the philosophy of "lack of mutable state."
Related Search Term(s): functional programming, Scala
Share this link: http://sdt.bz/37094
Most Read
Latest News
Resources
SAP unveils SAP HANA platform innovations for Big Data and spatial processing
Features include smart data access and expanded cloud deployment options
|
|
|
Alteryx raises $12 million to put Big Data analytics in the hands of all business analysts
Quest founder's firm, Toba Capital, selects Alteryx as its first analytics investment
|
|
|
Google I/O kicks off
Developers get new APIs and tools, and the Go language hits version 1.1
|
|
|
Jelastic launches new version of its Java and PHP hosting platform
Jelastic today announced the launch of a new version of its ultra-scalable cloud hosting platform
|
Telerik adds back-end services to Icenium mobile tool suite
Icenium Everlive makes the suite a complete app development platform, the company says
|
|
|
CollabNet fuses CloudForge, TeamForge
New pricing structure and integration gives developers an enterprise-grade choice for dist...
|
|
|
Eclipse release train for Kepler arrives June 26
New version of Eclipse includes Stardust for business process management, and Orion 3.0 fo...
|
|
|
Google I/O kicks off
Developers get new APIs and tools, and the Go language hits version 1.1
|
IDC MarketScape: Worldwide Cloud Testing and ASQ SaaS
Demand for solutions to test applications on the cloud and for the cloud is rising signifi...
|
|
|
Get to Know the Database Decision Factors
What should you look for when choosing a relational database system? This informative arti...
|
|
|
Exploring the Database Forest
Today’s database technology landscape is more dynamic and varied than ever before. What’s...
|
|
|
Data Management Resource Guide
Today’s data is generated by more than just applications. Data is generated by trillions o...
|