Skip to content
/ cygo Public

A toy programming language base on Golang and compile to C, no name yet

Notifications You must be signed in to change notification settings

kitech/cygo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

00df926 · Feb 8, 2021
Feb 27, 2020
Feb 9, 2020
Jan 10, 2020
Jan 20, 2021
May 7, 2019
Feb 8, 2021
Jan 20, 2021
Jul 13, 2019
Jan 30, 2020
Jan 29, 2021
Jan 13, 2020
Jun 25, 2019
Jul 22, 2019
Feb 27, 2020
Feb 23, 2020
Jun 26, 2019
Feb 8, 2021
Jun 26, 2019
Jul 10, 2019
Jan 28, 2020
Jan 22, 2021

Repository files navigation

Compile Go to C, with a generic library contains Go core features, like goroutine,channel,GC.

That's will generate minimal binary. The farther plan is compile any Go package to C.

The pain of Go

  • Too large binary size
  • Not zero cost call with C
  • Builtin string/array/map no methods
  • Too verbosity error handling, not like the Go2 try error handling proposal

Features

  • goroutine
  • channel
  • defer
  • GC
  • CGO
  • interface
  • closure
  • string/array/map with lot builtin methods
  • catch statement error handling ( )
  • unused var warning, not error
  • for range => for in
  • type foo struct => struct foo
  • unsafe.Pointer => voidptr
  • uintptr => usize
  • seamless C symbol use
  • zero cost C call
  • all variables reference

Install

cd $GOPATH
git clone https://github.com/kitech/cygo
cd cygo/bysrc
go build -o cygo

Example

./cygo ./tpkgs/hello
cmake .
make

more examples/tests https://github.com/kitech/cygo/tree/master/bysrc/tpkgs/

Source code structure:

Supported important syntax

  • defer
  • closure
  • select

Todos

  • dynamic stack resize
  • correct and more safe point for GC
  • support more OS/platforms
  • so much to do

Supported original Go packages

  • unsafe
  • errors

资料

About

A toy programming language base on Golang and compile to C, no name yet

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published