Giter Site home page Giter Site logo

owenthereal / godzilla Goto Github PK

View Code? Open in Web Editor NEW
1.5K 36.0 31.0 101 KB

Godzilla is a ES2015 to Go source code transpiler and runtime

Home Page: https://github.com/jingweno/godzilla

License: MIT License

Makefile 1.38% Go 98.05% JavaScript 0.57%
golang javascript compiler transpiler es2015

godzilla's Introduction

Godzilla: Go running JavaScript

Overview

Godzilla is a ES2015 to Go source code transpiler and runtime that is intended to be a near drop-in replacement for Node.js. It compiles ES2015 source code to Go source code which is then compiled to native code. The compiled Go source code is a series of calls to the Godzilla runtime, a Go library serving a similar purpose to Node.js.

Godzilla parses ES2015 source code with the awesome babylon. That means at the moment Node.js is required for compilation. As Godzilla becomes mature, babylon will be compiled to Go source code using Godzilla itself so that the Node.js dependency can be dropped.

Note that Godzilla is at a very early stage and only very few language features are implemented

asciicast

Compiling

Make sure Go and Node.js are installed properly, then run:

$ make

Running

$ echo "console.log('Hello, Godzilla')" | bin/godzilla run
Hello, Godzilla
$ echo "console.log('Hello, Godzilla')" | bin/godzilla build -o hello
$ ./hello
Hello, Godzilla

Performance

There are still lots of works to get Godzilla to a stable state, but this is one preliminary benchmark for a simple script about program startup time:

$ echo "console.log('Hello, Godzilla')" | bin/godzilla build -o hello
$ time ./hello
Hello, Godzilla
./hello  0.00s user 0.00s system 30% cpu 0.013 total

$ echo "console.log('Hello, Godzilla')" > hello.js
$ time node hello.js
Hello, Godzilla
node hello.js  0.07s user 0.03s system 70% cpu 0.137 total

Talks

You can find my GopherCon 2017 lightening talk here.

Related Arts

godzilla's People

Contributors

owenthereal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

godzilla's Issues

cannot `make`

$ make
go build -o bin/godzilla cmd/godzilla/*
cmd/godzilla/main.go:12:2: cannot find package "github.com/jingweno/godzilla/build" in any of:
        /usr/lib/go-1.7/src/github.com/jingweno/godzilla/build (from $GOROOT)
        ($GOPATH not set)
cmd/godzilla/main.go:13:2: cannot find package "github.com/spf13/cobra" in any of:
        /usr/lib/go-1.7/src/github.com/spf13/cobra (from $GOROOT)
        ($GOPATH not set)
Makefile:9: recipe for target 'build-godzilla' failed
make: *** [build-godzilla] Error 1

Roadmap? Help wanted?

This looks like a cool project!
Is there a roadmap of things that need to happen and in what order? Are there areas you'd like help in? A TODO list would be nice to help new developers take up this project.

Ideally, in the future, I could use this to compile and include my React server side renderer into my go binary so I don't need to run a separate server for SSR.

NPM install

I think you're missing an npm install step in your Makefile.

Having tried to install naively following the Readme, I think this might be needed:

build-godzilla-parser:
	cd parser && npm install && npm run build

Document the code

I wanna contribute to this project. It would have been nice if there was documentation for the produced code. You can use godoc for this purpose, I assume. ๐Ÿ˜„

Documentation

I have 2 specific questions:

  • Is there a way to compile a JS file instead of a JS string?
  • Would it be possible to compile a big projects such as nuxt based project?
    I love using nuxt but would like to pre render the pages using golang. Js might be slow for nuxt sites with more than 10000 pages.

Thanks

found an issue in the parser's package.json

in parser\package.json line 9 where it has the pkg script command, the -t option fails because of unrecognized syntax, just switching it to windows or linux makes it build correctly. Also another thing to point out is when it does build correctly it just says "Error: not supported by windows" when trying to compile a script, anything more complex returns things like objectExpressions and functionExpressions not being supported

Add a meaningful benchmark

For the sake of fairness, you should include a benchmark of nontrivial real-world code that consists of more than one statement in your documentation. As it stands, you are comparing of what I presume is a single call to your runtime to the bootstrap of a complex JIT... seriously ๐Ÿ˜ˆ ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.