News for hackers. Stuff that matters.
Re:The Simplicity of Single-File Golang Deployments by traceroute66 on Wednesday March 22, 2023 @11:39AM (#35262756)
> The fact that it produces a single static binary is one of the nicest things about golang.

AND unlike Rust, Go has an eminently usable and comprehensive stdlib.

It means that for most projects you can just Get Stuff Done (TM) instead of deciding which of 24 "reinventing the wheel" Rust Crates you want to use for X, Y and Z functions of your Rust binary.

Re:The Simplicity of Single-File Golang Deployments by tptacek on Wednesday March 22, 2023 @12:09PM (#35263232)
Please don't start random language fights.
Re:The Simplicity of Single-File Golang Deployments by tomcam on Wednesday March 22, 2023 @12:42PM (#35263702)
Directly addressing the topic of a upvoted article is starting random language fights?
Re:The Simplicity of Single-File Golang Deployments by doodpants on Wednesday March 22, 2023 @01:08PM (#35264039)
The article is about Go, and while the article mentions other languages for comparison, Rust is not one of them. So traceroute66's comment comes across as starting a Rust vs. Go fight where not appropriate.
Re:The Simplicity of Single-File Golang Deployments by djbusby on Wednesday March 22, 2023 @01:14PM (#35264124)
Not even, they just expressing an opinion.
Re:The Simplicity of Single-File Golang Deployments by tomcam on Wednesday March 22, 2023 @04:47PM (#35266852)
Doesn’t come across as starting a fight to me. Not even close.
Re:The Simplicity of Single-File Golang Deployments by benatkin on Wednesday March 22, 2023 @05:34PM (#35267378)
Yeah the only thing is how you parse "eminently usable and comprehensive". The way I read it, it's not saying that Rust's isn't "eminently usable", but that it isn't both of those things. At most it's suggesting that a standard library can't be "eminently usable" if it isn't comprehensive IMO - perhaps it can be extremely usable but not eminently usable. It would be like saying a manual transmission on a car can't be "eminently usable".
Re:The Simplicity of Single-File Golang Deployments by AmpsterMan on Wednesday March 22, 2023 @08:59PM (#35269257)
I think the comparison is totally apt and illustrates why Rust and Go get compared very often. They are both languages that compile to a binary, rather than running in a managed environment.
Re:The Simplicity of Single-File Golang Deployments by vore on Wednesday March 22, 2023 @05:44PM (#35267482)
Where does the word Rust appear in the article?
Re:The Simplicity of Single-File Golang Deployments by LanceH on Wednesday March 22, 2023 @11:16PM (#35270133)
In the comments about every article including Go, generally.
Re:The Simplicity of Single-File Golang Deployments by nimih on Wednesday March 22, 2023 @11:35PM (#35270237)
I can't speak for Go-centric articles in general, but for this one in particular, the only one (as of now, after 14 hours of comments) bringing up Rust is this single person with (apparently) a weird chip on their shoulder.
Re:The Simplicity of Single-File Golang Deployments by benatkin on Wednesday March 22, 2023 @05:28PM (#35267321)
That's no language fight. Rust doesn't want batteries included. That's highlighting a difference between the languages.
Re:The Simplicity of Single-File Golang Deployments by earthling8118 on Wednesday March 22, 2023 @12:09PM (#35263234)
From another point of view "usable" isn't a word I'd associate with Go, especially not when there is an "unlike Rust" in the phrase. I've not had any issues of the sort when building out Rust applications. At this point the only time I touch Go is if I need to modify something else someone has made-- which I avoid at all costs
Re:The Simplicity of Single-File Golang Deployments by aatd86 on Wednesday March 22, 2023 @06:31PM (#35267934)
Maybe AI will make it more palatable but I just can't get into Rust.

I can probably easily understand borrowing. It's mostly an issue of controlling pointer aliasing wrt mutability, especially in a multithreaded context I guess.

But that gottdarn syntax... And goroutines are too nice for the type of code I use.

I'm too spoiled with Go I guess.

Re:The Simplicity of Single-File Golang Deployments by brigadier132 on Wednesday March 22, 2023 @12:43PM (#35263710)
Using a crate is the opposite if reinventing the wheel. Also are we talking about go? The language without a set implementation?
Re:The Simplicity of Single-File Golang Deployments by asalahli on Wednesday March 22, 2023 @05:39PM (#35267432)
Parent is saying those crates themselves are reinventing the wheel, not talking about using a crate
Re:The Simplicity of Single-File Golang Deployments by brigadier132 on Wednesday March 22, 2023 @05:59PM (#35267641)
So by that logic Golang reinvented the wheel by creating a new programming language when java already existed
Re:The Simplicity of Single-File Golang Deployments by asalahli on Thursday March 23, 2023 @08:14PM (#35283369)
Yes. Is reinventing the wheel always a bad thing, though? Not if you ask me, not if the new wheel has novel characteristics and performs better in some aspects.
Re:The Simplicity of Single-File Golang Deployments by pjmlp on Wednesday March 22, 2023 @12:46PM (#35263751)
If only they would decide what to do with plugin package, not use SCM paths for packages and decide to eventually support enumerations instead of iota dance (Pascal style would be enough.

Maybe 10 more years.

Re:The Simplicity of Single-File Golang Deployments by Joker_vD on Wednesday March 22, 2023 @01:22PM (#35264226)

    type Kind enum {
        Simple,
        Complex,
        Emacs,
    }

    const kindStrings [Kind]string = {
        "simple",
        "complex",
        "emacs",
    }

    func (k Kind) String() string {
        return kindStrings[k]
    }

    func t() {
        var a = Kind.Emacs - Kind.Simple  // a has type int and value 2
        var b = Kind.Simple + Kind.Emacs  // type error
        var c = Kind.Simple + 1           // type error
        var d = len(Kind)                 // d has type int and value 3

        for k := range Kind {
            fmt.Printf("%v\n", k) // prints what you expect it to do
        }

        // not sure about legality or runtime behaviour of the followng
        var t = Kind.Emacs
        t++
        t = Kind(42)        
    }
Would be nice, not gonna lie.
Re:The Simplicity of Single-File Golang Deployments by randomdata on Wednesday March 22, 2023 @10:25PM (#35269741)
How is this any different than Go's existing enumerations, aside from the enumeration also creating an implicit list structure which, while kind of neat, isn't really a property of enumerations.

The parent is likely lamenting that Go doesn't enforce compile-time value constraints on enumerated sets like some languages do, but many other languages don't ether. Not even Typescript does. If Typescript doesn't find it important to have such value constraints, Go most certainly never will.

Re:The Simplicity of Single-File Golang Deployments by Joker_vD on Thursday March 23, 2023 @06:11AM (#35272428)
> Go's existing enumerations

Go doesn't have enumerations. So the first difference would be that my enums would actually exist.

> implicit list structure which, while kind of neat, isn't really a property of enumerations

It absolutely is, or people wouldn't have been regularly writing enums like

    typedef Kind enum {
        KindSimple,
        KindComplex,
        KindEmacs,
        Kind_NUM_VALUES
    };
which they do about half the time.

> likely lamenting that Go doesn't enforce compile-time value constraints

Yes, that's my complaint as well. Which is why that "not sure about legality" part in my example: you want to be able to enumerate the enum (duh), but with last_value_of_enum++ being illegal, writing for-loop with "<" is illegal too, that's why there is support for it in for-range.

With incrementing (used in loops almost exclusively) taken care of, the rest of arithmetics on enums is meaningless in general except maybe in case of subtraction (when you use enums as keys/indices for a fixed-sized array) which is why I allow it — but it produces an int, of course.

As for what should happen in Kind(42) example — perhaps it could work like type-assertions?

    k, err := Kind(42)
    if err != nil {
        return err
    }
Re:The Simplicity of Single-File Golang Deployments by randomdata on Thursday March 23, 2023 @08:16AM (#35273522)
> Go doesn't have enumerations. So the first difference would be that my enums would actually exist.

That's obviously not true. That's what the iota dance is for.

    type Kind int

    const (
        KindSimple Kind = iota
        KindComplex
        KindEmacs
        Kind_NUM_VALUES   
    )
Go doesn't have a literal enum keyword, if that's what you mean, but enumerations aren't defined by having a specific keyword or specific syntax. Enumerations are a more general concept, defined as a set of named constants. The above is functionally identical to your example in C, among a host of other languages.

> Yes, that's my complaint as well.

Fine, but that's not a property of enumerations. If one wants support for value constraints, surely one should ask for that and not for something the language has had since the beginning?

Re:The Simplicity of Single-File Golang Deployments by Joker_vD on Thursday March 23, 2023 @09:59AM (#35274909)
Mmm. The original comment asked for "Pascal-style enums". Those are different from C enums: they are incompatible with integers and other enums, they don't support arithmetic operations (you have to use succ()/pred() built-ins) and they contain precisely the named values. Plus, enums being ordinal types, you could use them as array indices in type definitions, like "array[Kind] of real".

So that's what I went with, because I actually liked Pascal-style enums but thought they could be somewhat improved, so what you've read is my ideas (Go is surprisingly close to Oberon and both lack enums).

Re:The Simplicity of Single-File Golang Deployments by randomdata on Thursday March 23, 2023 @10:57AM (#35275812)
The original comment asked for enumerations. Despite him not realizing, Go has those. It has a relatively unique syntax for defining enums, sure, but enumerations are not defined by specific syntax. They are a higher level concept that transcends any specific syntax implementation.

The original comment also hinted at wanting other features that some other languages have, including Pascal, although not stating which features specifically. I expect he was referring to wanting some kind of constraint system, which is the most common feature I hear requested of Go. But that's beyond the scope of enumerations.

Re:The Simplicity of Single-File Golang Deployments by p5v on Wednesday March 22, 2023 @05:29PM (#35267340)
Regarding the “iota dance,” I wrote my 2 cents on what could be a slightly more robust approach a couple of days ago: https://preslav.me/2023/03/17/create-robust-enums-in-golang/

P.S generic type sets make it even better. I’ll write an update to my post these days.

Re:The Simplicity of Single-File Golang Deployments by Asdrubalini on Wednesday March 22, 2023 @01:20PM (#35264197)
Rust's philosophy (unlike Python's, for example) consists in not including tons of stuff in the standard library, this way you can choose the best implementation for your specific use case from one of the many crates (which are super easy to install, by the way). There is no "always the best" implementation for a specific functionality, nor a legacy-but-still-officially-supported-in-std implementation that nobody uses anymore but still needs to be maintained with its own namespace.

I don't see this as negative or "reinventing the wheel". Reinventing the wheel would be writing your own implementation, which doesn't happen if you can choose from many high-quality crates.

Re:The Simplicity of Single-File Golang Deployments by abtinf on Wednesday March 22, 2023 @02:01PM (#35264796)
> legacy-but-still-officially-supported-in-std implementation

There is massive value in this.

Re:The Simplicity of Single-File Golang Deployments by Asdrubalini on Wednesday March 22, 2023 @04:50PM (#35266902)
Not officially supported doesn't mean not updated or not supported in general.
Re:The Simplicity of Single-File Golang Deployments by lenkite on Wednesday March 22, 2023 @03:11PM (#35265801)
"a legacy-but-still-officially-supported-in-std implementation that nobody uses anymore but still needs to be maintained with its own namespace."

The cardinality of the set of "nobody uses anymore" is usually in tens of millions.

Re:The Simplicity of Single-File Golang Deployments by Asdrubalini on Wednesday March 22, 2023 @04:51PM (#35266923)
If something is used by tens of millions, be sure that it will be updated even if legacy. Just not officially by the people who maintain the language.
Re:The Simplicity of Single-File Golang Deployments by apazzolini on Wednesday March 22, 2023 @07:28PM (#35268505)
Ah yes, the #1 thing golang is known for: a comprehensive stdlib. Like including a max function for integers, right?
Re:The Simplicity of Single-File Golang Deployments by BreakfastB0b on Thursday March 23, 2023 @06:20AM (#35272488)
That attitude assumes that the go standard library is the global maximum for Getting Stuff Done, and because of backwards compatibility guarantees ensures that it’s difficult to innovate on.

I think having a small standard library is actually a good thing because it encourages exploration of the space of possibilities.

For example Go’s stdlib http.HandlerFunc sucks, people instead opt for leaving it behind entirely in favour of Gin or trying to work around it with bad patterns like interface smuggling.