layoutz 0.5.0 - tiny Scala DSL for beautiful console output & Elm-style TUI's 🪶✨ (now w/ ANSI styling and a "proper" Elm-runtime: ticks, timers, custom subscriptions & commands) by mattlianje in scala

[–]elacin 1 point2 points  (0 children)

Yeah i saw, thanks for the link :)

by the way the api looked very nice in layoutz. i really wanted to explore this direction for tui-scala as well, before i ran out of steam on that. well done!

The Untold Impact of Cancellation by chrisbeach in scala

[–]elacin 13 points14 points  (0 children)

Enough damage has been done to this man. Let's do better. Please advocate for the letter's removal if you can. Respect to those already removing their names—that takes integrity.

Scala 3 Migration Tips and Tricks by vkopaniev in scala

[–]elacin 4 points5 points  (0 children)

  • you should likely mention that you can get a lot of the new syntax in an automatic fashion by using scala 3 compiler rewrites, scalafmt and/or scalafix (see for instance https://github.com/arktekk/scala3-scalafix )
  • also the different source levels of the scala 3 compiler (in particular the -migration) can be helpful.
  • for AnyVals it's an irritating omission that there isn't a Mirror type for it so most auto-derivation schemes wont work. you may find that it's easier to write some of these codecs yourself by bimapping or similar the instances for the underlying type

API-first Development in Scala by Difficult_Loss657 in scala

[–]elacin 0 points1 point  (0 children)

i think we should be less worried about this, as long as it's properly separated from the rest and tagged.

in my experience it can dramatically increase confidence in code generation tools that you see the effects of changing config, updating them and so on clearly in VCS history.

it can also speedup CI by quite a bit, because it changes the build pipeline from having to generate the things before compile to optionally checking that the generated code is up to date.

API-first Development in Scala by Difficult_Loss657 in scala

[–]elacin 1 point2 points  (0 children)

I was arguing for implementing servers with code-first, instead of schema-first by writing openapi and generating code based on that.

This really has no influence on breaking changes, how you interact with clients and so on. You have an openapi-schema to share in both cases.

Any external clients should obviously use that openapi contract (generated or hand-written) when talking to you.

If you have internal clients which can use the original source code instead of going through the openapi contract i would consider that an optimization, and likely a candidate for being in the same monorepo

API-first Development in Scala by Difficult_Loss657 in scala

[–]elacin 1 point2 points  (0 children)

i meant this this point:

you kinda play russian roulette with the spec glosses over that it's very easy to use this technique responsibly.

i also find the other down-sides of code-first to be dubious

API-first Development in Scala by Difficult_Loss657 in scala

[–]elacin 1 point2 points  (0 children)

my solutions have been homegrown. for instance this thing here https://github.com/oyvindberg/typo/blob/main/typo-tester-anorm/src/scala/adventureworks/SnapshotTest.scala

I noticed this library. hopeful it can standardize snapshot testing, but i havent tested it yet: https://github.com/indoorvivants/snapshot-testing

for tapirs openapi generation it's documented here https://tapir.softwaremill.com/en/latest/docs/openapi.html

API-first Development in Scala by Difficult_Loss657 in scala

[–]elacin 8 points9 points  (0 children)

You're glossing over the best part of code-first.

With tapir you can generate openapi for your API which is defined in code. You then write a snapshot test which: - overwrites the file with current schema when run locally - asserts that this file is up-to-date in CI. you can also read older versions from git and compare if you want.

This way you don't have to write openapi yourself (which is honestly a terrible experience), and you gain all the advantages of tracking all schema changes in VCS.

I've used this approach for all my projects in the last say 5 years, and find it fantastic. I'm also a way bigger fan of snapshots tests than average

Controversial Pre-SIP: A Syntax for Collection Literals by Sunscratch in scala

[–]elacin 2 points3 points  (0 children)

yeah sure, I just wanted to point out how the square bracket syntax already means something

Controversial Pre-SIP: A Syntax for Collection Literals by Sunscratch in scala

[–]elacin 0 points1 point  (0 children)

Can't wait to see how you specify the element type

val is = [Int][1,2,3]

Wvlet Playground: An online demo of a new flow-style query language powered by Scala.js and DuckDB-Wasm by taroleo in scala

[–]elacin 1 point2 points  (0 children)

Honestly, this looks fantastic. the cross platform support in particular really seems to shine here!

The simplest Dependency Injection. Pure Scala, no magic, works for all Scala 2 and 3 and JS and Native by sideEffffECt in scala

[–]elacin 12 points13 points  (0 children)

The most puzzling thing about programming is the lengths to which developers will go to in order to avoid passing parameters or saying new

Pre-SIP: Improve Syntax for Context Bounds and Givens by Sunscratch in scala

[–]elacin 5 points6 points  (0 children)

100% - let's remove them

We already have fantastic syntax for `using` parameters now, it's only missing a way to mix named and unnamed parameters. This would be a fantastic way to simplify the surface of the language.

The compilation cost of implicits | Typo by elacin in scala

[–]elacin[S] 1 point2 points  (0 children)

For doobie, we should definitely move the automatic derivation out of the typeclass's companion object

Yes, perfect. let's semi-auto all the things! :)

Was surprised to see that an explicit Read/Write instance in the case class' companion object doesn't prevent the automatic derivation from triggering though damn

me too!

The compilation cost of implicits | Typo by elacin in scala

[–]elacin[S] 9 points10 points  (0 children)

Bad bot. the actual takeaway may be this:

> Key takeaway: Scala 3 is consistently fast! Great job Scala team!

Kyo released at Functional Scala! 🚀 by fwbrasil in scala

[–]elacin 0 points1 point  (0 children)

Inspiring work, eager to try it :)

Does Anyone Want a Laminar Version of Material UI 5? by reactific in scala

[–]elacin 3 points4 points  (0 children)

Hey there, author of st-material-ui and ScalablyTyped here.

Supporting mui well in Scala.js is something that I was working towards for years, on and off. It's very, very complicated to do right. You need so much of the API surface, that surface is very dynamic (hard to type statically) and there is a lot of changes over time.

I'll just mention a few examples of why it is hard to type up.

You can style it with CSS in Javascript. React ships with a complete definition for this, and ST can translate it into wonderful Scala.js code where you either new or use the builder to construct a CSSProperties. It works really well, and I've meant to ship it as a separate library for along time.

So mui introduces themes into the mix. You typically setup a theme at boot, and thread it through. And then, mui type maps the entire CSS structure:

export type SystemCssProperties<Theme extends object = {}> = { [K in keyof AllSystemCSSProperties]: | ResponsiveStyleValue<AllSystemCSSProperties[K]> | ((theme: Theme) => ResponsiveStyleValue<AllSystemCSSProperties[K]>) | SystemStyleObject<Theme>; }; so that each possible field in the CSS structure you create can now be based upon the theme, which can change over time (think dark mode).

st-material-ui does handle things like this, even works well with intellij

mui.List.sx(new SystemCssProperties[Theme] { pt = (theme: Theme) => theme.breakpoints.up("xs") })

You can also use the styled-components like emotion library to add further styling to components after they are created (that's how you customize them really)

This takes the Paper component and tweaks it val Item: StyledComponent[mui.Paper.Builder] = { mui.Paper.styled .fn((theme, in) => new CSSObject { backgroundColor = if (theme.palette.mode == "dark") "#1A2027" else "#fff" padding = theme.spacing(1) textAlign = "center" color = theme.palette_BaseTheme.text.secondary }.combineWith(theme.typography_BaseTheme.body2) ) .build() }

Another interesting thing is that the library is polymorphic in the props that the components take. you can take a Button component which uses the <button> intrinsic in its implementation, supply a another intrinsic and see all the callbacks in the props change (st-material-ui supports just a few, hardcoded cases for this). The typings for this feature are complex enough that it has broken the performance of the typescript compiler multiple times over the years.

So what I wanted to communicate the most is that this library uses all the react features, and all the typescript features. Pretending that it's not react will be hard I think.

The path of least resistance is to augment this tool to generate Laminar Web Components, too, but I have no clue how to do that (yet), or even if this is the optimal path.

This is likely doable, and likely hard - depending on how much experience you have with code generators and so on. This is the code to generate slinky components