Solod: Go can be a better C
22 points by gcollazo
22 points by gcollazo
How does it deal with heap allocations caused by Go's escape analysis?
func foo() *bar {
return &bar{}
}
Does the above silently fail or cause an error?
So itself has few safeguards other than the default Go type checking. It will panic on out-of-bounds array access, but it won't stop you from returning a dangling pointer or forgetting to free allocated memory.
I think this is a straight translator, not a sophisticated compiler, so there's no escape analysis.
It seems interesting, and a fun project!
As an aside, over the years I have developed a tendency to heavily eschew "transpiler"[1] languages. While often times the languages themselves may be quite nice (gleam for example, and maybe Solod!), typically the debugging experience (both step debug, and error/stack traces) with such languages ends up being somewhat poor due to the information loss[2] during translation. While printf style debugging can work for small projects, I find it tends to fall apart quickly for large/complex ones.
[1]: in quotations because the term is loose, and some people disagree with the terminology in general
[2]: some languages like typescript use source-map gymnastics to alleviate this
I had a similar experience when learning vala for the first time.
At that time (If I remember correctly before 2010) I was a big fan of Glib, gtk and C. Vala started as a transpiler, and the promise of being able to write generic code and still use C libraries and that gnome ecosystem was seductive.
Debugging was hard in C, but at that time Vala made it even harder.
I have no idea how the language evolved, those are memories from another life almost, but debugging was a big deal for quitting that adventure.
I wrote JS/HTML/CSS transpilers and used them professionally for years and can confirm the gap is tooling support is a pain point (even with source maps). For us the tradeoff was speed of development (specialised languages) and consistency (similar syntax across artifacts) -- and Web development is much more forgiving than systems programming, so we rarely had to do in depth debugging sessions.
This is the basically the vision that has had me writing a lot in Odin recently. It's not strictly a subset of Go, but it's very clearly inspired and has nice things like generics.