Earlier quoted context omitted.
Are you really calling this ergonomic? https://github.com/codemix/ts-sql/blob/master/src/Evaluator.... Same thing but actually readable and maintanable would've been better implemented as a compile-time (build-time) script, basically source code generation.
Nobody said it's ergonomic to implement SQL in a type system. It was simply an answer to your question "What do you think is advanced about TS' type system and why?". It's advanced because you're able to implement SQL in types alone when with most languages you couldn't. The question on ergonomics is for the other languages where you can do this is it more or less ergonomic than this. Again that doesn't mean this IS…
Show HN: A SQL database implemented purely in TypeScript type annotations
141–150 of 196 posts
Re: Show HN: A SQL database implemented purely in TypeScript type annotations
#142Shameless plug: we're also working on project in the same domain. It actually uses the TypeScript compiler API to generate/update your SQL schema's and a typesafe (mongo like) API on top PostgreSQL. It's still very early stage, but if you're interested: https://samen.io
Re: Show HN: A SQL database implemented purely in TypeScript type annotations
#143Nice! I built something similar - A set of scripts that generate SQL statements from typescript types to wrap a PostgresSql db. It’s more a hybrid data structure where only relationships and certain fields become columns (which can be indexed and searched) and most of the other data becomes a Json column. I wasn’t completely satisfied with the final results, but it does at least allow me to add additional data fields…
> I built something similar - A set of scripts that generate SQL statements from typescript types to wrap a PostgresSql db. If you think these are similar I don't think you understand what this is / what it's actually doing.
I agree my wording could have been better.
Re: Show HN: A SQL database implemented purely in TypeScript type annotations
#144Re: Show HN: A SQL database implemented purely in TypeScript type annotations
#145I love Typescript -- I just wish there were an alternate runtime (.Net core CLR/DLR or other) that offered shared-memory green and/or native threading for true support for embarrassingly parallel but not vectorized workloads. FWICT, I don't think Deno changes things here much. Typescript on the BEAM would be interesting to me as well.
Re: Show HN: A SQL database implemented purely in TypeScript type annotations
#146Earlier quoted context omitted.
> Haskell has a much more expressive type system than Elm, but still lags behind Typescript unless you turn on a truly gargantuan number of extensions. IIUC: it's not a total order, Haskell (even '98) has things TypeScript doesn't[0], and TypeScript has things that Haskell (even with extensions) doesn't[1]. [0]: eg. higher-kinded types [1]: eg. (convenient) row polymorphism
Yeah you're right it's not a total order. I was being fast and loose and conveying a subjective feeling. RE row polymorphism, Typescript doesn't quite have what users of ML-like languages are asking for when they want row polymorphism (which is usually parametric polymorphism rather than subtyping). But it's close. As for convenient... well I'd argue by the time you've got the whole cornucopia of GHC extensions at th…
How would you distinguish this from the following?
function foo(x: T & {field: number}): T {
...
}
> As for convenient... well I'd argue by the time you've got the whole cornucopia of GHC extensions at the top of your file nothing is quite convenient at that point.That was one part of my point. That said, I think the problems implied by language extensions are often exaggerated (probably not deliberately so, most of the time).
The other part of my point was that even with all the extensions you need, I've not found good row types in Haskell, although the particular failings vary by approach. Which isn't to say I can't get something that works well enough for my particular situation most of the time.
Re: Show HN: A SQL database implemented purely in TypeScript type annotations
#147Earlier quoted context omitted.
From years of real-world experience, it's rare to run into types that are too complex to easily understand. The syntax is pretty easy to read, and the compiler and language service make it easy to navigate types, even if you haven't looked at the source for them yet.
FWIW I find that TypeScript types can sometimes be overwhelming or hard to decipher, especially some third-party library type definitions. The connect function from react-redux is one example: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/d07d... Since types can get really complex, I feel a need to be conscious of avoiding complexity when writing types myself, unless the value is enough to justify a hard-to…
What this really demonstrates to me is the difference between starting with TS vs migrating to it. Code that has to think about the types the first time it is being built is going to be better structured, on average, than purely dynamic code.
Re: Show HN: A SQL database implemented purely in TypeScript type annotations
#148TypeScript is becoming such a compelling language due to its insanely advanced type system (that allows for projects like this) that I now want to use it everywhere. I want it to become the next Python. I know Deno is supposed to be first class TypeScript but under the hood it's still a JavaScript runtime with all the baggage that comes with that. AssemblyScript is extremely interesting but last time I played with it…
If you're impressed with TypeScript, you should definitely check out ReScript (formerly BuckleScript). Its type system is clean and sound, and yet compiles to native JS without overhead. https://rescript-lang.org/docs/manual/latest/introduction
Then, I noticed it has the pipe operator! I'm going to be giving this a try.
Re: Show HN: A SQL database implemented purely in TypeScript type annotations
#149Earlier quoted context omitted.
Yeah you're right it's not a total order. I was being fast and loose and conveying a subjective feeling. RE row polymorphism, Typescript doesn't quite have what users of ML-like languages are asking for when they want row polymorphism (which is usually parametric polymorphism rather than subtyping). But it's close. As for convenient... well I'd argue by the time you've got the whole cornucopia of GHC extensions at th…
> RE row polymorphism, Typescript doesn't quite have what users of ML-like languages are asking for when they want row polymorphism (which is usually parametric polymorphism rather than subtyping). But it's close. How would you distinguish this from the following? function foo (x: T & {field: number}): T { ... } > As for convenient... well I'd argue by the time you've got the whole cornucopia of GHC extensions at the…
function foo(x: T & {field: number}): T {
return x;
}
function bar(x: T & {field: number}): T {
const x0 = foo(x);
// type error because x0 doesn't have field
// would compile fine with row types
const x1 = foo(x0);
return x1;
}
Yes it's true. I also sorely miss the lack of row types in Haskell (I miss them even in something like Idris where you can create them more easily, but it's still not great compared to first-class support).EDIT: I may be being dumb. You could probably fix this by adding an intersection type again on the right-hand side. I think there was something else I was missing from TS, but I'll have to noodle on it a bit more.
Re: Show HN: A SQL database implemented purely in TypeScript type annotations
#150Earlier quoted context omitted.
> RE row polymorphism, Typescript doesn't quite have what users of ML-like languages are asking for when they want row polymorphism (which is usually parametric polymorphism rather than subtyping). But it's close. How would you distinguish this from the following? function foo (x: T & {field: number}): T { ... } > As for convenient... well I'd argue by the time you've got the whole cornucopia of GHC extensions at the…
function foo (x: T & {field: number}): T { return x; } function bar (x: T & {field: number}): T { const x0 = foo(x); // type error because x0 doesn't have field // would compile fine with row types const x1 = foo(x0); return x1; } Yes it's true. I also sorely miss the lack of row types in Haskell (I miss them even in something like Idris where you can create them more easily, but it's still not great compared to firs…
But yeah, I agree that duplicating the intersection produces another interesting question.
In any case, "convenient approximation of row types" probably still applies to TS more than Haskell. And possibly also "more convenient row types", but that remains TBD.