Kian Wallace

Kian Wallace

1583525580

A Leisurely Stroll Through the Go Compiler

The Go compiler is bursting with curiosities, and this short tour provides a convenient way to discover all the highlights, from source to executable. Visit Parsing and AST Transformations, tour the endless optimisations of Generic SSA, witness the Generation of Machine Code, and finally end with Linking. Upgrade to enjoy a cream tea at Harrods.

#go #golang #webdev

What is GEEK

Buddha Community

A Leisurely Stroll Through the Go Compiler
Fannie  Zemlak

Fannie Zemlak

1599854400

What's new in the go 1.15

Go announced Go 1.15 version on 11 Aug 2020. Highlighted updates and features include Substantial improvements to the Go linker, Improved allocation for small objects at high core counts, X.509 CommonName deprecation, GOPROXY supports skipping proxies that return errors, New embedded tzdata package, Several Core Library improvements and more.

As Go promise for maintaining backward compatibility. After upgrading to the latest Go 1.15 version, almost all existing Golang applications or programs continue to compile and run as older Golang version.

#go #golang #go 1.15 #go features #go improvement #go package #go new features

Joseph  Murray

Joseph Murray

1624471200

Beginner's Guide to Compilation in Java

Java applications are complied to bytecode then JIT and JVM takes care of code execution. Here you will find some insights about how JIT compiler works.

I am guessing that many of you use Java as your primary language in your day-to-day work. Have you ever thought about why HotSpot is even called HotSpot or what the Tiered Compilation is and how it relates to Java? I will answer these questions and a few others through the course of this article. I will begin this by explaining a few things about compilation itself and the theory behind it.

Turning Source Code to Machine Code

In general, we can differentiate two basic ways of translating human readable code to instructions that can be understood by our computers:

Static (native, AOT) Compilation

  • After code is written, a compiler will take it and produce a binary executable file. This file will contain set of machine code instructions targeted for particular CPU architecture. Of course the same binary should be able to run on CPUs with similar set of instructions but in more complex cases your binary may fail to run and may require recompiling to meet server requirements. We lose the ability to run on multiple platforms for the benefit of faster execution on a dedicated platform.

Interpretation

  • Already existing source code will be run and turned into binary code line by line by the interpreter while the exact line is being executed. Thanks to this feature, the application may run on every CPU that has the correct interpreter. On the other hand, it will make the execution slower than in the case of statically compiled languages. We benefit from the ability to run on multiple platforms but lose on execution time.

As you can see both types have their advantages and disadvantages and are dedicated to specific use cases and will probably fail if not used in the correct case. You may ask – if there are only two ways does it mean that Java is an interpreted or a statically compiled language?

#java #jvm #compiler #graalvm #hotspot #compilation #jit compiler #native image #aot #tiered compilation

Vim-compiler-go: Vim Compiler Plugin for Go (golang)

Vim compiler file for Go (golang)

Compiles Go files in the background and usefully underlines and reports errors to the QuickFix window:

Installation:

Pathogen

Just clone this repo into your bundles directory:

git clone https://github.com/rjohnsondev/vim-compiler-go.git ~/.vim/bundle/vim-compiler-go

Either ensure the $GOROOT environment variable is set, or otherwise set the g:golang_goroot variable in .vimrc to where your go installation can be found. This must be an absolute path:

let g:golang_goroot = "/home/richard/go"

Manual installation

Drop golang.vim in ~/.vim/compiler directory.

Add the following line to the autocmd section of .vimrc

autocmd FileType go compiler golang

Set the g:golang_goroot variable to where your go installation can be found. This must be an absolute path

let g:golang_goroot = "/home/richard/go"

The plugin assumes a standard project layout with the files stored in a src directory. The GOPATH is set to one directory below the src folder.

Usage:

Golang is called after a buffer with Go code is saved. The QuickFix window is opened to show errors, warnings and hints provided by Golang.

To disable calling Golang every time a buffer is saved, put into .vimrc file:

let g:golang_onwrite = 0

The QuickFix window can be disabled with:

let g:golang_cwindow = 0

Setting highlights for the lines can be disabled with:

let g:golang_inline_highlight = 0

Of course, standard :make command can be used as is the case with every other compiler.

Author: Rjohnsondev
Source Code: https://github.com/rjohnsondev/vim-compiler-go 
License: 

#go #golang #compiler 

George  Koelpin

George Koelpin

1597086420

Tiny Go: Small Is Going Big

Summary

Ron Evans talks about TinyGo - a compiler for Go, written in Go itself, that uses LLVM to achieve very small, fast, and concurrent binaries that can also target devices where Go could never go before. The talk includes live coding of devices, RISC-V, WebAssembly, and a drone, to show some of what can be done today using TinyGo.

Bio

Ron Evans is an open source software developer, businessperson, author, and speaker.

About the conference

Software is changing the world. QCon empowers software development by facilitating the spread of knowledge and innovation in the developer community. A practitioner-driven conference, QCon is designed for technical team leads, architects, engineering directors, and project managers who influence innovation in their teams.

TinyGo

We’re here to talk about TinyGo, which is now officially sponsored by Google. Go is really big in the cloud by which we mean Go is big. Go executable programs are very large in Hello World in Go 1.13, which is the release right before the most recent release. Go programs are very large. That’s not a problem because clouds are infinitely scalable. What about the small places? What about the little places by which we mean microcontrollers, which are the small chips that actually run all the things in the world you care about, like the dialysis machine, or the brake systems, or other types of mission-critical, the refrigerator, and WebAssembly. What we’re talking about is true Edge computing, not this so-called Edge computing. Edge computing is not the data center nearest you. I’m sorry. I must respectfully disagree. The real Edge computing is in what we call the last centimeter. That’s what TinyGo is here for.

How TinyGo works is it’s a trinity between Go, TinyGo, and LLVM. The Go compiler itself is written in Go. All cool languages eventually reach a point where they can be compiled in themselves. It’s very self-referential, but it also proves that it works. The Go compiler tool chain is written in Go and a lot of the things that it uses are actually built into Go standard library. Then you’ve got LLVM. It’s a framework for building compilers. It’s being used by a couple of languages, one of them is a very cool language called Rust. We really admire the Rust community. Also, Swift, another very cool language. Some other cool languages recently Zig, written in LLVM language. The way that TinyGo works is we take the source code of Go and we parse it through the Go standard libraries to create the Go single static assignment form, which is taking the Go code and reducing it down to this very reduced type of syntax. Then we take that and TinyGo translates that into LLVM intermediate representation, which is what LLVM’s tool chain takes. Then using tools like Clang or LLD, which are the built-in tool chain that LLVM itself provides, we can then compile targets in LVM for very small places.

#go language #compilers #qcon london 2020 #demo #go

Gogo: Go to MIPS Compiler, Written in Go

gogo

Go to MIPS compiler, written in Go.

Gopher vector imported from egonelbre/gophers .

Logo

Components

ComponentDemo
Token generation / Lexertest1.out
Parserstruct.go :arrow_right: struct.html
IR generationscope.go :arrow_right: scope.ir
Code generationpascalTriangle.ir :arrow_right: pascalTriangle.asm

Setting up

Run ./scripts/setup.sh from the root directory of the project to set up the pre-commit git hooks.

Dependencies

Build

The following should generate relevant binaries inside the directory bin -

make

The generated binary bin/gogo can be used as follows -

Usage: gogo (-r | -r2s | -s) <filename>
  -p    Generates rightmost derivations used in bottom-up parsing
  -r    Generates IR instructions from go program
  -r2s  Generates the MIPS assembly from IR
  -s    Generates MIPS assembly from go program

NOTE: The generated MIPS assembly has been tested to work on SPIM MIPS32 simulator.

Testing

The tests can be built via -

make test

Author: Shivansh
Source Code: https://github.com/shivansh/gogo 
License: MIT license

#go #golang #compiler