HackerTrans
TopNewTrendsCommentsPastAskShowJobs

dloreto

no profile record

Submissions

Show HN: Go AI SDK – A Unified Go API for LLMs

github.com
4 points·by dloreto·letztes Jahr·0 comments

TySON: TypeScript Object Notation. Use TS as an embeddable config language.

github.com
6 points·by dloreto·vor 3 Jahren·3 comments

Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs

github.com
418 points·by dloreto·vor 3 Jahren·221 comments

comments

dloreto
·vor 3 Jahren·discuss
I have a similar view to yours: as soon as you need variables, imports, functions or any other type of logic ... the existing "data-only" formats break down. Over time people either invent new configuration languages that enable logic (i.e. cue or jsonnet), or they try to bolt-in some limited version of these primitives into their configuration.

My personal take is that at some point you are better of just using a full programming langugage like TypeScript. We created TySON https://github.com/jetpack-io/tyson to experiment with that idea.
dloreto
·vor 3 Jahren·discuss
JSON + types + functions using TypeScript syntax. Makes it possible to use TypeScript as a configuration language for applications written in `go`, and soon `rust` and other major languages.
dloreto
·vor 3 Jahren·discuss
A follow up:

1. We've now implemented pretty thorough testing: https://github.com/jetpack-io/typeid-go/blob/main/typeid_tes...

2. I clarified the prefix in the spec

Thanks for the feedback!
dloreto
·vor 3 Jahren·discuss
We've now implemented pretty thorough testing: https://github.com/jetpack-io/typeid-go/blob/main/typeid_tes...

Thanks for the feedback!
dloreto
·vor 3 Jahren·discuss
I hear you ... and I debated using either base58 or base64url. I do like the more compact encoding they provide.

Ultimately I ended up leaning towards a base32 encoding, because I didn't want to pre-suppose case sensitivity. For example, you might want to use the id as a filename, and you might be in an environment where you're stuck with a case insensitive filesystem.

Note that TypeID is using the Crockford alphabet and always in lowercase – *not* the full rules of Crockford's encoding. There's no hyphens allowed in TypeIDs, nor multiple encodings of the same ID with different variations of the ambiguous characters.
dloreto
·vor 3 Jahren·discuss
Thanks for the feedback!

We have tests for the base32 encoding which is the most complicated part of the implementation (https://github.com/jetpack-io/typeid-go/blob/main/base32/bas...) but your point stands. We'll add a more rigorous test suite (particularly as the number of implementations across different languages grows, and we want to make sure all the implementations are compatible with each other)

Re: prefix, is the concern that I haven't defined the allowed character set as part of the spec?
dloreto
·vor 3 Jahren·discuss
The checksum idea is interesting. I'm considering whether it makes sense to add it as part of the TypeID spec.
dloreto
·vor 3 Jahren·discuss
The CLI tool will support encoding/decoding any valid UUID, whether v1, v4, or v7. We picked v7 as the definition of the spec, because we need to choose one of them when generating a new random ID, and our opinion is that by default, that should be v7.

We might add a warning in the future if you decode/encode something that is not v7, but if it suits your use-case to encode UUIDv4 in this way, go for it. Just keep in mind that you'll lose the locality property.
dloreto
·vor 3 Jahren·discuss
It's based on UUIDv7 (in fact, a TypeID can be decoded into an UUIDv7). The main reasons to use TypeID over "raw" UUIDv7 are: 1) For the type safety, and 2) for the more compact string encoding.

If you don't need either of those, then UUIDv7 is the right choice.
dloreto
·vor 3 Jahren·discuss
That's how the type is encoded as a string, but type-safety ultimately comes from how the TypeID libraries allow you to validate that the type is correct.

For example, the PostgresSQL implementation of TypeID, would let you use a "domain type" to define a typeid subtype. Thus ensuring that the database itself always checks the validity of the type prefix. An example is here: https://github.com/jetpack-io/typeid-sql/blob/main/example/e...

In go, we're considering it making it easy to define a new Go type, that enforces a particular type prefix. If you can do that, then the Go type system would enforce you are passing the correct type of id.
dloreto
·vor 3 Jahren·discuss
The stated downsides come from poor data locality when using mostly random UUIDs; but you can keep most of the benefits of a globally unique identifier, and retain locality, by using UUIDv7.

At jetpack.io we've been doing exactly that via TypeIDs: https://github.com/jetpack-io/typeid and there's a PostgresSQL implementation available. TypeIDs are UUIDv7 with additional type information, so you also get type-safety in your IDs.
dloreto
·vor 3 Jahren·discuss
Tools like Devbox: https://github.com/jetpack-io/devbox are making this way easier. Devbox is powered by nix, but it hides all of the complexity and makes it easier to use.
dloreto
·vor 4 Jahren·discuss
Depending on your use case, devbox (https://github.com/jetpack-io/devbox) could be what you're looking for. It is powered by Nix, but abstracts the nix language away, so that you can use it like a "regular" package manager.

Currently it works on a "per-project" basis, but we're planning to add support to use it as your primary package manager for global installs as well.
dloreto
·vor 4 Jahren·discuss
The latest version of devbox allows pinning the sha of the nixpkgs repository to whatever you want. We don't yet allow pinning on a per-package basis within nixpkgs, but we're working on that.