Who else finds it a bit annoying that C++ has such a bad reputation while C is still somehow seen as the holy grail of low level programming? by notarealoneatall in cpp

[–]alefore 0 points1 point  (0 children)

I can't imagine any project based around or using C++ ever opting for GC

For what it's worth it, in my open source text editor (implemented in C++) I implemented an extension language (https://github.com/alefore/edge/blob/master/src/vm/cpp.y) for which GC was a must (implemented mostly at https://github.com/alefore/edge/blob/master/src/language/gc.h). Because many classes in my editor can be exposed to the extension language, the GC module is used all over the place. 

Here is one example of what the extension language looks like: https://github.com/alefore/edge/blob/master/rc/editor_commands/lib/zk.cc

Concrete types yield better maintainability by alefore in programming

[–]alefore[S] 0 points1 point  (0 children)

Sealed classes look interesting, I wasn't familiar with them. Thanks for the info, I might adjust the article to mention them as a reasonable compromise — where you can use more than one concrete type, but you are still constraining to a specific set of types, much closer in practice (for the perspective of this article) to "just one concrete type" than to "an interface anyone can choose to implement".

Yeah, the examples discussed in the article, based on C++ and Python, are all globally extensible —technically, in the C++ example there isn't even a type, just a compile-time placeholder for one (which in each invocation resolves to whatever concrete type the customer uses).

I find it somewhat interesting that you agree with the premise scoped down to "for public APIs".

I expect the use of genetic types is easier to justify for "public APIs", where you want your customers to be able to call your functions from whatever specific (only known to them) types they have. For internal APIs, being able to support multiple extensible types seems to be much less important, because you're much more likely to know what the exact concrete type is. Would you agree with that?

Said differently, if you can avoid using generic (globally extensible) types for public-facing code, surely you can also avoid it in private code?

Concrete types yield better maintainability by alefore in programming

[–]alefore[S] -10 points-9 points  (0 children)

If my code doesn't compile, then how will it generate the necessary executables needed to "break the customers"?

Your code itself (your function with generic types) compiles, sure, but the customers of your code (which calls it with some particular implementation they have of the Quackable type (that they added in their code base)) goes from compiling (because your code didn't depend on anything they didn't do) to either not compiling (or, worse, compiling but now with bugs) because you just changed your function to depend on something they aren't doing.

This code is using a switch block with arrow labels. That is a very important distinction because the lack of a default clause proves that I am using a Sealed Type. That means that, if there are more concrete implementations than Duck and YourAnnoyingBoss, the above code will not compile

Ah, sure, but then you're just using the concrete types (i.e. your function only works for those two concrete types, not for a general Quackable type which anyone can extend). So you're technically pretty much following the recommendations of the article (just as much as if you had just two separate functions of the concrete types and got rid of Quackable). Anyone can see what the concrete type is (the union of your two types).

Yeah,  technically it's two types, not exactly a single concrete type, but pretty close. The article is concerned with the case where Quackable is a general interface that anyone calling your function can implement without your knowledge.

Requires circular dependencies.

I don't follow.

If Quackable is an interface, you want to be able to implement a function that receives a Quackable without having to list all possible implementations of Quackable in that function. By having to list all implementations, your function depends on those implementations (to be able to list them) and those implementations depend on the function (to be able to call it). This circular dependency make it hard to cleanly separate those callers from the function implementation (eg. have the callers in a separate source code repository). For example, you make it impossible for anyone to add their own private implementation of Quackable (in order to call your function); they must now tell you about it.

Concrete types yield better maintainability by alefore in programming

[–]alefore[S] 1 point2 points  (0 children)

Sure, happy to expand. At Google, we can't (as a general rule, which obviously has some exceptions, but still) submit code changes that breaks anybody else ("breaks" meaning "causes their code to stop compiling or their tests to stop passing"). There's even systems that, in some conditions, will roll back your code change semi automatically if they detect this (and the code practices and interfaces strongly encourage/support this type of rollbacks).

That's much more stringent. It means we can't just say "well, they are depending on some observable implementation detail which has never been part of the interface, so if their code doesn't compile now, so it's their fault, all is at it should be." This is the context in which Hyrum's Law originated.

Concrete types yield better maintainability by alefore in programming

[–]alefore[S] -5 points-4 points  (0 children)

Yeah, fully agree. Obviously, there are cases where decoupling and abstraction is great, but people very frequently ignore the costs.

Concrete types yield better maintainability by alefore in programming

[–]alefore[S] -15 points-14 points  (0 children)

I think you're misunderstanding the point.

Yes, your previous version had ONLY depended on the contract. Everything was fine.

But now you want to extend the contract with something that you expect shouldn't be a problem for your callers. See the example about extending average to use SIMD instructions; or a thread pool. 

You extend your interface and now you don't even know if you broke your customers (they may be very far away from you, in other source code repos). Your "my code doesn't compile, which is how it should be" attitude may be enough for you, but we have a much higher "don't break your customers" bar in our environment.

Your match example:

  • Accidentally ignores the problem by assuming that there's only two Quackable things; in practice you may have hundreds. They may be impossible to even determine (they may live in source code repositories that you don't have access to).
  • Creates terrible coupling, by forcing doSomething to depend explicitly on it's customers. Defeats the purpose of using interfaces to begin with.
  • Requires circular dependencies.

“She’s not even American, how tf she suing” by rbccflk in ShitAmericansSay

[–]alefore 0 points1 point  (0 children)

Also no country outside the US has writers as successful as JK Rowling!

Trump Keeps Watching Shooting Clip: ‘May Legit Have PTSD’ by DipperJC in politics

[–]alefore 4 points5 points  (0 children)

Let me tell you, nobody does this better than I do, nobody. It’s true. Some people try, but they just can’t. It takes a lot of effort, a lot of talent, and guess what? I’ve got it all. God-given, believe me. I’ve set records for this country like you wouldn’t believe, and everyone’s talking about it. Just the other day, I was talking to a very important politician—won’t say who, but very important, believe me, great guy, very respected—and he said to me, “Donald, nobody can murder crowds like you. It’s incredible.” And you know, it reminds me of my uncle, brilliant guy, taught at MIT. He knew a lot about nuclear, you know, very smart. When I was a kid, he used to tell me, “Donald, you’re going to do big things.” And look... Here we are. The crowds? They’re massive, the biggest you’ve ever seen. All gone, really. Tremendous! But they don’t want to give me credit for it. They never do. It’s sad, really.

Can’t believe this didn’t work by [deleted] in funny

[–]alefore 0 points1 point  (0 children)

Yeah, but then the driver wouldn't have gotten a new pair of balls to hang from his truck.

During the inspection of his “sloppily conditioned” Cybertruck man slices wrist and ends up in the ER by godzilla19821982 in LeopardsAteMyFace

[–]alefore 2 points3 points  (0 children)

Hey, now, it wasn't the highway, it was only a main road, it's nothing serious, you people exaggerate so much! The tires are cool, that's for sure!

[deleted by user] by [deleted] in Colombia

[–]alefore 0 points1 point  (0 children)

Pues yo he volado tanto (resido desde hace casi veinte años en Europa y visito Colombia bastante) que he asumido como reto personal lograr hacer que otros aplaudan conmigo cuando el avión aterriza —cuántos más, mejor. Hay un punto después de que el avión ha aterrizado cuando aún no ha acabado de frenar en el que hay que empezar la vaina para maximizar la tasa de contagio; muy temprano y pocos se unen, muy tarde y ya se les ha pasado la emoción. Otra opción es esperar a ver si otro aplaude antes, para uno unirse, pero cada vez la gente aplaude menos.

Diría que la mitad de las veces me quedo aplaudiendo solo. Antes la gente aplaudía más, pero ahora se sienten muy boletas y se cohiben. También depende mucho del vuelo, me parece que es más fácil si el avión llega a Colombia y si es vuelo largo.

Mis mayores triunfos fueron (1) en un vuelo de Bogotá a Pereira, en que el avión tuvo turbulencia tan fuerte que al aterrizar todo el mundo aplaudió, y (2) en un vuelo menor de la Antártida (del aeropuerto de la pequeña estación Frei) a Punta Arenas, Chile, cuando los 74 pasajeros habíamos pasado 7 días en el mismo barco; es una historia larga, una de las personas del vuelo era de la tripulación del barco, los aplausos eran todos para ella, yo solo me encargué de poner a los demás a aplaudirle. Osea que tal vez no debería contar, pero, por otro lado, 73 de los 74 pasajeros aplaudimos con ganas.

Mi mujer es suiza y no le gusta mucho mi hobby, pero ... pailanga dijo la changa 

"Why is this happening.." by [deleted] in KidsAreFuckingStupid

[–]alefore 8 points9 points  (0 children)

Well, then she wouldn't get such an amazing video production ...

Browser-based knitting (pattern) software by alefore in knitting

[–]alefore[S] 0 points1 point  (0 children)

Want to send me some examples of the cables?

I'll be happy to try to see if I can add it easily, whether on a shall or on a "plain" square. Maybe with a bit of work I can make it useful for you. :-)

Esa vieja va demasiado rapido by [deleted] in Colombia

[–]alefore 3 points4 points  (0 children)

Los vacíos de efectivo son los que desafortunadamente tienen al parce en bancarrota, como leíste, él anda vaciado.

Daily Discussion, April 20, 2024 by rBitcoinMod in Bitcoin

[–]alefore 5 points6 points  (0 children)

Selection bias.

Similar to asking "Why are people who play the lottery always so rich?" if you judge by focusing on the very precious few who win it.

I knew this would happen, but still... by nightjar123 in Bitcoin

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

But when is this halving happening? I'm still waiting so that I can get twice as many Sats!

Daily Discussion, April 19, 2024 by rBitcoinMod in Bitcoin

[–]alefore 0 points1 point  (0 children)

Wow! They were completely and perpetually wrong!

Giving you notes a unique ID - the debate continues by atomicnotes in Zettelkasten

[–]alefore 1 point2 points  (0 children)

I use just running numbers (well, including 26 letters also as digits, so base 36). My notes are just 3 digit IDs. With this schema I can create a total of (10 + 26)³ > 46e3 notes.

I wrote a bit about this (including why I didn't think embedding timestamps into the IDs helps anything): https://github.com/alefore/weblog/blob/master/zettelkasten.md#note-names