November 26, 2022

COSFONE

Networking, PBX, IT, DIY Solution

Goscript: The Go language specification for Rust implementations

2 min read

Goscript: The Go language specification for Rust implementations



 

Goscript: The Go language specification for Rust implementations

The Anaconda developers recently released PyScript , a framework that lets developers remix Python code in HTML, which some call “JSP for Python”.

In fact, PyScript uses WebAssembly under the hood because it is built on Pyodide, which consists of a CPython 3.8 interpreter compiled to WebAssembly, allowing Python to be run in a web browser.

 

Goscript: The Go language specification for Rust implementations

 

Coincidentally, the developers adopted the same idea to make Go also run smoothly on the browser.

The https://goscript.dev website supports running Go code directly on the browser side.

This is a Go playground. The bottom layer uses Goscript and is implemented through WASM.

 

Goscript: The Go language specification for Rust implementations

 

Goscript is an unofficial implementation of the Go language specification, used for inlining or encapsulation of Rust projects , providing an easier way to encapsulate and call the underlying Rust code.

Like Lua is to Redis/WoW, or Python is to NumPy.

 

Goscript contains six projects:

  • parser:  Turn the source code into an AST, ported from the official Go code.
  • type checker: Based on AST for type deduction and type checking, it is also ported from Go official code.
  • codegen: Generate bytecode based on AST and type information.
  • vm: Run the bytecode.
  • std: Official library, ported from Go official library.
  • engine: Contains the native part of the official library, plus simple packaging.

Goscript implements almost all features of Go (pre 1.18, so generics are not included), and some official libraries have been ported. Check out the relevant test cases that have passed https://github.com/oxfeeefeee/goscript/tree/master/engine /tests .

Goscript project code: https://github.com/oxfeeefeee/goscript

 



Copyright © All rights reserved. | Newsphere by AF themes.