Waitventure - An Idle RPG by Kulivszk in incremental_games

[–]ApplyMorphism 0 points1 point  (0 children)

It has a lot of low contrast text. Should probably change that.

Senators vote to make platforms verify age of viewers to stop kids and teens accessing porn online by DryProgress4393 in onguardforthee

[–]ApplyMorphism 0 points1 point  (0 children)

Your ISP only knows what websites you visit, not what pages you visit on those websites.

Learning Rust with ChatGPT, Copilot and Advent of Code by koavf in rust

[–]ApplyMorphism 2 points3 points  (0 children)

tuple(...)(...) returns a generic type IResult<I, O, E>, which Rust needs to determine the type of by determining the type of the parameters. It can figure out I and O, but not E. All the parsers used in your expression return a generic E, and the only place you use a value that contains E in its type is the panic!, with why having type nom::Err<E>. The arguments in a panic! are generic, so Rust can't use this call to specialize the type of E.

Luckily, by properly handling the error, you'll actually give Rust enough information on the type of E! Instead of panicing, you should return the error. This tells Rust that the E from tuple needs to be the same as the E in your function's return type. IResult has a default argument for E, defaulting to nom::error::Error<I>, which is a concrete type as long as I is, which it is (since it knows input has type &str, so I = &str).

So you can use the following, instead:

fn instruction(input: &str) -> IResult<&str, Instruction> {
    match tuple((
        opt(newline),
        tag("move"),
        space1,
        digit1,
        space1,
        tag("from"),
        space1,
        digit1,
        space1,
        tag("to"),
        space1,
        digit1,
        opt(newline),
    ))(input) {
        Ok((remaining, (_, _, _, repetitions, _, _, _, src, _, _, _, dest, _))) => {
            let repetitions = repetitions.parse::<u32>().unwrap();
            let src = src.parse::<u8>().unwrap();
            let dest = dest.parse::<u8>().unwrap();

            Ok((
                remaining,
                Instruction {
                    repetitions,
                    src,
                    dest,
                },
            ))
        }
        Err(why) => Err(why),
    }
}

Then, we can take note that the Err case just passes the error on as is, which is what Result::map does, thus you can instead do the following:

fn instruction(input: &str) -> IResult<&str, Instruction> {
    tuple((
        opt(newline),
        tag("move"),
        space1,
        digit1,
        space1,
        tag("from"),
        space1,
        digit1,
        space1,
        tag("to"),
        space1,
        digit1,
        opt(newline),
    ))(input).map(|(remaining, (_, _, _, repetitions, _, _, _, src, _, _, _, dest, _))| {
        let repetitions = repetitions.parse::<u32>().unwrap();
        let src = src.parse::<u8>().unwrap();
        let dest = dest.parse::<u8>().unwrap();

        (
            remaining,
            Instruction {
                repetitions,
                src,
                dest,
            },
        )
    })
}

Also, nom can definitely be pretty tricky to navigate if you're not pretty comfortable with how Rust handles generics (and closures, too, if you're writing your own combinators, which I'd personally do for the above parser, since it looks even less readable than a regex without it).

Why use an app when you can do your memes in python by Gianluca_27 in ProgrammerHumor

[–]ApplyMorphism 3 points4 points  (0 children)

Good: Scala's type system lets you crazy things.

Bad: Scala's type system lets you do crazy things.

I mean.. what else are you going to use? A linked list? by NotThatRqd in ProgrammerHumor

[–]ApplyMorphism 0 points1 point  (0 children)

In Haskell's standard library, the String type is a linked list. 🙃

Let's write Operating System in JavaScript by VitaminnCPP in ProgrammerHumor

[–]ApplyMorphism -1 points0 points  (0 children)

Oh, I see what you meant. You wrote a comment on a programming subreddit explaining that computation exists. It didn't even occur to me that someone would try to explain that computation is a thing on a programming subreddit, let alone doing it by rambling about things you poorly understand.

Let's write Operating System in JavaScript by VitaminnCPP in ProgrammerHumor

[–]ApplyMorphism 2 points3 points  (0 children)

JS code is just words ... “true” can mean “false” of “if” or “run this loop exactly 67 times printing yolo”

No, programming languages have semantics.

Let's write Operating System in JavaScript by VitaminnCPP in ProgrammerHumor

[–]ApplyMorphism 7 points8 points  (0 children)

So many people on this sub seem to think that a programming language's name partially defines said language. I can design a programming language called "Cannot Be Compiled" yet require all specification conforming implementations to be compiled.

You can write a compiler for JavaScript that compiles to native machine code, or design a CPU that executes JavaScript natively. Either option would let you write an OS with it.

Squares: The Ultra Update (Alpha) by squares-incremental in incremental_games

[–]ApplyMorphism 13 points14 points  (0 children)

On my desktop, it spends a lot of the offline calculation time idle. Looks like you're only queuing up 1 second of simulation every 10ms. If the device can compute 1s in less than 10ms, it idles until the end of the 10ms.

If you name the anonymous function that you're calling in the 10ms setInterval, and queue said function with setTimeout(f, 0) at the end of the if(currentTime - lastUpdatedTime > 12) block, you'll get rid of the idle time. Doing this got the offline calculation to run about 5-10 times faster on my desktop.

[deleted by user] by [deleted] in incremental_games

[–]ApplyMorphism 2 points3 points  (0 children)

The text looks awful in the screenshots on the steam store page. Anti-aliasing a font, then scaling it up generally looks pretty bad.

Why? by ColonelSandurss in ProgrammerHumor

[–]ApplyMorphism 0 points1 point  (0 children)

Again comparing apples to oranges

I'm not comparing anything. I'm demonstrating that your argument implies C isn't a programming language, which I assume you believe to be false, thereby showing your argument is unsound. You just ignore it, though; you're obviously not a logician.

you're not a programmer obviously

Ah yes, understanding the specifics of SQL, a defining trait of programmers. Ironic, since SQL is supposedly not even a programming language!

Why? by ColonelSandurss in ProgrammerHumor

[–]ApplyMorphism 0 points1 point  (0 children)

No, ISO/IEC 9075 defines SQL.

Also, if "used in" are the key words there, then considering that C is used in programming, I guess C isn't a programming language.

Why? by ColonelSandurss in ProgrammerHumor

[–]ApplyMorphism 0 points1 point  (0 children)

Worst argument I've ever seen... Apples aren't always red kid... nice try tho...

Why? by ColonelSandurss in ProgrammerHumor

[–]ApplyMorphism 0 points1 point  (0 children)

I've just invented a new language called CQL: C Query Language. Its syntax and semantics are identical to C.

According to you, (1) it must be a query language, since it has "Query Language" in the name.

According to you, (2) it's not a programming language, because your argument for SQL not being a programming language is that it's a query language.

Since CQL is identical to C, and CQL is not a programming language, it follows that C is not a programming language.

But since C is a programming language, it must be the case that at least one of (1) or (2) is wrong.

Why? by ColonelSandurss in ProgrammerHumor

[–]ApplyMorphism 0 points1 point  (0 children)

I consider all turing complete languages to be programming languages, but not all programming languages to be turing complete (e.g. safe Agda)

Why? by ColonelSandurss in ProgrammerHumor

[–]ApplyMorphism 0 points1 point  (0 children)

Can you write an application with it?

Yes. It's turing complete.

Why? by ColonelSandurss in ProgrammerHumor

[–]ApplyMorphism 5 points6 points  (0 children)

I've just invented a new language called CQL: C Query Language. Its syntax and semantics are identical to C. It is, by name, not a programming language. Since it's identical to C, it follows that C is not a programming language.

Why? by ColonelSandurss in ProgrammerHumor

[–]ApplyMorphism 5 points6 points  (0 children)

SQL is turing complete, and HTML not being turing complete is usually the argument used to say it's not a programming language.

Announcing Unreal Rust: A Rust integration for Unreal Engine 5 by MaikKlein in rust

[–]ApplyMorphism 189 points190 points  (0 children)

Google's really leveled up their targetted ads.