Live data from Hacker News

From First Principles: Why Scala?

lihaoyi.com

111–120 of 342 posts

Re: From First Principles: Why Scala?

#111

Earlier quoted context omitted.

Clojure still sounds like research group to me.

Tell that to Amazon, Apple, Netflix, Cognitect and all enterprises that produce reliable and performant software with it everyday.

I don’t know of anyone at those companies using clojure and I haven’t seen any tech blogposts by those companies about using clojure. If clojure exists at those companies I imagine it’s a small very niche team.

Re: From First Principles: Why Scala?

#112

If I've said it once I've said it a thousand times: the day Scala kills sbt officially will be the day thousands of devs consider a return to it. Until then, I couldn't dare.

I don't know. I have no real love for SBT but I have yet to find a build tool that I actually like and that covers all the use cases and has the ecosystem that I want. Maybe it is just a really hard problem and extremely resistant to creating a simple interface. Unless of course you consciously decide to punt on the hard cases (which if fine sometimes).

Re: From First Principles: Why Scala?

#113

I am a Scala programmer & think it's a great language. Here are some arguments for why not Scala: * Li's libs (os-lib, upickle, utest) have clean public interfaces, but most Scala ecosystem libs are hard to use, see the JSON alternatives for examples: https://www.lihaoyi.com/post/uJsonfastflexibleandintuitiveJS... * The Mill build tool looks a lot better than SBT, but seems like everyone is still using SBT * Scala mi…

After a number of years with Python, I started a position working in Scala about 6 months ago. I really wanted to learn something new, and become acquainted with functional programming concepts. I agree with most of the above. A couple of additional thoughts: * sbt -- I still have a lot of coming up to speed to do here, but the manual is like 500 pages and it's somewhat overwhelming. There are tons of little oddities…

> It's a pretty big mountain, though, and there are times where I have doubts whether the benefits will be worth it. Would love to hear some re-assurance! ;)

It’s not worth it, the entire language is a mountain of documentation and hard to understand concepts that just gets in the way of actually delivering product features for the business. It will help you to think differently about programming problems though.

Re: From First Principles: Why Scala?

#114
post #93

Earlier quoted context omitted.

> Hard to win technical arguments with Scala geniuses that like using complicated language features. I was on a team building good old crud apps using monads, monoids, categories, combinators, effects cats, seamless and bunch of other nonsense that i've now purged from my brain. You could've easily mistaken our team for a programming language research group at a university. This is literally the number one reason i w…

>I was on a team building good old crud apps using monads, monoids, categories Here's the thing, if you look at a basic Spring crud app, you are also using Monads, Monoids, Categories, Traverse, etc. but you aren't expressing it in the type system. Seriously go look at modern Spring's flux stuff, it's all there minus the type classes. I've seen teams that tried to over engineer Spring, teams that tried to over engine…

Yeah, I'd say that Spring is the Java equivalent of the same problem (over-engineering), just using reflection and runtime bytecode generation instead.

I agree that using Monads, Monoids, etc. isn't necessarily indicative of over engineering in itself. If used well they can make the code clearer/simpler.

Re: From First Principles: Why Scala?

#115
post #101

> In contrast, cross-compilers for dynamic languages like Clojure tend to have a long-list of caveats and incompatibilites I don't think the author fully comprehended the linked resource (namely https://clojurescript.org/about/differences ). Perhaps he just noted the its size. A good chunk of the document lists things in common, not differences. The actual differences have nothing to do with dynamic typing and are de…

> - don't pretend the JVM and JS have identical runtimes when it comes to concurrency or numerics. Clojure is a language, not a platform abstraction. > - Emit efficient, optimally minifiable javascript code, at the cost of offering something less traditionally lisp-y when it comes to eval, macros, and other forms of code loading. Those are still possible, but some discipline is imposed. This is exactly the kind of th…

ScalaJS is one of the projects which I don't understand why more people don't rave about. It's /extremely/ nice that I can have a single project which share code between them for validation; no need for swagger or OpenAPI.

Re: From First Principles: Why Scala?

#116
post #25
post #8

Earlier quoted context omitted.

It looks like its a build tool? Are you obligated to use that with scala or something?

You're not obligated, but much like Maven is the build tool for Java, sbt is the build tool for Scala. You use alternatives at your own peril. This means you won't be able to understand other people's builds, for example. I know some Scala projects use Maven instead. Whether that's a good idea is debatable!

> You use alternatives at your own peril. This means you won't be able to understand other people's builds, for example.

The tradeoff is with SBT, you won't be able to understand your own builds!

(This is kind of a joke, but not really...)

Re: From First Principles: Why Scala?

#117
post #14

Scala is just an amazing language. I'm very happy that the worst of the 'Scala as a worse Haskell' days is over and that the Scala community is finding it's own programming style. I remember years ago when I had a heated discussion about local mutable state. An that time it felt like heresy to even suggest it. I just recently had another discussion with the same programmer and he was like: "Yeah, that works". Good ti…

I still find that Scala devs think they’re writing Haskell. From what I’ve seen in the community, no one cares about shipping code, they care about whether or not it’s “pure”.

To give them their credit. The argument from the purists is that purity is itself about shipping code. As a long-time scala developer who has started using the pure-FP ecosystem (cats,cats-effect mainly) I am starting to see their point. It takes some time to grok but once you do then it is amazingly productive to work with.

Re: From First Principles: Why Scala?

#118
post #26

Earlier quoted context omitted.

> Scala defines its own set of collection classes [...] One (arguably) negative consequence of this is that Scala's collections don't play nice with Hibernate and similar ORMs. Due to the way they work, both Scala and Hibernate wanted to "take over" your collections, and obviously they cannot do so at the same time. Of course, it's arguable whether this is a flaw with Scala or with Hibernate, but for the programmers…

The two major SQL libraries in the Scala ecosystem these days are Doobie ( https://tpolecat.github.io/doobie/ ) and Slick ( https://scala-slick.org/ ). With Doobie you manually write your queries, and then map the results into the objects in your domain model. Nothing is generated for you. OTOH, nothing is hidden and you are free to write queries as optimized and specialized as you need. The real selling point of Doo…

I have had poor experiences with "fancy" SQL libraries in multiple languages. This includes Slick and Quill in Scala.

I don't remember what the problems were with Slick that leave such a bad feeling when I hear its name -- that was 5 years ago -- but I had problems with Quill just last year. I was trying to use it to generate an efficient "in" query against a two column composite primary key, and nothing seemed to work. Since it uses macro magic, one of my attempts triggered an internal compiler error instead of normal compiler feedback.

I ended up dropping Quill for ScalikeJDBC:

http://scalikejdbc.org/

It seems to be less popular/active than other libraries, but it is dead simple to use, even for developers new to Scala. I write exactly the SQL I want just like I would in psql. There is little-to-no magic. I think that the only slightly magical feature I use is variable interpolation into SQL ("SQLInterpolation") that prevents injection attacks. It actually has capabilities to automatically map tables/columns into different structures and generate code for you, but my team doesn't use any of that. We just write SQL.

Re: From First Principles: Why Scala?

#119
post #96
post #44

I think that the Scala experience will get even better with Scala 3, tons of well thought refactorings for metaprogramming and typeclasses, among others. Also, looking forward to (optional) indentation based syntax.

It's funny, because my experience is almost the opposite. My Scala skills are a bit rusty at this point and I promised myself to get back in the game once Scala 3 was released. Most of it I like. The new syntax, however, is really putting me off. My #1 problem with Scala has always been its huge upfront complexity and the quality of libraries, which are often over-engineered and not nearly enough UX-centric (cough im…

Opposite for me. After years of Scala (which I like) I recently tried to port a few things to Scala 3 and it really feels like some of the wtf-implicit part is gone. We'll still need to make a complete idea about this version 3 though.

Re: From First Principles: Why Scala?

#120
post #93

Earlier quoted context omitted.

> Hard to win technical arguments with Scala geniuses that like using complicated language features. I was on a team building good old crud apps using monads, monoids, categories, combinators, effects cats, seamless and bunch of other nonsense that i've now purged from my brain. You could've easily mistaken our team for a programming language research group at a university. This is literally the number one reason i w…

>I was on a team building good old crud apps using monads, monoids, categories Here's the thing, if you look at a basic Spring crud app, you are also using Monads, Monoids, Categories, Traverse, etc. but you aren't expressing it in the type system. Seriously go look at modern Spring's flux stuff, it's all there minus the type classes. I've seen teams that tried to over engineer Spring, teams that tried to over engine…

> Seriously go look at modern Spring's flux stuff, it's all there minus the type classes.

I don't use spring or plan to use it. Not quite sure why it needs to be looked up. What are you trying to say?

Post reply on HN