News for hackers. Stuff that matters.
Re:Yaegi – Yet Another Go Interpreter by skybrian on Wednesday July 24, 2019 @12:09PM (#20516660)
You can do similar things by writing tests as you go, plus then you can keep the tests if they seem useful.
Re:Yaegi – Yet Another Go Interpreter by bndw on Wednesday July 24, 2019 @04:27PM (#20519294)
In my experience, the transition from running the code to see if it works to running the tests to see if it works, is a major milestone in producing high quality software.
Re:Yaegi – Yet Another Go Interpreter by kbd on Wednesday July 24, 2019 @12:53PM (#20517089)
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.
Re:Yaegi – Yet Another Go Interpreter by marcrosoft on Wednesday July 24, 2019 @12:59PM (#20517164)
Tests are perfect for "do outputs match what I expect". If you don't know what you are expecting yet just to `t.Error("")`. When you are done fiddling around and want to solidify what you expect add the `if foo != expectation`.
Re:Yaegi – Yet Another Go Interpreter by jpittis on Wednesday July 24, 2019 @01:03PM (#20517205)
To add to this, editor commands to quickly switch to your test file, auto generate test boilerplate and run the currently highlighted test are super helpful to speed up this loop.
Re:Yaegi – Yet Another Go Interpreter by wc- on Wednesday July 24, 2019 @01:24PM (#20517430)
This sounds really helpful, can you provide any links to read more about setting these helpers up?
Re:Yaegi – Yet Another Go Interpreter by jpittis on Wednesday July 24, 2019 @02:07PM (#20517926)
It completely changed the way I write Go. This is editor specific though.

I use Vim for programming Go and have a few custom scripts built on top of https://github.com/fatih/vim-go.

Re:Yaegi – Yet Another Go Interpreter by InvOfSmallC on Wednesday July 24, 2019 @02:45PM (#20518313)
I actually did a pair programming session with JBrains on TDD to enhance my skill. What he explained to me was exactly this. You need to test something, for example you want to test how regexp works. You start writing tests with your expectations and go on. After you are satisfied, you actually keep this in a package for reference and documentation on works the library.
Re:Yaegi – Yet Another Go Interpreter by sreque on Wednesday July 24, 2019 @01:03PM (#20517206)
I disagree with this to some extent. Unit tests are a pretty good poor-mans REPL in languages that don't have REPLs. For instance, I've seen people write fake unit tests to do things like query a database for analysis purposes; it was just the fastest way they could come up with to do the exploratory work. What makes a unit test a good poor-mans REPL in a language like java with an IDE is:

* Java IDEs, especially eclipse, are amazing at fast, incremental compilation. You make one change, and then only recompile what you need to.

* Java has no relatively expensive link stage like C++, C, even C# to a lesser extent, when running tests from an IDE. Your IDE can run your unit tests and also be smart enough to only load the classes it needs to run the test.

Most dynamic languages already have a REPL, so the technique of using unit tests for exploratory work isn't necessary, but I think it's very useful for Java at least.

Re:Yaegi – Yet Another Go Interpreter by stcredzero on Wednesday July 24, 2019 @01:51PM (#20517737)
Unit tests are a pretty good poor-mans REPL in languages that don't have REPLs.

Java IDEs, especially eclipse, are amazing at fast, incremental compilation. You make one change, and then only recompile what you need to.

I always found this lugubrious compared to the experience in many Smalltalks. The Java vs. Smalltalk USENET flame wars in the 90's were partly motivated by the downgrade in developer UX caused by the taking of the Smalltalk runtime model and deliberately crippling it.

Granted, Java has made amazing progress since then, as have IDEs generally. Is there a non-Smalltalk environment that lets one "code in the debugger" to the same extent as Smalltalk? I know of Clojure and the kind of experience shown with LightTable. (To elaborate, to "code in the debugger" in Smalltalk is very nimble and powerful. It's kind of like the turn-based version of LightTable but with pausing in the debugger and manual tinkering/time-travel with the context stack.)

Re:Yaegi – Yet Another Go Interpreter by sreque on Thursday July 25, 2019 @01:29PM (#20527457)
The JVM is less dynamic in its ability to reload code, but the payoff is that java code can be 10-100x faster than smalltalk code. I personally think the performance gain is worth it. Hotspot has some limited support for hot code reloading, which is a pre-requisite to being able to "code in your debugger", but it's limited enough that I don't bother with it. Alternatively, you can code in a dynamic language on the JVM such as JRuby or Clojure and have full support for "coding in the debugger". These languages are also a lot slower than Java.
Re:Yaegi – Yet Another Go Interpreter by skybrian on Wednesday July 24, 2019 @03:11PM (#20518603)
We are talking Go here, which has a fast compiler. The IDE integration isn't always as good as Java, though.
Re:Yaegi – Yet Another Go Interpreter by sreque on Thursday July 25, 2019 @01:13PM (#20527305)
Go has a fast compiler but to my knowledge has zero support for incremental compilation. It has to recompile the entire project, transitively with all its dependencies, before you can run your code modification. I haven't code in go, but IMO this does not scale well as projects grow in size.
Re:Yaegi – Yet Another Go Interpreter by stcredzero on Wednesday July 24, 2019 @04:26PM (#20519283)
I find GoLand to be quite good.
Re:Yaegi – Yet Another Go Interpreter by sitkack on Wednesday July 24, 2019 @08:05PM (#20521413)
Seconded, GoLand isn't just quite good, it is phenomenal. If you aren't running it, you need to have a compelling reason.

https://www.jetbrains.com/go/

Re:Yaegi – Yet Another Go Interpreter by weberc2 on Wednesday July 24, 2019 @05:27PM (#20519929)
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 by stcredzero on Wednesday July 24, 2019 @06:34PM (#20520697)
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)

Re:Yaegi – Yet Another Go Interpreter by weberc2 on Wednesday July 24, 2019 @07:02PM (#20520963)
This experience is commonplace in Python. Can’t speak so much for other languages.