Talk:Scala (programming language): Difference between revisions

Content deleted Content added
SSTbot (talk | contribs)
top: Added {{vital article}}
Undid revision 1292283394 by 187.158.38.155 (talk) Tidying up.
 
(27 intermediate revisions by 21 users not shown)
Line 1:
{{Talk header}}
{{Vital article|topic=Technology|level=5|class=C}}
{{WikiProjectBannerShell|1={{WikiProject Javabanner shell|class=CB|importancevital=yes|1=mid}}
{{WikiProject Computing|class=CJava|importance=low}}mid}}
{{WikiProject Statistics |importance=high}}
 
{{WikiProject Computer science|importance=high}}
{{findsourcesnotice|Scala|programming}}
{{WikiProject Computing |importance=high|software=yes }}
}}
 
==Belgian Band==
Line 39 ⟶ 41:
 
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. <small><span class="autosigned">— Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[User:ספלינטור|ספלינטור]] ([[User talk:ספלינטור|talk]] • [[Special:Contributions/ספלינטור|contribs]]) 21:07, 20 July 2013 (UTC)</span></small><!-- Template:Unsigned --> <!--Autosigned by SineBot-->
 
----
 
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.
[[Special:Contributions/192.93.161.33|192.93.161.33]] ([[User talk:192.93.161.33|talk]]) 13:59, 30 August 2023 (UTC)
 
== Quick sort example ==
Line 92 ⟶ 105:
 
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.[[Special:Contributions/77.254.197.201|77.254.197.201]] ([[User talk: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. <!-- Template:Unsigned --><small class="autosigned">—&nbsp;Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[User:R.I.McGhee|R.I.McGhee]] ([[User talk:R.I.McGhee#top|talk]] • [[Special:Contributions/R.I.McGhee|contribs]]) 03:07, 7 November 2018 (UTC)</small> <!--Autosigned by SineBot-->
 
== Imperative programming in Scala? ==
Line 165 ⟶ 182:
 
 
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 :) &mdash;&nbsp;[[User:Anndelion|<fontspan colorstyle="color:#6B8E23;">'''anndelion'''</fontspan>]]&nbsp;[[User_talk:Anndelion|<span style="font-size:110%; font-weight:bold; vertical-align:text-middle; color:#DAA520"><span class="Unicode">&#8251;</span></span>]] 22:24, 12 April 2011 (UTC)
 
== Portmanteau? ==
 
From 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.) [[Special:Contributions/84.203.37.10|84.203.37.10]] ([[User talk: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? [[Special:Contributions/2001:861:3285:7E00:8F34:79F5:E70B:7ED5|2001:861:3285:7E00:8F34:79F5:E70B:7ED5]] ([[User talk:2001:861:3285:7E00:8F34:79F5:E70B:7ED5|talk]]) 14:59, 27 October 2022 (UTC)
 
== No import needed for java.lang in Java ==
Line 240 ⟶ 260:
:'''Support'''. Rankings covers adoption well enough. [[User:Brycehughes|Brycehughes]] ([[User talk:Brycehughes|talk]]) 18:59, 30 June 2014 (UTC)
:'''Support'''. [[User:Soc88|Soc88]] ([[User talk:Soc88|talk]]) <!--Template:Undated--><small class="autosigned">—Preceding [[Wikipedia:Signatures|undated]] comment added 21:25, 18 April 2018 (UTC)</small> <!--Autosigned by SineBot-->
:'''Objection.''' The section contributes to understanding adoption. [[Special:Contributions/87.138.226.29|87.138.226.29]] ([[User talk:87.138.226.29|talk]]) 21:15, 28 March 2023 (UTC)
 
== Scala support for currying ==
Line 247 ⟶ 268:
Here is ''modN'':
 
<sourcesyntaxhighlight lang="scala">
def modN(n: Int)(x: Int) = ((x % n) == 0)
</syntaxhighlight>
</source>
 
Here are the expressions that use ''modN'' to create a function argument:
 
<sourcesyntaxhighlight lang="scala">
println(filter(nums, modN(2)))
println(filter(nums, modN(3)))
</syntaxhighlight>
</source>
 
It is clear that we have a value binding, which is what happens for partial functions, not currying. [[User:Nxavar|Nxavar]] ([[User talk:Nxavar|talk]]) 18:15, 5 November 2014 (UTC)
Line 264 ⟶ 285:
::The example function in the book is:
 
<sourcesyntaxhighlight lang="scala">
def sum(f: Int => Int): (Int, Int) => Int = {
def sumF(a: Int, b: Int): Int =
Line 270 ⟶ 291:
sumF
}
</syntaxhighlight>
</source>
 
::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.
Line 276 ⟶ 297:
::This is how a curried function for addition would look like in Scala:
 
<sourcesyntaxhighlight lang="scala">
def add(a: Int): (Int) => Int = {
def increment(b: Int): Int =
Line 284 ⟶ 305:
 
var c = add(5)(6) // c = 11
</syntaxhighlight>
</source>
 
::In conclusion, Scala supports currying, although none of the examples mentioned here are about currying. [[User:Nxavar|Nxavar]] ([[User talk:Nxavar|talk]]) 19:59, 5 November 2014 (UTC)
 
:::While there is a difference in Scala between
<sourcesyntaxhighlight lang="scala">
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
</syntaxhighlight>
</source>
for all these goes that
<sourcesyntaxhighlight lang="scala">
val c: Int = foo1(5)(6) //or foo2(5)(6) or foo3(5)(6)
</syntaxhighlight>
</source>
is perfectly legal and does what you expect. The difference shows up at
<sourcesyntaxhighlight lang="scala">
val tst1: Int => Int => Int = foo1 _
val tst2: Int => Int => Int = foo2 _
val tst3: Int => Int => Int = foo3
</syntaxhighlight>
</source>
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. [[User:Martijn Hoekstra|Martijn Hoekstra]] ([[User talk:Martijn Hoekstra|talk]]) 14:48, 13 November 2014 (UTC)
 
Line 321 ⟶ 342:
 
<ref>https://en.wikipedia.org/wiki/Scala_%28programming_language%29#Example_with_classes </ref>
 
: The reason they are there is to provide an immutable field. The way <code>x</code> and <code>y</code> are setup is to produce the same effect as the Scala class parameters of the same name.
:[[User:Deuceboise|Deuceboise]] ([[User talk:Deuceboise|talk]]) 17:02, 17 January 2019 (UTC)
 
{{reflist-talk}}
 
== <code>import</code> in example ==
Line 329 ⟶ 355:
 
[[User:Sinthoniel|Sinthoniel]] ([[User talk: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 <code>import foo.Bar._</code> where <code>Bar</code> is a singleton object.
:[[User:Deuceboise|Deuceboise]] ([[User talk:Deuceboise|talk]]) 16:04, 17 January 2019 (UTC)
 
== External links modified ==
Line 341 ⟶ 369:
{{sourcecheck|checked=false}}
 
Cheers.—[[User:Cyberbot II|<sup style="color:green;font-family:Courier;">cyberbot II</sup>]]<small><sub style="margin-left:-14.9ex;color:green;font-family:Comic Sans MS;">[[User talk:Cyberbot II|<span style="color:green;">Talk to my owner</span>]]:Online</sub></small> 20:14, 13 January 2016 (UTC)
 
== Confusing wording ==
Line 354 ⟶ 382:
 
Also, the general criticism of Scala breaking compatibility, having poor tooling and being too complex should be mentioned, if reputable resources can be found. [[User:Soc88|Soc88]] ([[User talk:Soc88|talk]])
 
== Re: Functional tendencies ==
 
Early 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)?
[[User:Deuceboise|Deuceboise]] ([[User talk:Deuceboise|talk]]) 16:45, 17 January 2019 (UTC)
 
== scala doesn't have algebraic data types ==
 
The 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? [[User:Myrmornis|Myrmornis]] ([[User talk: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 [[User:SethTisue|SethTisue]] ([[User talk:SethTisue|talk]]) 19:01, 20 February 2022 (UTC)
 
== Tooling ==
 
There 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? [[User:ITriedMyBest|ITriedMyBest]] ([[User talk:ITriedMyBest|talk]]) 21:24, 9 May 2022 (UTC)
 
== "Point" class code example and addToGrid() ==
 
In the given code example, a method called <code>addToGrid()</code> 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?
 
[[User:Timrb|Timrb]] ([[User talk: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. [[Special:Contributions/2600:4040:767E:4600:B0E2:7424:AC7:C066|2600:4040:767E:4600:B0E2:7424:AC7:C066]] ([[User talk:2600:4040:767E:4600:B0E2:7424:AC7:C066|talk]]) 18:49, 3 November 2023 (UTC)
 
== Questionable open-source licence for Akka ==
 
The 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 [https://www.lightbend.com/akka/license 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 [https://www.lightbend.com/akka/license-faq 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.
 
[[User:Bruno Unna|Bruno Unna]] ([[User talk:Bruno Unna|talk]]) 21:50, 7 January 2023 (UTC)
 
== Outdated version information ==
 
Currently 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. [[Special:Contributions/2A02:A313:823F:4800:64E7:6829:BCCC:81A4|2A02:A313:823F:4800:64E7:6829:BCCC:81A4]] ([[User talk:2A02:A313:823F:4800:64E7:6829:BCCC:81A4|talk]]) 14:54, 28 August 2023 (UTC)
== "[[:Scala (programming language]]" listed at [[Wikipedia:Redirects for discussion|Redirects for discussion]] ==
[[File:Information.svg|30px]]
The redirect <span class="plainlinks">[//en.wikipedia.org/w/index.php?title=Scala_(programming_language&redirect=no Scala (programming language]</span> has been listed at [[Wikipedia:Redirects for discussion|redirects for discussion]] to determine whether its use and function meets the [[Wikipedia:Redirect|redirect guidelines]]. Readers of this page are welcome to comment on this redirect at '''{{slink|Wikipedia:Redirects for discussion/Log/2024 April 8#Scala (programming language}}''' until a consensus is reached. <!-- Template:RFDNote --> <span style="background-color: #FFCFBF; font-variant: small-caps">[[User:Utopes|Utopes]] <sub>('''[[User talk:Utopes|talk]]''' / '''[[Special:Contributions/Utopes|cont]]''')</sub></span> 00:58, 8 April 2024 (UTC)