Live data from Hacker News

Yaegi – Yet Another Go Interpreter

blog.containo.us

51–60 of 77 posts

Re: Yaegi – Yet Another Go Interpreter

#51
post #44
post #3

Programming in a language lacking a repl is always uncomfortable. I always wind up making a 'scratch.{ext}' file and running it to test things (scratch.* is in my global gitignore). Happy an interpreter+repl now exists for Go.

I use the go playground for this. Only problem I have run into is lack of sane time values.

Me too but if I had a repl I’d probably prefer that.

Re: Yaegi – Yet Another Go Interpreter

#53
post #13
post #4

Earlier quoted context omitted.

You can do similar things by writing tests as you go, plus then you can keep the tests if they seem useful.

For one meaning of "test", sort of, but repls are useful for far more than "do outputs match what I expect". Test writing is not very good for exploratory programming.

This tends to be more important in dynamic languages where "the outputs" are often hilariously far from what is reasonable to expect. At least that's where I find I use a REPL in Python--load in some poorly-documented 3rd party library to see what the return type of a function is (for some given inputs) and what properties are available on that object (since the "type" isn't much good given the aforementioned poor state of the docs). In Go, however, you get all the information you need from the type and godoc.org.

Re: Yaegi – Yet Another Go Interpreter

#56
Very cool idea. Doesn't seem ready for prime time yet -- tried running it on a small Go program to score boggle boards, and got errors in the interpreter.

Playing around, it seems to have problems assigning int literals to int8 variables, and it seems to sometimes have problems re-assigning pointer values.

Re: Yaegi – Yet Another Go Interpreter

#57

Why would I need a Go Interpreter? What advantage does it provide over using a precompiled binary?

There are some circumstances where an interpreter is useful: For example, it should be possible to make better golang repls with an interpreter than with a binary.

In a "scripting" scenario, you can load some golang code at runtime without needing to bring the full golang compiler toolchain along, which keeps the nice "single binary" deploys of golang. It may be possible to sandbox scripts as well (though I haven't looked into how that could work with this implementation), which could reduce the risk of running scripts (less likely to shoot yourself in the foot. Probably not a security boundary -just look at how much work goes into safe JS in browsers to have that).

Re: Yaegi – Yet Another Go Interpreter

#58

Why would I need a Go Interpreter? What advantage does it provide over using a precompiled binary?

There are some circumstances where an interpreter is useful: For example, it should be possible to make better golang repls with an interpreter than with a binary. In a "scripting" scenario, you can load some golang code at runtime without needing to bring the full golang compiler toolchain along, which keeps the nice "single binary" deploys of golang. It may be possible to sandbox scripts as well (though I haven't l…

Sandboxing is possible but only if it brings it's own standard library (I think... I'm not familiar with how go implements io at it's roots)

Re: Yaegi – Yet Another Go Interpreter

#59
post #58

Earlier quoted context omitted.

There are some circumstances where an interpreter is useful: For example, it should be possible to make better golang repls with an interpreter than with a binary. In a "scripting" scenario, you can load some golang code at runtime without needing to bring the full golang compiler toolchain along, which keeps the nice "single binary" deploys of golang. It may be possible to sandbox scripts as well (though I haven't l…

Sandboxing is possible but only if it brings it's own standard library (I think... I'm not familiar with how go implements io at it's roots)

I'm working on an approach for Golang sandboxing which works through whitelisting imports, and munging all references, casting operations, and function calls, which lets one whitelist those as well. I would disallow all io and network access.

Re: Yaegi – Yet Another Go Interpreter

#60
post #53
post #13

Earlier quoted context omitted.

For one meaning of "test", sort of, but repls are useful for far more than "do outputs match what I expect". Test writing is not very good for exploratory programming.

This tends to be more important in dynamic languages where "the outputs" are often hilariously far from what is reasonable to expect. At least that's where I find I use a REPL in Python--load in some poorly-documented 3rd party library to see what the return type of a function is (for some given inputs) and what properties are available on that object (since the "type" isn't much good given the aforementioned poor st…

This tends to be more important in dynamic languages where "the outputs" are often hilariously far from what is reasonable to expect.

Most of my experience with dynamic language programming is far from what you describe above. About the only place where I've encountered the like is with Javascript.

https://archive.org/details/wat_destroyallsoftware

I once experienced "magic" jumps in the debugger in Smalltalk, but that was because of some liberties taken with custom methods implemented in C, or because of missing_method style metaprogramming. (#doesNotUndedrstand: in Smalltalk)

Post reply on HN