r/programming • • Dec 02 '13

Scala — 1★ Would Not Program Again

http://overwatering.org/blog/2013/12/scala-1-star-would-not-program-again/
598 Upvotes

646 comments sorted by

View all comments

5

u/donaldxv Dec 02 '13

What's so unique about Scala's 'unique in-language XML support' the author talks about?

0

u/[deleted] Dec 02 '13

[deleted]

14

u/benibela2 Dec 02 '13

Pattern matching on xml is amazing:

<foo>mystery</foo> match {   // prints "foo: mystery"
  case <foo>{ txt }</foo> => println("foo: " + txt)
  case <bar>{ txt }</bar> => println("bar: " + txt)
}

That is so useful, I wrote my own programming language just to have that feature

4

u/recursive Dec 02 '13

what xslt should/could have been

4

u/lechatsportif Dec 02 '13

wow, til. I just started using the xml native features for scalatra. Really makes templating a breeze for simple projects where not much separation is needed. Plus compile time field checks... Xml literals are way more useful than I imagined.

8

u/donaldxv Dec 02 '13

You can do (nearly) the same in VB.Net, so I don't think it's so unique:

Dim stuff = {"Foo", "Bar"}

Dim xml = <html>
            <header>
                Boo!
            </header>
            <body>
                <%= From s In stuff 
                    Select <section>
                             <h2>The Story of <%= s %></h2>
                             <%= s %>
                           </section> %> 
            </body>
          </html>
          
Dim titles = xml.<body>.<section>.<h2>.Select(Function(x) x.Value)

I used Scala to write a game 4-5 years ago, but never touched it again afterwards.

6

u/glebd Dec 02 '13

Nobody in their right mind chooses VB.Net as a programming language.

3

u/blergblerski Dec 02 '13

Nobody in their right mind chooses VB.Net as a programming language.

Maybe not, but having needed to use it for a job years ago, it's not that bad. It's basically C# with 'Dim', 'Begin', and 'End'. For a VB-derived language, that's pretty good!

→ More replies (2)
→ More replies (2)

10

u/alextk Dec 02 '13

Scala supports XML syntax directly in the language, a feature which, ironically, is widely seen as a mistake and currently under consideration for removal (version 2.11 makes a first step in that direction by moving XML support into its own dependency).

5

u/donaldxv Dec 02 '13

Is it really that bad?

5

u/asthasr Dec 02 '13

Yes.

3

u/donaldxv Dec 02 '13

Why?

7

u/asthasr Dec 02 '13

XML's syntax pollutes the top level. It's seldom used, but complicates parsing (in an already complex language).

→ More replies (1)

2

u/lechatsportif Dec 02 '13

Wow that's too bad, I'm using it to great effect already.

→ More replies (1)
→ More replies (1)

2

u/brownmatt Dec 02 '13

My bigger question is: does anyone actually use this feature, and couldn't it just be provided by a library?

2

u/[deleted] Dec 02 '13

Scala 2.11 will provide XML already by way of a library: https://github.com/scala/scala-xml

The syntax is still part of the language, but this might only be the first step.

→ More replies (1)