Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compare with zod #2430

Merged
merged 1 commit into from
Apr 2, 2024
Merged

Compare with zod #2430

merged 1 commit into from
Apr 2, 2024

Conversation

rosano
Copy link
Contributor

@rosano rosano commented Mar 28, 2024

I might have put this at the beginning of the README, but to be safer opted for just before the 'Documentation' heading.

Type

  • Documentation Update

Description

To help newbies like me understand the differences between effect schema and similar projects. This comparison page could be a useful example for a more complete comparison.

Related

Closes #2406.

@rosano rosano requested a review from gcanti as a code owner March 28, 2024 19:14
Copy link

changeset-bot bot commented Mar 28, 2024

⚠️ No Changeset found

Latest commit: 85f5c23

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@KhraksMamtsov
Copy link
Contributor

Feature-wise, zod can do 50% that schema can do.

with the previous wording, it seems that the scheme is in a weak position, but this is not the case.

@gcanti gcanti added the schema label Mar 29, 2024
1. `schema` transformations are bidirectional, so it not only decodes like `zod` but also encodes.
2. `schema` is integrated with `Effect` and inherits some benefits from it (such as dependency tracking in transformations).
3. `schema` is highly customizable through annotations, allowing users to attach meta-information.
4. `schema` uses a functional programming style with combinators and transformations (while `zod` provides a chainable API).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid mentioning FP at any cost, IMHO 😅

Suggested change
4. `schema` uses a functional programming style with combinators and transformations (while `zod` provides a chainable API).
4. `schema` provides many combinators and transformations making it highly composable (while `zod` provides a chainable API).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But with my suggestion, I'm not sure how composability contrasts with the chainable API because you can compose stuff through chaining, too.

The downside is that chainable APIs are not tree-shakable because the methods are attached to the objects prototype itself. schema may result in much smaller bundle size compared to zod, which is something frontenders will appreciate. But this needs to be verified in practice, I haven't done that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that schema will include the Effect runtime the smaller bundle size will only materialize in extreme use cases, wouldn't make such argument. What we can safely say is that chainable APIs can't be extended due to lack of extension functions in JS / TS, pipeable APIs can be extended as they are just composition of functions

@mikearnaldi mikearnaldi merged commit 04e096d into Effect-TS:main Apr 2, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Comparison with zod
5 participants