3 ms·
Looking at the dependencies, I realized that it is now common to implement database bindings purely in the host language (vs. using vendor provided C/C++ SDK.)
by flakiness 5y ago
Looking at the dependencies, I realized that it is now common to implement database bindings purely in the host language (vs. using vendor provided C/C++ SDK.)
Deno PG [1] and MySQL [2] does it. This makes sense considering Deno's security model. But Node libs do the same [3][4]! This also kinda make sense, as node-based JS has to be async most of the time. Still it's such a hassle.
Anyways, kudos to both communities. You've done a lot!
- [1] https://deno.land/x/postgres@v0.11.2 https://deno.land/x/postgres@v0.11.2
- [2] https://deno.land/x/mysql@v2.9.0 https://deno.land/x/mysql@v2.9.0
- [3] https://github.com/brianc/node-postgres/tree/master/packages/pg https://github.com/brianc/node-postgres/tree/master/packages...
- [4] https://github.com/mysqljs/mysql https://github.com/mysqljs/mysql
- eloff 5y agoIt's because synchronous libraries that block don't play well with async event loop code like node or deno. You'd have to run them on a thread pool and pass data back and forth to avoid blocking. This phenomenon also happens in go and rust for similar reasons.
- wrnr 5y agoWriting extensions in rust is also an option, not done it myself but it seems to use the systems shared library capabilities: https://blog.logrocket.com/how-to-create-a-deno-plugin-in-rust/ https://blog.logrocket.com/how-to-create-a-deno-plugin-in-ru...
- pjmlp 5y agoIt was already common with Java and .NET, hence why the vocabulary types define multiple levels for the database drivers. For example with JDBC: Type 1 driver - JDBC-ODBC bridge Type 2 driver - Native-API driver Type 3 driver - Network-Protocol driver (Middleware driver) Type 4 driver - Database-Protocol driver (Pure Java driver) or thin driver. Most modern drivers are all type 4.
- flakiness 5y agoMost of Java drivers are different since there is official implementation. That's possible mainly because Java is very popular language. Deno is more community driven. Maybe Node is closer to Java these days.
- maple3142 5y agoI think one reason is using native C/C++ SDK makes it harder to install (compared to pure JavaScript/TypeScript), because you can't assume that compiler is always available. For example, you need to install extra tools to use install node modules with native dependencies on Windows.
- js2 5y ago[4b] https://github.com/sidorares/node-mysql2 https://github.com/sidorares/node-mysql2 [4] doesn't use parameter binding; rather, it inserts escaped values into the SQL statement client-side in place of any "?" placeholders. [4] also doesn't support prepared statements. [4b] uses parameter binding, sending the SQL statement as is separate from the values, as well as supports prepared statements.