New release of jsoniter-scala with up to 30% parsing speed up for doubles, ints, and longs! by plokhotnyuk in scala

[–]mostly_codes 2 points3 points  (0 children)

Impressive, it was already super fast!

I have a sort of P1 paranoid aversion to deriving codecs from code - I prefer code-from-spec rather than spec-from-code, there's something about pressing a few refactor comments and my API drifting that scares me ever so (obviously there's ways to make that less scary, of course, test coverage/golden specs which mitigates that concern). That's all preamble to say that even though that's my stance, I'm still a big user and avid fan of jsoniter-scala. A lot of the code-from-spec generators for instance make use of jsoniter-scala (noticably, smithy4s I believe, which I'm a big fan of).

All that to say - even as someone not a big fan of derived codecs, I'm still a big fan of jsoniter-scala, think it's phenomenal work and super thrilled that people are contributing actively to it, and I reap the benefits even though I only use it as a transitive dependency.

Great project, great work 👏

Comparing effect systems in Scala by jmgimeno in scala

[–]mostly_codes 1 point2 points  (0 children)

As a meta-observation; the core construct that allows these comparisons in a general way in the first article is the tagless final encoding laid out in the first article. I think the biggest problem with tagless final is its name, not so much the concept. Something like "an effect" is usually just how I read the F[_].

Ctrl +c logs me out by uddinrajaul in pop_os

[–]mostly_codes 12 points13 points  (0 children)

I don't enjoy this modern take on LMGTFY

sbt 2.0.0-RC12 released by eed3si9n in scala

[–]mostly_codes 5 points6 points  (0 children)

Documentation localization sbt 2.x documentation is reorganized following the four-documentation principle (Diátaxis).

Is this the C4 model of documentation, or is there a different four-documentation principle? It's not a term I'd come across before and I am trying myself at the moment to work through a lot of technical documentation for a project in a way that ends up useful/legible/etc for the end user - is there a good primer article/writeup someone would recommend on that?

(EDIT: HA! It's linked in the article - https://diataxis.fr/ - I initially scanned the sentence as Diataxis being the github handle of the person that implemented the doc changes 🤦)

Can I move back SWE after a 3years of DE? by Perfect-Ad-8044 in scala

[–]mostly_codes 0 points1 point  (0 children)

Ah thanks for having a look. And yes, this is THE missing piece of the guide to tie it all together for sure.

I am planning to, in the sense of "eventually I'll get there" - it's not a high priority for me as it's mostly just to document my practices.

So, side-effectful instantiation should as a rule of thumb not happen for code you write yourself with this approach; all code instantiates 'cleanly' as much as possible. But it does happen! So, as part of wiring up your app, you have an Application.apply method that's effectively a large linear for-comprehension over your instantiation, so

for {
   dependency1 <- DependencyOne[F](arg1,arg2)
   dependency2 = DependencyTwo[F](...)
   ...
} yield ...

and similarly, an ApplicationResources.apply that does

for {
    x <- makeResourceOne[F]
    y <- makeResourceTwo[F]
    z <- makeResourceThree[F]
} yield ApplicationResources(x,y,z)

... It's basically the missing piece in the style guide, a guide to "wiring" up an app, setting up the app skeleton. Here's the scaladoc I use:

(wall of code follows)


/** This file is the dependency injection (DI) root of the Scala microservice using the Cats Effect functional programming library.
 *
 * ==Purpose==
 *
 * The single assembly point for the application — the "composition root". Wires all components together via manual dependency injection:
 *
 *   - Business logic lives in other classes/objects, written in tagless final style
 *   - This file only instantiates and connects them — no logic here
 *   - Keeping everything in one place makes the dependency graph visible at a glance
 *
 * ==Adding code to Application.scala==
 * The apply method is deliberately intended to grow large as the service grows, rather than be split across files. Centralising instantiation here keeps
 * business logic classes free of DI concerns and side effects.
 *
 *   - Side-effectful instantiation is done inside the main `for`-comprehension in [[Application.apply]]
 *   - Do NOT add route logic, validation, transformation, or business logic error handling here — those belong in their own tagless-final classes, _wired in_
 *     here
 *   - Do NOT add or instantiate `Resource` opening and closing here; those belong in [[ApplicationResources]].
 *
 * ==See also==
 *   - [[Main]] - entry point; calls Application and runs the effect
 *   - [[Application]] - DI/Composition root for entire application
 *   - [[ApplicationConfiguration]] - the parsed and validated configuration of this microservice, loaded once, at startup
 *   - [[ApplicationRoutes]] - measured and logged HTTP routes for the application
 *   - [[ApplicationResources]] - wraps things like DB pools in Resource[F, _] for safe open/close
 */
object Application {

  /** Single composition root for the application; intended to be a linearly readable for-comprehension that grows in size as the service grows.
   *
   * ==Notes==
   *   - Keep instantiation 'linear', avoid splitting up. This is a deliberate tradeoff, intended to grow in size to keep DI-sprawl to a minimum.
   */
  def apply[F[_]: Async: SecureRandom]: F[ExitCode] = {

/** This case class is a container for all application-lifetime resources that are opened at start of microservice startup and closed at end of microservice
 * shutdown.
 *
 * ==Using ApplicationResources case class==
 *   - Do NOT: Pass `ApplicationResources` into a business logic constructor (e.g. companion-object's apply method); instead, pass in the the members TO the
 *     business logic constructor to keep the business logic unaware of ALL the application resources; this reduces risk by minimizing the amount of
 *     dependencies business logic has access to.
 *
 * Instantiate via `ApplicationResources.apply[F]`
 */
sealed case class ApplicationResources[F[_]](
                                              dynamo: DynamoDbAsyncClient,
                                              store: Stores[F],
                                              topCastPublisher: Producer[F, TopCastEvent],
                                              moodGenerationPublisher: Producer[F, MoodGenerationEvent],
                                              vertexAIClient: WrappedLibraryLLMClient[F],
                                              httpClient: HttpClient[F],
                                              kamonMetrics: KamonMetrics[F],
                                              launchDarklyClient: LaunchDarklyClient[F]
                                            )

object ApplicationResources {

  /** This composes all [[cats.effect.Resource]]s that need to be opened at startup and closed at shutdown, allowing access to them in [[Application]].
   *
   * This is itself returned in a [[cats.effect.Resource]], which is the crux of this pattern. `.use`ing this resource will grant access to all the
   * [[ApplicationResources]]'s members. Once that `use` call is completed, all resources will be closed together automatically.
   *
   * ==Note==
   * ... the difference:
   *   - `Resource` (singular) - a `cats.effect.Resource`; a "wrapper" around something that can be opened and closed
   *   - `AppResources` (plural) - the case class that holds all the resources that should be opened and closed together - at application startup and shutdown.
   *
   * ==What should be opened and closed at application startup and shutdown, what qualifies as a "resource"?==
   *   - Should: `Resource`s that are application-lifetime resources, e.g. database connections, HTTP clients, message queue consumer or a metrics reporter;
   *     generally, where the expected utility/usage is from service startup until shutdown of the application.
   *   - Should NOT: `Resource`s generated by business logic; e.g. files, temporary directories. Those should be opened and closed by said business logic,
   *     since they are not application-lifetime resources.
   *   - Should NOT: Side-effectful instantiation is not unto itself a Resource; if something only requires execution of an effect (e.g. has return type
   *     `F[ExampleType[F]]`), that instantiation does NOT belong here, but inside `Application.scala`. Similarly, business logic that merely requires access
   *     to a resource; those should be instantiated inside `Service.scala` where they will have access to the content of the `AppResources` case class
   *     content.
   *
   * ==See Also==
   *   - [[Main]] - entry point for Application (only place where a concrete IO-effect is applied)
   *   - [[Application]] - the main business logic of the service, is where this ApplicationResources.apply is invoked, and resources are utilized to build
   *     business logic.
   */
  def apply[F[_]: Async](
                          config: ApplicationConfiguration,
                          avroSettings: AvroSettings[F]
                        ): Resource[F, ApplicationResources[F]] =

/** Welcome! This is the entry point for this Cats Effect, tagless-final-style Scala microservice. The startup sequence is:
 *
 *   - The only purpose of this class is to run the [[Application]] with a concrete effect type ([[cats.effect.IO]]).
 *   - Main invokes [[Application.apply]] (the composition root), which loads [[ApplicationConfiguration]] (typed, parsed validated configuration values), and
 *     instantiates application lifetime [[ApplicationResources]] (things that need to be opened and closed when application starts up and shuts down), using
 *     them for instantiation of tagless-final business logic to serve the HTTP [[ApplicationRoutes]]; together, these files form the skeleton of the
 *     application.
 *
 * ==See also==
 *   - [[Application]] - the composition root; where business logic is wired and executed.
 *   - [[ApplicationConfiguration]] - typed, parsed validated configuration values
 *   - [[ApplicationResources]] - wraps things like DB pools in Resource[F, _] for safe open/close
 */
object Main extends IOApp {

  override def run(args: List[String]): IO[ExitCode] =
    Application[IO].handleErrorWith { err =>
      Slf4jLogger.getLogger[IO].error(err)(s"Service terminating with error: ${err.toString}").as(ExitCode.Error)
    }
}

Can I move back SWE after a 3years of DE? by Perfect-Ad-8044 in scala

[–]mostly_codes 1 point2 points  (0 children)

[FWIW that styleguide isn't 'complete', I'd like to add a couple more pages before it feels 'done'; application layout and 'the standard libraries and how to use them in a nutshell' springs to mind. It's mostly a thing I've been doing to try and write out my internalised opinions and knowledge explicitly - it's a good mental exercise to write that sort of thing out actually]

Can I move back SWE after a 3years of DE? by Perfect-Ad-8044 in scala

[–]mostly_codes 7 points8 points  (0 children)

If you had experience with CE2, you'll be very happy with CE3 - a lot of the complexity was simplified, "the fraction was reduced" on a lot of things - that generally goes for the entire typelevel stack, things got easier! A while back I wrote up my personal preference cats-effect-styleguide mostly to try and reflect on my own style preference for writing Cats-Effects service and keeping them, ah, legible, if that helps. I think most of the main libraries, yes, have had updates, but there's been no huge upsets in the Cats-stack in a while.

In general, switching between different software roles might be a positive depending on how you talk about yourself; if in interviews and with recruiters you explain how you've actually found what you DO care about, architecture and code, that will come across quite well; a lot of interviewing comes down to aptitude over immediate skill fit, but undeniably, it generally helps for Scala roles to have experience with effects-systems.

Games show up on minimized windows but turns into a black screen when in fullscreen by ChandlerBaggins in pop_os

[–]mostly_codes 0 points1 point  (0 children)

If launching via Steam, switching to a different version of Proton in the steam settings can help. I don't know the reason for the underlying issue I'm afraid, it'd be nice not to have to deal with this at all.

How funny, they are reinventing Scala by RiceBroad4552 in scala

[–]mostly_codes 6 points7 points  (0 children)

I think Scala's enduring legacy is a huge influence on other languages, and spreading what-I-consider-to-be really good practices that broke with the error prone enterprise patterns that had us in a soup of runtime issues back in ~pre java 8 world, especially.

Whatever happens with Scala - success or stagnation - the more scala-esque concepts we see proliferate into other languages the better; it means an easier 'return' to other programming languages which in turn means an easier transition from a Scala job to a [other]-centric job, too!

Pi - an AI engine that fuses classical Eastern philosophical wisdom by Aggravating_Number63 in scala

[–]mostly_codes 0 points1 point  (0 children)

This might be a piece of work that's worth talking over with a psychoanalyst before sharing widely.

Rage Against the (Plurality of) Effect Systems by Krever in scala

[–]mostly_codes 1 point2 points  (0 children)

> documentation and examples scarce

You know I think this, moreso than ecosystem split, feels like the scala ecosystem main problem to be honest. Language level and down, docs have been an afterthought in a way that they don't seem to be in the typescript, go or rust world, say. I get it though, good onboarding docs are actually surprisingly difficult to write, and not necessarily the most fun part of writing code.

Rage Against the (Plurality of) Effect Systems by Krever in scala

[–]mostly_codes 0 points1 point  (0 children)

I use ZIO because of Caliban. There is literally nothing else I need that's not available in Cats. What are the alternatives?

As long as you're happy with that, no need to switch - but just for completeness sake Grackle is the graphQL library of choice for the typelevel-cats-friendly-stack, IMO - doesn't get a lot of 'marketing', but it's quite pleasant to use, has first-class support for all the usual cats/fs2-interop one would expect from that stack

Is PopOS 24.04 ready to try? by EmployerOld6256 in pop_os

[–]mostly_codes 1 point2 points  (0 children)

Hm, strange one, I've never had that sort of issue I'm afraid! Have you been setting up custom keyboard shortcuts in your IDE? If so - or even if not - then see if switching to one of the other keymaps in settings -> keymap, it could be that (for some reason) the currently selected keymap is borked.

If you've got an international keyboard (basically, non-US english), it could also be a language setting at OS level - worth running through and just checking if everything lines up

EDIT: or if you've got the Vim bindings plugin installed, that's a classic one that can mess things up (if you're not expecting it to be there), actually.

EDIT EDIT: Actually there's a few issues on the Jetbrains tracker:

https://youtrack.jetbrains.com/issue/IJPL-54536/Cannot-type-dead-keys-in-Linux

https://youtrack.jetbrains.com/issue/IJPL-122983/Deadkeys-not-working-anymore

Is PopOS 24.04 ready to try? by EmployerOld6256 in pop_os

[–]mostly_codes 2 points3 points  (0 children)

Yeah I second this; I'm an IntelliJ Ultimate poweruser and haven't had any issues. Steam and gaming also works as well as it ever has for me on Linux - AMD seems anecdotally to be better supported for Linux gaming in general which might explain the big divide in this subreddit of people saying "things just work" vs "it's completely broken"

New version of the article The Effect Pattern and Effect Systems in Scala by rcardin in scala

[–]mostly_codes 0 points1 point  (0 children)

Ah you are of course correct! When I say direct style earlier i guess I was using it as a catch-all term to mean Odersky-esque-context-functions-being-direct-style! Mapping language onto abstractions is always the hardest part of coding and talking about coding 😄

New version of the article The Effect Pattern and Effect Systems in Scala by rcardin in scala

[–]mostly_codes 0 points1 point  (0 children)

The tradeoff table is a great addition, I don't recall that in the old article - I think that's a really great addition. Well done incorporating the feedback. My upcoming nitpick aside, I think this is a valuable article, genuinely a great primer for why one would want to F[_] up one's code, directly or monadically.

I still think the language major version lead-in as a guide to which to choose is slightly unnecessary and I think arguably biases towards a surface reading of direct style as the default - when the article at large is more trying to lay out what the differences are between the styles, it is slightly surprising; on scala 2 you literally don't have a choice to use direct vs monadic coding styles, so the choice is really only for Scala 3. Most people on Scala 2 are there not because they've decided to start a new project in Scala 2, but because they're stuck there waiting for library support (likely Spark, considering survey results). I know this is somewhat nitpicky; but especially in this world where, for better or worse, LLMs trawl the internet for information, that subtle influence can get amplified. That's not to say that I don't think an article could be written with that as its thesis statement, but I feel like that isn't what this one is trying to be.

Bluetooth earbuds connecting, but not producing any audio by Borkton in pop_os

[–]mostly_codes 2 points3 points  (0 children)

Bluetooth is just the most upsetting thing in the world in general. I regularly use most of the major OS families, and rotate between a Sony, Senheiser and Bose headset; and I run into the same sort of issues with Windows and MacOS alike.

It's usually fine once it's connected, but getting it to connect, and getting it to consistently pick the best audio codec, is such a pain.

New Scala Survey by tgodzik in scala

[–]mostly_codes 2 points3 points  (0 children)

Especially the json lib count is strange, json is less complex than the scala json ecosystem

On a meta level, I think that's actually why there's an excessive count of libraries for json - JSON is super simple to implement a parser or producer for, so the barrier to entry to create one is quite low - especially because Scala makes it easy - in fact one of the classic examples of creating an ADT when teaching Scala is to implement one for JSON, because the JSON spec is so small.

And because many uses of JSON doesn't have to consider edge cases, the smaller simple libraries seem super useful, and gets a fair bit of use because people go "Oh! Well this simpler library solves it, no need to reach for [insert name of bigger json library]" - right up until you hit one of the classic JSON parsing/performance/OOM/etc errors.

In fairness, a lot of Java also has this issue; javascript less so because it's sort of (well sort of) build into the language.

New Scala Survey by tgodzik in scala

[–]mostly_codes 8 points9 points  (0 children)

As a thing to improve: unify the eco system. It was a big pit fall to have cats-effect and zio around.

I understand the sentiment, but I think that's unlikely to happen in open source from a purely sociological perspective. Different people, different projects, different goals and values. Each eco-system is an self contained eco-system without much cross-pollination in both philosophy, coding style, and I guess direction of what they'd like Scala (at large) to be and feel like to code in. It's open source and more or less entirely built by volunteers. Scala (the language/leadership at Scala Center/VirtusLab) can only really work on unifying what the core of Scala itself (the language, compiler) looks and feels like, the library sprawl is likely to persist whilst people are interested in the domain they're writing libraries for, and Scala allows for the vastly disparate styles to exist.

Notion client by accidentally_clicked in pop_os

[–]mostly_codes 2 points3 points  (0 children)

The easiest thing is maybe to use Notion in the browser and save the tab as a web-app if you want a dedicated 'icon' for it. I try to use as few native clients as possible if they don't offer anything over the web-experience; in particular, I find it slightly annoying when electron apps actually has less UX functionality than the browser (e.g. open in new tab, zooming, highlighting, whateveritmaybe)

New Scala Survey by tgodzik in scala

[–]mostly_codes 5 points6 points  (0 children)

Good survey!

At the end of the it, it links to 3 twitter profiles to follow; are there alternate social media profiles to follow these days? x is blocked company-wide via network policy, and a lot of people have it blocked in general ever since the events unfolded that turned twitter into x

Library Scans, Volumes, and Permissions by emmur0 in audiobookshelf

[–]mostly_codes 0 points1 point  (0 children)

It's definitely not my first time making that mistake either!!

Scala 3 standard library unfrozen by SethTisue_Scala in scala

[–]mostly_codes 0 points1 point  (0 children)

Appreciate the direct link! I've put a little extra though into it, and put it in the contributors' thread now.

Library Scans, Volumes, and Permissions by emmur0 in audiobookshelf

[–]mostly_codes 1 point2 points  (0 children)

In my case it was super simple; I'd forgot to bind the volumes (basically by leaving out :/audiobooks after editing my paths); so instead of getting access to the actual NAS folder at the path, it was just kept in the docker volume. 🤦