Live data from Hacker News

Why I’m Frustrated with Go

dev.to

191–200 of 233 posts

Re: Why I’m Frustrated with Go

#191

Earlier quoted context omitted.

Most modern dynamic languages have strong types. In Python you will get a TypeError if you try to add a string and an int or use > on a tuple and a dict. As for data validation, the hard part of it is not checking type but that the value is safe and coherent. And dynamic languages excel at that because they make complex declarative schema descriptions easy while powerful. See marshmallow for Python: https://marshmall…

> Most modern dynamic languages have strong types. In Python you will get a TypeError if you try to add a string and an int or use > on a tuple and a dict. >>> (1,2) > {1: 2} True >And dynamic languages excel at that because they make complex declarative schema descriptions easy while powerful. Marshmallow looks like it works the same way as existing systems in statically types languages. e.g. Serde in Rust: https://…

  In [60]: (1,2) > {1: 2}
  ---------------------------------------------------------------------------
  TypeError                                 Traceback (most recent call last)
   in ()
  ----> 1 (1,2) > {1: 2}

  TypeError: '>' not supported between instances of 'tuple' and 'dict'

Re: Why I’m Frustrated with Go

#192

> That’s an infuriating amount of code to write 24 lines, really ?

It was down to 10 after a suggestion in the comments. Given the number of times you might actually need an immutable, ordered map (total count so far in my life = 0), having to write 10 lines of code does seem like an odd reason to be furious with an entire programming language.

Re: Why I’m Frustrated with Go

#193

Earlier quoted context omitted.

Most modern dynamic languages have strong types. In Python you will get a TypeError if you try to add a string and an int or use > on a tuple and a dict. As for data validation, the hard part of it is not checking type but that the value is safe and coherent. And dynamic languages excel at that because they make complex declarative schema descriptions easy while powerful. See marshmallow for Python: https://marshmall…

> Most modern dynamic languages have strong types. In Python you will get a TypeError if you try to add a string and an int or use > on a tuple and a dict. >>> (1,2) > {1: 2} True >And dynamic languages excel at that because they make complex declarative schema descriptions easy while powerful. Marshmallow looks like it works the same way as existing systems in statically types languages. e.g. Serde in Rust: https://…

He means Python 3.

Re: Why I’m Frustrated with Go

#194

Earlier quoted context omitted.

>I found it a chore to maintain Go-based systems My opinion is the opposite. Almost every go code base I've seen is extremely consistent compared to other languages. Going from one code base to another is almost always seamless because learning Go involves learning the Go tools which forces you to follow Go coding standards. I'd choose to work on a Go code base over Java or C++ any day of the week. I don't have much…

I tried Go and so far I'm feeling that Go forces me to abandon error checking and even if error is catched, I have no idea where this error comes from, because there's no stacktrace or anything like that. Best thing I've come to is using strings as errors (completely throwing out any error hierarchy) and returning new error string for every call with call information (doing poor job which Java would do for me automat…

This is not the right way to do things.

Re: Why I’m Frustrated with Go

#195
post #11

I did Go for years, but stopped doing any serious work in it about a year ago. In general, I found it a chore to maintain Go-based systems. There's a lot to like about Go. But it doesn't seem pragmatic for the types of applications I see people using it for. For example, the entire error thing is absurd. Anders Hejlsberg got this right many years ago: 9 out of 10 errors are "handled" by a central error handler (log +…

I've done my first project with go. Goroutines are undoubtedly cool and I like the strong typing.

* Unfortunately error handling sucks (no stacktrace by default? Let's go back to the days of peppering print statements around just for fun).

* DB support is terrible (I've spent hours doing what I could have done in half an hour with python).

* It's so verbose, even simple things like mapping over an array to create another array requires a for-loop dance. Same for just checking if a value is in an array. Same, obviously for no exceptions which you either love or hate. I hate.

I can't see myself doing any other projects with it.

Re: Why I’m Frustrated with Go

#196
post #75

Earlier quoted context omitted.

Yes, humanrebar is really grasping at straws. :) I would also mention that using mutable and const_cast is frowned upon and it can be trivially searched for and forbidden. Their comment about const iterators also misses the mark. Yes, the designers of the C++ standard library did a bit more work and now everyone has a high-quality type-safe dictionary implementation available. That's how it's supposed to work...

> humanrebar is really grasping at straws. :) On the contrary, I've had to mentor a lot of C++ developers where they were surprised when their put-const-on-it approach to providing safety resulted in production bugs. I think it's fair for people to be surprised by this sort of thing. And I don't think the things Go developers have to do are all that much worse than equivalent code in C++. In C++, 'const' mostly means…

> On the contrary, I've had to mentor a lot of C++ developers where they were surprised when their put-const-on-it approach to providing safety resulted in production bugs.

Can you provide any concrete example on how adding a const qualifier introduces bugs? Besides disallowing calls to mutable member functions, adding const qualifiers changes nothing in the code.

Re: Why I’m Frustrated with Go

#197

Earlier quoted context omitted.

> Actually C++ doesn't have immutable data unless you count compile-time constants and literals. You can declare things 'const', but that only provides a read-only (1) view on mutable data. const std::set & s // This is a read-only view. const std::set s // This is immutable. > Another approach is to just declare member variables 'const'. So you have a 'const map ' as a member variable. Except for that to work, you n…

> const std::set s // This is immutable. > Foo() : s(helper()) {} // This is a move, not a copy. First, I'll point out that the data of s is not immutable. The fact that you can const_cast away the const and change the value makes that clear. If people do things like that (or corrupt memory or have race conditions in the code), C++ doesn't necessarily give you clear exceptions or compiler errors. Many of the ways to…

> The fact that you can const_cast away

No, you cant. The standard states that "any attempt to modify a const object during its lifetime results in undefined behavior".

If you're intentionally writing code that relies on undefined behavior, you are intentionally writing broken code.

Re: Why I’m Frustrated with Go

#198
post #20

Earlier quoted context omitted.

Is it possible to write a reusable version of something like this in Go without using interface{}?

If "static codegen" is considered OK, then I guess yes, and I guess you can use The Thing[0] to even make them look like actual generics. Every user of the library will need to run codegen to post-process their source files and generate the relevant instantiations of the "generic" collection. [0] https://www.reddit.com/r/rust/comments/5penft/parallelizing_...

So you can do it in Go in the same sense that you can do it in assembly language.

Re: Why I’m Frustrated with Go

#199

Earlier quoted context omitted.

I don't like the "central exception handler" idea -- it is invariably too far away from the error site to do anything intelligent. I do like Erlang's approach with hierarchical error domains ("processes" and "supervisor trees"), and I honestly think Go made a mistake here: The semi-recent introduction of Context acknowledges that a control hierarchy is present and an important part of a concurrent, distributed applic…

I don't think a central exception handler means ONLY handle exception in one very specific point. It means that if you can handle an error handle it, otherwise let the central exception handler handle it. I really like Elixir and the Erlang VM but supervisor trees are not a perfect solution either. For all the talk about how in Erlang you just let things fail and don't have to do defensive coding, any non-trivial app…

If you need an ETS table to have greater resiliency move it up higher in the supervision tree. Nothing prevents you from starting it at the application level.

Also you have a lot of control of your supervision tree. You can specify the quantity and frequency of failures that would cause a supervisor to fail. For some use cases, 3 failures in 5 seconds might be reason enough to restart that supervisor. For other use cases, a much higher failure rate might be justified.

Re: Why I’m Frustrated with Go

#200

Earlier quoted context omitted.

Go is nowhere near the speed of C. But why not consider Rust?

The Rust team decided to promote Rust as a "systems programming" language. And even though it can obviously do much more, and the bindings for most popular libraries are available [1], this label somehow attracts programmers who are more systems oriented and I think the language will continue to develop in this way, whereas Go/D/Nim will tend to try to be more general. [1] Imagine how surprised I was the other day to…

I don't see why it's surprising to see a game programming library binding for Rust. I was drawn to it because it was advertised as a "systems programming" language. From a graphics perspective, this means that it's trying to be fast and gives me good control over low level stuff.
Post reply on HN