News for hackers. Stuff that matters.
Re:My Vision of D’s Future by atombender on Tuesday October 15, 2019 @04:03PM (#21263037)
I'm a fan of Go's "go run". For example, you can do:

  go run main.go
or:

  go run ./cmd/server
When invoked this way, Go compiles your code behind the scenes, but you don't have to create a binary.

This means Go lends itself pretty well to ad-hoc scripting or writing small script-like tools.

Unfortunately, Go doesn't support shebang lines, but with gorun [1] you can:

    #!/usr/bin/env gorun

    package main

    func main() {
      println("Hello world!")
    }
[1] https://github.com/erning/gorun
Re:My Vision of D’s Future by btbytes on Tuesday October 15, 2019 @08:36PM (#21265797)
D's default package manager already allows you to write code like this which 1. runs the code like a script 2. downloads dependencies if they are required.

    #!/usr/bin/env dub
    /+ dub.sdl:
        name "allthepythons"
        dependency "d-glob" version="~>0.3.0"
    +/

    import std.stdio : stdout;
    import glob : glob;
    
    void main () {
        foreach (entry ; glob("/usr/local/bin/python*")) {
            stdout.writefln("%s", entry);
        }
    }
Re:My Vision of D’s Future by 1980phipsi on Tuesday October 15, 2019 @08:58PM (#21265943)
Dub's documentation should use some love...
Re:My Vision of D’s Future by paulddraper on Tuesday October 15, 2019 @05:48PM (#21264264)
D already works like this.

Scala (Ammonite) works like this.

The author isn't complaining about keystrokes; he wants the compile + run process to be faster. Using an interpreter instead of a compiler would make it faster.

Re:My Vision of D’s Future by apta on Tuesday October 15, 2019 @06:36PM (#21264750)
Java has the same now (since Java 9 I think).
Re:My Vision of D’s Future by hactually on Friday October 18, 2019 @12:52AM (#21288792)
So you're saying it's as simple as:

java build ./app/ ./app

That's impressive if true as last I worked with Java it was a mess

Re:My Vision of D’s Future by apta on Saturday October 19, 2019 @10:02PM (#21301916)
Not quite. You can run `java Foo.java` and it will compile and execute the class file (and remove it when done).
Re:My Vision of D’s Future by floatboth on Tuesday October 15, 2019 @04:59PM (#21263688)
D compilers do work as a shebang already.
Re:My Vision of D’s Future by grogenaut on Wednesday October 16, 2019 @01:58AM (#21267476)
I actually use this for all of my complicated build scripts and just use make to glue them together. For instance I have a stack name from computer,branch,sha,username that I calculate so I have a different stack per thing I'm working on. I tried getting that to work with awk fu but doesn't work the same on every platform, so instead "go run cmd/get_stack_name/main.go" instead. Fast and like it.