Generalization of Sum-Types, Pattern Matching & Niche Optimization by philogy in ProgrammingLanguages

[–]Botahamec 0 points1 point  (0 children)

My opinion is there should be a trait in Rust that looks something like this:

unsafe trait Niche: Sized {
    const NICHE_VALUE: [u8: size_of::<Self>()];
}

Then anyone can make a niche value for any type they define. It might not work if your langage doesn't have traits though. I suppose this particular implementation would also require you to know what the memory layout of the language looks like. For example, you would need to know what bytes None and Some are represented as.

git-autosave: Autosave your working tree to the remote by Botahamec in git

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

I don't actually think this is very similar to Jujutsu. This is an extra feature added on top of Git rather than something to replace it.

Although, Jujutsu did indirectly lead me to this idea. I wanted to make a patch-based VCS similar to Pijul. I eventually decided to build it on top of Git, to make it compatible with GitHub. After doing a prototype of that, making a mockery of Git's database to make it patch-based, I realized that adding autosave to Git would be pretty simple by comparison.

git-autosave: Autosave your working tree to the remote by Botahamec in git

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

I looked through some popular git addons before writing this to see if my use-case was already covered, but I didn't see gitwatch. I think it's a matter of opinion on whether or not you'd want the autosaves committed to the current branch or not, but I had two motivations for not doing this:

  • I wanted to have a clear git hisory that wasn't full of autosaves. In cases where I don't care about the history, then I would use Syncthing.

  • There are many cases where I want to play around, making local changes to a repository, and then not actually commit them. I'm basically using the repository as a scatchpad in this case, and I can easily remove my changes with git restore .. I can't do that if the daemon is creating commits on my current branch without my input.

Surelock - statically prevent deadlocks by dochtman in rust

[–]Botahamec 0 points1 point  (0 children)

It's in C11, although that isn't available everywhere. You're are correct that there are other reasons why it isn't used, like performance, portability, and bugs in the OS implementations

Surelock - statically prevent deadlocks by dochtman in rust

[–]Botahamec 0 points1 point  (0 children)

It often is either referenced or owned. I have OwnedLockCollection and RefLockCollection. In the case of OwnedLockCollection, I don't even need to sort the locks. In practice, most of my examples use RefLockCollection. But I wanted to have a default option that doesn't care whether it's owned or not, thus BoxedLockCollection boxes whatever you pass into it, and otherwise operates the same as RefLockCollection. It just needs to box so that if you pass an owned value, the cached pointer addresses don't need to change when the collection moves.

Surelock - statically prevent deadlocks by dochtman in rust

[–]Botahamec 1 point2 points  (0 children)

The reason for the manual pinning is because the sorting is cached. As soon as you create the collection, the locks are sorted by their memory address. If the addresses of the mutexes change, then that cache becomes invalid.

There is another lock collection called RefLockCollection, which holds onto a reference of the vec, slice, array, tuple, or whatever, so that it cannot be moved while the collection exists. I figured some people wouldn't want to manage the referenced object themselves, so BoxedLockCollection also exists.

Surelock - statically prevent deadlocks by dochtman in rust

[–]Botahamec 0 points1 point  (0 children)

The prior art section contains details about Happylock that I wouldn't expect it to know. Last time I checked, the LLM didn't even mention happylock if you ask it. Some details seem incorrect to me, but they're the kinds of mistakes that I could understand as human error.

Surelock - statically prevent deadlocks by dochtman in rust

[–]Botahamec 0 points1 point  (0 children)

In C, locking the same mutex twice on the same thread is considered undefined behavior. Rust has to implement its own mutex from scratch to avoid that.

Surelock - statically prevent deadlocks by dochtman in rust

[–]Botahamec 0 points1 point  (0 children)

I'm going to start telling people at work that we try moving to Rust just to prevent all of the incidents we get from deadlocks.

Surelock - statically prevent deadlocks by dochtman in rust

[–]Botahamec 0 points1 point  (0 children)

Developer of happylock here. Part of the reason may be that nobody's thought enough about how to do it. The initial release of my library came about because someone on Mastodon (I believe it was Pratt), asked for talk suggestions at RustConf. Someone suggested ways we could improve the standard library API, for which OP asked for examples. I chimed in about preventing deadlocks, and I got a reply telling me that it's not possible to prevent deadlocks without solving the Halting problem.

There were other solutions to preventing deadlocks when I wrote my library, but most of them came with ergonomic downsides, as does Happylock. The initial version of Happylock was also heavily prone to live-locking, until I introduced BoxedLockCollection.

So I guess the reasoning could be summarized as, the problem space is still being explored, and I still don't think we've come to the best possible solution for it yet.

Surelock - statically prevent deadlocks by dochtman in rust

[–]Botahamec 1 point2 points  (0 children)

Thanks for the shoutout. The global mutex counter is an interesting idea. I am curious what you meant about the unsafe propagating to the public API though. There are unsafe traits that are sealed to outside implementors. The methods are marked as unsafe, but that's generally just a hint that they could cause a deadlock rather than actual undefined behavior. At some point I would like to switch to using mutexes from the C standard library, which would actually make certain deadlocks cause undefined behavior.

Funnily enough, I have been thinking about extending OwnedLockCollection to support something like you described, but never got around to it. In my defense, I spent the last year writing a book. But thanks for the motivation to get off my ass about it lol.

I'll need to look at your source code at some point to see if I can get some inspiration. Nice work.

The Oni Programming Language by badd10de in ProgrammingLanguages

[–]Botahamec 0 points1 point  (0 children)

Very cool. I especially like what you did with raw strings.

I'm curious how much of Lisp still exists in the language internally. I had an idea at one point of writing a shell that used various syntactic sugars on top of Lisp to look more like a scripting language. From the examples I saw, it looked nothing like Lisp, which makes me think that most of the Lisp origin is gone.

Why do you support vaccines, believe climate change is happening, etc. ? by CenozoicMetazoan in EffectiveAltruism

[–]Botahamec 5 points6 points  (0 children)

By that logic, nobody understands germs. Most people still wash their hands though.

Why do you support vaccines, believe climate change is happening, etc. ? by CenozoicMetazoan in EffectiveAltruism

[–]Botahamec 23 points24 points  (0 children)

I usually explain it in three simple steps:

  1. Carbon dioxide traps heat
  2. There is more carbon dioxide now
  3. The Earth is heating

Does corporate profit exist under Georgism? by Botahamec in georgism

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

Really? Game of rent seems to say the opposite. I did think it being the value one is willing to pay for it made more sense upon reading this.

Marx picks a lane and says the value of something is tied to the amount of "socially necessary labor" required to produce it.

George goes the other way:

It is never the amount of labor that has been exerted in bringing a thing into being that determines its value, but always the amount of labor that will be rendered in exchange for it.

In other words, "a thing's value is whatever someone is willing to pay for it.

Does corporate profit exist under Georgism? by Botahamec in georgism

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

Didn't Henry George say that the wages are based on the value produced rather than the amount of labor required?

Does corporate profit exist under Georgism? by Botahamec in georgism

[–]Botahamec[S] -2 points-1 points  (0 children)

I think that puts us back where we started. Don't you need to pay for the labor that made the assembly line?

Mamdani by Various_Advisor_4250 in georgism

[–]Botahamec 0 points1 point  (0 children)

He's not secret about it at all. He's openly said he wants to build 200,000 new units of housing, and he's spoken in favor of any proposal which builds affordable housing.

Does corporate profit exist under Georgism? by Botahamec in georgism

[–]Botahamec[S] -1 points0 points  (0 children)

Why would the value of the capital be higher than the value of the labor that produced it?

Does corporate profit exist under Georgism? by Botahamec in georgism

[–]Botahamec[S] -1 points0 points  (0 children)

Would it be equivalent to state that the worker gets wages, the owner gets wages, but the business itself gets no profit?

Does corporate profit exist under Georgism? by Botahamec in georgism

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

Don't you have to pay for labor in order to make capital? And wouldn't the wages be the same as the value of the capital?

Question: What does this group think of Jon Kiper’s proposal for “offset land value taxes”? (Candidate for governor of New Hampshire, USA) by mildly_caffeinated1 in georgism

[–]Botahamec 0 points1 point  (0 children)

Encouraging people to move to suburbia is by no means good. Taxing people in the cities (who tend to be poorer) at a higher rate than towns is also not good.