Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Other than the things mentioned so far, I'm glad to see reflection filling out -- the day a Go REPL will be possible is approaching.

Very close indeed! Struct, array and function types still can't be constructed at run time, but as of Go 1.1, function values can be as well as slice, map and channel types. I exploit some of this in my `ty` package. [1,2]

[1] - http://godoc.org/github.com/BurntSushi/ty

[2] - http://blog.burntsushi.net/type-parametric-functions-golang



This is pretty cool!

I tried to convince rsc at some point about the enormous value of REPLs for rapid development.. imagine connecting to an embedded REPL on a server to do live debugging. I don't think I quite convinced him to drop everything and do it himself, though.

Do you have plans to experiment with a transpiler to smooth away all the remaining type noise?

Maybe a first step would be to explore how one could add pluggable 'dialect translators' to the go tool so that anyone could write simple extensions for the language while preserving the existing toolchain.


> Do you have plans to experiment with a transpiler to smooth away all the remaining type noise?

I don't have any particular plans; the `ty` package was a night of hacking plus several days of polishing/writing. :-)

One of the major bummers about moving into the reflection world is performance. My blog article talks about it a little bit, but it's also worth looking more closely at the things I didn't talk about in the benchmarks. (For instance, it seems that function calls in the reflection world pay a very steep price.)

Re transpiler: do you mean a {Language}-to-Go source translation? If so, it seems like you'd want to avoid `reflect` completely in that case. But maybe I am misunderstanding.

> I tried to convince rsc at some point about the enormous value of REPLs for rapid development ... I don't think I quite convinced him to drop everything and do it himself, though.

A REPL would be very nice, but a REPL using `reflect` would definitely be a lot of work. You'd need to make extensive use of the sub-packages in `go` to convert the `Read` portion of the `REPL` into appropriate reflection types. You could do it now, but you wouldn't be able to define new functions, structs or interfaces. And `reflect` cannot spawn goroutines either, which is a bummer.


> ... the day a Go REPL will be possible is approaching.

A REPL is possible even today.

All is needed is an interpreter for the language and there are a few already available.

Nothing new, this is the same approach taken by many languages, provide an interactive environment for the REPL and a compiler for distribution.

Being done since the early days of computing.


Or an incremental compiler.


For a REPL workflow it usually does not work, because most developers are trying out pieces of the application.

When I work with ML or Lisp based languages, I am always copied code snippets, which might land in separate modules afterwards.

Unless you mean a JIT at the REPL environment.




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: