Talk:Scala (programming language)
This is the talk page for discussing improvements to the Scala (programming language) article. This is not a forum for general discussion of the article's subject. |
Article policies
|
Find sources: Google (books · news · scholar · free images · WP refs) · FENS · JSTOR · TWL |
This level-5 vital article is rated B-class on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Belgian Band
editWhat about the band from Belgium? — Preceding unsigned comment added by 217.82.196.35 (talk) 17:52, 3 December 2004 (UTC)
Make this a disambiguation page?
editThe programming language and the music stuff should not be in one article... — Preceding unsigned comment added by 24.217.227.208 (talk) 03:46, 23 April 2005 (UTC)
You should also consider the scala that makes digital signage software. — Preceding unsigned comment added by 63.145.211.105 (talk) 21:29, 1 August 2005 (UTC)
To get an idea how many different Scala's there are, look at this page... http://www.scala.org.au/linscala.htm — Preceding unsigned comment added by 63.145.211.105 (talk) 20:49, 2 November 2005 (UTC)
Promotion.
editSeems 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)
See http://grokbase.com/t/gg/scala-user/131pet3xr5/whats-the-state-of-scala-net. I think that it should be edited, since as it is written now, it seems that .NET is fully supported, which is not quite the state. — Preceding unsigned comment added by ספלינטור (talk • contribs) 21:07, 20 July 2013 (UTC)
Scala can call Java classes or use its jars, but the opposite isn't true: Java can't interact with Scala methods or classes (at least, not easily). This makes Scala not interoperable with Java. This isn't mentioned enough.
Maybe Scala had for goal to address issues of Java, but currently it's learning curve put it among the programming langages the most difficult to learn.
Consider it's TIOBE ranking falling to 0.5%, or books about Machine Learning available now, that are now explaining Apache Spark programmation with the help of Python and not Scala anymore.
Yes, same as some wrote here, I believe that this page is too much promotional. And that reality is not so nice. 192.93.161.33 (talk) 13:59, 30 August 2023 (UTC)
Quick sort example
editI 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.
editThe 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?
editNo 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
editThe 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)
I realise this is a bit rude these days, but after three supporting comments spanning 2 years, the last of which is now more than three years old, I'm just going to change the last syllable of the noted pronunciation. There is no reason nor precedent for the final vowel to be a schwa (ə). Indeed, the schwa renders it quite difficult to pronounce and, ignoring the fact that it has already been explained not to be a schwa, is an entirely unlikely pronunciation.
Based on numerous recordings of the author on Youtube and similar sites I have chosen the IPA "ʌ" (respell "u"); some may debate that "a:" is more correct, but at least such a debate would be somewhat dialectical, rather than any support of schwa, which is simply misguided, or at best a result of the rather odd yet repeated choice of "about" as an example of the schwa sound in many IPA references.77.254.197.201 (talk) 14:14, 19 July 2013 (UTC)
I disagree with the above editor, you certainly can’t say that a schwa is unnatural in English. A schwa in Scala would make the most sense if you don’t stress the final syllable, same as you would in Java /ˈdʒɑːvə/ and koala /koʊˈɑːlə/. I don’t know of any case of a syllable final /ʌ/ other than monosyllabic words such as 'pho', and even then this is only true of some dialects of American English. I don’t know of any dialect of English which allows /ʌ/ to exist unstressed.
However, Martin is a German and will more naturally say Scala without a schwa, so the ruling on /ˈskɑːlɑː/ is fine by me, but most English speaking programmers will prefer /ˈskɑːlə/, so I’d appreciate both being listed as valid. — Preceding unsigned comment added by R.I.McGhee (talk • contribs) 03:07, 7 November 2018 (UTC)
Imperative programming in Scala?
editThis 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?
editIn...
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
editI 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
editSome 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).
Too close for comfort / barely-disguised plagiarism?
editArticle: Scala is a pure object-oriented language in the sense that every value is an object. Data types and behaviors of objects are described by classes and traits. Class abstractions are extended by subclassing and by a flexible mixin-based composition mechanism to avoid the problems of multiple inheritance.
scala-lang.org: Scala is a pure object-oriented language in the sense that every value is an object. Types and behavior of objects are described by classes and traits. Classes are extended by subclassing and a flexible mixin-based composition mechanism as a clean replacement for multiple inheritance.
Article: The design of Scala acknowledges the fact that, in practice, the development of domain-specific applications often requires domain-specific language extensions. Scala provides a novel combination of language mechanisms that make it easy to smoothly add new language constructs in the form of libraries:
- any method may be used as an infix or postfix operator, and
- closures are constructed automatically depending on the expected type (target typing).
A joint use of both features facilitates the definition of new statements without extending the syntax and without using macro-like meta-programming facilities.
scala-lang.org: The design of Scala acknowledges the fact that in practice, the development of domain-specific applications often requires domain-specific language extensions. Scala provides a unique combination of language mechanisms that make it easy to smoothly add new language constructs in form of libraries:
- any method may be used as an infix or postfix operator, and
- closures are constructed automatically depending on the expected type (target typing).
A joint use of both features facilitates the definition of new statements without extending the syntax and without using macro-like meta-programming facilities.
There may be more; I see nothing on Scala's site indicating that the text was released under Creative Commons. I'm hoping someone will verify that I'm not overlooking something obvious :) — anndelion ※ 22:24, 12 April 2011 (UTC)
Portmanteau?
editFrom the article: "The name Scala is a portmanteau of "scalable" and "language"..." That's not at all like the typical portmanteau, and much more like an acronym, as it's using only initial elements of each component, and the terminal of neither. Someone have a source calling it a portmanteau, that we can then ascribe to that source? Or perhaps better to play safe, and call it as "blend"? (Albeit a somewhat redundant one, since the "la" is (initial) in both root words.) 84.203.37.10 (talk) 17:30, 25 May 2012 (UTC)
- I agree actually, I would even say it seems that Scala is just the first five letters of "Scalable". Furthermore, the cited reference ([13]) doesn't seem to discuss about anything such as a portmanteau word.
- Potentially just say it is based on the word Scalable? 2001:861:3285:7E00:8F34:79F5:E70B:7ED5 (talk) 14:59, 27 October 2022 (UTC)
No import needed for java.lang in Java
editKnowing jack about Scala, I'm reluctant to edit the source code examples. However, the example that compares java.lang.Math in the two languages is wrong. All java.lang classes get imported automatically. See Java Specification 7.3Isaac Rabinovitch (talk) 23:34, 9 August 2012 (UTC)
Syntactic differences shown by code example
editThe article says: "1. Scala does not require semicolons." OK, but how come I don't see any semicolons in the Java code?
Scala still has type erasure
editThis part: "It cleans up what are often considered to have been poor design decisions in Java (e.g. type erasure" is at least misleading if not completely wrong. Type erasure in Scala is still present. There are workarounds, yes, but it is not solved(or "cleaned up") by the language at all. The same workarounds can be implemented in Java. — Preceding unsigned comment added by 149.135.146.69 (talk) 11:43, 15 April 2013 (UTC)
While technically the JVM exhibits type erasure, it would be misleading to call Scala's concept of "reified types" a work around. It really is a clean solution to type erasure. More so since Scala 2.10, where "manifests" are replaced by "type tags" which fully represent the Scala type system, meaning that you can have available at runtime every single aspect of a type. Type tags are used as type classes, e.g. def foo[A: TypeTag], and the Scala compiler will synthesise such type classes—at compile time (see http://docs.scala-lang.org/overviews/reflection/overview.html#inspecting_a_runtime_type_including_generic_types_at_runtime). It is not possible in Java to create a "workaround" that would come any near this approach. Indeed, the article should include a section on type reification. ItemState (talk) 17:19, 19 July 2013 (UTC)
Introduction Clean Up
editI feel the current introduction paragraph(s) are really poor and messy. Neither are they well structured, nor do they strike a good balance between conciseness and detail. In some questions they go into very specific details, while some things are almost identically repeated across different paragraphs.
It is indeed difficult to write a good introduction to Scala that strikes that balance. So my suggestion is to elaborate a bit on a new introduction in the talk page, before messing around with the actual article.
Here is my take on it (no references, -sigh-). Paragraph 1 should give a good overview of its scope. P2 than describes its environment (JVM) and gives examples of what it offers in terms of functional and OOP. P3 highlights Scala's type system, arguably the most important part of the language. I feel that this might be difficult to understand for someone not familiar with these terms? How to do this? P4 says something about Scala's syntax from the Java perspective (arguably the main source of adopters), P5 and P6 are somewhat disconnected: Talking a bit about Scala's novel contributions, and the concurrency paradigm (which is generally associated with Scala).
- - -
Scala (/ˈskɑːlʌ/ SKAH-lu) is a programming language which blends the paradigms of object-orientation and functional programming. It is statically typed with advanced language features, while still trying to be concise and elegant and maintaining the feel of a dynamic language. The name Scala is a blend of "scalable" and "language", signifying that it is designed to grow with the demands of its users. It can be employed in diverse scenarios such as lightweight scripting or distributed server applications.
Scala programs commonly run on the JVM and are compiled to Java bytecode. Good interoperability with Java libraries is a major goal. Several ongoing projects exist to bring Scala to other platforms such as .NET and JavaScript. On the JVM, Scala shares the basic properties of Java, such as its memory management and threading model, but introduces many advanced concepts. On the functional programming side, these include anonymous functions, optional lazy evaluation and call-by-name, pattern matching and algebraic types, and prominent support of immutable data structures—provided by way of its required standard library. Scala has a more unified type system than Java: There is no distinction between statements and expressions, none between primitive types and reference types, and values and types can both appear as (method or constructor) parameters or (class or local) members. Language elements can often appear in any scope, for example classes, methods and symbol imports can appear in any nesting level, and block expressions can be written anywhere.
Scala's type system is particularly elaborated. It has a top, a bottom and a unit type, it can express higher-order types, singleton types, intersection types and multiple inheritance through mixin composition, it supports type bounds and declaration site variance, and provides path-dependent types and type projections (denoting a nested type). Scala uses a limited form of type inference, making explicit type annotations often omissible.
Scala's syntax uses curly braces and focuses on ease of adoption for programmers coming from Java. While one can use a style akin to Java, "idiomatic" Scala encourages immutable over mutable variables, functional over imperative style, and the type-safe use of the Option class instead of null. Scala allows runtime exceptions like Java, but does not require to declare or catch them.
Scala also adds some novel constructs such a scoping rule called "implicits", a way by which the compiler is able to automatically fill in parameters. Implicits are used to define type classes and extension methods in Scala.
While it is often described as specially suited for concurrent programming, Scala advocates library based solutions over built-in language constructs. For example, actors, futures and software transactional memory are provided through libraries. — Preceding unsigned comment added by ItemState (talk • contribs) 22:13, 21 July 2013 (UTC)
General Clean Up
editI think the article would benefit from adding a version history section (perhaps with or under history). This would allow to concisely introduce named/default arguments, reified generics/reflection 2.10, macros, delimited continuation (if at all), parallel collections (if at all), string interpolation (if at all).
In general, someone should go radically through that article and give it a half way consistent touch (and probably cut away some parts). Right now it just feels like a dump of each and every feature that is available in Scala. Why is delimited continuations mentioned, but not XML literals? Many arbitrary choices.
The introductory I just wrote (above) already suffers from being too long. The article needs a good concept of nesting the information. Perhaps some stuff could even go into separate articles (e.g., Scala collections, Implicits (unique concept of Scala), perhaps Scala vs. Java).
ItemState (talk) —Preceding undated comment added 22:25, 21 July 2013 (UTC)
Tone
editThe lead reads like promotional material for the language. It actually creates a hype. The wording is far from optimal in many cases. Nxavar (talk) 21:31, 25 April 2014 (UTC)
- @Nxavar: Could you specify those cases? Brycehughes (talk) 03:39, 26 April 2014 (UTC)
- I edited the first paragraph for tone as an example. The "source" for elegance was removed since it was not supporting the argument that Scala is elegant. Similar tone editing can be done for the second paragraph. The amount of technical information (the way it is presented is one of the typical ways of creating hype for technology products), for example, needs to be reduced. Nxavar (talk) 08:42, 26 April 2014 (UTC)
- @Nxavar: Thanks. Could you edit the second paragraph as well? I took a look at it, but I'm not sure how I'd go about it. Usually better to make the edits you desire as apposed to fly-by tagging and leaving it for others. Brycehughes (talk) 15:27, 26 April 2014 (UTC)
- In my edit of the first paragraph I had as a model the way other languages are presented in Wikipedia. I am a programmer myself but I have little knowledge and experience in functional programming. While the first paragraph was general enough to be edited by a non-expert in functional languages, I think the second needs someone more familiar with this programming paradigm, because it goes into a lot of detail. As a general comment, I believe that the amount of detail should be reduced, which would be easier with a rewrite. The problem is I don't know what to take out, or how to group things. Maybe you can take a shot at a rewrite? Nxavar (talk) 11:16, 27 April 2014 (UTC)
- @Nxavar: Ok, done. Brycehughes (talk) 17:03, 27 April 2014 (UTC)
- In my edit of the first paragraph I had as a model the way other languages are presented in Wikipedia. I am a programmer myself but I have little knowledge and experience in functional programming. While the first paragraph was general enough to be edited by a non-expert in functional languages, I think the second needs someone more familiar with this programming paradigm, because it goes into a lot of detail. As a general comment, I believe that the amount of detail should be reduced, which would be easier with a rewrite. The problem is I don't know what to take out, or how to group things. Maybe you can take a shot at a rewrite? Nxavar (talk) 11:16, 27 April 2014 (UTC)
- @Nxavar: Thanks. Could you edit the second paragraph as well? I took a look at it, but I'm not sure how I'd go about it. Usually better to make the edits you desire as apposed to fly-by tagging and leaving it for others. Brycehughes (talk) 15:27, 26 April 2014 (UTC)
- I edited the first paragraph for tone as an example. The "source" for elegance was removed since it was not supporting the argument that Scala is elegant. Similar tone editing can be done for the second paragraph. The amount of technical information (the way it is presented is one of the typical ways of creating hype for technology products), for example, needs to be reduced. Nxavar (talk) 08:42, 26 April 2014 (UTC)
I'm a beginner in editing Wikipedia articles, but I have a few comments. Firstly, I think this section should be merged with section 3 - promotion, as it discussed a similar problem with this article. In addition, I have a few other edits to help balance the tone of the article:
- Lines 1-2: "a very strong static type system". I think "a static type system" will do, but if some adjective is to be kept, we should at least remove the "very"
- Lines 2-3: "were inspired by criticism of Java's shortcomings". The "shortcomings" part is an opinion. We could write that the language was inspirted by criticism of Java, as criticism can be subjective. Adding the phrase "of Java's shortcomings" makes a statement that the criticism is justified.
- In the section "Features (with reference to Java)" the third paragraph makes a bold case that Scala has significantly more features than Java which make the language "theoretically cleaner". This is a highly promoting tone, that should at least be backed up with references if not completely rewritten.
I have other examples as well, but I think these 3 are a good start. Deansg (talk)
Companies
editAny objection to deleting the "Companies" section? Scala was broad acceptance now, as indicated by the immediately preceding "language rankings" section, and the "companies" section has become merely a spam pot. Michaelmalak (talk) 15:51, 30 June 2014 (UTC)
- Support. Rankings covers adoption well enough. Brycehughes (talk) 18:59, 30 June 2014 (UTC)
- Support. Soc88 (talk) —Preceding undated comment added 21:25, 18 April 2018 (UTC)
- Objection. The section contributes to understanding adoption. 87.138.226.29 (talk) 21:15, 28 March 2023 (UTC)
Scala support for currying
editThe article mentions that Scala supports currying. Checking the the Scala Documentation I found a section on currying. However, the example given is that of a partial function. Interestingly there is a note after the example saying that "modN is partially applied in the two filter calls", modN being the function that is supposedly being curried.
Here is modN:
def modN(n: Int)(x: Int) = ((x % n) == 0)
Here are the expressions that use modN to create a function argument:
println(filter(nums, modN(2)))
println(filter(nums, modN(3)))
It is clear that we have a value binding, which is what happens for partial functions, not currying. Nxavar (talk) 18:15, 5 November 2014 (UTC)
- I'm not expert enough in functional programming to identify the difference, but does this Odersky document convey actual currying on page 23? Scala By Example Michaelmalak (talk) 18:47, 5 November 2014 (UTC)
- The example function in the book is:
def sum(f: Int => Int): (Int, Int) => Int = {
def sumF(a: Int, b: Int): Int =
if (a > b) 0 else f(a) + sumF(a + 1, b)
sumF
}
- It takes a function with one argument and it embeds it to another function which is then returned. The above example is not currying because the returned function is not a single argument function. However, it shows that Scala has syntactic support for currying.
- This is how a curried function for addition would look like in Scala:
def add(a: Int): (Int) => Int = {
def increment(b: Int): Int =
a + b
increment
}
var c = add(5)(6) // c = 11
- In conclusion, Scala supports currying, although none of the examples mentioned here are about currying. Nxavar (talk) 19:59, 5 November 2014 (UTC)
- While there is a difference in Scala between
def foo1(a: Int)(b: Int): Int = a + b
def foo2(a: Int): (Int) => Int = (b: Int) => a + b
val foo3: Int => Int => Int = (a: Int) => (b: Int) => a + b
for all these goes that
val c: Int = foo1(5)(6) //or foo2(5)(6) or foo3(5)(6)
is perfectly legal and does what you expect. The difference shows up at
val tst1: Int => Int => Int = foo1 _
val tst2: Int => Int => Int = foo2 _
val tst3: Int => Int => Int = foo3
where methods need eta expansion to be converted to functions. Technically speaking only foo3 is a (curried) function, the other two are methods. Calling foo2 a curried function, but not foo1 doesn't seem right. Martijn Hoekstra (talk) 14:48, 13 November 2014 (UTC)
- Agree, my mistake. I was confused by the equivalence of partial application and currying for two-argument functions. Nxavar (talk) 20:20, 15 November 2014 (UTC)
Still a reference to .NET
editShouldn't this: ", or .NET libraries in the .NET implementation." be removed? -- Dough34 (talk) 16:01, 6 March 2015 (UTC)
java functions are unused in Comparison Java and Scala with classes
editHey,
i'm not very familiar with java but as i can see, the function getX() and getY() were defined, but never used. Therefore, i don't think this comparison is fair because the java code is bloated.
regards
- The reason they are there is to provide an immutable field. The way
x
andy
are setup is to produce the same effect as the Scala class parameters of the same name. - Deuceboise (talk) 17:02, 17 January 2019 (UTC)
import
in example
edit
In the section Basic example, it is said:
- Instead of Java's
import foo.*;
, Scala usesimport foo._
.
But it looks more like an equivalent of Java's import static foo.Bar.*;
. IS that a mistake in the article or is there more about Scala's import?
Sinthoniel (talk) 12:46, 18 December 2015 (UTC)
- The confusion is likely due to Scala not having static methods. The closest equivalent to importing static methods in Scala would be
import foo.Bar._
whereBar
is a singleton object. - Deuceboise (talk) 16:04, 17 January 2019 (UTC)
External links modified
editHello fellow Wikipedians,
I have just added archive links to one external link on Scala (programming language). Please take a moment to review my edit. If necessary, add {{cbignore}}
after the link to keep me from modifying it. Alternatively, you can add {{nobots|deny=InternetArchiveBot}}
to keep me off the page altogether. I made the following changes:
- Added archive https://web.archive.org/20100831041226/http://blog.lostlake.org:80/index.php?/archives/73-For-all-you-know,-its-just-another-Java-library.html to http://blog.lostlake.org/index.php?/archives/73-For-all-you-know,-its-just-another-Java-library.html
When you have finished reviewing my changes, please set the checked parameter below to true to let others know.
This message was posted before February 2018. After February 2018, "External links modified" talk page sections are no longer generated or monitored by InternetArchiveBot. No special action is required regarding these talk page notices, other than regular verification using the archive tool instructions below. Editors have permission to delete these "External links modified" talk page sections if they want to de-clutter talk pages, but see the RfC before doing mass systematic removals. This message is updated dynamically through the template {{source check}}
(last update: 5 June 2024).
- If you have discovered URLs which were erroneously considered dead by the bot, you can report them with this tool.
- If you found an error with any archives or the URLs themselves, you can fix them with this tool.
Cheers.—cyberbot IITalk to my owner:Online 20:14, 13 January 2016 (UTC)
Confusing wording
editIn section Everything is an expression, shouldn't the text "To make it clear that all expressions are functions," instead read "all functions are expressions"? I'm learning Scala and this is a helpful article but that bit confuses me. 2602:306:3760:16E0:108A:C9C6:3DA4:7E13 (talk) 20:18, 13 August 2016 (UTC)
Criticism
editThe criticism section should probably expanded with better information.
For instance, the statements made by the Paul Phillips (https://www.youtube.com/watch?v=TS1lpKBMkgg, https://www.youtube.com/watch?v=uiJycy6dFSQ, https://www.youtube.com/watch?v=4jh94gowim0), one of the main contributors to Scala and the co-founder of the company behind Scala should be more relevant than what some random CTO says. Also, the creators of Kotlin described why they invented their own language instead of using Scala, which also offers some insights. There is also https://soc.github.io/scala/departure, which I can't add due to WP:OR.
Also, the general criticism of Scala breaking compatibility, having poor tooling and being too complex should be mentioned, if reputable resources can be found. Soc88 (talk)
Re: Functional tendencies
editEarly in the section there is a list of functional features of Scala that seem to be meant to highlight the differences from Java, however, type local inference was introduced in Java 10 and expanded slightly in Java 10(albeit not to extent of Scala). Should this be removed or clarified that while java has added type inference, in Scala it is more comprehensive(e.g. unneeded under most circumstances for return types in Scala)? Deuceboise (talk) 16:45, 17 January 2019 (UTC)
scala doesn't have algebraic data types
editThe article says scala has algebraic data types, but I think that's misleading. It doesn't have native support for them in the way that Haskell or Rust does. Instead They are sort of simulated by case classes. Agreed? Article should be edited accordingly? Myrmornis (talk) 13:25, 4 February 2022 (UTC)
For Scala 2 I think the claim was perhaps debatable, but with Scala 3's `enum` algebraic data types are directly and unambiguously supported, IMO. See https://docs.scala-lang.org/scala3/reference/enums/adts.html SethTisue (talk) 19:01, 20 February 2022 (UTC)
Tooling
editThere are so many tools around Scala: SBT, Mill, Coursier, Bloop, Metals with implementations for different editors respective IDEs, the legacy Eclipse based Scala IDE and probably more. That can be confusing. As far as I can see until now only SBT has a dedicated article on Wikipedia and it is questionable if any of the others satisfy Wikipedia's notability criteria. Maybe those can me mentioned here in a chapter about tooling with a short description of what they are responsible for in the tool chain (I think tool graph does describe it better). Maybe together with an SVG visualizing the relations between the tools. What is your opinion? ITriedMyBest (talk) 21:24, 9 May 2022 (UTC)
"Point" class code example and addToGrid()
editIn the given code example, a method called addToGrid()
is called but not defined. Not only is this confusing, but (at least in the Java example), it's incorrect code.
I don't speak Scala (that's why I was here), but could someone with knowledge of both languages correct the example so it's possible to interpret precisely?
Timrb (talk) 19:26, 1 July 2022 (UTC)
- Done. I changed it to `+=` to illustrate how operators can be defined and called in infix notation. I also changed the Java version to `addPoint` instead of `addToGrid` because it really just adds any point and only adds to grid when it's called on the grid instance. 2600:4040:767E:4600:B0E2:7424:AC7:C066 (talk) 18:49, 3 November 2023 (UTC)
Questionable open-source licence for Akka
editThe section about Concurrency describes how Scala no longer provides native support for actors, relying on the third-party platform called Akka. The text also states, though, that Akka is an open-source platform.
> ...it also included support for the actor model, which is now available as a separate open source platform Akka
However, starting with version 2.7.0 (the current one), Lightbend switched the licence of Akka from Apache 2.0 to Business Source License 1.1.
As far as I know, the new licence is not an approved open source licence. I'm not a lawyer, but from their own FAQ:
> The BSL requires that the code licensed revert to an approved open source license (“Change License”) after a period of time (“Change Date”) which can be no later than 4 years.
I think that it's safer to remove the "open source" before the Akka name.
Outdated version information
editCurrently Scala supports as stable 3 versions of the language: 2.12.x, 2.13.x and 3.3.x. However, only 1 of them is displayed as newest stable: 2.12.5. This is doubly wrong: 2.12.5 is not the newest in 2.12.x line (that would be 2.12.11) and the newest stable Scala in general is 3.3.0. This data is available when one look into Wikidata but it is not reflected on this page. 2A02:A313:823F:4800:64E7:6829:BCCC:81A4 (talk) 14:54, 28 August 2023 (UTC)
"Scala (programming language" listed at Redirects for discussion
editThe redirect Scala (programming language has been listed at redirects for discussion to determine whether its use and function meets the redirect guidelines. Readers of this page are welcome to comment on this redirect at Wikipedia:Redirects for discussion/Log/2024 April 8 § Scala (programming language until a consensus is reached. Utopes (talk / cont) 00:58, 8 April 2024 (UTC)