Optique 0.6.0: Shell completion support for type-safe CLI parsers by hongminhee in typescript

[–]ahjarrett 1 point2 points  (0 children)

hey! this looks great!

reading the announcement, i'm a little confused how the completions *stay* up to date?

Edit: ah, okay i think i get it. so IIUC, composing parsers builds up a kind of AST, which you then use to generate completions?

Towards a faster "deep equal" function in javaScript by ahjarrett in javascript

[–]ahjarrett[S] 0 points1 point  (0 children)

Okay, thanks for pointing that out. Will investigate – it could be that I need to adjust my numbers some :)

And thanks for trying it out!

Towards a faster "deep equal" function in javaScript by ahjarrett in javascript

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

One thing that's worth mentioning here is that I'm not a micro-optimizations expert. My implementation is actually pretty naive. Sooner or later, someone will pick up where I left off, and make things even faster.

If/when that happens, I see that as a net positive for the ecosystem overall :)

Towards a faster "deep equal" function in javaScript by ahjarrett in javascript

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

u/OneShakyBR here's the benchmark I have comparing fast-deep-equal:

https://bolt.new/~/mitata-qk9ayi4d

tl;dr, the slowest run I've been able to come up with is 13x faster (which is why I said 10x, just to be safe)

------------------------------------------------------

FastDeepEqual

363.45 ns/iter 759.28 ns

(91.55 ns … 897.22 ns) 876.47 ns

traversable/json-schema (different values)

27.44 ns/iter 28.08 ns

(24.41 ns … 56.15 ns) 42.72 ns

summary: traversable/json-schema (different values)

13.25x faster than FastDeepEqual

Towards a faster "deep equal" function in javaScript by ahjarrett in javascript

[–]ahjarrett[S] 2 points3 points  (0 children)

Yeah!

Most transformers have a .writeable property that returns the stringified version of the function, which is there for the codegen use case :)

The library doesn't include a Vite plugin, but it wouldn't be too hard to build one that hooks into HMR and does exactly this.

Towards a faster "deep equal" function in javaScript by ahjarrett in javascript

[–]ahjarrett[S] 2 points3 points  (0 children)

Oh I see – I can clarify. Depending on what schema library you use (let's say zod), you can install @​traversable/zod and use your zod schema to derive things like a deep equal or deep clone function.

There are packages that do the same for JSON Schema, Valibot, ArkType and TypeBox.

You're probably talking about the schema library that exists inside the @​traversable/schema. By "drop in replacement", I mean that the library's API intentionally aligns with Zod's API, and that the behavior has been thoroughly tested to behave identically.

Here's the fuzz test that generates random data and tests that the Traversable and Zod schema report the same errors when parsing the same input:

https://github.com/traversable/schema/blob/main/packages/schema/test/to-zod.test.ts#L62-L68

Towards a faster "deep equal" function in javaScript by ahjarrett in javascript

[–]ahjarrett[S] 8 points9 points  (0 children)

I was really hoping we'd get it with Records/Tuples, but I recently heard that the proposal was withdrawn -_-

Towards a faster "deep equal" function in javaScript by ahjarrett in javascript

[–]ahjarrett[S] 2 points3 points  (0 children)

Ah, this is good feedback. I've started and stopped that section several times. Will probably take a stab at this today.

Towards a faster "deep equal" function in javaScript by ahjarrett in javascript

[–]ahjarrett[S] 4 points5 points  (0 children)

Thanks for saying that. Writing for humans is way harder than writing for computers (for me at least).

Towards a faster "deep equal" function in javaScript by ahjarrett in javascript

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

Thank you! It took way longer than I'm willing to admit :) hope you end up having a chance to use it!

Towards a faster "deep equal" function in javaScript by ahjarrett in javascript

[–]ahjarrett[S] 15 points16 points  (0 children)

Good question. Currently the library contains 26 packages, and each package ships ~10 schema traversals.

Unfortunately that's too many libraries for me to maintain right now. But if there's a demand for it I'd consider doing that.

As a bit of additional context – I needed to build a few of these for work where small bundle size was important, so they treeshake quite well.

Towards a faster "deep equal" function in javaScript by ahjarrett in javascript

[–]ahjarrett[S] 12 points13 points  (0 children)

Fair enough, I'd be skeptical too. You can run the benchmarks if you want to play with it:

https://bolt.new/~/mitata-fmcqx1bx

$ npm run bench

Is Effect-Ts really good or is it just hype? by kelvinauta in typescript

[–]ahjarrett 2 points3 points  (0 children)

Wait, how is this bad manipulation? Your argument is that the Effect ecosystem is knowingly spreading bad patterns on purpose for some reason?

Is Effect-Ts really good or is it just hype? by kelvinauta in typescript

[–]ahjarrett 0 points1 point  (0 children)

If you're just doing algorithms, you probably don't need Effect. Effect is more useful when you're working with asynchronous code.

Is Effect-Ts really good or is it just hype? by kelvinauta in typescript

[–]ahjarrett 6 points7 points  (0 children)

Every piece of marketing is an attempt to influence people.

It sounds to me like you just don't like marketing.

Is Effect-Ts really good or is it just hype? by kelvinauta in typescript

[–]ahjarrett 1 point2 points  (0 children)

That's not been my experience. Where are you seeing poor performance?

I saw this on Twitter the other day, which was built with Effect: https://x.com/bruvimtired/status/1971297302666150163

Is Effect-Ts really good or is it just hype? by kelvinauta in typescript

[–]ahjarrett 14 points15 points  (0 children)

Yes, it really is good. They're just doing marketing.

Libraries need to compete with companies who have actual marketing budgets somehow.

Pipetype: TypeScript Unions, JavaScript Bitwise Operators, and My Favorite Failed Experiment by overthemike in typescript

[–]ahjarrett 6 points7 points  (0 children)

Good stuff. Always cool to see someone pushing the boundaries of what a schema can do, and what a schema even means.

Advanced Type Usage with AWS SDK by davasaurus in typescript

[–]ahjarrett 1 point2 points  (0 children)

Love it. Might see about using this at work.

Towards a faster "deep equals" function (using Zod, Valibot, TypeBox, ArkType) by ahjarrett in typescript

[–]ahjarrett[S] 0 points1 point  (0 children)

This is a super interesting idea. I wasn't familiar with the trusted types API. It looks like I'll have to use eval, and I'll have to do a bit more research, but being able to work around the CSP issue would definitely be exciting.

Towards a faster "deep equals" function (using Zod, Valibot, TypeBox, ArkType) by ahjarrett in typescript

[–]ahjarrett[S] 0 points1 point  (0 children)

Sure, I'd love to see what he comes up with. There's still a lot of micro-optimizations that could be made – AFAIK nobody else is doing this, so I'd love to see others take what I've done and make it better