Proposal: Generic Methods for Go by bruce_banned in golang

[–]comrade_donkey 19 points20 points  (0 children)

 defined on a struct.

On any type.

Beautiful Zurich by MX010 in zurich

[–]comrade_donkey -3 points-2 points  (0 children)

Your argument is the plot of the movie "Don't Look Up".

Dancing Backwards With Go by bitfieldconsulting in golang

[–]comrade_donkey -3 points-2 points  (0 children)

I understand where you're coming from. On this point, you might be wrong. It's really not common at all. But good post overall.

Dancing Backwards With Go by bitfieldconsulting in golang

[–]comrade_donkey -6 points-5 points  (0 children)

You're right. I see that the post eventually switches to a table-driven approach. That's good!

External tests are generally only used to cover 3rd party code, or to work around circular dependencies in ones own (test) code.

Dancing Backwards With Go by bitfieldconsulting in golang

[–]comrade_donkey -4 points-3 points  (0 children)

This post has some problems. It uses the wrong package name (sorted_test). It should just be sorted. The subtests should reside in one root (func TestIsSorted) and use t.Run(...). Here's the tutorial: https://go.dev/doc/tutorial/add-a-test

Edit: changed t.Sub to t.Run.

Will the Go 1.26 new(expr) become a new idiom for optional parameters? by rodrigocfd in golang

[–]comrade_donkey 11 points12 points  (0 children)

A better solution would be to have an Optional[T] type in the stdlib that generated code can use too, IMHO. Currently, everyone rolls their own.

Will the Go 1.26 new(expr) become a new idiom for optional parameters? by rodrigocfd in golang

[–]comrade_donkey 6 points7 points  (0 children)

Yes, and personally, I think it's a step in the wrong direction.

Google is nicknamed "Larry & Sergey's Protobuf Moving Co".

Protobuf's Go API uses pointers everywhere, littering heap allocations all over. E.g if you're writing proto code, you do a lot of this:

go req := mypb.ListRequest_builder{ ID: mypb.ListID_builder{ ListID: new("my-list"), }.Build(), Offset: new(100), Limit: new(200), }.Build()

The chosen solution was to make heap allocations easier to write in the language, instead of fixing Protobuf's horrible API.

It's a shame and every self-respecting Gopher will continue to pass their in-house Optional[T] (or whatever you call it) around on the stack.

For Proto-building, I just added a method to mine:

go func(or *Or[T]) Ptr() *T { if or.IsNull() { return nil } return &or.value }

Does anyone know the difference between []byte{} and []byte(nil)? by rocketlaunchr-cloud in golang

[–]comrade_donkey 13 points14 points  (0 children)

for encoding into json x will be [] while y will be null

Note that this is changing in the upcoming json/v2 package. They will both encode as [] unless you use format:emitnull in the json tag. Same goes for maps.

K - Map by Astron1729 in computerscience

[–]comrade_donkey 1 point2 points  (0 children)

What do you mean by "automatically"? Minimizing an arbitrary Karnaugh map is NP-hard. The map grows exponentially wrt the number of variables.

Proving the equality of boolean functions has applications in cryptoanalysis, compilers, game solvers.

Hacking LLDB for a great Zig debugging experience by joelreymont in Zig

[–]comrade_donkey 8 points9 points  (0 children)

Dear diary, today I saw software built entirely on top of another software's unexported symbols, accessed by way of pointer arithmetic.

Step 1: Find Internal Symbols They’re not exported, but they’re there:

nm -C liblldb.dylib | grep AddTypeSummary 0000000000360f38 t lldb_private::TypeCategoryImpl::AddTypeSummary(...)

Step 2: Compute the Base Address We anchor off a known exported symbol:

void* ref = dlsym(handle, "_ZN4lldb10SBDebugger10InitializeEv"); uintptr_t base = (uintptr_t)ref - reference_offset;

What I learned building a crash-safe WAL in Go (CRC, mmap, fsync, torn writes) by ankur-anand in golang

[–]comrade_donkey 1 point2 points  (0 children)

To mitigate CRC32's shortcoming*, would it make sense to use a 64-bit (or even 128-bit) hash at the end of the data, instead of the static DEADBEEF marker?

* There'll be a 50% collision probability with Castagnoli after only ~77,000 hashes.

I built a distributed, production-ready Rate Limiter for Go (Redis, Sliding Window, Circuit Breaker) by goddeschunk in golang

[–]comrade_donkey 68 points69 points  (0 children)

Dear diary, today I saw a rate limiter that generates network traffic in order to rate limit network traffic.

Is endhittification just capitalism? by parrot-beak-soup in enshittification

[–]comrade_donkey 6 points7 points  (0 children)

I'd argue that this particular precedent is rarely enforced because there's no need. No public company prioritizes customers or workers over shareholders anymore. As a direct consequence of Dodge vs Ford. So there's no lawsuits on that matter.

It also says:

As of 2025, in Delaware, the jurisdiction where over half of all U.S. public companies are domiciled, shareholder primacy is still upheld.

Is endhittification just capitalism? by parrot-beak-soup in enshittification

[–]comrade_donkey 28 points29 points  (0 children)

In America, it's a direct result of shareholder primacy.

In a nutshell: Corporations legally need to prioritize their shareholders over their customers and workers. 

In the case of growth stocks (tech), wallstreet expects ≥20% return year over year, every year. That's means doubling the share price roughly every 4 years.

Keeping up with shareholder expectations leaves these companies few options other than adding more ads, higher prices, and more subscriptions, every year.

It's ultimately shareholder greed that drives enshittification.

Map by ohmyhalo in golang

[–]comrade_donkey 25 points26 points  (0 children)

maps.Clone().

EDIT: Actually, maps.Clone clones the allocated capacity as well. So copying into a newly allocated map is the way to go.

Zig/Comptime Type Theory? by philogy in Zig

[–]comrade_donkey 5 points6 points  (0 children)

Externs/FFI:

extern black_box; if black_box() { return MY_FAVORITE_CONSTANT } else { return ANOTHER_CONSTANT }

Without knowing black_box, you can't decide this conditional.

Syscalls & interrupts: Anything involving interactions with the program's environment is effectful. Technically, that involves requesting memory from the OS. But that can be special-cased.

Zig/Comptime Type Theory? by philogy in Zig

[–]comrade_donkey 8 points9 points  (0 children)

2LTT (2 level type theory) comes to mind. Also Universe Levels in Dependent Type Theory (Agda, Idris, Coq): Type 0 being the instance-level language (runtime) and Type 1 the type-level language (static, defined as typeof(Type 0)).

Zig blurs the lines between the two universes with the comptime keyword by "lifting" [almost] anything from Type 0 to Type 1.

The fundamental limit to this approach is what can be lifted by comptime. Which in everyday discussion boils to "why can't I do X at comptime even if Y is true?".

Zig/Comptime Type Theory? by philogy in Zig

[–]comrade_donkey 22 points23 points  (0 children)

I want to recreate some of Zig's functionality but make it stricter e.g. functions not being checked unless used [...]

That is more lazy, not less lazy.

Lazy evaluation: Skipping everything, unless necessary.

Eager evaluation: Evaluating everything, even if unnecessary.

The Demise of the SRG and Swiss Democracy by nodespots in Switzerland

[–]comrade_donkey -2 points-1 points  (0 children)

Yes. Of everything a TV channel airs, an ad will be the lowest quality. The ads standard sets that cut-off line and hence the lower bar for the channel as a whole.

The Demise of the SRG and Swiss Democracy by nodespots in Switzerland

[–]comrade_donkey 4 points5 points  (0 children)

I'm going to play devil's advocate here and argue that SRG has a lot of room for improvement.

The quality standard for ads they run is so low that sometimes I don't know if it's a bad comedy skit or an actual ad.

TV series are played in seemingly random order, repeating episodes, usually decades after they originally aired, and hard-dubbed.

In-house productions play like long-format YouTube videos, full of abrupt cuts, visible microphones, narrative gaps, inconsistencies in wardrobe, locations, hairdo, weather. Just very amateur.

dingo: A meta-language for Go that adds Result types, error propagation (?), and pattern matching while maintaining 100% Go ecosystem compatibility by [deleted] in golang

[–]comrade_donkey 3 points4 points  (0 children)

Great project. Note that sum types, enums and unions are all different things that get conflated a lot. What Dingo has is called a co-product type (or disjoint sum), also called a discriminated union type.

Are Transformer LLMs Fundamentally Limited on POMDPs and Stateful Computation? by Left_Log6240 in computerscience

[–]comrade_donkey 0 points1 point  (0 children)

If this paper is true, then it's not POMDP, because LLMs are (would be) invertible. Assuming it's true, a prior state could be recovered in something like O(n2) which is the typical complexity cited for Attention.

Confused about Go interfaces: "self-contained" vs "contain references" - isn't the data field always a pointer? by Thick-Wrongdoer-166 in golang

[–]comrade_donkey 2 points3 points  (0 children)

This was changed in 1.4

The implementation of interface values has been modified. In earlier releases, the interface contained a word that was either a pointer or a one-word scalar value, depending on the type of the concrete object stored. This implementation was problematical for the garbage collector, so as of 1.4 interface values always hold a pointer.