5 ms·
The biggest thing that is still in the language that they should have removed early on is the native XML syntax support. If I were them I would take it out in 3
by spullara 15y ago
The biggest thing that is still in the language that they should have removed early on is the native XML syntax support. If I were them I would take it out in 3.0 and break from that bad decision.
- deleted 15y ago[deleted]
- dustingetz 15y agoplease elaborate? do you think its harmful because it influences people to reach for XML instead of another format?
- kikibobo69 15y agoI used to agree, until I ran into a bunch of inline StringBuilder Java XML where no schema existed, and simply converting it to Scala at least ensured it was well-formed while we reverse-engineered a schema. I agree it's not something one should use much (well, maybe with Lift), but wow, is it ever useful when it's useful. I agree, doesn't hurt much; helps massively when you need it.
- jorgeortiz85 15y agoSee my answer on Quora to "Will Scala ever remove XML literals?" http://www.quora.com/Will-Scala-ever-remove-XML-literals http://www.quora.com/Will-Scala-ever-remove-XML-literals Summary: No. At the time that Scala was started, built-in support for XML showcased one area were object-oriented decomposition failed and functional programming proved quite useful. Today the benefits of FP are more well known, and it's generally agreed that if Scala were starting from scratch it would not include XML literals. However, given that XML literals are in the language already, that large code bases have come to rely on them, and that they generally don't get in the way if you don't use them, it's unlikely that they will be removed.
- _sh 15y agoSolution: move it to a library, like perl did with it's format syntax, and take it out of core.
- jorgeortiz85 15y agoThis is hard because Scala's XML support affects the parser. At the lexical level. Scala does have compiler plugins, but it doesn't have parser plugins.
- corruptmemory 15y agoAgreed. Macros and reader macros ;-)
- jorgeortiz85 15y agoLet me know when you figure out how to statically type check those. You could publish a paper or two, I'm sure.
- corruptmemory 15y agoNemerle already does it: http://nemerle.org/macros.html http://nemerle.org/macros.html, so does Template Haskell: http://www.haskell.org/haskellwiki/Template_Haskell http://www.haskell.org/haskellwiki/Template_Haskell
- a_strange_guy 15y agoYou don't typecheck macros since they run at compile time. You typecheck the expanded code instead.
- samth 15y agoAnd we did! Check out: http://blog.racket-lang.org/2011/03/languages-as-libraries-pldi-2011.html http://blog.racket-lang.org/2011/03/languages-as-libraries-p...
- corruptmemory 15y ago
- fizx 15y ago...because what scala needs is more api-breaking decisions...
- curtis 15y agoPutting XML literals in the language just feels wrong. On the other hand, they've turned out to be damn useful when you're writing the back end for a web application.
- corruptmemory 15y agoIt was a mistake. A better effort would have been to implement a first-class Macro system a-la Lisp. You can see here that Nemerle supports macros and makes dealing with XML like relatively painless as if it were built in: http://nemerle.org/About/#ID0E6G http://nemerle.org/About/#ID0E6G Macros for the win.
- cageface 15y agoDisagree. Scala's syntax is already complex enough and flexible enough to all but eliminate the need for macros. XML literals were a marketing gimmick. More conventional XML support in a library would have been adequate.
- corruptmemory 15y agoInteresting. This is a common perception but not an easily justified one. A macro-system a-la Lisp (or Nemerle) could easily replace compiler plugins, and there is an active compiler plugin community so extensions to the compiler are desirable. As someone who writes in Scala every day for a living and have used the built-in XML support here and there I do not consider Scala syntax to be complex, but the XML support is ~eh~. Despite limitations and warts it's a pretty nice language to code in on a daily basis if you're going to code on the JVM. Macros would definitely enhance Scala's productivity. If you don't like them don't use them. Certainly doesn't mean that others could not put such a tool to good use.
- cageface 15y agoThat's the problem with macros. It's hard enough to read Scala code as it is if the author wants to be clever. Throw in macros and it's game over. In languages with relatively inflexible or primitive syntaxes macros are a blessing but I think they're unnecessary in Scala.
- corruptmemory 15y agoThere are several decent Scala-esque alternatives to the built-in XML support (with has many things broken about it). For instance: Anti-XML http://anti-xml.org/ http://anti-xml.org/ and Scala-Scales: http://code.google.com/p/scala-scales/ http://code.google.com/p/scala-scales/ they can't replace the functionality of the built-in support (need to alter parser/compiler for that), but are considerably more sane than the default functionality in scala.xml