Live data from Hacker News

The 4-chan Go programmer

dolthub.com

41–50 of 177 posts

Re: The 4-chan Go programmer

#41
post #35

Here's a counterpoint blog using a chan that sends a chan in order to implement a dynamic dispatch mechanism. This is in Limbo not Go. But same concepts. Maybe the complexity proves the point. https://ipn.caerwyn.com/2007/07/lab-78-dynamic-dispatch.html...

For those wondering, Limbo is a predecessor of Go hand used in the Inferno operating system, a descendant of plan9.

Re: The 4-chan Go programmer

#42
post #7

As a scientist that ends up working closely with actual professional software engineers... lots of the stuff they do looks like this do me, and I can't for the life of me make sense of why you'd do it. I have seen a single line of code passed through 4 "interface functions" before it is called that call each other sequentially, and are of course in separate files in separate folders. It makes reading the code to figu…

This is actually really bad practice and a very “over eager junior engineer” way of writing software. You’re not off base at all that it seems excessive and confusing. It’s the kind of thing that seems technically complex and maybe even “elegant” (in isolation, when you first write the “interesting” code) at first but becomes a technical nightmare when used in real software that has to grow around and with it. You’re…

when I was learning Go, I read a guide that told you to fire off a goroutine to walk a tree and send the values back to the main goroutine via a channel. I think about that "just an example" guide a lot when I see bad channel code.

For me the biggest red flag is somebody using a channel as part of an exported library function signature, either as a param or a return value. Almost never the right call.

Re: The 4-chan Go programmer

#43

There is a Go developer that defends using channels four times like in this blog, he also made some great medium posts in which he details real use cases. His name is Christopher, if you want to find more about him, just Google “chris chan 4chan”.

Can someone explain this for people who don't want to do it?

You won't be scarred for life after searching for some random dude. You are on a hackers forum and are afraid of a web search?

Re: The 4-chan Go programmer

#44

There is a Go developer that defends using channels four times like in this blog, he also made some great medium posts in which he details real use cases. His name is Christopher, if you want to find more about him, just Google “chris chan 4chan”.

Can someone explain this for people who don't want to do it?

Chris Chan is the amalgamation of the worst parts of imageboards. Also could argue he is a victim to the internet.

Re: The 4-chan Go programmer

#45

Earlier quoted context omitted.

I mean to a point that makes sense; you got your base data types like idk, a bank account number which can be validated, which is inside a bank account which can be validated, which is in a customer which can be validated, etc etc. Visitor pattern style, I believe?

imagine allowing invalid values to exist

imagine enforcing invariants as part of the design of a software system

Re: The 4-chan Go programmer

#46

Earlier quoted context omitted.

> I have seen a single line of code passed through 4 "interface functions" I once had to deal with a HTTP handler that called `Validate` on interface A which called `Validate` on interface B which called `Validate` on interface C which called `Validate` on interface D which finally did the actual work. There was a lot of profanity that month.

I mean to a point that makes sense; you got your base data types like idk, a bank account number which can be validated, which is inside a bank account which can be validated, which is in a customer which can be validated, etc etc. Visitor pattern style, I believe?

That would make sense but this was one piece of data being validated against a lookup based off that data. The previous devs just had a, uh, Unique™ style of development. I swear they must have been on some kind of "editor tab count" bonus scheme.

Re: The 4-chan Go programmer

#47
post #7

As a scientist that ends up working closely with actual professional software engineers... lots of the stuff they do looks like this do me, and I can't for the life of me make sense of why you'd do it. I have seen a single line of code passed through 4 "interface functions" before it is called that call each other sequentially, and are of course in separate files in separate folders. It makes reading the code to figu…

I enjoy reading about new languages on HN. It’s weird because the grammar is weird. It’s like seeing start var ! oper addition sub var !! mltplctn var % close close or something and eventually you realize it means a + b*c. Why invent a new language? Why not just write list if you want a list of integers or write Channel or one of the idioms that everyone knows? I don’t know, but it can be fun to play with communicati…

What "everyone knows" depends on who everyone is. There was syntax prior to templates with angle brackets.

Re: The 4-chan Go programmer

#48
post #29
post #7

As a scientist that ends up working closely with actual professional software engineers... lots of the stuff they do looks like this do me, and I can't for the life of me make sense of why you'd do it. I have seen a single line of code passed through 4 "interface functions" before it is called that call each other sequentially, and are of course in separate files in separate folders. It makes reading the code to figu…

this is the classic over abstraction problem so that you can change things behind an interface at some point down the line if you ever need to while being totally opaque to any consuming code. A lot of languages force you to start with this from day one, unless you want to go refactor everything to use an interface later on, so people just do it even when there will literally never be a reason to (and for testability…

Do you have a concrete example by any chance?

Re: The 4-chan Go programmer

#49
channel of channel is a normal pattern, although it more commonly looks like a channel of struct vals, and the struct type has a field that's a channel. it's lets you send requests that are completed, whose values can be awaited on out of order, to avoid head of line blocking. something like `type request struct { params, reply chan response }`, where you send those requests on a channel, they get dispatched to some worker, and then the worker does the work and puts the result on the reply chan. But two is as high as I've ever found useful, I don't think I've ever seen a use case for a chan chan chan.

Re: The 4-chan Go programmer

#50
post #7

As a scientist that ends up working closely with actual professional software engineers... lots of the stuff they do looks like this do me, and I can't for the life of me make sense of why you'd do it. I have seen a single line of code passed through 4 "interface functions" before it is called that call each other sequentially, and are of course in separate files in separate folders. It makes reading the code to figu…

It gets worse (this isn't too much of an exaggeration): https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpris....

Sometimes there's a scary lack of understanding and competency where you'd expect to find it.

As an undergrad, I once spent about half an hour peer programming with a computer science PhD - it was enlightening.

He didn't have the slightest understanding of software - calling me out for things like not checking that the size of a (standard library) data structure wasn't negative.

But other times these things are done for a reason; sometimes it's actually sane and sometimes it's just a way to deal with the lunacy of a codebase forged by the madmen who came before you.

Post reply on HN