5 ms·
SQL isn't type-safe, so Prisma has that over it if nothing else. There's also a lot to be said for the difficulty in composing efficient SQL queries. If this to
by throwaway894345 7y ago
SQL isn't type-safe, so Prisma has that over it if nothing else. There's also a lot to be said for the difficulty in composing efficient SQL queries. If this tool can do that (I would be surprised) it would be a significant advancement (yes, this would be "making you not learn SQL" in the same way C makes you "not learn assembly").
- jayd16 7y agoHmm, in what sense is SQL not type safe where this would be type safe, though? You could still use out of date client code connected to a DB that has had its schema change, no? The DB and the code are not packaged together so is there even such a thing as compile time type safety?
- throwaway894345 7y agoSomething like this would make sure that all queries are correct per some expected schema and processes keep the expected and live schemas in sync. Such a process might be "database migrations run in the CD pipeline and nothing else changes the database". Of course there are edge cases here and there (someone will eventually need to log into a production database), but these processes go a long way toward reducing risk.
- alde 7y agoSQL is as type-safe as the DB engine allows it to be. PostgreSQL is type-safe. Extracting these types and making them available and usable in your lang-of-choice at compile time is a different problem though.
- throwaway894345 7y agoYes, when we talk about type safety, we generally mean "compile time" type safety. Python is also "type safe" at runtime (which is to say, "it's strongly typed"), but we don't conventionally consider Python to be type-safe.
- alde 7y agoWell, all I am saying is that PostgreSQL provides you with compile-time type-safety when your write your queries. Bringing this type information at "compile-time" into your language of choice where you embed your queries can also be done but is a harder problem. There is good progress in that sphere but it is still in it is infancy. The GraphQL eco-system for example, has this figured out using code generators. A similar thing can be done with DBs.
- adsharma 7y agopython is type-safe if you use python3 and avoid the dynamic parts of the language using a linter.
- Groxx 7y agoSince it does no checking of the annotations at runtime: I don't really think this is accurate. This prints `5` for instance: https://repl.it/repls/DarkorchidFailingComputationalscience https://repl.it/repls/DarkorchidFailingComputationalscience def do(s: int) -> str: return 5 print(do("123")) Python is duck-typed. Wrong types aren't detected until they fail to quack correctly.
- adsharma 7y agoIf you run mypy or pyre-check on the code above, it'll give you a type error, just like a C compiler would.
- Groxx 7y agoSure, but that's like saying "valgrind exists, so C has out-of-bounds checks". It doesn't. External tools have just found ways to add optional safety that the language lacks.
- fulafel 7y agoThat depends on who you generally talk with. Dynamic typing/static typing are orthogonal to eg weak/strong typing and other type system features, that's estabilished terminology.