Scala makes things "just work"

myndian.de

Samstag, 26. November 2005

Scala makes things "just work"

This is our response to Anonymous generic methods making things “just work” using Scala instead of C#. Others had coded solutions in Java or Groovy.

Here’s our code in Scala. Have a look, how simple things can be:

object FindPersonsDemo with Application
{
  case class Person(firstName: String, 
                    lastName: String,
                    age: Int);

  val persons = List(
      Person(“Cathi”, “Gero”, 35),
      Person(“Ted”, “Neward”, 35),
      Person(“Stephanie”, “Gero”, 12),
      Person(“Michael”, “Neward”, 12));
 
  val newards = for (val p <- persons;
                     p.lastName == “Neward”) yield p;
   
  Console.println(newards);
}

The solution in groovy is also very short and nice to read. I was impressed. We had a look at Groovy for some time, because it seems to be a very cool scripting language, with Java roots which makes it very interesting. So we tried to start using it for tests. We tried. With little success. After asking some questions in the user mailing list we got an solution, which did not satisfy us.

Many groovy examples I have read were confusing. There are so much tricks and things you have to know to understand them. A nice example is the map creation syntax, which starts a great discussion in the mailing list. It seems to be very nice:
def map = [name:“Wallace”, likes:“cheese”]
But you can only use Strings as identifier. I had not seen this until some one points this out on the mailing list. This is very ugly, I think.

Let’s get back to the example. I think Scala is much faster and in contrast to a scripting language and it is type save. Yes, it’s really type save, even if you don’t see some type informations in this short piece of code.

I think we will have a look at Groovy again in the future, but Scala seems to be the language of choice at the moment. (beside the standard languages like Java, C#, ...) There’s nother Nice one, but it does not seem to be stable enough for use in real projects.

The first real post in our new blog, by the way. :-)
Geschrieben von Jörg in Softwaretechnik um 20:48 | Kommentar (1) | Trackbacks (0)
Tags für diesen Artikel: c#, groovy, java, nice, scala
Artikel mit ähnlichen Themen:
  • Toying around ... with Scala
  • Grails tutorials and a free e-book
  • Runnig Grails
  • Premature optimization and object orientation
  • POJOs, POGOs und POCOs
  • View technologys for generated web layers
  • More about Groovy SQL Maps
  • Make your SQL Maps Groovy!
  • Groovy again
  • last language war language trolling

Trackbacks
Trackback für spezifische URI dieses Eintrags

Keine Trackbacks

Kommentare
Ansicht der Kommentare: (Linear | Verschachtelt)

Starting identifiers with numbers is generally bad practice and illegal for variable names in most languages.

Groovy can also compile to java byte code which makes it generally faster than most scripting languages :-)
Kommentar (1)
#1 Demis am 30.12.2005 02:00 (Antwort)
Yes, it is a bad idea to start identifiers with numbers, but that is not the point. My critic concerning the Groovy map syntax is, that it is not a map syntax. It is a property syntax.

There was a nice example on the mailing list where someone had to map numbers to the days of the week. That is not possible with this syntax, but not an uncommon case, I think. You also could not use variables as identifiers.

It is a nice syntax, if you accept, that it is just for properties. But why is it not a real map syntax?

Groovy is not very fast. Most other scripting languages seems to be faster, even if you compile groovy. But speed is not everything.
Kommentar (1)
#1.1 Jörg am 30.12.2005 08:29 (Antwort)
Ruby:

Struct.new(:firstname, :lastname, :age)
puts [Person.new(’Cathi’, ‘Gero’, 35),
Person.new(’Ted’, ‘Neward’, 35),
Person.new(’Stephanie’, ‘Gero’, 12),
Person.new(’Michael’, ‘Neward’, 12)
].select{|p| p.lastname == ‘Neward’}
Kommentar (1)
#2 Jules Jacobs am 12.01.2006 19:53 (Antwort)

Kommentar schreiben

Umschließende Sterne heben ein Wort hervor (*wort*), per _wort_ kann ein Wort unterstrichen werden.
Standard-Text Smilies wie :-) und ;-) werden zu Bildern konvertiert.
Die angegebene E-Mail-Adresse wird nicht dargestellt, sondern nur für eventuelle Benachrichtigungen verwendet.

Um maschinelle und automatische Übertragung von Spamkommentaren zu verhindern, bitte die Zeichenfolge im dargestellten Bild in der Eingabemaske eintragen. Nur wenn die Zeichenfolge richtig eingegeben wurde, kann der Kommentar angenommen werden. Bitte beachten Sie, dass Ihr Browser Cookies unterstützen muss um dieses Verfahren anzuwenden.
CAPTCHA

Sie können [geshi lang=LANG][/lang] Tags verwenden um Quellcode abhängig von der gewählten Programmiersprache einzubinden
 
 

Suche

Inhalt

Startseite
Galerien
Impressum

Kategorien

  • XML Alltag
  • XML Internet
  • XML Musik
  • XML Politik
  • XML Reise
  • XML Softwaretechnik
  • XML Sonstiges
  • XML Visuelles

Alle Kategorien

Archive

Februar 2012
Januar 2012
Dezember 2011
Das Neueste ...
Älteres ...

Blog abonnieren

XML RSS 2.0 feed
ATOM/XML ATOM 1.0 feed
XML RSS 2.0 Kommentare

Login

Verwaltung des Blogs

Login

Aktuelle Einträge

Netzwerkkultur verändert die Gesellschaft
Dienstag, 17. November

Absolute and relative date and time
Sonntag, 18. Oktober

Oren Lavie - Her Morning Elegance
Dienstag, 6. Oktober

Twitter & Blogroll
Samstag, 8. August

Read It Later: Round-Trip-Integration mit Firefox und Google-Reader
Montag, 3. August

Blogroll

* Jörg bei Twitter
* Jens bei Twitter
* Nils bei Twitter

* Beetlebum
* a life less ordinary?
* Martin Fowler's Bliki
* Springify
* BILDblog
* Plazeboalarm
* LawBlog
* ADOM Blog
* Being busy
* Dr. Gero Presser

Links

* Heise
* The Scala Programming Language
Nils' Fotos bei fotocommunity.de
Jogi auf Qype
Get Firefox!
Use OpenOffice.org

Heise News

* Auch Tschechien setzt ACTA-Ratifizierung aus

* Datenschutz-Zertifikat für De-Mail-Lösung von Mentana-Claimsoft

* Brüssel will schärfer gegen Copyrightverstöße im Web vorgehen

* Corning und Samsung wollen gemeinsam OLEDs fertigen

* Cloudyn bietet Dienst zur Überwachung der Kosten in der Cloud

kostenloser Counter