Over the course of the weekend a number of people asked me about Scala and wasn’t time for a lightening talk so here are some of the resources and topics to help see why scala and where it fits.
The reasons I use Scala is that it helps me think more clearly (reason more simply) about programming in general and Java/WebObjects programming specifically. I’m sure it’s not for everybody but the ability to use functional patterns and object oriented practices side by side allows me to make this move without having to shut-down productivity while I learn a new language. In Scala you can use any Java library you want and you also have access to a number of high-quality Scala projects (like Spark which is how I initially came to Scala) Dennis and Andrus both talked about lambdas and other features of Java 8 that come from a more functional environment that can be very useful. Scala is one way to have those features in Java 6 and 7 without having to move to Java 8 entirely. - In addition to the lambdas that are gaining popularity in Java 8, there are many other concepts that are available in Scala (and some in Java 8) - Option/Some/None is a way of dealing with methods that may return a result or null. (Java 8 has “Optionals”) The intention of the Option is to reduce the exposure to NPE and give the compiler some help in catching these issues instead of relying on users to find them for you. - Pattern Matching and Case Classes. I don’t know if Java 8 has an analogous structure, but being able to use classes and type hierarchies in switch statements has proven to be very helpful to me and made some parts of my code more clear. - scala.collections.JavaConversions offers a seamless way to use all of the Scala collections goodness with java (and foundation) collections like NSArray/NSDictionary. Dennis touched on this in his Lambdas talk. The following line is an example similar to what he had in his talk. In this case, there is an NSDictionary of field labels being applied to array from a CSV line. val pmap: Map[String, String] = TreatmentObservationParser.txfieldlabels map { case (key, value) => (key, toks(value)) } - companion objects. A companion object is similar to the static elements of a java class. Elements in a Scala class are all on a specific instance. This is better understood through code, so if you go through any of the basic tutorials you’ll understand it better than my email. - traits: Traits are like interfaces except they can have implementation. This allows for composable clases. Traits are a multiple inheritance mechanism that uses very strict order evaluation to avoid shooting yourself in the foot. I haven’t gone very far down this road, but the places where I’ve worked with this appear to be able to reduce the amount of repetition and boilerplate code required. - map, filter, tuples, comprehensions, flat maps, data folding, reduce, optimized tail recursion, and lots of other things that I’m still digging through. Anyway… here are things that can help you with WebObjects and Scala. These provide specific examples of doing WOComponents and other common WO classes in Scala. Take note of the EOTemplates also. You can work normally with EO’s using the standard EOGenerator templates, but these provide some smoother integration with Scala. Some info on the community WIKI (with thanks to the authors of these pages): WebObjects and Scala - Divergent Paradigms https://wiki.wocommunity.org/display/documentation/WebObjects+and+Scala+-+Divergent+Paradigms <https://wiki.wocommunity.org/display/documentation/WebObjects+and+Scala+-+Divergent+Paradigms> WebObjects with Scala https://wiki.wocommunity.org/display/documentation/WebObjects+with+Scala <https://wiki.wocommunity.org/display/documentation/WebObjects+with+Scala> EOGeneratorTemplates: Ravi Mendis and John Huss https://wiki.wocommunity.org/display/WOL/EOGenerator+Templates+and+Additions <https://wiki.wocommunity.org/display/WOL/EOGenerator+Templates+and+Additions> Some Scala and Akka resources: TypeSafe: The inventor of Scala (Martin Odersky) is a founder of TypeSafe and they manage the language, tooling and related product areas. http://typesafe.com <http://typesafe.com/> ScalaIDE: standalone eclipse distribution or plugin for existing eclipse. All you have to do to work with scala in WO is to add Scala Nature. http://scala-ide.org Coursera “Functional Programming in Scala”, “Reactive Programming”: This is a very good general introduction to functional programming practices and mechanisms using Scala. Twitter Scala School: Twitter uses a lot of Scala and they have published useful information on practices, patterns and styles https://twitter.github.io/scala_school/ Stack Overflow: A very active Scala, Akka and Play environment Let It Crash: This is a blog that has lots of excellent articles on practical Akka and Scala usage http://letitcrash.com Books: “Scala for Java Programmers”, “Functional Programming in Scala”, “Scala for the Impatient”, “Scala Cookbook”, “Atomic Scala”, “Scala in Action” I am not the final word on any of this and I still have a lot to learn. All this is is a list of information that has been helpful to me in evaluating whether Scala was a useful part of the toolbox and how to work productively with it as quickly as possible. Larry Mills-Gahl elem...@gmail.com
signature.asc
Description: Message signed with OpenPGP using GPGMail
_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com