Replies: 5 comments 3 replies
-
Fable to Go would be amazing! 😱 ❤️ |
Beta Was this translation helpful? Give feedback.
-
Perhaps:
|
Beta Was this translation helpful? Give feedback.
-
Thanks @ncave. Another thing is unit handling. Go do not have optional parameters or overloading so e.g simple generics like this becomes a problem: let fn(a) = a
let main () =
fn() This is because type unit struct{}
func fn[_A any](a _A) _A {
return a
}
func main() {
fn(unit{})
} This works, but would make interop a bit more difficult. I have the same problem in Python sort of, where you would see code like this: def fn(a: Optional[__A]=None) -> Optional[__A]:
return a
def main(__unit: Literal[None]=None) -> None:
fn() Which is not pretty, but it works. I guess you don't have this problem in Rust since Rust has a unit type!? I guess I have to invent a unit value and then think about interop later. |
Beta Was this translation helpful? Give feedback.
-
Example on howto dump the Go AST from a string literal program. Online Go parsers such as astexplorer cannot handle generics: package main
import (
"go/ast"
"go/parser"
"go/token"
)
func main() {
fset := token.NewFileSet()
src := `package foo
import (
"fmt"
"time"
)
func SumIntsOrFloats[K comparable, V int64 | float64](m map[K]V) V {
var s V
for _, v := range m {
s += v
}
return s
}
func bar() {
fmt.Println(time.Now())
}`
a, _ := parser.ParseFile(fset, "", src, parser.DeclarationErrors)
ast.Print(token.NewFileSet(), a)
} |
Beta Was this translation helpful? Give feedback.
-
Hi @dbrattli , I see you closed your WIP PR because you chose Rust instead. Rust is definitely better than Go IMO, so kudos for developing the Rust transpiler indeed, but why kill the Go one anyway? Just wondering if there would be any value on resurrecting it, cause being a dotnet dev and not be able to use the Go ecosystem is kind of a bummer for me. BTW, wrt Go and error handling today I found this gem: https://github.com/samber/mo (maybe its Option and Result types map well to FSharp.Core's). |
Beta Was this translation helpful? Give feedback.
-
Exploring in #3345 the possibility of translating F# and Fable into the [Go programming language] (https://go.dev/). It started with looking into Cython and Rust for writing Python extension modules. Then after getting introduced to Go I figured it could be a good language for Fable. Clean simple syntax, GC and very fast tooling makes it an attractive target language. Anyways, a long way to go but let's do this one step at a time.
I've currently done some testing with functions and nested closures to see how things works out with generics. No big surprises so far so hopefully there will be no hard blockers.
Things to figure out:
PS: Would be very interesting to one day run @ncave ray-tracer project and see where Go would end up on the performance scale.
Beta Was this translation helpful? Give feedback.
All reactions