Hacker News new | ask | show | jobs
by slopinthebag 60 days ago
it's for people who want to write ocaml or rust, but in typescript for some reason
1 comments

It does seem like they're boiling the ocean, for... whatever reason programmers do these things.

Rebuild JS's core data structures: https://effect.website/docs/v4/api/effect/Array

Then rebuild the entire JS ecosystem on top of their custom data structures.

And then the main heading on their home page is "Reliable TypeScript for the AI era"? Really? I'll pass.

part of it is because js is a throwing language, and since there are no "checked" exceptions they need to basically rebuild the universe in their paradigm.

but they seem to want to rebuild everything, eg

> The Console service exposes common console methods such as logging, warnings, errors, groups, counters, tables, and timers. Because console access goes through a service, programs can use custom console implementations in tests or other environments. This module also includes scoped helpers that close console groups or timers automatically.

yeah idk mate

Console is the very core of what I expect an effect system to need to reimplement.

Console is IO and IO is the effect.

just use a dependency injected logger then...
Not playing devil's advocate or anything, but effect systems go beyond DI: it's not just about passing around a capability, but managing its lifecycle in a referentially transparent manner, i.e. monads all the way down. It's a real pain, but they set themselves up to bear the burden, so, good for the rest of us I guess?
This is super useful though. It allows you to swap out implementations for things like logging and monitoring. Not sure what the confusion is here.
Petty aside: Several JS people I know who were previously quite down on using a dependency injection framework are now seeing the benefits after adopting Effect. The most egregious example being a colleague who considered the adaption of DI tooling to be a language-level defect. It’s now one of his primary selling points for Effect.
i wouldn't consider the opinions of people who consider themselves "js people" to be particularly interesting, considering the ultimate state of that ecosystem. i say that as someone who writes js professionally.
you dont need an entire runtime to implement polymorphic console.logging. tbh the fact they want to implement the world to do this is more of an inditement against this approach than anything else
It isn't a case of wanting to implement the world to do this though.

Instead, it is a case of the active users of the library saying, "Wow, the Effect way of doing this is so much nicer, can we have everything this way please?"

It literally says:

> Works with JavaScript arrays

Yes but why? Why should I import a giant dependency to do this:

  a = [1, 2, 3];
  foo = effect.Array.append(a, 4);
instead of using what's built in to the language?

  a = [1, 2, 3];
  foo = [...a, 4];
You wouldn't. Effect isn't an array library.
did you read the docs? it says

"Use when you need to guarantee a non-empty result after adding a required trailing value."

...whatever that means lol

The types allow you to very narrowly define functions so that you can, for example, require that a NonEmptyArray be passed. This helps to fulfill that requirement without casts.
NonEmpty is a type that allows you to distinguish between:

    a = [undefined];
    res = a.pop() // undefined

    a = [];
    res = a.pop() // undefined
As a Python person, that 2nd one looks like a bug. Expecting an exception there. Although also Python doesn't have an `undefined`; `None` would have to suffice.