[ art / civ / cult / cyb / diy / drg / feels / layer / lit / λ / q / r / sci / sec / tech / w / zzz ] archive provided by lainchan.jp

lainchan archive - /λ/ - 15096



File: 1458547048954.png (71.6 KB, 300x169, scala.png)

No.15096

Any lainons here using Scala?

Reasons to use:

1. Combines functional and object oriented programming styles into one language.
2. Runs on the JVM which means you can call any Java library you want very easily.
3. Static typing catches so many errors at compile time and makes larger programs cleaner.
4. Clean and concise syntax.
5. Cluster computing. Apache Spark, which is the premier large scale data processing framework is written in Scala. Hadoop is in Java and so easy to use (see 2.).

  No.15097

Use frege instead: https://github.com/Frege/frege
It's pretty much 1:1 haskell on the JVM.

  No.15098

Personally I enjoy Clojure more

  No.15102

I would go with Clojure or Frege, instead.

  No.15103

>1. Combines functional and object oriented programming styles into one language.
That's a reason I wouldn't want to use it.
>2. Runs on the JVM which means you can call any Java library you want very easily.
This is a good thing how? Yay, a language that'll be hilariously slow!
>3. Static typing catches so many errors at compile time and makes larger programs cleaner.
Ah, the delicious 'cleaner' buzzword.
>4. Clean and concise syntax.
Objectively false. It looks like every unreadable part of every language was merged into one. Look in the OP photograph for proof.
>5. Cluster computing. Apache Spark, which is the premier large scale data processing framework is written in Scala. Hadoop is in Java and so easy to use (see 2.).
Since when is this some type of Scala feature? I'm actually having trouble thinking of a language that can't do Cluster Computing.

  No.15106

We need OCaml for the JVM.

  No.15111

>This is a good thing how? Yay, a language that'll be hilariously slow!
There are a lot of businesses that want all their stuff on the JVM.
If you get to lead a project, you could use one of the better JVM languages instead of Java.

There's a surprising amount of JVM languages: https://en.wikipedia.org/wiki/List_of_JVM_languages

  No.15112

File: 1458592847919.png (303.75 KB, 134x200, 1458243659396.png)


  No.15328

>>15112
Yeah, the "Java is ______ slow!" meme is pretty retarded at this point.

  No.15344

>>15103
Saying Spark is "just another cluster computing framework" is a bit off. Spark won the Dayton 100TB sorting challenge https://spark.apache.org/news/spark-wins-daytona-gray-sort-100tb-benchmark.html and is way ahead of most other frameworks. 

  No.15354

>>15096
Lainon using scala here.  Even took the Ordesky course which op's pic is from, which I actually recommend, if you haven't read SICP already.  I have all the videos and PDFs on retroshare too.

As for scala itself, its mostly built to compete with the likes of rust, swing, and go than ocaml and clojure with a focus on building web apps.  Although it can also do android apps.  Antox is in scala but it's code looks like shit TBH.  Honestly the best thing about scala is the Try object.  Instead of explicitly declaring and handling all errors at every step you can just ignore it all until the top level then handle it there, unless you want to explicitly handle it earlier.

My biggest complaint is the some libraries can get unnessarily arcane for the point of making it "more user friendly".  eg Look at all those test styles used by ScalaTest http://www.scalatest.org/user_guide/selecting_a_style.  Sometimes, just stick to object.method(args).  Everything else is just confusing the programmer.

I'm just starting to get into the typesafe/lightbend stack with slick but a lot of little red flags are going off that Ordesky got into that for the money and not to make good code.  Like whatever the fuck "activator" is.  Fuck that noise.  Sounds like some android studio you-must-let-me-hold-your-hand bullshit.

  No.15361

File: 1459586542721.png (41.99 KB, 200x165, scala-chan.jpg)

I had to learn Scala in my first two programming-courses in the university. As everyone else I was expecting to start with Java and wasn't really happy about this because I did some Java-Foo before and the language was imho meh. So I was very happy to get pushed into something new.
Programming Scala doesn't tastes like Java because you are able to solve most problems on a functional way - at least if you're willing to do it. The language developers have also realized that these ''everything must be OOP'' was a mistake and you're able to use this wonderful case-classes which are something between structs and classes - with real pattern matching. Yeah, pattern matching is able in the method-/functionheads, too.
Honestly speaking I had really fun with Scala and don't understand why most of my fellow students don't like it - mostly those who'd never written a single line of code in their life before. Scala was also the language for me which showed me how nice it could be to write functional code and so I learned some functional languages (atm I'm into Elixir) for myself.

Now my 2 cents to OPs points:
>1. Combines functional and object oriented programming styles into one language.
Well… the question is if you really want this. Imho this is mostly well done in Scala but this depends on the personal taste. However it's an easy way into testing functional programming for people with an OOP-background.
>2. Runs on the JVM which means you can call any Java library you want very easily.
It's both a blessing and a curse. As long you're just using code from the Java-Std'lib. it works well. But if you're forced (or insane and willing) to use a big Java-Library it's sometimes a hell of programming because it expects the Java-types and now you're into converting (not casting at least) the Scala-types. Oh types: Scala hast cleaned up with this idiocy of int and Integer and now everything is an object. But you're able to override things like ''=='' and don't have to call this stupid ''compareTo'' every time.
>3. Static typing catches so many errors at compile time and makes larger programs cleaner.
ACK
>4. Clean and concise syntax.
Scala looks really fancy if you're writing code in the infix style (''Object method parameter'') instead of the normal postfix style (''Object.method(parameter)''). But this doesn't werk sometimes because of priority, brackets or just pure hate against you.
>5. Cluster computing. Apache Spark, which is the premier large scale data processing framework is written in Scala. Hadoop is in Java and so easy to use (see 2.).
Maybe have a look at Akka. **I haven't but people say it's cool :^)**

tl;dr: Nice language with some flaws which is at least worth a try.

  No.16353

What makes Scala better than the other JVM languages?

What makes it stand out from other languages period?

  No.16354

>>15103
I don't even use Scala, but please refrain from making these kind of obnoxious /g/-ricer-tier posts in the future. Your post is just a series of angry buzzwords. C'mon, man.

  No.16355

>>15096
My main language is racket lisp, but Scala looks like it might be a nice next "big"/serious language to learn. It looks really portable, which is nice (jvm is very portable in its own, and Scala also has JavaScript and Native code back ends), and has a ton of libraries. I don't mind the language offering both functional and oop paradigms, lisp does the same thing.

  No.16566

>>16353
I like the idea of Scala. I want to like writing it, I really do. But when I fire it up and try to do a couple project eulers, and I get compile time errors for not explicitly casting my Uint as an Int when trying to do a range with list.length(), or when I get problems because some methods return vectors and others return lists and some more return ordered lists which have to be explicitly cast to lists, it makes me wonder if I'm doing it wrong or something.

  No.17493

>>16566
Use interfaces, brotendo. Never explicitly request a List or a Vector, instead request and Iterable, or a Seq or IndexedSeq if you need efficient random access. This way you avoid casting entirely.

You should be doing that with any OOP language frankly.

  No.17503

>>15096
My main problem with it is that it runs slower.

  No.17504

>>16354
You claim his on-topic and substantiated post is "a series of angry buzzwords" while simultaneously dismissing his post as "obnoxious /g/-ricer-tier". Kindly take your butthurt post policing and shove it.

  No.17851

File: 1470749815102.png (47.02 KB, 200x170, mycodecantfail.jpg)

Do any of you scala devs use scalatest? I've found is very nice for writing simple single case tests but its not very extensible. I can't find a meaningful way to do data driven testing like I can in NUnit.

Is there anything wrong with just using JUnit for scala?

  No.17854

>>17503
Compered to what?

  No.17868

>>15096

Been meaning to learn it because of Chisel and RISC-V.

  No.17869

>>17851
Of course you could just use JUnit, but it just feels not so comfy imho. I'm using Specs2 if I want to have Unit-tests in Scala. ScalaCheck seems promising, too.

No one talked about recursion itt. Scala supports tail-recursion instead of languages like Python.

  No.17873

>>17869
> Scala supports tail-recursion
Does that mean you can't call Scala code from Java?

  No.17896

>>17873
How did you jumped to that conclusion? The Scala-compiler just checks if there aren't variables on the stack and compiles it to some CPU-friendly iterative code. This doesn't affect the signature (why should it?) and so you won't have any problems.

  No.17897

>>17896
I though it was full TCO, which would need different calling conventions on the JVM. But turns out it's only for self-recursion, it can't even optimize mutually recursive cases.

  No.18043

>>17869
I'm looking at ScalaCheck because, 1) it wrapped into ScalaTest as PropSpec and 2) it seems to have come from Ordesky or at least his college. It also has a more mathematical approach to unit testing that I appreciate.

I looked at JUnit and it can't do parameterized tests well or at all without some small third party package.

  No.18283

>>17873
You can absolutely call Scala code from java code assuming you have Scala as a dependency as usual. You will run into issues with functional interfaces; Scala's Function classes are different from Java 8's, same with their lambda's.

  No.19981

I use Scala at work. My team is a mix of sr. engineers with Java experience, and jr. devs with FP backgrounds (I know Clojure, and 2 others used Haskell). We took a vote and chose Scala as a compromise because of your points 1 and 2, since we had a greenfield project to try it out on.

I like it much more than Java. Our biggest pain points have been from interacting with some Java types during interop (conversion implicits usually work, but some edge cases tripped us up for a while) and occasionally fighting the type system.

I'm also not a fan of having so much syntax, but I just don't like having syntax at all, and it's still better than Java.

  No.20758

anyone have Functional Programming in Scala handy? Looking to get my feet wet

  No.20760

File: 1481611370173.png (12.01 MB, 200x200, Paul Chiusano, Rúnar Bjarnason-Functional Programming in Scala-Manning Publications (2014).pdf)

>>20758

Nevermind, for anyone else in need...

  No.20781

File: 1481710634098.png (306.8 KB, 200x200, fragezeichenmödchen.png)

Anyone has a good suggestion for nicely written Scala programs to look at and learn from?

  No.20816

>>20781

What little Scala I've done was working with a Minecraft mod (project red). There are a few that use Scala.

  No.21575

added Qmc5KR3F8mfDmgozCwRgvuk3MKxmWracpd1VWJ41gaU6bs Video/Coursera/Scala