Is there any book or online tutorial for Scala DSL? - scala

I read this one for DSL scala http://camel.apache.org/scala-dsl-getting-started.html. It doesn't help much for me. I want more details. Can any one help me out?

There is Debashish Gnosh book DSLs in action. It isn't focused entirely on Scala, but has a good section on DSL developemnt using Scala. Generally this would be enough for starter knowledge, for deeper experience I would look at either ScalaTest or Specs source code.

There is a lot of research ongoing in this area, especially regarding high-performing Scala DSLs. Look at:
Lightweight Modular Staging
Delite

I've published an article about building regular DSLs in Scala.
A short overview: most-likely the DSL you're trying to build belongs to a class of regular languages. If so, you can model this DSL with a finite state machine. The article contains a step-by-step manual how to transform that FSM to Scala code.

Related

Good examples of idiomatic scala code

Scala is a large and complex language. In my experience, the best way to learn such a language is to read really good code. Are there any open source examples of such code? What can you recommend?
Scalaz. Be aware that it's written in a far more functional style than most Scala code.
Twitter Util (already mentioned in #axel22's answer).
The Scala standard library should be pretty idiomatic in most places. The Scala Swing library is another example.
Usually people who write various frameworks know what they are doing and are experts in Scala. Frameworks such as Akka or Play are good examples of this. Twitter's projects are another.

Important Scala concepts to "be thorough in" when learning Lift

I am learning Scala with the intention that I be able to develop in Lift. What are the Scala concepts that are highly ingrained to Lift, that I must be thorough in?
What are the concepts/design styles that I must start early to lead to maintainable Lift projects?
Particularly, I am interested in lazy vars, actors and pattern matching
To me, there are no scala fields that you won't use in Lift. Of course it can depend a lot on what you are working on. For exemple I did't have to use actors but some people chose Scala for their webapp because of them.
However here is what I personally recommend as a first aid kit:
The List API
I use a lot the List API. Mastering it is useful for all data anylisis and filtering cases. If you use Mapper[T] in Lift, it will return some List[T] as a result.
As you are interested in pattern matching I am sorry to tell you that with List you won't have to use match a lot.
Object oriented programming
It sounds silly but another interesting fields to master is the difference between Class and Object including of course inner classes and inner objects as, later on in Lift they will have different meanings in snippets to know if the snippet is a singleton, if the val is static of not...
Scala traits can also be powerful in Lift context, but in fact they are useful everywhere
Scala XML support
Mastering Scala XML will be very useful as you will certainly have to set some xml by hand, so if you don't have problems with this it will be really helpful.
To the list Chris wrote I would add:
Actors
While Lift has it own LiftActor and CometActors implementation, it is helpful to understand how to interact and use the actor paradigm. Comet, which is one of the best features in Lift is written using Actors.
Box
Lift has something similar to Scala's Option, called Box. A box can have any of these three statues, Full, Empty or Failure. You can read more about it on David's blog
Where to find help
While you will find useful answers here on SO (Like Chris's answer), most of the Lift community hangs out at the mailing list. There are thousands of questions and answers there.
We are currently working on a cookbook, there is the
wiki, there are three books about Lift, Lift in Action, SImply Lift and Exploring Lift

Is there a central site/page for "advanced Scala" topics?

Despite having read "Programming in Scala" several times, I still often finds important Scala constructs that were not explained in the book, like
#uncheckedVariance
#specialized
and other strange constructs like
new { ... } // No class name!
and so on.
I find this rather frustrating, considering that the book was written by the Scala "inventor" himself, and others.
I tried to read the language specification, but it's made for academics, rather than practicing programmers. It made my head spin.
Is there a website for "Everything "Programming in Scala" Didn't Tell You" ?
There was the daily-scala Blog, but it died over a year ago.
Currently, we're working on a central documentation site for scala-lang.org. We're hoping that this solves a lot of the documentation issues that new users face. More details on this effort can be found at http://heather.miller.am/blog/2011/07/improving-scala-documentation/, but in summary...
Believe it or not, there are a lot of documents that the Scala team has produced but which simply aren't in HTML or are otherwise difficult to find. Such as Martin's new Collections API, his document on Arrays, or Adriaan's on Type Constructor Inference.
One goal of such a site is to collect all of this documentation in one place, in a searchable, organized, and easy-to-navigate format.
Another goal is to collect excellent community documentation out there, and to put it in the same place as well. For that, we are actively looking for quality (article/overview-like) material with maintainers. Examples include the Scala Style Guide, and Daniel Spiewak's Scala for Java Refugees.
Yet another goal is to make it easy for contributors to participate- so the site is built from RST source, which will live in a documentation-only github repo at https://github.com/scala/scala-docs.
So, in short, something better is on it's way, and contributors are very welcome to participate.
EDIT: http://docs.scala-lang.org is now live.
Several documents considered to be rather detailed or even obscure are already available. This includes all "Scala Improvement Proposals" (the proposals produced when new language features are suggested, and which are usually very detailed, and written by the implementers themselves). Also available is the entire glossary from Programming in Scala, Scala cheatsheets, amongst many other documents. The bottom-line of the site is to be community-focused and contribution-friendly-- so, free, and totally open. Suggested topics to cover are also welcome.
Take a look at scalaz and typelevel librairies (shapeless, spire, etc.), they rely on many advanced features of Scala.
*scalaz was for a time part of typelevel, but it is no more the case.
Josh Sureth's book goes a little beyond the usual. It's not as far as I'd like but I'm not his core audience - still, there's a lot of good stuff in there.
http://www.manning.com/suereth
Scala IRC: irc://irc.freenode.net/scala
Scala forum: http://scala-forum.org/
Blogs: Just look at http://planetscala.com/
Programming Scala (Wampler, Payne): http://ofps.oreilly.com/titles/9780596155957/
Programming in Scala (Odersky, Venners, Spoon) - good but Scala 2.8: http://www.artima.com/pins1ed/
The new documentation page is online:
http://docs.scala-lang.org/
I've kept a library of advanced Scala resources, primarily talks and blog posts. It's updated pretty regularly as I find new, interesting content.
Happy to add new links to it if anyone has recommendations.
Try to read SBT Source: https://github.com/harrah/xsbt/wiki
Its a good exercise. Also check out the book 'scala in depth' : http://www.manning.com/suereth/ by
Joshua D. Suereth
I believe there are a lot of good answer here. But as a sharing of experience. I have been coding Scala for 2 year (not my full time job), and been progressively better at it. My project is 97% Scala, and I have been able to do most of it with:
Programming Scala
The scala-user list
Stackoverflow
This cover most of the need for the "user" side of Scala, meaning all you need to create working application. However if you want to write some more complex code, or create powerful typed libraries you definitely need more.
If you want to go beyond the basics and are prepared to delve deeply into type system, and libraries, then the alternatives I use:
Use the community, scala enthusiast are really nice. I have worked with folks form Specs, Scalaz and Lift.
IRC is really good and some of the core contributors to some of the big library frequently show up.
Jump to source code, but don't try to understand everything. Scala type system can be daunting, however you normally don't need to understand 100% of it to use it.
If you really need to get into the nitty gritty details, hit the language specs, development list, and get to know the key people.
However you can really be very effective in Scala without needing to understand every single bit of the language.

Good Scala introductory article/video to whet the appetite

What are some good online articles or videos you've seen that would be most likely to get a developer interested in Scala? I'm looking for an introduction that is brief & to the point that dives right into example code, and would leave a developer who does not know Scala wanting to learn more about it.
Try in this order:
Pragmatic Real-World Scala - This video shows off all kinds of things that would make a Java developer drool.
Programming In Scala - This is simply a great general-purpose programming book. In addition to being a gentle, clear introduction to the language, it's also a fantastic introduction to functional programming concepts and language design. Even if you hate Scala,
this book will make you a better programmer.
Scala For Java Refugees - Very well-written mostly gentle introduction to major Scala concepts.
Another tour of Scala - A Java-centric breakdown of fundamental Scala features.
i went to this talk, it was excellent. can't tell if it is still there due to our internet restrictions, if it's not i'll delete this post.
http://powerhost.powerstream.net/008/00102/100203Scala.wmv
I'd go straight to the horse's mouth, the Scala website itself: Code Examples.
http://www.escalatesoft.com/screencasts
Escalate software is in the process of creating a series of screencasts for Scala information sharing and training purposes. The first available screencasts are provided here for free and cover the new features of Scala 2.8. In the longer term we will create training materials in the form of these videos along with supporting material that will be for sale from this and other sources as well.
http://blog.jaoo.dk/2009/03/09/an-introduction-to-the-scala-programming-language-by-bill-venners/
Take a look at the following presentation by Jonas Bonér (a well known figure in the Scala community, responsible for the AKKA actors concurrency framework). I'm sure this will whet the appetite for Scala.
http://www.infoq.com/presentations/Scala-Jonas-Boner
german introduction, maybe useful for you: http://www.rheinjug.de/videos/gse.lectures.app/Player.html#Scala
I would recommend Chapter 1. Zero to Sixty: Introducing Scala of the Programming Scala book by Dean Wampler and Alex Payne. The rest of the book is also great. The book is freely available online.
EDIT
I recently bought and read the Atomic Scala book by Bruce Eckel and Dianne Marsh. This is the best book I have read so far for anyone wanting to learn Scala.

Please suggest direction for my small scala project

As a academic project of 6 months in college me and my 3 friends are going to implement "Distributed Caching" in scala language.
Being new to both of these concepts and this being our first project I would be really happy if you guys could provide some direction.
I am currently learning scala.
Please let me know which particular features of language to be learned for this particular project.
Any online resources for learning distributed caching.
thanks in advance
You could have a look at Terracotta and especially at its uses in implementing Distributed Caching. You could have a look at the source code of the open source edition of Terracotta. Also, you could even consider Terracotta as your framework for building the distributed cache. I don't have any personal experience in using Terracotta with Scala, but it has been done.
Features of the language... Try starting with the Programming in Scala book. It's a very good resource. If you want to do any concurrency you will have to be proficient in using Actors. I would recommend having a look over all the features of Scala. Each one has its uses and you will need to know at least a bit of them to recognise situations in which to use their power. :)
-- Flaviu Cipcigan
You might want to look at the project Velocity page.
In MSDN also there is an article about distributed caching in general.
I'm not sure, but I think the Akka project might is already doing what you're looking for (and a whole lot more). Perhaps you can take inspiration from that.