Readit News logoReadit News
bjacobso commented on Modern Node.js Patterns   kashw1n.com/blog/nodejs-2... · Posted by u/eustoria
exhaze · a month ago
Tangential, but thought I'd share since validation and API calls go hand-in-hand: I'm personally a fan of using `ts-rest` for the entire stack since it's the leanest of all the compile + runtime zod/json schema-based validation sets of libraries out there. It lets you plug in whatever HTTP client you want (personally, I use bun, or fastify in a node env). The added overhead is totally worth it (for me, anyway) for shifting basically all type safety correctness to compile time.

Curious what other folks think and if there are any other options? I feel like I've searched pretty exhaustively, and it's the only one I found that was both lightweight and had robust enough type safety.

bjacobso · a month ago
I migrated from ts-rest to Effect/HttpApi. It's an incredible ecosystem, and Effect/Schema has over taken my domain layer. Definitely a learning curve though.
bjacobso commented on Zod 4   zod.dev/v4... · Posted by u/bpierre
satvikpendem · 3 months ago
We also chose ArkType after evaluating Zod, Valibot, and Effect Schema, among others. It seemed to have the best developer experience while also being much faster. It also supports the Standard Schema project which I believe Effect Schema does not fully support.
bjacobso · 3 months ago
I believe Effect Schema fully supports Standard Schema, the issue is that it supports much more than Standard Schema, so not all schemas will work and thus provide compile time errors.
bjacobso commented on Evolving OpenAI's Structure   openai.com/index/evolving... · Posted by u/rohitpaulk
bjacobso · 4 months ago
I think the main issue is they accidentally created an incredible consumer brand with ChatGPT. They should sell that asset to World.
bjacobso commented on Show HN: libmodulor – An opinionated TS library to build multi-platform apps   github.com/c100k/libmodul... · Posted by u/pmdfgy
bjacobso · 7 months ago
You should check out https://effect.website/

It might help you implement some of these ideas

bjacobso commented on Zod: TypeScript-first schema validation with static type inference   zod.dev/... · Posted by u/tosh
dimal · a year ago
How did you find learning Effect? The sales pitch sounds great, but when I went through the docs it seemed pretty confusing to me. I’m sure there are reasons for the everything but I couldn’t grok it. In particular, I’m thinking of the Express integration example.[0] I look at that and think, I need all that just to create a server and a route? What’s the benefit there? I’m hesitant to buy into the ecosystem after looking at that. I want to like it, though.

[0] https://effect.website/docs/integrations/express

bjacobso · a year ago
I agree, some of there examples are a little overly complicated by their quest to be hyper composable. In fact they should probably remove that example. I am currently using it with Remix, and using their @effect/platform package to produce a simple web handler (request: Request) => Response (thank remix for heavily promoting the adoption of web standards).

I fully agree parts of the ecosystem are complex, and likely not fully ready for broad adoption. But I do think things will simplify with time, patterns will emerge, and it will be seen as react-for-the-backend, the de facto first choice. effect + schema + platform + cluster will be an extremely compelling stack.

bjacobso commented on Zod: TypeScript-first schema validation with static type inference   zod.dev/... · Posted by u/tosh
morbicer · a year ago
I feel like Effect is today's Ramda. So cool but it's going to be regretted by you and people coming after you in few years. Me and my team reverted to more stupid code and we are happier.
bjacobso · a year ago
that is certainly a possibility
bjacobso commented on Zod: TypeScript-first schema validation with static type inference   zod.dev/... · Posted by u/tosh
steve_adams_86 · a year ago
I love Zod, but recently I've been converting to Effect's Data and Schema modules.

Previously I liked a combination of Zod and ts-pattern to create safe, pattern matching-oriented logic around my data. I find Effect is designed far better for this, so far. I'm enjoying it a lot. The Schema module has a nice convention for expressing validators, and it's very composable and flexible: https://effect.website/docs/guides/schema/introduction

There are also really nice aspects like the interoperability between Schema and Data, allowing you to safely parse data from outside your application boundary then perform safe operations like exhaustively matching on tagged types (essentially discriminated unions): https://effect.website/docs/other/data-types/data#is-and-mat...

It feels extremely productive and intuitive once you get the hang of it. I didn't expect to like it so much.

I think the real power here is that these modules also have full interop with the rest of Effect. Effects are like little lazy loaded logical bits that are all consistent in how they resolve, making it trivial to compose and execute logic. Data and Schema fit into the ecosystem perfectly, making it really easy to compose very resilient, scalable, reliable data pipelines for example. I'm a convert.

Zod is awesome if you don't want to adopt Effect wholesale, though.

bjacobso · a year ago
I've had a very similar experience, and have been slowly moving from zod and ts-rest to @effect/schema and @effect/platform/HttpApi as well as migration to Effect Match from ts-pattern. There is a learning curve but its a pretty incredible ecosystem once you are in it for a bit.

I think the real turning point was typescript 5.5 (May 2024). The creator of typescript personally fixed a bug that unlocked a more natural generator syntax for Effect, which I think unlocks mainstream adoption potential.

https://twitter.com/MichaelArnaldi/status/178506160889445172...https://github.com/microsoft/TypeScript/pull/58337

bjacobso commented on Zod: TypeScript-first schema validation with static type inference   zod.dev/... · Posted by u/tosh
kaoD · a year ago
Nice. I'm looking to migrate away from a legacy custom framework over Express and this could help.

If someone has tried both, can anyone share how it compares with tRPC[0]?

[0] https://trpc.io/

bjacobso · a year ago
From my understanding trpc is very similar, however, the rpc mechanism is not a standard. ts-rest produces openapi schemas and speaks REST over http, as well as a typed client.

That being said, I am actually slowly migrating off ts-rest and adopting @effect/schema and @effect/platform/HttpApi, I foresee this being the direction the typescript ecosystem heads in over the next few years. However, the APIs are not stable yet and it has a bit of a learning curve, so would not adopt lightly

bjacobso commented on Zod: TypeScript-first schema validation with static type inference   zod.dev/... · Posted by u/tosh
bjacobso · a year ago
zod is great, but I have been moving to @effect/schema and think it deserves a mention here. @effect/schema is the evolution of io-ts, which originally inspired zod.

It supports decoding as well as encoding, and fits natively into the rest of the effect ecosystem.

https://effect.website/docs/guides/schema/introduction

It does come with the cost of importing effect, so might not be the best in certain scenarios. However, there are smaller options than zod if that is a concern.

bjacobso commented on Zod: TypeScript-first schema validation with static type inference   zod.dev/... · Posted by u/tosh
aleksiy123 · a year ago
Does anyone have a nice combination of tooling for typed handlers + client generation.

Thinking maybe Zod + Zod open API.

Really looking to replicate similar spec first workflow similar to protobuf services.

https://typespec.io/ also looks promising but seems early.

bjacobso · a year ago
I think you are looking for https://ts-rest.com/

u/bjacobso

KarmaCake day145April 28, 2009
About
YC S09

http://benjacobson.com

ben.j.jacobson@gmail.com

View Original