{"id":15285847,"url":"https://github.com/paulcager/gerlang","last_synced_at":"2025-05-07T04:11:41.558Z","repository":{"id":97965724,"uuid":"111301858","full_name":"paulcager/gerlang","owner":"paulcager","description":"Calling Go functions from Erlang","archived":false,"fork":false,"pushed_at":"2018-04-25T21:01:11.000Z","size":459,"stargazers_count":29,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-07T04:11:34.051Z","etag":null,"topics":["cgo","erlang","erlang-nif","go","golang","nif"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paulcager.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-19T14:21:02.000Z","updated_at":"2024-11-04T23:40:36.000Z","dependencies_parsed_at":"2023-03-30T20:17:07.111Z","dependency_job_id":null,"html_url":"https://github.com/paulcager/gerlang","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulcager%2Fgerlang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulcager%2Fgerlang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulcager%2Fgerlang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulcager%2Fgerlang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paulcager","download_url":"https://codeload.github.com/paulcager/gerlang/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252810274,"owners_count":21807759,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cgo","erlang","erlang-nif","go","golang","nif"],"created_at":"2024-09-30T15:07:50.084Z","updated_at":"2025-05-07T04:11:41.527Z","avatar_url":"https://github.com/paulcager.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gerlang\n_Calling Go functions from Erlang_\n\nApril 2018: This is a work in progress.\n\n## The aim\n_Allow Erlang programs to call Go functions with minimum inconvenience._\n\nIt's certainly _possible_ for an Erlang program to call a function written in Go, but it's frustratingly\ndifficult. You must write an Erlang [NIF](http://erlang.org/doc/tutorial/nif.html) in C,\ntranslate Erlang terms into Golang data structures, and then use\n[CGO](https://github.com/golang/go/wiki/cgo) to call the Go function.\n\nFor many projects this overhead is too big, and most developers would just re-implement the\nGolang code in Erlang. The aim of this project is to make the process simple enough that calling\nGo from Erlang is easy.\n\n\n## How It Will Work\n\n*   A generator program accepts a list of packages to be processed.\n*   The generator produces everything that is needed to call the exported Go functions\n    from Erlang:\n    *   An Erlang source module containing function definitions for each exported\n        function and variable in the package. \n    *   A NIF to translate between Erlang terms and Golang data structures. \n    *   A shared object containing the compiled Golang packages, plus code to interact with the NIF. \n\n\n## What Didn't Work\n\nhttps://punch.photoshelter.com/image/I0000ZvleumhOmDo\n\n### NIFs and Golang Plugins\n\nThis work is saved in branch `nif-plugin-experiment`.\n\n* An Erlang module (`ergo`) provided various functions to call into Go.\n* The Erlang module called out to a small NIF, which in turn called the Golang `Call` function.\n* `Call` looked up the target function (a named function within a Golang plugin) and translated\n  Erlang parameters (\"terms\") into the types required by the Golang function.\n* The function was called, and its return value(s) converted back to Erlang terms.\n\nThis was abandoned because Golang [does not support](https://github.com/golang/go/issues/18123)\na Shared Object (`-buildmode=c-shared`) calling a Golang plugin.\n\n### Erlang Ports\n\nAn [Erlang port](http://erlang.org/doc/tutorial/c_port.html) is a common way to call out\nto external programs from Erlang, but is way too heavyweight for my purposes.\n\n### C Nodes and JInterface\n\nUsing a technique such as [Erlang C Nodes](http://erlang.org/doc/tutorial/cnode.html) or\n[JInterface](http://erlang.org/doc/apps/jinterface/jinterface_users_guide.html)  is an interesting\nidea, but doesn't fit in with the lightweight approach I'm looking for.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulcager%2Fgerlang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaulcager%2Fgerlang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulcager%2Fgerlang/lists"}