Live data from Hacker News

Monocle: Optics Library for Scala

optics.dev

61–70 of 70 posts

Re: Monocle: Optics Library for Scala

#61

am I the only one who isn't a little disappointed that this wasn't a library to model the physics of physical lenses?

By "isn't a little disappointed" do you mean very disappointed or not disappointed at all? Although that may not be an important distinction as I think the two groups are roughly the same size.

woops, I meant to say "is a little dissapointed"

Re: Monocle: Optics Library for Scala

#62

I'm still trying to reason what the value proposition of Scala is in a business sense. Developer are more expensive and harder to find, the tooling is weaker, the ecosystem less deep, performance suspect, and the overall XP feels clunky. Plus our hardware is procedural, and contains/manages state within the instruction pipeline. I strongly believe it doesn't belong as a core business technology.

In the right hands, the terseness and expansive nature of the language (big stdlib, java interop, implicits/givens, higher-kinded types, immutability first, etc) can greatly increase productivity, however it takes a higher caliber of developer to wield it effectively. Not to mention also the rich ecosystem in the functional side of the house with ZIO/Typelevel, or distributed frameworks like Akka.

Poor Scala devs output complete junk, however high performers produce incredibly elegant and concise code.

Re: Monocle: Optics Library for Scala

#63

Earlier quoted context omitted.

The small pool of experienced developers is actually awesome. I waste a lot less time screening candidates and they're usually above average. Moreover, despite what people claim I've had no issues mentoring juniors or people coming from other paradigms but willing to learn. Tooling isn't as good as plain Java but good enough, and certainly better than that of more niche FP languages. The ecosystem is pretty rich in s…

You have a lot fewer candidates to pull from too, which is often a more limiting factor for a business. Business don't need everyone to be a rockstar who's also a FP whiz. But FP languages need that.

I've been leading hiring efforts for my team for a while now and Scala has never been the bottleneck. Especially now that the Scala market has shrunk a bit.

It's true you need some level of expertise and seniority, but that doesn't mean you need to hire only FP wizards, far from it. I believe most modern hybrid languages can be dangerous without supervision.

Re: Monocle: Optics Library for Scala

#64

Earlier quoted context omitted.

You have a lot fewer candidates to pull from too, which is often a more limiting factor for a business. Business don't need everyone to be a rockstar who's also a FP whiz. But FP languages need that.

For what it's worth, Scala is a multi-paradigm language and can be used as a pure OO language. This is a great way to start for programmers with an OO background

I'm not sure it's a good idea though. Scala failed (mainly to Kotlin) as a "better Java". If you aren't committed to Scala's unique features, I would avoid it. It doesn't mean you need to go all in though, Scala can be simple, simpler than Java in fact.

Re: Monocle: Optics Library for Scala

#65
post #31
post #26

Earlier quoted context omitted.

Does it offer creating a mutable view on top of the immutable structure that can be used to accumulate a whole set of changes to later be materialized into a copy with the changes? (or to be used directly, at whatever cost would be required) That's something I've been wondering why it's not more of an established thing. It would basically be docker, but for in-memory reference graphs instead of filesystems.

You can compose together a bunch of edit operations (an edit command, if you like) and apply them at once at the end, is that what you mean?

Kind of. Can you use the interim state fork (original plus changes, not yet committed into a new immutable) as a "readable" type, the union of mutable and immutable variants? That would resolve choice dilemmas like the decision between mutable and immutable builders: keep the mutable where it is only used by the creating thread, materialise into an immutable when it needs to cross thread boundaries, fork where a thread needs to adapt a little and have all consumers typed to the readable version so that they can work with either, without requiring a new immutable.

Re: Monocle: Optics Library for Scala

#66

Earlier quoted context omitted.

Performance is in the same space as java or go, but it's a much higher level language, so easier to write, easier to read, and easier to review. The language prevents many classes of errors without cluttering the written logic, so it's easier to understand what it's doing in terms of business domain. The jvm ecosystem is also massive. If developers are more expensive, presumably there's a reason they're able to ask t…

> Performance is in the same space as java or go, but it's a much higher level language, so easier to write, easier to read, and easier to review. What metrics are you using to make the claim that it's "easier" than more widely known, better tooled, and easier to search languages? >The language prevents many classes of errors without cluttering the written logic, so it's easier to understand what it's doing in terms…

There are no studies for anything, and if there were, they would be outdated by the time they are published.

So if you ask such a question, do you really expect anything more than people's firsthand experiences?

But I'll tell you my own side as well: doing anything with concurrency in any other language (yes, including Go and Rust) is just much much harder in comparison to Scala.

No wait, that's not true. There are languages that are better suited for that. But they are either academic or extremely niche and come with other problems (such as lack of ecosystem or much worse performance).

> The fact is there a fewer FP devs. Why is that if FP is "better"?

The fact is also that the number of FP devs has been and is growing. And so has the number of languages with those features.

> There's fewer Scala devs, because Scala isn't better.

What metrics are you using to make the claim that it "isn't better"?

Re: Monocle: Optics Library for Scala

#67
post #65
post #31

Earlier quoted context omitted.

You can compose together a bunch of edit operations (an edit command, if you like) and apply them at once at the end, is that what you mean?

Kind of. Can you use the interim state fork (original plus changes, not yet committed into a new immutable) as a "readable" type, the union of mutable and immutable variants? That would resolve choice dilemmas like the decision between mutable and immutable builders: keep the mutable where it is only used by the creating thread, materialise into an immutable when it needs to cross thread boundaries, fork where a thre…

> Can you use the interim state fork (original plus changes, not yet committed into a new immutable) as a "readable" type, the union of mutable and immutable variants?

Not really, not at a language semantics level - although in practice if you applied your current mutation to the original object, did something with the result, and then threw the "partially edited object" away, the JVM's escape analysis might catch that and never fully materialise the "partially edited object". Note that nothing is really mutable, not even your edit operations - you form your combined edit by composing together a bunch of smaller edits, but all those edits are immutable.

Re: Monocle: Optics Library for Scala

#68
post #67
post #65

Earlier quoted context omitted.

Kind of. Can you use the interim state fork (original plus changes, not yet committed into a new immutable) as a "readable" type, the union of mutable and immutable variants? That would resolve choice dilemmas like the decision between mutable and immutable builders: keep the mutable where it is only used by the creating thread, materialise into an immutable when it needs to cross thread boundaries, fork where a thre…

> Can you use the interim state fork (original plus changes, not yet committed into a new immutable) as a "readable" type, the union of mutable and immutable variants? Not really, not at a language semantics level - although in practice if you applied your current mutation to the original object, did something with the result, and then threw the "partially edited object" away, the JVM's escape analysis might catch th…

Thanks for your patience. I guess the big blocker for the hypothetical "full triangle of readable-mutable-immutable" is that deep read operations would have to create a potentially long lived object for each intermediate step in e.g. a getter chain if you want to avoid special syntax. And then you're back to extreme reliance on escape analysis. And at some point even correctly identified nonescaping allocations start summing up.

Re: Monocle: Optics Library for Scala

#69

Earlier quoted context omitted.

> Performance is in the same space as java or go, but it's a much higher level language, so easier to write, easier to read, and easier to review. What metrics are you using to make the claim that it's "easier" than more widely known, better tooled, and easier to search languages? >The language prevents many classes of errors without cluttering the written logic, so it's easier to understand what it's doing in terms…

There are no studies for anything, and if there were, they would be outdated by the time they are published. So if you ask such a question, do you really expect anything more than people's firsthand experiences? But I'll tell you my own side as well: doing anything with concurrency in any other language (yes, including Go and Rust) is just much much harder in comparison to Scala. No wait, that's not true. There are l…

Fewer devs, fewer libs, fewer tools, fewer projects.

Those are all quantified with out a research study.

Re: Monocle: Optics Library for Scala

#70

Earlier quoted context omitted.

> Performance is in the same space as java or go, but it's a much higher level language, so easier to write, easier to read, and easier to review. What metrics are you using to make the claim that it's "easier" than more widely known, better tooled, and easier to search languages? >The language prevents many classes of errors without cluttering the written logic, so it's easier to understand what it's doing in terms…

My claim is backed by years of direct experience with C, C++, Java, Go, Scala, PHP, and Python. I can tell you that Scala has been the easiest to write, read, and review by far. I'm not sure why you'd expect "easier to read and review" to be metrizable. Nor do I see the connection between those things and wide use, tooling, or searchability. If you need to search something to understand what you're reading, I suppose…

Having also used all those languages, Scala was easily the worst documented, tooled, and community supported.

That makes it worse as a language overall because of the reduced devex.

You may personally find it great, but as a business language, it isn't.

Post reply on HN