News for hackers. Stuff that matters.
Re:Show HN: Sqinn-Go is a Golang library for accessing SQLit... by ComputerGuru on Wednesday October 04, 2023 @04:17PM (#37771073)
But compiling the non-go assistant process is not going to be any easier than cgo, right?
Re:Show HN: Sqinn-Go is a Golang library for accessing SQLit... by parhamn on Wednesday October 04, 2023 @04:36PM (#37771362)
Well its a different access pattern. As the underlying library points out:

> It is used in programming environments that do not allow calling C API functions.

Also I guess which one is easier will be subjective. The steps are sorta similar:

Step 1) install sqlite or squinn on the base system (the latter might be harder)

Step 2) if sqllite use cgo, if squinn just use go (the former might be harder but more performant)

Re:Show HN: Sqinn-Go is a Golang library for accessing SQLit... by ComputerGuru on Wednesday October 04, 2023 @10:31PM (#37774261)
Which programming environments that do not allow calling C API functions also let you build/ship arbitrary C executables, though? (Genuinely curious what scenarios this unlocks.)
Re:Show HN: Sqinn-Go is a Golang library for accessing SQLit... by cvilsmeier on Saturday October 07, 2023 @06:22PM (#37806034)
I use it for SQLite Database access in Go and Java. Java lets you theoretically interface with C code, but it's a lot of JNI/DLL/SO work. It's much easier for me to just os/exec (or Runtime/exec in Java) and send data back and forth. Your mileage may vary, of course.
Re:Show HN: Sqinn-Go is a Golang library for accessing SQLit... by codetrotter on Wednesday October 04, 2023 @04:32PM (#37771300)
In the mentioned https://gitlab.com/cznic/sqlite there would not be any assistant process, right?
Re:Show HN: Sqinn-Go is a Golang library for accessing SQLit... by jerf on Wednesday October 04, 2023 @04:56PM (#37771656)
No, but that has the disadvantage of being C compiled into Go, then being compiled into native executable.

I'm actually surprised by how readable this came out; props to the Go->C compiler author. But you can guess that pushing this sort of thing through the Go compiler is going to cause some slowdowns due to sheer paradigm mismatch: https://gitlab.com/cznic/sqlite/-/blob/master/lib/sqlite_lin...

Re:Show HN: Sqinn-Go is a Golang library for accessing SQLit... by throwaway894345 on Wednesday October 04, 2023 @05:24PM (#37772005)
I don’t think the paradigm is particularly mismatched, right? If you translate C to Go, it would be pretty much best case for Go (neither language likes lots of small allocations). But Go lacks a lot of optimizations that most C compilers support, like return value optimization, aggressive inlining, etc. C also has lighter-weight function calls and so on that you pay for in Go.

Maybe this is what you mean by paradigm mismatch, but usually I would think of something like translating an allocation-heavy Java app into Go as paradigm mismatch.

Re:Show HN: Sqinn-Go is a Golang library for accessing SQLit... by theamk on Wednesday October 04, 2023 @10:44PM (#37774355)
I don't think so.

The main go compilation must work in all sorts of environments: dev computers, CI runners.. it should be quick and automated to keep development fast. It should be easy, so everyone on your team can do this.

The assistant process is basically built once and then never changes, you just need to keep a binary somewhere (and they seem to be <1MB so you can check them into git directly). So a single person somewhere has to figure how to do a C build once, and everyone else can benefit. Have your someone ssh into CI runner directly and install gcc. Spend a day installing compiler and messing with Makefiles on exotic OS. You only do it once and you are good forever (or until you want to bump sqlite version)

Re:Show HN: Sqinn-Go is a Golang library for accessing SQLit... by cvilsmeier on Thursday October 05, 2023 @08:12AM (#37777587)
> But compiling the non-go assistant process is not going to be any easier than cgo, right?

Right. But you have to do it only once, or you can download a pre-built library from https://github.com/cvilsmeier/sqinn/releases (windows/amd64 or linux/amd64)