7 ms·
Typelevel Scala
- noelwelsh 10y agoThis is fantastic. It's already fixing many of the issues I run into in my day-to-day Scala programming. I hope it serves as a good test-bed for features to make their way into the "official" compiler.
- 35bge57dtjku 10y agoWhat are those issues?
- atemerev 10y agoI am not happy about it. Typelevel projects are just porting the style familiar to Haskell programmers to Scala, and a full fork to accomodate this style seems to be an overkill. I know, many people are happy to go full throttle on Cats/Scalaz/whatever, but there's already Haskell for that. Official Scala documentation never even mentions the word "monad" (not even once!), and I think this is a good thing.
- thinkpad20 10y agoI might be missing something, but can't you just choose not to use it? For those using Scala who are interested in access to more advanced functional programming techniques, or using libraries that are written with a more "mathy" bent, this seems like a good thing. For those who'd prefer to never have to read the word "monad", just use something else.
- atemerev 10y agoBut I am happy with Scala as it is. Why should I use something else? I, of course, know what a monad is, but I do not exactly care. For me, expressiveness is much more important than purity. I even use vars where it is appropriate! :)
- svanderbleek 10y agoYes, please stop trying to make Scala Haskell. And please start switching to Haskell :)
- harveywi 10y agoScala has jokingly been called Hascalator [1], but not everyone who is "ready" to make the leap to Haskell can actually do it (existing work tied to JVM, dependencies on JVM libraries, etc.) or wants to do it (better ability to reason about resource usage, familiarity with tooling, etc.). [1] https://twitter.com/yakticus/status/577663763991564288 https://twitter.com/yakticus/status/577663763991564288
- atemerev 10y agoI do write in Haskell where it is appropriate (for fun, or if I want to prototype some complex domain model). Otherwise, I am quite happy with Scala. :)
- whateveracct 10y agoWhile it doesn't mention monad, for comprehensions are first-class support for them. Whether or not you can get over the use of the word. What else are you going to call F[_], bind, and point???
- harveywi 10y agoI guess you could just call F[_] a monoid in the category of endofunctors of F[_]...
- bad_user 10y agoThe Typelevel Scala is nothing more than a branch on which experiments can happen before pull requests are made in the main branch. The people involved have already contributed fixes, like the following by Miles Sabin, which is huge and will make Scala much better: https://github.com/scala/scala/pull/5102 https://github.com/scala/scala/pull/5102 - so basically we've got here a bunch of people that are extremely productive, working for free for the betterment of our tools and you don't like it because? > Official Scala documentation never even mentions the word "monad" (not even once!), and I think this is a good thing Actually that's a huge mistake because Scala is amongst the few languages that can express the Monad as a type. In most mainstream languages monads aren't explained because those languages lack the capacity for doing it. It's no wonder that people have a hard time understanding monads without a type to look at, as that would be like describing an elephant to a blind man. Do you think you understand Iterable because of its name? No, you understand it because you've seen its interface clearly described and then you used it and learned to appreciate it. And really, the strangest things happens when you don't talk about it. You still have for comprehensions, but surprise, they don't behave like in Python, "yield" is again overloaded, having nothing to do with Python's yield or Ruby's yield, and people stumble for no good reason, because it is hard to connect what seems like syntactic sugar over iterators to an expansion using map and flatMap. Along with "computation expressions" from F# or other bullshit naming meant to not scare away the most sensitive of us, the big problem that happens is that people get confused and don't even know what to search for. Search for monads and you'll find endless articles, tutorials, books, research. Search for comprehensions and you get shit. This is basically anti-intellectualism, the same kind of attitude that made Trump popular and that encouraged Brexit. The same kind of attitude that made the Option type in Java violate the Functor laws, taking a concept and destroying its essence just because we're afraid of big words and the opinions of experts.
- agentgt 10y agoWell one of the confusions I think early on (or at least professed confusion on Lambda the Ultimate IIRC) is that Scala is mixed paradigm and that adds additional load for learning. Some feel it should go full FP (what I mean by that is really discourage OOP, side effects, etc...). There is some valid arguments as Rust and Haskell might end up being an easier language to master as you can completely avoid the OOP conversation (polymorphic inheritance seems incredibly simple yet there are whole books written on how to use it.. ie patterns). I'm curious do you prefer a more OOP imperative approach with some FP or do you prefer the opposite (FP with some slight OOP)?
- atemerev 10y agoOOP hate is common these days, but I always has been an OOP enthusiast. I used to write in Smalltalk, I implemented a few metaobject protocols of my own, and I think OOP had deserves its success (unfortunately, C++/Java is not really OOP... However, some principles still apply). So, when a language appeared to combine the best ideas from FP and OOP, I happily embraced it. And I want it to stay this way.
- tlarkworthy 10y agoSometimes you really need to drop into mutation of state in perf critical paths
- roberthensing 10y agoThere are great tools for that in both Scala and Haskell. In Scala you can use var, which is easy. In Haskell you can write your algorithm using ST and then use it as a pure function by means of runST. The type system guarantees that all such state is local to the invocation.
- seanmcdirmid 10y agoScala is a really great OO language, enabling very useful statically typed mixin compositions that you won't find in any other language. Uunfortunately, the vocal side of the community is very much anti OOP, so you don't hear about them much, but it is still there.
- saosebastiao 10y agoThis isn't as bad as it looks. Think of it like an additional experimental scalac that is more ready to integrate into mainline scala than Dotty is. I'm fully on board with you...I think Scalaz as a library is a virus, and it's community is toxic, and it's desperate desire to turn Scala into Haskell ends up turning an awesome ML-inspired language into a vastly inferior religious (...ahem, pure) language. But Cats and Shapeless aren't Scalaz. They have concepts that happen to exist in Haskell, but they aren't Haskell's concepts to own any more than C owns imperative programming. If anything, Mathematics owns the concepts and Haskell happened to borrow them to make a terrible purist concept slightly more practical. It turns out that when you need the concepts (and I have, on a couple of occasions), it makes Scala slightly more practical as well.
- runT1ME 10y agoYou happen to think the most popular scala library is a virus? We use it extensively at Verizon, and it exists just fine with 'impure' code, Akka code, or whatever else various teams decide to also pull in. Codebases that don't use Scalaz end up re-inventing it, usually in a more buggy way and at a waste of developer effort. Reinventing is fine on your own for a learning exercise and I certainly did it a few times, but in production code, just use Scalaz. Or sure, I suppose if you want to use a copy and pasted into a new repo version of Scalaz, go for Cats. I don't even know why Shapeless is brought into the conversation, it has a much more narrow use case and I almost never reach for it. I've also found the Scalaz community and chat room on IRC quite helpful, whereas I've had some really unpleasant interactions with Cats committers. To go around spreading FUD and promoting an alpha level library that's less than half as popular as Scalaz (according to Github stars) is just irresponsible.
- AzzieElbab 10y agoExactly. Practically every interesting scala lib (from scalatest to play to sbt) has internal implementation of functional patterns.
- kod 10y agoSorry, but there's no way scalaz is a more popular library than Spark.
- bobbyi_settv 10y ago> Official Scala documentation never even mentions the word "monad" By coincidence, I was reading the official guide to Futures yesterday: http://docs.scala-lang.org/overviews/core/futures.html http://docs.scala-lang.org/overviews/core/futures.html And was (pleasantly) surprised to find that it contains the sentence "Try[T] is similar to Option[T] or Either[T, S], in that it is a monad potentially holding a value of some type" as well as a later reference to "monadic operations without side-effects".
- merb 10y agoactually without some concepts its pretty hard to not have boilerplate code. I mean OptionT and maybe OneAnd is pretty useful.
- srparish 10y agoAre future versions of cats going to require the typelevel scala?
- davegurnell 10y agoNo. I don't believe so. Think of Typelevel Scala as a tool to help people test out improvements to Scala as a whole, not as something that is going to deviate significantly from Lightbend Scala.
- partycoder 10y agoWell, it's not the first time people try to steer Scala to a different direction. Paul Phillips for instance, after many complaints on the direction the language was going, forked Scala (but now his fork is largely abandoned). https://github.com/paulp/policy https://github.com/paulp/policy
- ci5er 10y agoWas he trying to fork the language or the compiler? I thought he wanted a better (by his metrics) compiler for the same language. Did I misunderstand his intent way-back-when this was a thing?
- partycoder 10y agoThe compiler apparently.
- 0xmohit 10y agoRelated discussion: Policy – A fork of the Scala compiler [0] [0] https://news.ycombinator.com/item?id=8276565 https://news.ycombinator.com/item?id=8276565