Talk:Scala (programming language)
![]() | Java Stub‑class Low‑importance | |||||||||
|
Promotion.
Seems to me that this article is a bit too promoting of the Scala language. A more neutral p-o-w would be in place.
Which parts specifically do you think should be changed? -- Phouk
I didn't write the first comment about it being too self-promoting, but it certainly has that feel. Here's an example sentence: "Scala provides a unique combination of language mechanisms that make it easy to smoothly add new language constructs in the form of libraries". The word "unique" is particularly objectionable. There are (at least) thousands of interpreted languages out there. Is scala truly the only one for which it is "easy to smoothly add new language constructs in the form of libraries" to?
- IMHO, if 'unique' is kept, it should be supported by an external quote / citation. Alternatively, what about calling it a 'novel' approach. The way Scala can be extended is indeed strikingly different from what we know of other mainstream languages (It's not dynamically rebinding a prototype and it's not some kind of macro feature) 93.104.71.211 (talk) 23:08, 25 February 2011 (UTC)
Scala might be very good, of course. But the words "performance", "speed", "scope", and "memory" do not appear in the current form of the article, so it doesn't have the feel of a dispassionate examination of the language. Son of eugene (talk) 19:09, 30 October 2010 (UTC)
12.27.255.133 21:51, 27 September 2007 (UTC) The Scala homepage doesn't say anything about .Net, just the JVM...
See point 5.2 in the faq (http://www.scala-lang.org/docu/faq.html#id2244551): Q: Does Scala work on .NET? A: There are plans for Scala to run on .NET, and the previous version of Scala ran on .NET, but the current version does not. While .NET has many similarities to Java, it has enough idiosyncrasies that the port is non-trivial. -- Phouk
As of May 6, 2008, supporting the .NET backend is a current focus of the Scala team. This feature did languish for a while. —Preceding unsigned comment added by 128.197.41.105 (talk) 16:29, 7 May 2008 (UTC)
Quick sort example
I propose the following variant of quick sort, which uses List.partition
and does a slightly simpler concatenation.
I think it is easier to understand.
def qsort(l: List[Int]): List[Int] = { l match { case Nil => l case pivot :: tail => { val (lt, gte) = tail.partition(_ < pivot) qsort(lt) ::: pivot :: qsort(gte) } } }
Opinions?
--DavidBiesack (talk) 22:17, 7 February 2008 (UTC)
- Just my opinion: the existing example is meant to be a direct translation of the Erlang example, and allowing the reader to compare the syntax on the same code is important. For me the current example is quite easy to understand and has a more "functional" style. And yep, the point is that in functional programs one line of code can express much more than in imperative ones, so they're too short for the imperative programmer to understand, but that's the coding style I've seen used by experienced programmers most of the time, so IMHO one just has to get used, and I'd keep this.
- I have studied Scheme and Haskell at a university course (and a bit more of Haskell), and I still remember that feeling (I mean, I never got really used to functional programming, unfortunately), so I'm arguing this even if I'm no expert. And all my previous contact with Scala was a paper with examples in Scala, explained to our class in less than one hour.
So, the only good point of your version is that it should be slightly faster since it uses List.partition
and does just one pass on the list, but that's not relevant for an introductory article, IMHO.
--Blaisorblade (talk) 03:17, 7 January 2009 (UTC)
Maybe I'm wrong, but I think the example has a bug: What happens if the pivot element is in the list more than once? For example: "2, 2, 3" In this case, the result of sorting would be "2, 3", because every element with the same value as the pivot element is filtered out, but only one element with the value of the pivot element is reinserted. To correct it, I would replace "tail.filter(_ >= pivot)" with "tail.filter(_ > pivot)" and not insert the pivot element manually. --84.177.151.15 (talk) 21:39, 22 September 2009 (UTC)
polymorphic methods.
The article currently contains a reference to 'Polymorphic methods' which cross links to Polymorphism (computer science) which is a redirect to Type polymorphism. Is there a better page to link to? Regards, Ben Aveling 09:11, 7 September 2008 (UTC)
Add performance discussion?
No discussion about the performance cost of advanced Scala features is present. I have reasons to believe their support for advanced features has some cost, some discussion about that is present here: http://wiki.jvmlangsummit.com/ScalaOptimization, since a "future works" section is present. Could someone add a mention of that? --Blaisorblade (talk) 03:30, 7 January 2009 (UTC)
- Further, there is an associated published workshop paper which we can cite:
- Iulian Dragoş, Optimizing Higher-Order Functions in Scala, Third International Workshop on Implementation, Compilation, Optimization of Object-Oriented Languages, Programs and Systems (ICOOOLPS 2008), 2008
- — Matt Crypto 10:18, 7 January 2009 (UTC)
Pronunciation of Scala
The given pronunciation doesn't seem right. The main author of Scala (Odersky) pronounces it (in the podcast referenced by the article, for example) as the Italian word (meaning stairs, stairway, ladder etc.). Something like /'ska:la/ in fake IPA. I'm not sure how to show both pronunciations in Wiki but I'd be even happier with just the one correct pronunciation. —Preceding unsigned comment added by 92.234.33.124 (talk) 20:09, 11 February 2009 (UTC)
See also: http://scala.sygneca.com/faqs/general#how-is-scala-pronounced 92.234.33.124 (talk) 20:21, 11 February 2009 (UTC)
It should also be noted that the proper pronunciation (which is skah-lah) can be found in a footnote on page 3 of "Programming in Scala" by Martin Odersky, Lex Spoon, and Bill Venners (http://www.artima.com/shop/programming_in_scala). Enum (talk) 05:55, 23 January 2010 (UTC)
Imperative programming in Scala?
This article does not say whether Scala allows imperative (non-functional) programming style. Please ammend the article with an answer on the question whether Scala is a purely functional, mostly functional, or both functional and imperative language. 77.127.45.42 (talk) 00:29, 14 November 2009 (UTC)
From what I understand, it supports scripting / imperative style, object oriented style, and functional style. It also implements the actor model for concurrency. I think all of these things should be added to the article. Enum (talk) 05:48, 23 January 2010 (UTC)
A Scala program can be purely imperative, purely functional or a mix of both styles. It is advisable to minimize or eliminate imperative coding involving concurrency. —Preceding unsigned comment added by 24.29.41.118 (talk) 06:52, 19 May 2010 (UTC)
Correctness of given functional quicksort?
In...
def qsort(list: List[Int]): List[Int] = list match { case Nil => Nil case pivot::tail => qsort(tail.filter(_ < pivot)) ::: pivot :: qsort(tail.filter(_ >= pivot)) }
... it seems to me that the code may [always does?] yield an incorrect duplication of the pivot value [1 more copy than in the input], and yet changing "qsort(tail.filter(_ >= pivot))" to "qsort(tail.filter(_ > pivot))" will only replace one problem with another: now, the pivot value will be represented only once in the sorted output even if it was present multiple times in the input. I think the "solution" is to replace the existing example with the one above [i.e. on this talk page]. Maybe I am misunderstanding something here. Comments and/or suggestions? —Preceding unsigned comment added by 66.114.69.71 (talk) 07:41, 26 November 2009 (UTC)
The code in the article at the time of this comment works (though it could be optimized with a tail call). Enum (talk) 05:50, 23 January 2010 (UTC)
Correct Scala code for qsort
I think the partitioning of the collection was not done correctly, pivot is the element in the middle of the sequence, in the traditional quick-sort algorithm. Moreover a good typing would use Seq instead of List or Array.
def qsort(seq: Seq[Int]): Seq[Int] = { if (seq.length < 2) seq else { val pivot = seq(seq.length / 2) qsort(seq.filter(pivot > _)) ++ seq.filter(pivot == _) ++ qsort(seq.filter(pivot < _)) } }
(not signed)
In an ideal case, the pivot would be set to the median of the values contained in the list. Choosing a number in the middle of a list of randomly distributed numbers would not improve speed at all, only harm it by adding a division to every recursive call (Though division is also considered a constant-time operation). In any case, I think the argument against the current version is moot and would not improve the article. Enum (talk) 06:05, 23 January 2010 (UTC)
Sources
Some source links seem to point to wrong or dead resources (e.g. [2] would point to .NET if the link were not dead, although the text talks about Java Micro Edition).