addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwchatcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscrosseditemptyheartexportfacebookfolderfullheartglobegmailgoogleimagesinstagramlinklocation-pinmagnifying-glassmailminusmoremuplabelShape 3 + Rectangle 1outlookpersonplusprice-ribbonImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruseryahoo

Re: [lsug] Help for Scala Newbs

From: Robin G.
Sent on: Tuesday, March 12, 2013 5:29 PM

One hitch with the "instantiate traits 'directly'" approach mentioned in that talk is that you can get shadowing that you wouldn't normally get with ordinary classes. For example, the old way here works as expected:

class CommonBaseClass {

  val name: String

}

class Person extends CommonBaseClass(override val name: String, val employer: String)

class Outer extends CommonBaseClass {

  val name = "Acme Co."

  val me = new Person(name = "Robin", employer = this.name)   // or just name

}

But the new way causes unexpected behaviour (or maybe expected... different people may expect different things to happen here):

class CommonBaseClass {

  val name: String

}

trait Person extends CommonBaseClass {

  val employer: String

}

class Outer extends CommonBaseClass {

  val name = "Acme Co."

  val me = new Person {

     override val name = "Robin"

     override val employer = name    // employer now equals "Robin"

// OK, not too surprising, but what happens if Person.name is only defined in a superclass, so it's not so visible here?

  }

}

Oops, by rewriting my code I've suddenly accidentally lost my Acme Co job and become self-employed ;)

Although this way is actually more powerful, because it allows you to have "constructor arguments" which depend on each other using lazy vals...

 

On[masked]:47, Caoilte O'Connor wrote:

I think Jamie was saying _use_ case classes (and implicitly that that would be for pattern matching too). I think this recent meetup covered why you might not want to use classes themselves (basically you can always just instantiate traits anonymously or use case classes).
The problem with the cake pattern is that there are a couple of different ways to do it but no standardised pattern that will iron out all the quirks. I thought Daniel Spiewak's NEScala keynote did a particularly good job at summarising the situation (but I wish he'd had another half hour).
c

On Tue, Mar 12, 2013 at 1:26 PM, Jim Collins <[address removed]> wrote:
I don't entirely agree with what you said regarding classes and case classes for data structures. Case classes and pattern matching are very useful.

On 12 March[masked]:04, Jamie Pullar <[address removed]> wrote:
I would recommend for starting in Scala if you are going to be writing production level code, then focus on getting a few core principles in place to save on future re-factoring.
Don't use nulls, make sure you have a good understanding of Option, and how it can be thought of as a List of one element.
Try to remove any state, and ring fence as much as possible the state you can't do without (transactions and the like).
Try to avoid using classes, case classes for data structures, traits for functions is often sufficient for nearly everything.
The cake pattern is a tad odd, but worth getting your head around.
Look into structures like the new Try monad, as you shouldn't be catching exceptions.
If you can't make something purely functional, try to abstract it so that you can return to it for later refactoring when your experience of Scala has improved.
Anyone else got any lessons?


On Tue, Mar 12, 2013 at 11:28 AM, Alois Cochard <[address removed]> wrote:



On 12 March[masked]:41, Samantha hepburn <[address removed]> wrote:
Thanks Gemma this is very useful. I have abbreviated parts of what you have said so that we could put this into a post that could work for students and Java devs alike. 
If anyone else has any thoughts or comments they would like to add to this under the headings:
Why you should look at the Scala language?
Because it rocks
 
or
How to do it?
I'd be interested in hearing them. Again either directly or through the list...
Samantha Hepburn
Business Development Executive

recworks.co.uk | [address removed] | Linkedin 
| Skype samantharecworks | Mobile [masked] | Office [masked] |  Fax: [masked] 

For all our latest jobs, visit www.recworks.co.uk/jobs

RecWorks Ltd  |  Registered in England and Wales. Registered No. [masked] 

Email disclaimer: This email contains information which may be confidential. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) do not copy this communication, or disclose it to any other person. If you have received this email in error please notify the sender immediately, delete the message from your computer system and destroy any copies.  Except where this email is sent in the usual course of our business, any views or opinions presented are solely those of the author and do not necessarily represent those of RecWorks Ltd. Although RecWorks Ltd operates anti-virus programs, it does not accept responsibility for any damage whatsoever that is caused by viruses being passed. Replies to this email may be monitored and/or recorded by RecWorks Ltd for operational or business reasons.
On 11 Mar 2013, at 15:35, Gemma <[address removed]> wrote:

Hi Sam,
I am one of the java developers who is switching into Scala. I am not a graduate, although I feel like one (in the sense that I still have loads of things to learn) as the English language barrier has slowed down my learning curve when I moved to London 6 years ago. Nonetheless I may have enough experience and a bit of vision to understand the popularization of this language.

It is said functional languages allows to write code in a concise and elegant way (something I've heard of any language I learnt :p) as well as easy concurrency code because it always works with immutable objects (i.e. it can't happen that two threads would amend the value of the same variable at the "same time"). I also believe their syntax and language constructions (loops, function definitions,etc.) goes well with domain problems such as machine learning or complex code that requires from more elaborated algorithms. What Scala also seems to fit in is in systems that last couple of decades have been implemented using OOP. The latter with the fact that Scala compiles to the JVM may explain why this language is becoming popular for java developers. In addition, I think technologies are a bit like business in the way that they become successful when they are used at the right time. Nowadays we have computers with several CPUs and it is said that this has greatly contributed to the success of languages that  use side effect free functions as a basic building block. This is the case of Scala, Clojure, Haskell,etc.
Looking at other languages like Rubgy, Python or even CoffeScript I could recognize concepts that I've learnt when I did the course in Scala. I guess those are the so called functional style features. It is important to understand the paradigm (e.g. lambda calculus) as that is what differentiates one program from another. Languages are just tools that allows us to talk to computers. The level of abstraction in our minds is what really makes the difference (at the end is all translated to bits, isn't it?). In other words you could program in Scala following a imperative style and don't get any advantage of the declarative programming paradigm. 
The way I am approaching this myself started with the course given my Martin Odesky in Coursera (www.coursera.org). Despite the academic approach I found it extremely good to set the basis for further study. My idea is to carry on doing small exercises, such as well known algorithms (e.g. dijstra, mergesort,etc.) at the same time I attend dojos, hack days,etc. (Next Saturday is at MindCandy, good to extend to other interesting technologies of the Typesafe stack. I can't go myself as I have an exam on the same day but I went to Hack the Tower in central london and it was all worth). To go further in this language you may need to be able to use it in your work environment but that is another story that more experienced scala developers could talk about.
To sum up, there is nothing that says that java developers should move to Scala, this is just an option for a path as a developer, however the Scala community welcomes anyone who wants to join us. You can either do a self study course (online tutorials, coursera, books, etc.) or if you can afford it you can go to a more structured, speed up training courses. In any case make sure you get the basis right. Go beyond and understand the whole picture.


Hope this information is of any use. I am not an expert in this theme so let me apologize in advance if there is something written which is incorrect. Anyone who wants to clarify or comment please feel free to do so.
Best regards,
Gemma

On 11 March[masked]:47, Samantha hepburn <[address removed]> wrote:
Hey guys,
Sam here, some of you know me from the LJC but for those that haven’t yet met me I’m the chatty South African Evangelist at RecWorks 
We’re seeing a growing interest in Scala from LJC members, especially juniors and graduates asking questions about Scala e.g Why as Java devs they should get into Scala, how to get into it and where to start.
We’ve heard of a few online courses and wondered which were good/worth looking into. Others have asked if they should just get stuck in with an open source Scala project and go the self-taught route. I’m by no means a coder so I thought it would be worth posting this here and getting groups input so we could put something together for Java developers looking to learn some Scala skills.
If you have any thoughts, please reply directly or through the list.
Kind regards,
Sam
Samantha Hepburn
Business Development Executive

recworks.co.uk | [address removed] | Linkedin 
| Skype samantharecworks | Mobile [masked] | Office [masked] |  Fax: [masked] 

For all our latest jobs, visit www.recworks.co.uk/jobs

RecWorks Ltd  |  Registered in England and Wales. Registered No. [masked] 

Email disclaimer: This email contains information which may be confidential. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) do not copy this communication, or disclose it to any other person. If you have received this email in error please notify the sender immediately, delete the message from your computer system and destroy any copies.  Except where this email is sent in the usual course of our business, any views or opinions presented are solely those of the author and do not necessarily represent those of RecWorks Ltd. Although RecWorks Ltd operates anti-virus programs, it does not accept responsibility for any damage whatsoever that is caused by viruses being passed. Replies to this email may be monitored and/or recorded by RecWorks Ltd for operational or business reasons.





--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Samantha hepburn ([address removed]) from London Scala Users' Group.
To learn more about Samantha hepburn, visit his/her member profile
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, POB 4668 #37895 NY NY USA 10163 | [address removed]




--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Gemma ([address removed]) from London Scala Users' Group.
To learn more about Gemma, visit his/her member profile
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, POB 4668 #37895 NY NY USA 10163 | [address removed]





--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Samantha hepburn ([address removed]) from London Scala Users' Group.
To learn more about Samantha hepburn, visit his/her member profile
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, POB 4668 #37895 NY NY USA 10163 | [address removed]


--




--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Alois Cochard ([address removed]) from London Scala Users' Group.
To learn more about Alois Cochard, visit his/her member profile




--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Jamie Pullar ([address removed]) from London Scala Users' Group.
To learn more about Jamie Pullar, visit his/her member profile





--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Jim Collins ([address removed]) from London Scala Users' Group.
To learn more about Jim Collins, visit his/her member profile
Meetup, POB 4668 #37895 NY NY USA 10163 | [address removed]




--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Caoilte O'Connor ([address removed]) from London Scala Users' Group.
To learn more about Caoilte O'Connor, visit his/her member profile
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, POB 4668 #37895 NY NY USA 10163 | [address removed]

 

 

This email message originally included an attachment.

Our Sponsors

  • Scala Dojo

    Web site for monthly Scala Dojo

  • Scala Jobs

    Google Group of Scala Jobs in the London Area

  • _.underscore

    Scala consultants, trainers, and developers, based in London, UK

  • Springer

    Help and supporters of the monthly dojo

  • Skills Matter

    Provide the venue for many of our meetings.

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy