[-] cgtjsiwy@programming.dev 6 points 3 months ago* (last edited 3 months ago)

For your holy-mod-sword example specifically, the better approach is to specify a structured data format (think Excel sheets) that your game loads from a specific directory at startup and inserts the found items, NPCs etc. into the game's runtime data structures (e.g. loot tables).

For example, Skyrim (and other Bethesda games) do this with .esp-files, which allow you to import a big variety of different game entities. In a small indie game, the format doesn't have to be anything special; e.g. Elin modders use plain .xlsx files, where the columns are item name, item weight, item sell value, item damage, etc.

The above approach works for static data, such as simple items, but you'll need more to allow modders to write Turing complete scripts. There are two different approaches to this:

  • Expose a language runtime in which the game runs mods. You can design your own language and/or runtime (e.g. Warcraft 3 has JASS), or use existing ones (this is basically what eval is, though you'll need to hide builtins, globals and such by passing extra parameters). These approaches are theoretically safe thanks to the runtime sandbox, but there are often unintended ways to escape the sandbox and execute arbitrary code.
  • Inject the mod executable directly into the game with tools like BepInEx (Unity) or DLL injection (used by e.g. Skyrim Script Extender). There are no security guard rails, so you'll need to manually review mods.
[-] cgtjsiwy@programming.dev 10 points 1 year ago

I wonder when Firefox is going to add a configuration menu for keybinds.

[-] cgtjsiwy@programming.dev 11 points 1 year ago

all of these are different ways to say “firefox account”?

Basically yes. The idea is that each suffix represents something that's typically a separate word in English, and you can mix and match suffixes just as you'd mix words.

  • my account -> tilini
  • to an account -> tilille
  • to my account -> tililleni
  • to my account too -> tilillenikin
[-] cgtjsiwy@programming.dev 12 points 1 year ago

As a Finnish speaker, I just can't see generic localisation systems like Fluent working with agglutinative languages. For instance, consider the Polish example for Firefox Account from Fluent's front page:

-sync-brand-name = {$case ->
   *[nominative] Konto Firefox
    [genitive] Konta Firefox
    [accusative] Kontem Firefox
}

In Finnish, this would be called Firefox-tili. Tili means account and belongs to the Kotus type 5 words, which specifies how the word is inflected with various suffixes. Fluent doesn't support agglutination, so you'd have to specify every form of the word separately:

-sync-brand-name = {$case ->
    [nominative] Firefox-tili
    [partitive] Firefox-tiliä
    ... 10ish more inflections
    [nominative first person] Firefox-tilini
    [partitive first person] Firefox-tiliäni
    ... 10ish more inflections
    ... the above inflections but for 2nd and 3rd persons
    [nominative first person plural] Firefox-tilimme
    [partitive first person plural] Firefox-tiliämme
    ... 10ish more inflections
    ... the above inflections but for 2nd and 3rd persons plural
    [nominative first person questioning] Firefox-tilinikö
    [no idea what this is even called] Firefox-tilittömänäkin
    [no idea what this is even called 2] Firefox-tililleensäkään
    ... lots more
}

Ideally, you'd only specify that Firefox-tili is a type 5 word and the system generates all of that boilerplate.

[-] cgtjsiwy@programming.dev 14 points 1 year ago

Teams does actually have a sound cue when people join calls: high-pitched repeated beeps that most people can't hear due to presbycusis, and the few who do hear it think they're going crazy.

Related reddit thread.

[-] cgtjsiwy@programming.dev 6 points 2 years ago

Regular expressions are great and can always be matched in linear time with respect to the input string length.

The problem is that JS standard library RegExps aren't actually regular expressions, but rather a much broader language, which is impossible to implement efficiently. If RegExp switched to proper regular expressions, they would match much faster but supporting backreferences like /(.*)x\1/ would be impossible.

[-] cgtjsiwy@programming.dev 12 points 2 years ago

It would be much easier to read if it was actually table, i.e., if hex codes and the characters were separated into their own columns.

[-] cgtjsiwy@programming.dev 58 points 2 years ago

My workplace has the opposite problem.

The company has been in dire need of programmers for years, so they hired people (including myself) without tests. However, the work involves lots of custom iterators and the occasional handcrafted parser, which most of the company is incapable of writing. The bright side is that management has their metrics mostly right, so I'm getting lots of raises for solving fun problems.

[-] cgtjsiwy@programming.dev 3 points 2 years ago

Agreed. I think operator overloading is a necessary feature in any math-oriented or general-purpose language. Being able to write formulae the same way as they're written in the source paper is a huge boon to readability.

[-] cgtjsiwy@programming.dev 3 points 2 years ago

What is the median amount of times you end up shuffling the array before it is sorted?

The answer is n! where n is length of the array.

I assume you meant mean instead of median. The median of a geometric distribution with parameter p is ceil(-1/log~2~(1-p)).

[-] cgtjsiwy@programming.dev 5 points 2 years ago

The author wanted "a more powerful type of inference that can actually infer the whole type of a function by analyzing the body of the function", which Rust doesn't have by design.

[-] cgtjsiwy@programming.dev 3 points 2 years ago* (last edited 2 years ago)

Although I’ve used a number of languages including Python, Javascript, and Go to build software, the bulk of my experience is working in Java.

Notably, Python's type annotations are extremely similar to Typescript. I guess the author hadn't used Python's type annotations very much (which is understandable considering they're often missing from libraries and the implementations are buggier than Typescript).

view more: next ›

cgtjsiwy

joined 2 years ago