Idea: Go as intermediate language

696 views
Skip to first unread message

Archos

unread,
Aug 9, 2014, 3:04:44 AM8/9/14
to golan...@googlegroups.com
After of write something related into other post...

Do you think that Go could be used like IL for that some libraries could be used from other languages? (Excluded low-level libraries, i.e. audio/video; you will want C or rather Rust for such task).

Since the sintaxis is simple, it should not be very complicated the transpiling from Go to other languages.
But to get it, I think that would be necessary to define a sub-set of Go language, removing stuff like related to the communication: channels, select, defer, etc.

Archos

unread,
Aug 9, 2014, 3:24:09 AM8/9/14
to golan...@googlegroups.com
Really, it has a great potentia to be used in libraries and server's clients, as in databases -- when a new database is released, community start to coding a library in its language with different quality and maintenance but it would be more productive if the team would code two versions, (a) for programs that handle concurrency (Go) and (b) for the vast majority (python, ruby).

andrewc...@gmail.com

unread,
Aug 9, 2014, 5:21:14 AM8/9/14
to golan...@googlegroups.com
Less the syntax, more the fact that tools/ssa etc exists.

egon

unread,
Aug 9, 2014, 2:51:24 PM8/9/14
to golan...@googlegroups.com
The code that is good JavaScript code is not necessarily good Rust code. The code that's great C code may not be good C++ code. Each language has their own idioms and the approach that fits into one language may not fit to another language.

Transpiled result would be better than nothing, but a language taylored approach would be better. Also, for libraries there is already SWIG.

+ egon

minux

unread,
Aug 9, 2014, 8:04:59 PM8/9/14
to Archos, golang-nuts
On Sat, Aug 9, 2014 at 3:04 AM, Archos <raul...@sent.com> wrote:
After of write something related into other post...

Do you think that Go could be used like IL for that some libraries could be used from other languages? (Excluded low-level libraries, i.e. audio/video; you will want C or rather Rust for such task).

Since the sintaxis is simple, it should not be very complicated the transpiling from Go to other languages.
Syntax is simple, but that is irrelevant for judging the difficulty of translate Go to another language.
The real obstacle is the semantics, not the syntax. (There are successful translators that can translate C
into various languages, but is there a Go translator that is _fully_ standard compliant?)

I still think C is more suitable IL than Go.

But to get it, I think that would be necessary to define a sub-set of Go language, removing stuff like related to the communication: channels, select, defer, etc.
Then you get C (probably something that's even worse than C.)

Archos

unread,
Aug 10, 2014, 12:09:32 AM8/10/14
to golan...@googlegroups.com


El sábado, 9 de agosto de 2014 19:51:24 UTC+1, egon escribió:
On Saturday, 9 August 2014 10:04:44 UTC+3, Archos wrote:
After of write something related into other post...

Do you think that Go could be used like IL for that some libraries could be used from other languages? (Excluded low-level libraries, i.e. audio/video; you will want C or rather Rust for such task).

Since the sintaxis is simple, it should not be very complicated the transpiling from Go to other languages.
But to get it, I think that would be necessary to define a sub-set of Go language, removing stuff like related to the communication: channels, select, defer, etc.


The code that is good JavaScript code is not necessarily good Rust code. The code that's great C code may not be good C++ code. Each language has their own idioms and the approach that fits into one language may not fit to another language.

What is a a good code generated? For me, it means that the performance of code generated been similar to the handwritten code.
And like example, you have the transpiler from Dart to JS whose performance is very close to handwritten JavaScript:

https://www.dartlang.org/support/faq.html#q-how-can-dart2js-produce-javascript-that-runs-faster-than-handwritten-javascript
https://www.dartlang.org/performance/

Archos

unread,
Aug 10, 2014, 10:13:31 AM8/10/14
to golan...@googlegroups.com

To use C would be return the past, to writing unsafe code and to spending the most part of time bebugging instead of writting new code. With Go, I have only had used a debugger for parsers, specially in one to parsing correctly the full spec. of email.

Using Go, you get the parser ready to use (http://golang.org/pkg/go/); In fact I've used a sub-set to create a  data definition language and can handle it from other languages and DBMSs.
Besides, you have the SSA although I've not played with it.

adon...@google.com

unread,
Aug 11, 2014, 7:20:32 PM8/11/14
to golan...@googlegroups.com
Archos, I never understand your posts to this list.  Each week, you ask about a new and impractical scheme for translating Go to other languages, or translating another language to Go, seemingly without regard for the character of the source language, compatibility with existing libraries, or tolerable performance.

If you want to run code in a browser, write it in JavaScript (or CoffeeScript, Dart, or TypeScript), or compile Go (or your favourite language) to JavaScript using Native Client or emscripten.  If you want to run Go code on a mobile device, just wait: support is coming.  If you need to generate code in a portable systems language, use C.  If you want an intermediate language for optimization and code-generation, use LLVM.   If you miss a favourite library in some other language, port it to Go.

What problem are you trying to solve?

andrewc...@gmail.com

unread,
Aug 11, 2014, 9:08:45 PM8/11/14
to golan...@googlegroups.com, adon...@google.com
I would like to point out https://github.com/gopherjs/gopherjs now supports goroutines, so nearly all of go works there so emscripten probably isn't the best suggestion for js and go.
Reply all
Reply to author
Forward
0 new messages