@doty@mastodon.social avatar

doty

@doty@mastodon.social

John Doty

This profile is from a federated server and may be incomplete. Browse more on the original instance.

aeva, to random
@aeva@mastodon.gamedev.place avatar

I love American Science & Surplus. It's the only store to have earned the right to add me to their mailing list.

Sadly they were out of optical illusions, but I ordered an ugly llama doll, some bouncy balls for the cats, and a cute little novelty star projector thing, and a free mystery item :3

doty,
@doty@mastodon.social avatar

@aeva I had never heard of this before and now I have and I might be ruined. Thanks!

mcc, to random
@mcc@mastodon.social avatar

Imagine I am interested in a server such as Redis that I can use as an fast in-memory data store accessible from several processes at once. Imagine I would not use the SSPL (new, weird, proprietary license) version. Can you recommend to me:

  • A fork of Redis from before they went to the SSPL.
  • A Redis alternative that is open source and does about the same thing

I've never actually used Redis and have no attachment to its particular quirks. I just think I might need something like it someday.

doty,
@doty@mastodon.social avatar

@mcc Garnet is a new thing, wire-compatible with redis, that just dropped. MIT licensed. It seems like it could plausibly work: https://github.com/microsoft/garnet

(It is new enough that I don't know that I could recommend it but it is currently at the top of the list of things that I would try if I needed a redis-alike, for what it's worth.)

mcc, to random
@mcc@mastodon.social avatar

More cursed C# questions!

We have a P/Invoke method. We want it to pass through a function pointer from the C# to the C side.

We say:
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate void Callback();

We make that an argument of our P/Invoke method:

[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
public static extern void RegisterCEventHandler(Callback c);

If we have a method, we say: RegisterCEventHandler(MethodName);

This works so far. But then—

(1/2)

doty,
@doty@mastodon.social avatar

@mcc Did you find an answer to this?

There is a terrible cursed answer but it might help you:

public static void RegisterEventHandler(Action callback) {
RegisterCEventHandler(() => callback());
}

(I don't remember the type compatibility rules for delegates, I'm afraid.)

doty,
@doty@mastodon.social avatar

@mcc I'm sorry I misunderstood.

I thought the goal was to be able to call between logically-compatible but nominally-incompatible delegate types? The compiler-generated lambdas can do this, was the point, and can provide whatever thunk you need between managed and unmanaged.

doty,
@doty@mastodon.social avatar

@mcc Ah, I see. I don't think I will be much help, then. :D

Maybe this is the documentation you are looking for, which describes how managed types become unmanaged and vice versa. https://learn.microsoft.com/en-us/dotnet/standard/native-interop/type-marshalling

You have probably already found that though. I don't know what “type representation in C#” means in this problem.

mcc, to random
@mcc@mastodon.social avatar

I regret to inform you I have another cursed C# question

Short version: "What is the most performant way to associate a value with a type?"

Long version: I created a custom System.Attribute; I attached it to several of my classes The first time I reflect on such a class's attributes, I want to create several cached values derived from those attributes, and store them where I can get them the next time I reflect. But turns out System.Attribute.GetCustomAttributes creates a new object each time…

doty,
@doty@mastodon.social avatar

@mcc Have you tried using System.Type as the key in your dictionary?

It used to be that it compared by reference, that is, identical types were guaranteed to have reference equality, and so it was very easy to cache per-type information in a dictionary keyed by the Type.

I have not written a lot of code against dotnet core though so it could be that they have changed this.

mcc, to random
@mcc@mastodon.social avatar

Absurd C++ question. Say i do this:

std::string *str = get_pointer();

*str = string("Something");

If I'm not totally confused, that second line will do two things. It will call ~std::string() on *str, then it will assign the new string "something" to *str.

Is there a way to opt out of that ~? Say I really need, never mind if it's a good idea I just need, to store a str in a buffer created outside C++. When I'm done with it I'll call the destructor by hand. How do I initially populate it?

doty,
@doty@mastodon.social avatar

@mcc Can you std::swap the contents and then conveniently lose track of the original value?

mcc, to random
@mcc@mastodon.social avatar

In c#, sizeof(T) returns a int32, not a UIntPtr/nuint.

doty,
@doty@mastodon.social avatar

@mcc Blame Visual Basic 7 for deciding that unsigned integers didn’t belong in their language. 😞

doty,
@doty@mastodon.social avatar

@mcc The whole Common Language Subset thing is so weird. The CLR was supposed to be polyglot from the jump, unlike Java, so they built a runtime but prohibited the standard library from using all of it for compatibility reasons. Then C# was so successful that everybody went for C# compatibility instead of CLS compatibility, and none of the polyglot stuff ever really materialized.

doty,
@doty@mastodon.social avatar

@mcc you probably have a good reason to use a default parameter instead of a zero-arity overload of the method, which is how the framework tends to work around this limitation.

mcc, to random
@mcc@mastodon.social avatar

Say I'm in C# and I want to have a type that acts like a OCaml ADT or a Rust Enum— it can be either CONST1, or CONST2, or an object of a particular type I specify.

Is there a C#-idiomatic way to do this?

doty,
@doty@mastodon.social avatar

@mcc If you want the compiler to check exhaustiveness, then you need to use a visitor-esque pattern with a base class and an abstract virtual method. You can type a lot behind the scenes to make it very cute at the call site with lambdas and stuff but fundamentally that’s what you got, and the cuteness is not idiomatic.

If you are willing to bail on exhaustiveness then a switch expression with is operators is the way to go.

mcc, to random
@mcc@mastodon.social avatar

I do not like the Beatles song "Yesterday" but I think if it were still using Paul McCartney's original placeholder lyrics of "Scrambled eggs / Oh baby how I love your legs" I would like it

doty,
@doty@mastodon.social avatar

@mcc OH! This reminds me of the very excellent talk "Comedy Writing With Small Generative Models" from Strange Loop last year, in which Jamie Brew automates the invention of rhyming parodies with small language models: https://youtu.be/M2o4f_2L0No?si=oeGSZpKOfSaYu1HV&t=1953

mcc, to random
@mcc@mastodon.social avatar

Ok so if the DJ Shadow Action Adventure Tour is hitting your city I recommend highly trying to get a ticket as there was some unbelievably sick shit in there

doty,
@doty@mastodon.social avatar

@mcc As a longtime fan but somebody who has seen DJ Shadow live multiple times, do you think there is enough new and cool there to be worth it?

doty,
@doty@mastodon.social avatar

@mcc thanks, that’s really helpful.

The last time I saw him was in 2017 (yikes, 7 years?). I have not seen him play drums before. So I guess that is new.

mcc, to random
@mcc@mastodon.social avatar

Okay so I now have a local copy of the hbomberguy "Plagiarism and You (Tube)" video, an open-source, pre-LLM speech recognition library for Python, and I am about to do something very pointless

doty,
@doty@mastodon.social avatar

@mcc holy shit that’s a good sentence though

mcc, to random
@mcc@mastodon.social avatar

I appear to have somehow broken rsync. I'm telling it to sync a directory tree containing 613,624 files, and it keeps getting like 20 files in and just hanging. This is such a baffling situation I'm wondering if like, the linux kernel on the other side is broken or something.

doty,
@doty@mastodon.social avatar

@mcc @whitequark I have a zero-compression streaming zip implementation for node.js, if that is something you would be interested in?

I used it for exactly the thing I think you want, which is to be able to jam a bunch of files together into a single archive for convenient handling.

doty,
@doty@mastodon.social avatar

@mcc @whitequark I'm sorry, I was reacting to the sentiment that maybe it would be faster to re-export into a single zip file than to get the many-filed results of the export off the computer, but that would require a working zip library.

I had no reason to think my implementation would have been better than the one you tried before you tried it. At the time I built mine there were no streaming zip file implementations in node, but it seemed you had found one… I am sorry it was so frustrating.

doty,
@doty@mastodon.social avatar

@mcc Ah, alas. Le code de l'escalier.

mcc, to random
@mcc@mastodon.social avatar

Working with compiler triples today which means I keep getting messages involving "-unknown-elf" and I cannot stop thinking about the Unknown Elf. How do we summon the Unknown Elf. What if the Unknown Elf can never be found

doty,
@doty@mastodon.social avatar

@mcc the elf that can be known is not the true elf

mcc, to random
@mcc@mastodon.social avatar

Night danger

doty,
@doty@mastodon.social avatar

@mcc deserves a quiet night

eniko, to random
@eniko@peoplemaking.games avatar

content pipelines for games are a mistake. imagine if you had to run all your images and fonts and stuff through some pipeline before you could put them up on the web for a website? that's what you're doing with games

just parse the dang PNG it ain't that hard

doty,
@doty@mastodon.social avatar

@eniko plus, think of all that extra time people will have to appreciate your cool loading screen!

eniko, (edited ) to Lisp
@eniko@peoplemaking.games avatar

So @gaycodegal gave me a great suggestion for my lisp. I haven't quite worked out what to call them, but they're custom read syntax shorthand macros. So in the same way you can type 'foo to mean (quote foo) you can make your own shorthands that are applied at read time. So for example you could make a ++ macro to increment a variable:

(shorthand ++ (var)
`(set ,var (+ ,var 1)))

So when the parser encounters ++ x it'll turn it into (set x (+ x 1)), and it works just like a macro normally would

That means I could create if/elseif/else like this

(shorthand elseif (cond yes no)
`(if ,cond ,yes ,no))
(shorthand else (exp) exp)

(if (< x 0)
(foo)
elseif (> x 10)
(bar)
else
(baz))

Which would expand to

(if (< x 0)
(foo)
(if (> x 10)
(bar)
(baz)))

doty,
@doty@mastodon.social avatar

@eniko I think the thing you’re looking for is called a “reader macro” in other lisps? But they don’t necessarily come with built-in token matching or anything….

b0rk, to random
@b0rk@jvns.ca avatar

just got back from the last strange loop. I had a blast and I'm very grateful that I got to keynote one of my favourite conferences before it ended ❤

will put up a video when they release it!

doty,
@doty@mastodon.social avatar

@b0rk I really enjoyed your talk! Thank you for being there and giving it!

eniko, to random
@eniko@peoplemaking.games avatar

I really wanna code an operating system 😩

doty,
@doty@mastodon.social avatar

@eniko Port MS-DOS to RISC-V?

mcc, to random
@mcc@mastodon.social avatar

Anyway uhh when making these music posts I'm never sure whether to emphasize musical content or technical process but for the record this one really does very effectively use sound to paint an evocative alien landscape. A couple times this week I've just put this video on the TV and let it run while I work on the couch https://mastodon.social/@mcc/111070730650718852

doty,
@doty@mastodon.social avatar

@mcc What I like in the way of commentary is what makes it interesting to you, whether that’s technical process or musical quality or both. (Thank you for continuing to share!)

  • All
  • Subscribed
  • Moderated
  • Favorites
  • provamag3
  • kavyap
  • rosin
  • ethstaker
  • Backrooms
  • DreamBathrooms
  • magazineikmin
  • thenastyranch
  • Youngstown
  • slotface
  • InstantRegret
  • khanakhh
  • mdbf
  • hgfsjryuu7
  • anitta
  • Durango
  • osvaldo12
  • GTA5RPClips
  • ngwrru68w68
  • tacticalgear
  • cisconetworking
  • tester
  • everett
  • normalnudes
  • cubers
  • modclub
  • Leos
  • JUstTest
  • All magazines