Go's Sweet 16

(go.dev)

152 points | by 0xedb 10 hours ago ago

82 comments

  • Xeoncross 9 hours ago

    I know they say that your programming language isn't the bottleneck, but I remember sitting there being frustrated as a young dev that I couldn't parse faster in the languages I was using when I learned about Go.

    It took a few more years before I actually got around to learning it and I have to say I've never picked up a language so quickly. (Which makes sense, it's got the smallest language spec of any of them)

    I'm sure there are plenty of reasons this is wrong, but it feels like Go gets me 80% of the way to Rust with 20% of the effort.

    • roncesvalles 8 hours ago

      The nice thing about Go is that you can learn "all of it" in a reasonable amount of time: gotchas, concurrency stuff, everything. There is something very comforting about knowing the entire spec of a language.

      I'm convinced no more than a handful of humans understand all of C# or C++, and inevitably you'll come across some obscure thing and have to context switch out of reading code to learn whatever the fuck a "partial method" or "generic delegate" means, and then keep reading that codebase if you still have momentum left.

      • asa400 7 hours ago

        > The nice thing about Go is that you can learn "all of it" in a reasonable amount of time

        This always feels like one of those “taste” things that some programmers tend to like on a personal level but has almost no evidence that it leads to more real-world success vs any other language.

        Like, people get real work done every day at scale with C# and C++. And Java, and Ruby, and Rust, and JavaScript. And every other language that programmers castigate as being huge and bloated.

        I’m not saying it’s wrong to have a preference for smaller languages, I just haven’t seen anything in my career to indicate that smaller languages outperform when it comes to faster delivery or less bugs.

        As an aside, I’d even go so far as to say that the main problem with C++ is not that it has so many features in number, but that its features interact with each other in unpredictable ways. Said another way, it’s not the number of nodes in the graph, but the number of edges and the manner of those edges.

        • synthetic-echo 5 hours ago

          Just an anecdote and not necessarily generalizable, but I can at least give one example:

          I'm in academia doing ML research where, for all intents and purposes, we work exclusively in Python. We had a massive CSV dataset which required sorting, filtering, and other data transformations. Without getting into details, we had to rerun the entire process when new data came in roughly every week. Even using every trick to speed up the Python code, it took around 3 days.

          I got so annoyed by it that I decided to rewrite it in a compiled language. Since it had been a few years since I've written any C/C++, which was only for a single class in undergrad and I remember very little of, I decided to give Go a try.

          I was able to learn enough of the language and write up a simple program to do the data processing in less than a few hours, which reduced the time it took from 3+ days to less than 2 hours.

          I unfortunately haven't had a chance or a need to write any more Go since then. I'm sure other compiled, GC languages (e.g., Nim) would've been just as productive or performant, but I know that C/C++ would've taken me much longer to figure out and would've been much harder to read/understand for the others that work with me who pretty much only know Python. I'm fairly certain that if any of them needed to add to the program, they'd be able to do so without wasting more than a day to do so.

          • Denzel 5 hours ago

            Did you try scipy/numpy or any python library with a compiled implementation before picking up Go?

            • synthetic-echo 4 hours ago

              Of course, but the dataset was mostly strings that needed to be cross-referenced with GIS data. Tried every library under the sun. The greatest speed up I got was using polars to process the mostly-string CSVs, but didn't help much. With that said, I think polars was also just released when we were working with that dataset and I'm sure there's been a lot of performance improvements since then.

        • kalterdev 4 hours ago

          > I’m not saying it’s wrong to have a preference for smaller languages, I just haven’t seen anything in my career to indicate that smaller languages outperform when it comes to faster delivery or less bugs.

          I can imagine myself grappling with a language feature unobvious to me and eventually getting distracted. Sure, there is a lot of things unobvious to me but Go is not one of them and it influenced the whole environment.

          Or, when choosing the right language feature, I could end up with weighing up excessively many choices and still failing to get it right, from the language correctness perspective (to make code scalable, look nice, uniform, play well with other features, etc).

          An example not related to Go: bash and rc [1]. Understanding 16 pages of Duff’s rc manual was enough for me to start writing scripts faster than I did in bash. It did push me to ease my concerns about program correctness, though, which I welcomed. The whole process became more enjoyable without bashisms getting in the way.

          Maybe it’s hard to measure the exact benefit but it should exist.

          1: https://9p.io/sys/doc/rc.html

      • egl2020 7 hours ago

        I've been writing go professionally for about ten years, and with go I regularly find myself saying "this is pretty boring", followed by "but that's a good thing" because I'm pretty sure that I won't do anything in a go program that would cause the other team members much trouble if I were to get run over by a bus or die of boredom.

        In contrast writing C++ feels like solving an endless series of puzzles, and there is a constant temptation to do Something Really Clever.

        • stackghost 5 hours ago

          Go is okay. I don't hate it but I certainly don't love it.

          The packaging story is better than c++ or python but that's not saying much, the way it handles private repos is a colossal pain, and the fact that originally you had to have everything under one particular blessed directory and modules were an afterthought sure speaks volumes about the critical thinking (or lack thereof) that went into the design.

          Also I miss being able to use exceptions.

          • throwaway894345 4 hours ago

            When Go was new, having better package management than Python and C++ was saying a lot. I’m sure Go wasn’t the first, but there weren’t many mainstream languages that didn’t make you learn some imperative DSL just to add dependencies.

            • stackghost 3 hours ago

              Sure, but all those languages didn't have the psychotic design that mandated all your code lives under $GOPATH for the first several versions.

              I'm not saying it's awful, it's just a pretty mid language, is all.

              • gp 3 hours ago

                The language has changed a lot since then. Give it a fresh look sometime.

      • kermatt 7 hours ago

        > I'm convinced no more than a handful of humans understand all of C# or C++

        How would the proportion of humans that understand all of Rust compare?

        • Measter an hour ago

          For Rust vs C++, I'd say it'll be much easier to have a complete understanding of Rust. C++ is an immensely complex language, with a lot of feature interactions.

          C# is actually fairly complex. I'm not sure if it's quite at the same level as Rust, but I wouldn't say it's that far behind in difficulty for complete understanding.

        • metaltyphoon 7 hours ago

          Rust isn’t that complicated if you have some background in non GC languages.

          • j16sdiz 5 hours ago

            Parent say _all_ of it, not a subset for everyday use.

      • morshu9001 8 hours ago

        This is also what I like about JS, except it's even easier than Go. Meanwhile Python has a surprising number of random features.

        • alexjplant 8 hours ago

          ECMAScript is an order of magnitude more complicated than Go by virtually every measure - length of language spec, ease of parsing, number of context-sensitive keywords and operators, etc.

          • ttoinou 5 hours ago

            Yeah I’m pretty sure people who say JS is easy don’t know about its Prototype based OOP

        • legends2k 7 hours ago

          Sorry, hard disagree. Try to understand what `this` means in JS in its entirety and you'll agree it's by no stretch of the imagination a simple language. It's more mind-bending and hence _The Good Parts_.

        • woodruffw 8 hours ago

          I think JS is notoriously complicated: the phrase “the good parts” has broad recognition among programmers.

        • jchw 8 hours ago

          Just so we're on the same page, this is the current JS spec:

          https://262.ecma-international.org/16.0/index.html

          I don't agree. (And frankly don't like using JS without at least TypeScript.)

        • cratermoon 6 hours ago
        • ajross 7 hours ago

          The Javascript world hides its complexity outside the core language, though. JS itself isn't so weird (though as always see the "Wat?" video), but the incantations required to type and read the actual code are pretty wild.

          By the time you understand all of typescript, your templating environment of choice, and especially the increasingly arcane build complexity of the npm world, you've put in hours comparable to what you'd have spent learning C# or Java for sure (probably more). Still easier than C++ or Rust though.

        • llmexperience 6 hours ago

          Tell me you have no idea what you’re talking about without explicitly saying the phrase.

    • throw1111221 6 hours ago

      Well that's good, since Go was specifically designed for juniors.

      From Rob Pike himself: "It must be familiar, roughly C-like. Programmers working at Google are early in their careers and are most familiar with procedural languages, particularly from the C family. The need to get programmers productive quickly in a new language means that the language cannot be too radical."

      However, the main design goal was to reduce build times at Google. This is why unused dependencies are a compile time error.

      https://go.dev/talks/2012/splash.article#TOC_6.

      • the_gipsy 35 minutes ago

        > This is why unused dependencies are a compile time error.

        https://go.dev/doc/faq?utm_source=chatgpt.com#unused_variabl...

        > There are two reasons for having no warnings. First, if it’s worth complaining about, it’s worth fixing in the code. (Conversely, if it’s not worth fixing, it’s not worth mentioning.) Second, having the compiler generate warnings encourages the implementation to warn about weak cases that can make compilation noisy, masking real errors that should be fixed.

        I believe this was a mistake (one that sadly Zig also follows). In practice there are too many things that wouldn't make sense being compiler errors, so you need to run a linter. When you need to comment out or remove some code temporarily, it won't even build, and then you have to remove a chain of unused vars/imports until it let's you, it's just annoying.

        Meanwhile, unlinted go programs are full of little bugs, e.g. unchecked errors or bugs in err-var misuse. If there only were warnings...

      • pkaye 6 hours ago

        Doesn't Google use mostly C++?

        • throw1111221 6 hours ago

          Just because it was a design goal doesn't mean it succeeded ;)

          From Russ Cox this time: "Q. What language do you think Go is trying to displace? ... One of the surprises for me has been the variety of languages that new Go programmers used to use. When we launched, we were trying to explain Go to C++ programmers, but many of the programmers Go has attracted have come from more dynamic languages like Python or Ruby."

          https://research.swtch.com/gotour

          • Measter an hour ago

            It's interesting that I've also heard the same from people involved in Rust. Expecting more interest from C++ programmers and being surprised by the numbers of Ruby/Python programmers interested.

            I wonder if it's that Ruby/Python programmers were interested in using these kinds of languages but were being pushed away by C/C++.

        • allset_ 14 minutes ago

          No.

        • dpe82 5 hours ago

          It really depends on product area.

    • morshu9001 8 hours ago

      Language can be bottleneck if there's something huge missing from it that you need, like how many of them didn't have first class support for cooperative multitasking, or maybe you need it to be compiled, or not compiled, or GC vs no GC. Go started out with solid greenthreading, while afaik no major lang/runtime had something comparable at the time (Java now does supposedly).

      The thing people tend to overvalue is the little syntax differences, like how Scala wanted to be a nicer Java, or even ObjC vs Swift before the latter got async/await.

    • tptacek 7 hours ago

      I don't understand the framing you have here, of Rust being an asymptote of language capability. It isn't. It's its own set of tradeoffs. In 2025, it would not make much sense to write a browser in Go. But there are a lot of network services it doesn't really make sense to write in Rust: you give up a lot (colored functions, the borrow checker) to avoid GC and goroutines.

      Rust is great. One of the stupidest things in modern programming practice is the slapfight between these two language communities.

    • zer00eyz 7 hours ago

      I write a lot of Go, a bit of Rust, and Zig is slowly creeping in.

      To add to the above comment, a lot of what Go does encourages readability... Yes it feels pedantic at moments (error handling), but those cultural, and stylistic elements that seem painful to write make reading better.

      Portable binaries are a blessing, fast compile times, and the choices made around 3rd party libraries and vendoring are all just icing on the cake.

      That 80 percent feeling is more than just the language, as written, its all the things that come along with it...

      • cwbriscoe 5 hours ago

        Error handling isn't even a pain to write any more with AI autocomplete which gets it right 95%+ of the time in my experience.

        • zer00eyz 5 hours ago

          You're not wrong but... there is a large contingent of the Go community that has a rather strong reaction to AI/ML/LLM generated code at any level.

          I keep using the analogy, that the tools are just nail guns for office workers but some people remain sticks in the mud.

          • 9rx 4 minutes ago

            > there is a large contingent of the Go community that has a rather strong reaction to AI/ML/LLM generated code at any level.

            This Go community that you speak of isn't bothered by writing the boilerplate themselves in the first place, though. For everyone else the LLMs provide.

    • throwaway894345 4 hours ago

      Similar story for me. I was looking for a language that just got out of the way. That didn’t require me to learn a full imparable DSL just to add a few dependencies and which could easily produce some artifact that I could share around without needing to make sure the target machine had all the right dependencies installed.

    • tialaramex 9 hours ago

      > I'm sure there are plenty of reasons this is wrong, but it feels like Go gets me 80% of the way to Rust with 20% of the effort.

      I don't see it. Can you say what 80% you feel like you're getting?

      The type system doesn't feel anything alike, I guess the syntax is alike in the sense that Go is a semi-colon language and Rust though actually basically an ML deliberately dresses as a semi-colon language but otherwise not really. They're both relatively modern, so you get decent tooling out of the box.

      But this feels a bit like if somebody told me that this new pizza restaurant does a cheese pizza that's 80% similar to the Duck Ho Fun from that little place near the extremely tacky student bar. Duck Ho Fun doesn't have nothing in common with cheese pizza, they're both best (in my opinion) if cooked very quickly with high heat - but there's not a lot of commonality.

      • klodolph 9 hours ago

        > I don't see it. Can you say what 80% you feel like you're getting?

        I read it as “80% of the way to Rust levels of reliability and performance.” That doesn’t mean that the type system or syntax is at all similar, but that you get some of the same benefits.

        I might say that, “C gets you 80% of the way to assembly with 20% of the effort.” From context, you could make a reasonable guess that I’m talking about performance.

        • Xeoncross 9 hours ago

          Yes, for me I've always pushed the limits of what kinds of memory and cpu usage I can get out of languages. NLP, text conversion, video encoding, image rendering, etc...

          Rust beats Go in performance.. but nothing like how far behind Java, C#, or scripting languages (python, ruby, typescript, etc..) are from all the work I've done with them. I get most of the performance of Rust with very little effort a fully contained stdlib/test suite/package manger/formatter/etc.. with Go.

          • vips7L 5 hours ago

            Go is in the same performance profile as Java and C#. There are tons of benchmarks that support this.

          • echelon 8 hours ago

            Rust is the most defect free language I have ever had the pleasure of working with. It's a language where you can almost be certain that if it compiles and if you wrote tests, you'll have no runtime bugs.

            I can only think of two production bugs I've written in Rust this year. Minor bugs. And I write a lot of Rust.

            The language has very intentional design around error handling: Result<T,E>, Option<T>, match, if let, functional predicates, mapping, `?`, etc.

            Go, on the other hand, has nil and extremely exhausting boilerplate error checking.

            Honestly, Go has been one of my worst languages outside of Python, Ruby, and JavaScript for error introduction. It's a total pain in the ass to handle errors and exceptional behavior. And this leads to making mistakes and stupid gotchas.

            I'm so glad newer languages are picking up on and copying Rust's design choices from day one. It's a godsend to be done with null and exceptions.

            I really want a fast, memory managed, statically typed scripting language somewhere between Rust and Go that's fast to compile like Go, but designed in a safe way like Rust. I need it for my smaller tasks and scripting. Swift is kind of nice, but it's too Apple centric and hard to use outside of Apple platforms.

            I'm honestly totally content to keep using Rust in a wife variety of problem domains. It's an S-tier language.

            • nine_k 8 hours ago

              > I really want a fast, memory managed, statically typed scripting language somewhere between Rust and Go that's fast to compile

              It could as well be Haskell :) Only partly a joke: https://zignar.net/2021/07/09/why-haskell-became-my-favorite...

            • Xeoncross 8 hours ago

              I agree with a lot of what you said. I'm hoping Rust will warm on me as I improve in it. I hate nil/null.

              > Go... extremely exhausting boilerplate error checking

              This actually isn't correct. That's because Go is the only language that makes you think about errors at every step. If you just ignored them and passed them up like exceptions or maybe you're basically just exchanging handling errors for assuming the whole thing pass/fail.

              If you you write actual error checking like Go in Rust (or Java, or any other language) then Go is often less noisy.

              It's just two very different approaches to error handling that the dev community is split on. Here's a pretty good explanation from a rust dev: https://www.youtube.com/watch?v=YZhwOWvoR3I

      • NoboruWataya 9 hours ago

        I guess the 80% would be a reasonably performant compiled binary with easily managed dependencies? And the extra 20% would be the additional performance and peace of mind provided by the strictness of the Rust compiler.

      • password4321 9 hours ago

        Single binary deployment was a big deal when Go was young; that might be worth a few percent. Also: automatically avoiding entire categories of potential vulnerabilities due to language-level design choices and features. Not compile times though ;)

      • kace91 9 hours ago

        Wild guess but, with the current JS/python dominance, maybe it’s just the benefits of a (modern) compiled language.

  • ashishb 8 hours ago

    Contributing to a new Go codebase is easy.

    The Go codebases look all alike. Not only the language has really few primitives but also the code conventions enforced by standard library, gofmt, and golangci-lint implies that the structure of code bases are very similar.

    Many language communities can't even agree on the build tooling.

    • trenchpilgrim an hour ago

      I'm still trying to convince the scientists I work with that they should format their code or use linters. Making them mandatory in Go was a good decision.

    • stOneskull 2 hours ago

      i've just started learning Go and i really like this aspect. one way to do things, one way to format.. the % operator is a bit confusing for a negative number - that took me down a little rabbit-hole, learning about how a remainder can be different to how i normally think about it.

  • tschellenbach 9 hours ago

    10 week onboarding program we use here for go backend devs: https://www.reddit.com/r/golang/comments/1eiea6q/10_week_pla...

    go is amazing. switches from python to go 7 years ago. It's the reason our startup did well

  • tail_exchange 9 hours ago

    I was very skeptical of Go when I started learning it, but it quickly became my favourite language. I like how simple but powerful it is.

    If I had a magic wand, the only things I would add is better nulability checks, add stack traces by default for errors, and exhaustive checks for sum types. Other than that, it does everything I want.

  • weakfish 9 hours ago

    I like Go. Coming from Python, I appreciate having most things be explicit in nature vs. magical, and having concurrency not feel like a bolted on nightmare.

    Writing microservices at $DAYJOB feels far easier and less guess-work, even if it requires more upfront code, because it’s clear what each piece does and why.

    • jsight 9 hours ago

      I've finally gotten around to learning Go this year and I'm having a pretty similar experience.

      It really feels like a simpler language and ecosystem compared to Python. On top of that, it performs much better!

  • MichaelNolan 9 hours ago

    Go would probably be my favorite language if it just had a few more features around functional programming. Specifically around immutability and nullness, and maybe exhaustive switch statements. Then it just might be perfect.

    At work we use Uber’s NillAway, so that helps bit. https://github.com/uber-go/nilaway Though actually having the type system handle it would be nicer.

    • kellpossible2 4 hours ago

      Go with Sum types and no nil pointers would be fantastic! Is it too much to dream of? It feels like Gleam gets pretty close but it flies off in a bunch of other directions.

  • srameshc 9 hours ago

    Go is my favorite programming language. I remember when I first found Go and it was because I was using Java back then and learnign Akka framework for concurrent programming . I realized Go was so much less code compared to Java and I could understand it effortlessly. Since then I have been using it very regularly but still I don't feel I am good at this language. But it helps me get the work done. Cheers to the 16th anniversary of Go.

  • threemux 7 hours ago

    I use Go every day at work and it's still the first thing I reach for when completing personal projects. It gets better every year. Keep up the good work Go team!

  • jryio 9 hours ago

    Glad to see that the bowling development team is focusing on deterministic tooling like language server protocol in gopls and using static analysis for automatically restoring code with go fix.

    Recently I made the same assertions as to Go's advantage for LLM/AI orchestration.

    https://news.ycombinator.com/item?id=45895897

    It would not surprise me that Google (being the massive services company that it is) would have sent an internal memo instructing teams not to use the Python tool chain to produce production agents or tooling and use Golang.

    • somekyle2 7 hours ago

      Even 15 years ago or so when Guido was still there I recall being told "we aren't supposed to write any new services in Python. It starts easy, then things get messy and end up needing to be rewritten." I recall it mostly being perf and tooling support, but also lack of typing, which has changed since then, so maybe they've gotten more accepting.

  • adamddev1 2 hours ago

    I'm thankful for Go because it was an easy first introduction to static typing.

    I remember making a little web app and seeing the type errors pop up magically in all he right places where I missed things in my structs. It was a life-changing experience.

  • Pbhaskal 4 hours ago

    It has been my go to language since 2020. I was given a task to complete in a week and my lead told just go through Go playground and write the code (it was some snmp receiver/transmit stuff). To my surprise it was so easy to learn, write and more importantly test. Only recent thing i have not learned is generics, hopefully will get their sooner. Coming from java background the things Go did felt so clever and just too good to believe

  • zmj 6 hours ago

    I'm glad Go exists. If nothing else, it cemented that tooling is at least as important as the language.

  • bobjordan 7 hours ago

    I tried to use go in a project 6-7 years ago and was kind of shocked by needing to fetch packages directly from source control with a real absence of built in versioning. That turned me off and I went back to python. I gather that now there’s a new system with go modules. I should probably revisit it.

  • p2detar 8 hours ago

    I recently finished my first ever side gig in Go - a web platform that organizes business processes between multiple actors. Got paid and more feature requests are coming in. Fronted with Caddy, the whole thing runs flawlessly on a $5 VPS. I love Go.

  • kasperset 7 hours ago

    I am not really familiar with Go but I wonder where it would be without Google's support and maintenance. I have no doubt it is a solid language with some really smart people in programming language design behind it. It is so much easy to release programming language but so much difficult to maintain and curate it over time.

  • captainkrtek 5 hours ago

    Been happily working in Go since 2014. My career has spanned C, Python, C#, Ruby, and a smattering of other languages, but am always quite fond and preferential towards Go.

  • nicodjimenez 6 hours ago

    Golang to me is a great runtime and very poor language. I could maybe get used to the C pointer-like syntax and to half of my code checking if err != nil, but the lack of classes is a step too far. The Golang idiomatic approach is to have a sprawling set of microservices talking to each other over the network, to manage complexity instead of having classes. This makes sense for things like systems agents (eg K8) but doesn't make sense for most applications because it complicates the development experience unnecessarily and monoliths are also easier to debug.

    I would not use Golang for a big codebase with lots of business logic. Golang has not made a dent in Java usage at big companies, no large company is going to try replacing their Java codebases with Golang because there's no benefit, Java is almost as fast as Golang and has classes and actually has a richer set of concurrency primitives.

    • wanderlust123 6 hours ago

      I think lack of classes is highly desirable. So much enterprise code is poorly put together abstractions.

      I think go needs some more functional aspects, like iterators and result type/pattern matching.

  • rishabhaiover 7 hours ago

    Love Go! It gently introduced me to the systems programming world.

  • ModernMech 6 hours ago

    Oh wow, so it's already been 16 years since Google steamrolled the Go! language, which had existed a decade before Go and had every right to the name. This was when they were still pretending "do no evil" was their brand.

    There may be no honor amongst thieves but there is honor amongst langdevs, and when they did Go! dirty, Google made clear which one they are.

    Status changed to Unfortunate

    https://github.com/golang/go/issues/9#issuecomment-66047478

    • MagicMoonlight 5 hours ago

      Does anyone use that other language? No!

      • ModernMech 4 hours ago

        That's not the point, no one uses 99% of languages, so if that's the standard then it's a free-for-all. The PL community is small, so norms are important.

        PL naming code is:

        1. Whoever uses the name first, has claim to the name. Using the name first is measured by: when was the spec published, or when is the first repo commit.

        2. A name can be reused IFF the author has abandoned the original project. Usually there's a grace period depending on how long the project was under development. But if a project is abandoned then there's nothing to stop someone from picking up the name.

        3. Under no circumstances should a PL dev step on the name of a currently active PL project. If that happens, it's up to the most recently named project to change their name, not the older project even if the newer project has money behind it.

        4. Language names with historical notoriety are essentially "retired" despite not being actively developed anymore.

        All of this is reasonable, because the PL namespace is still largely unsaturated*. There are plenty of one syllable English words that are out there for grabs. All sorts of animals, verbs, nouns, and human names that are common for PLs are there for the taking. There's no reason to step on someone else's work just because there's some tie in with your company's branding.

        So it's pretty bottom basement behavior for luminaries like Ken Thompson and Rob Pike to cosign Google throwing around their weight to step on another dev's work, and then say essentially "make me" when asked to stop.

        * This of course does not apply to the single-letter langs, but even still, that namespace doesn't really have 25 langs under active development.

  • MagicMoonlight 5 hours ago

    I just can’t get over the idiotic syntax.

    Instead of “int x”

    You have “var x int”

    Which obscures the type, making it harder to read the code. The only justification is that 16 years ago, some guy thought he was being clever. For 99.99% of code, it’s a worse syntax. Nobody does eight levels of pointer redirection in typical everyday code.

    • bbkane 4 hours ago

      I prefer this, especially for more complex types like functions- https://go.dev/blog/declaration-syntax gives an overview of their thought process

    • LexiMax 4 hours ago

      16 years is a bit of an under-estimate. I think the first popular language with this form of declaration was Pascal.

          var
              foo: char;
      
      Go was developed by many of the minds behind C, and inertia would have led them to C-style declaration. I don't know if they've ever told anybody why they went with the Pascal style, but I would bet money on the fact that Pascal-style declarations are simply easier and faster for computers to parse. And it doesn't just help with compile speed, it also makes syntax highlighting far more reliable and speeds up tooling.

      Sure, it's initially kind of annoying if you're used to the C style of type before identifier, but it's something you can quickly get to grips with. And as time has gone on, it seems like a style that a lot of modern languages have adopted. Off the top of my head, I think this style is in TypeScript, Python type hints, Go, Rust, Nim, Zig, and Odin. I asked Claude for a few more examples and apparently it's also used by Kotlin, Swift, and various flavors of ML and Haskell.

      But hey, if you're still a fan of type before variable, PHP has your back.

          class User {
              public int $id;
              public ?string $name;
      
              public function __construct(int $id, ?string $name) {
                  $this->id = $id;
                  $this->name = $name;
              }
          }
  • sedatk 9 hours ago

    I remember when Go was born, then, it turned out there was already another programming language called "Go!", but nobody cared, and everybody forgot about that other Go!. So, happy birthday, Go, and rest in peace, Go!

    https://en.wikipedia.org/wiki/Go!_(programming_language)#Con...