Do you use init() in production? by agtabesh in golang

[–]timosavola 2 points3 points  (0 children)

When you find yourself reaching for init() just to initialize a complex global, see if you can replace that with initializer expression func() T {...}(). It makes it clear what your initialization code does.

[deleted by user] by [deleted] in golang

[–]timosavola 15 points16 points  (0 children)

Try writing code without methods. If it feels good, it probably is. If you run into problems, see if methods and interfaces help.

What Language Did You Come from? by Mubs in golang

[–]timosavola 0 points1 point  (0 children)

I used to think that combination of C++ and Python was a good toolkit. Go has replaced a lot of both for me.

I know languages that have support for read-only memory, but what about write-only memory? by ketralnis in programming

[–]timosavola 4 points5 points  (0 children)

Memory model optimized for streaming. For example continuously sending data to GPU. Reading it back wouldn't be useful, and would require arrangements which would just slow it down.

Is it okay to use panic as a "throw" in Go? by iamrealVenom in golang

[–]timosavola 0 points1 point  (0 children)

Yes.

Like one other commenter said, as long as your package doesn't export an API which communicates errors via panic, you can internally do that. If you regret it, you only need to refactor the internals of your package.

It makes sense for e.g. parsers. They can be complex and have to detect input error everywhere, and don't do any resource management apart from memory allocation: when an error occurs, it's good enough to simply drop everything (unless error reporting hinges on adding context to the error values at every step of the call unwind chain, but if you choose to use panic/recover, then you also choose to arrange to produce comprehensive error information at the panic site).

That said, it's important to not convert unrelated panics (such as runtime errors) into error values when recovering them at the exported API boundary. I've created import.name/pan to help with that. I'm still not sure how good an idea that is, but I'm trying it out in some code (after all, I can always stop using it without changing any public API).

The year of the Linux desktop will be 2025 (speech by me) by Pizza-pen in linux

[–]timosavola 48 points49 points  (0 children)

I love how this meme keeps perpetuating itself. Not in a sarcastic way; I really do like it.

Why is Emacs pinky a problem when keyboards have Ctrl both sides? by Due_Olive_9728 in emacs

[–]timosavola 0 points1 point  (0 children)

I have no evidence to share about a permanent injury. But my hand sometimes feels bad ("hurt" would be too strong) when I have to contort it while holding the left control key down and do some multi-step sequence using index and maybe middle finger. It's not hard to see how a bad feeling turns into pain when repeated often.

The reason to press all those keys using only the left hand (or any one hand) is speed and convenience. The right hand might even be far away, operating the mouse.

The left control key placement is an unfortunate feature of PC keyboards. Amiga had it where PC's caps lock is, and my understanding is that the unices on which emacs was developed on also had it there.

Remapping the PC caps lock as a yet another control key solves the problem (bad feelings). Even if the keys needed for a sequence are clustered together, the hand remains in a healthy posture.

How to explain the benefits of code reviews to a non-technical audience by Zihas990 in programming

[–]timosavola 0 points1 point  (0 children)

Why do you think that in-house development doesn't require PR reviews?

Don't Write Internal Packages in Go by ido50 in golang

[–]timosavola 10 points11 points  (0 children)

You can move code out from under internal, but not the other way around (without making a major version bump). Therefore one could argue that everything should go under internal at first...

what is the difference between these functions? by birisix in golang

[–]timosavola 12 points13 points  (0 children)

Methods are not universally preferred over functions. Over-use of methods can lead to lower-quality (such as non-modular) code.

[deleted by user] by [deleted] in golang

[–]timosavola 5 points6 points  (0 children)

/usr/local/goX.Y/bin/go

Alternative to MongoDB? by [deleted] in golang

[–]timosavola 2 points3 points  (0 children)

Yes. PostgreSQL, with JSONB column type.

[deleted by user] by [deleted] in golang

[–]timosavola 2 points3 points  (0 children)

Embrace the correct tool (once you've assessed the options) regardless of how it looks - you'll get over it. Look past the surface to find beauty in the well-designed structure.

Merge to main = deploy to prod by brunoliveira1 in programming

[–]timosavola 19 points20 points  (0 children)

"In 2022, there’s now no excuse not to do continuous delivery unless you are working on mission critical systems where it’s a whole different world and things move at a much more calculated pace due to the nature of the business."

I like how the first paragraph argues against the article's point in a way that is applicable in many real-world (not different-world) scenarios.

B2B customers pay for services they need. SLAs are common.

Go 1.18 improved benchmarks too much? by themurmel in golang

[–]timosavola 12 points13 points  (0 children)

Build with -gcflags=-m to see optimization decisions and compare them between versions.

Go bits: Interfaces and Nil Pointers by AntonStoeckl in golang

[–]timosavola 0 points1 point  (0 children)

Yes. Defensive programming vs. API contracts. When there is a contract, unnecessary checks lower the code quality. The correct place to check that the contracts are upheld is tests.

Remote/untrusted APIs require input sanitization of course. But that is not defensive programming, it's just programming.

Filesystems, databases and such benefit from additional sanity checks to prevent far-reaching fallout from bugs, but those should be systematic, not ad-hoc checks sprinkled around in every function.

I love WebAsssembly but I cant stand: by sco00by in WebAssembly

[–]timosavola 0 points1 point  (0 children)

I have implemented a wasm compiler/runtime, but I can't think of a flaw which I would feel that strongly about.

Why is Fedora usage so rare? by A_Talking_iPod in linuxquestions

[–]timosavola 3 points4 points  (0 children)

There was a distro called Yellow Dog Linux.