The lack of third-party libraries that prevent the use of Scala?

I started learning Scala the other day. As for the language itself, I think it's fantastic, no problems there at all. To help in the learning process, I set myself the task of loading, analyzing and indexing text from HTML pages.

Performing the above, I found myself constantly digging into existing Java libraries. I found that I had to use Java libraries for:

1) Open the connection - java.net.URL

2) HTML parsing (TagSoup - since a regular XML parser does not process the most poorly formed HTML)

3) Text Index (Lucene)

Given that I had to rely on Java libraries to do quite a bit of hard work, I had to wonder if I should use Scala for a start, except for training. This was partly due to the fact that the comparison between them required additional mental effort, for example, it was not intuitively obvious than the type of Scala byte [], since everything is an object in Scala. This is this extra mental processing that can make the process seem a little awkward.

Does anyone else think that fewer third-party libraries (compared to Java) is an obstacle to using Scala in commercial projects?

, if you can call existing Java libraries, does it even matter, or do you need to use two different languages ​​in the code base to make it harder?

+3
3

( ):

Pimp my Library

, Java , Scala, , . . Scala XML , XML. :

class Service {
val pp = new scala.xml.PrettyPrinter(80,2)
def content = 
  pp.format(<foo><bar>{something()}</bar></foo>)
}

, ,

import scala.xml.Elem

object PrettyXml {
  val pp = new scala.xml.PrettyPrinter(80,2)
}

trait PrettyXml {
  case class Formatted(xml:Elem) { 
    def pretty = PrettyXml.pp.format(xml) 
  }
  implicit def toFormatted(xml:Elem) = Formatted(xml)
}

class Service extends PrettyXML {
  val pp = new scala.xml.PrettyPrinter(80,2)
  def content = 
    <foo><bar>{something()}</bar></foo> pretty
}

, , PrettyXML .

+5

. Java .jar( .class). Scala? , .class. - Java! , :

- , ( Java) Scala ?

, .

Java, , , ?

java- .jar, .


: , Scala , . , , Java, , Scala , ( ) .

+12

, . Scala:

  • Java- Scala. Scala - , , - , .
  • Java- Scala , Java- Java, . , Java , , Scala Scala Java. Java, , ( ), ( ), "" ( ) , (- ) ( , Java-1.5), . , Scala Java " ", , .
  • Using wrapping or pimping is actually quite easy to take the native Java library and make it almost joyful to use Scala as the native library. I expect that in the near future, simply great Scala adapters will be available for most major corporate libraries.
+4
source

Source: https://habr.com/ru/post/1762812/


All Articles