Programming thread

Haven't companies been using AI pretty extensively for at least 5-10 years now?
Actual Indians, who are arguably more of a threat to a codebase than any real AI
I heard the start menu in Windows 11 is a React native app now. Most pajeet thing I have heard in years.

Whether it was made by an LLM or a team of pajeets is up to reader interpretation and speculation. Regardless, the result is bloat and noticeable lag from what I've read.

Edit: Related link (archive)
Today I learned that Microsoft incorporates React Native into certain parts of the Windows 11 system UI. They're using it for bits of the Start menu, as shown at ReactConf, and also in sections of the Settings app, as discussed in a Microsoft Devblog.

But here's the thing: why? I've been watching loads of sessions from this year's Microsoft Build, and I've learned that Microsoft is currently backing eight different UI frameworks for Windows, all getting updates. The main ones are .NET MAUI, which handles cross-platform UI, and WinUI 3, designed specifically for Windows. So, it's a bit baffling why they're going with React Native when they have frameworks they've built and optimized themselves for their OS.

The main downside of WinUI seems to be its performance issues, which Microsoft has acknowledged in the past, and keeps acknowledging still, going as far as having their partners recommend older WPF as an alternative for performance-critical applications. But even then, why stick with eight different frameworks when most of them could be swapped out with React Native? It's a bit of a head-scratcher, to be honest.
 
Last edited:
I heard the start menu in Windows 11 is a React native app now. Most pajeet thing I have heard in years.
Not too surprised but still had to look it up and found a video about it, they're using it for the "Recommended apps" part of the start menu, and also in (parts of) the settings app? Even Office isn't safe...
start.webp
settings.webp

word.webp
Here it's only the comment function but I'm sure that's not the only part using React.
Which might partly explain why they recently added a feature to make Office boot faster by just having it run as a background process until you actually want to use it, because apparently starting Office apps was beginning to take too long for some people.
 
I decided to do an annotated edit of your gamba sesh code in order to improve upon it, I hope that it helps you learn.
Thank you so much for this. I'm gonna be 100% honest with you I don't understand half of what's going on in that code. But I'm gonna dedicate myself to figuring it out and using that info to improve my game. I've got a "python for dummies" book sitting next to me that I should probably read.
 
I was able to update and revise my gamba game. I was able to implement a bunch of the changes Private Tag Reporter suggested (once again, thank you). I was able to keep the feature where once you start you can't stop, but I did add a secret way to end the game. Also I was able to get variable bets working.

Python:
import random

class Gamestate:
    def __init__(self,wins=0,losses=0,cash=100):
        self.wins = wins
        self.losses = losses
        self.cash = cash

    @staticmethod
    def start_game():
        return Gamestate()

def gamba_game(game_state):
    
    game_roll = random.randint(1,100)

    while True:

        bet = input("how much would you like to bet?: $")

        try:
            stake = int(bet)

            if stake > game_state.cash:
                print("You don't have that much money!")
            else:
                print(f"You bet ${stake}")

                if game_roll > 51:
                    print("Yes!")
                    game_state.wins = game_state.wins + 1
                    game_state.cash = game_state.cash + stake
                    print(f"You won ${stake}, \nyour balance is ${game_state.cash}")
                    break
                else:
                    print("No")
                    game_state.losses = game_state.losses + 1
                    game_state.cash = game_state.cash - stake
                    print(f"You lost ${stake}, \nyour balance is ${game_state.cash}")
                    break
        except ValueError:
            print("Invalid input")

def gamba_start(game_state):
    
    print(f"Welcome to the casino! \nYou have ${game_state.cash}.")

    while True:
        play =  input(f"Would you like to play?(yes/no): ")
        
        play = play.lower()

        match play:
            case "yes"|"y":
                gamba_sesh(game_state)
                break
            case "no"|"n":
                print("That's probably a good idea")
                break
            case _:
                print("Invalid input, please try again")

def gamba_sesh(game_state):

    gamba_game(game_state)

    while True:
        
        if game_state.cash <= 0:
            print("Dude I just lost it all")
            print(f"wins {game_state.wins}")
            print(f"losses {game_state.losses}")
            break
        else:
            play_again = input("Play again (yes/no): ")

            play_again = play_again.lower()
            
            match play_again:
                case "yes"|"y":
                    gamba_game(game_state)
                case "i need crack":
                    print("Oh shit guys I gotta go!")
                    break
                case _:
                    print("One more and I'm out!")
                    gamba_game(game_state)

game_state_start = Gamestate.start_game()
gamba_start(game_state_start)

I will say that I did ask ChatGPT for help on one of the problems I had, but ChatGPT didn't know how to fix it. It suggested a solution that straight up didn't work, twice, so I just had to figure out the solution myself. I'm really surprised that this relatively simple game is beyond ChatGPT's understanding. It looks like from here on out ChatGPT won't be able to help me, whether or not I want it to.

Did I fuck up in any major way?
 
Did I fuck up in any major way?
No, this is actually pretty solid code, but I do have some constructive advice if you're interested.

Your code is absolutely fine, these are nitpicks in case you're interested in learning more, feel free to disregard :)

1. In Python, the 'correct' way to have code run when the file is run is to use a __name__ guard. This is used so that if you use your code in another file, things that are meant to run as scripts don't trigger.

2. Any time you reuse something, i.e those match strings, (i.e. "yes"|"no", it's helpful to outline them as a variable. This makes it such that if you want to add say "sure" as an option, you only have to change it in one place. I'd also advice looking into the enum module if you start adding a lot of options, it's good for situations like this where you have a set of constant values

3. Whenever you read user input from the function, it's beneficial to catch KeyboardInterrupt, which happens if the user uses Ctrl+C in the terminal. This is a really common pattern in any command line software.

Instead of
Python:
play_again = input("Play again (yes/no): ")

You would do
Python:
try:
    play_again = input("Play again (yes/no): ")
except KeyboardInterrupt:
    break # or handle quitting however you'd prefer

4. In gamba_game you don't need to put the totality of your code in the try block, you can do one of two things
Python:
try:
    stake = int (bet)
except ValueError:
   print("Invalid input")
   continue
# <- rest of code after

Or,

Python:
try:
    stake = int (bet)
except ValueError:
   print("Invalid input")
else:
   # <- rest of code after

Being precise with the scope at which you catch exceptions is very helpful for debugging, also, more levels of nesting in code is what can be described as a 'code smell', something that feels like it could cause a problem. It also makes thing smore readable.

5. If you're using a newer editor like VSCode or whatever, they have support for static analysis, which helps you catch bugs and improves auto-completion in the editor. To that end, python provides something called type annotations. These are a utility for you while writing your code, and for others. They don't really influence the execution of your code, (though a lot of libraries use them for API bindings), but they're helpful.
By default, for functions, tools assumes function parameters without annotations to be typing.Any, and function return types to be None, though most will also try to infer it as well.

As an example, here would be Gamestate with them added

Python:
class Gamestate:
    def __init__(self, wins: int = 0, losses: int = 0, cash: int = 0):
        ... # You can annotated the member fields if you want, but most tools will infer it from the parameters in __init__
    
    @static_method
    def start_game() -> "Gamestate":  # You can wrap them in strings, this is helpful in instances like here where the type isn't technically defined yet
        return Gamestate()

for a function like gamba_start, you'd change def gamba_start(game_state): to def gamba_start(game_state: Gamestate):
 
Did I fuck up in any major way?
no and while the message above is comprehensive i will say that i personally try to account for spaces at the beginning or end of an input by using .strip() idk if thats unnecessary and im sure someone will let me know if it is but for example in a small tool im writing for myself where i take an input i put .strip() at the end of my inputs as well as try to catch spaces in my file handling. Again it may just be niggling over nothing but its what i try to practice:
Python:
def prompt_user_for_url():
    """Prompts user for the URLs they wish to download
    Function takes no arguments and returns a list of the URLs"""
    URLS = []
 
    while True:
        URL = input(
            "┌──────────────────────────────────────────────────────────┐\n"
            "│ Enter a video URL or the path to a .txt file of links    │\n"
            "│ ──────────────────────────────────────────────────────── │\n"
            "│ • Each URL in the file should be on its own line         │\n"
            "│ • Whitespace will be trimmed                             │\n"
            "│ • Leave blank and press [Enter] to proceed               │\n"
            "└──────────────────────────────────────────────────────────┘\n"
            "➤ Your input: "
        ).strip()
        #if the input is blank break the loop.
        if not URL:
            break
     
        #checks if the url variable is file
        if os.path.isfile(URL) :
            with open(URL, "r", encoding="utf-8") as file:
                URLS.extend([line.strip()for line in file if line.strip()
                print(f"✔ Loaded {len(URLS)} link{'s' if len(URLS) != 1 else ''} from the file.")
            break
        else:
            URLS.append(URL)
         
    return URLS

also if you want to customize the terminal in anyway you may want to look into the colorama module
 
Last edited:
What do kiwis think the best learner's first language is?
My first language was Java. I picked up a book and learned it. Now I code in primarily c++ with graphics libraries like SDL & SFML because I enjoy the potential speed and lower level language but I don't care to deal with the graphics when I'll never do that better myself anyway (I like doing things myself but that's too far even for me). Java is great in my opinion because it handles memory for you (in an inelegant way albeit), it's VERY object oriented (some dislike it for that but OOP is useful and easy to learn), it handles the graphics in an easy to understand way, and provides many intuitive standard functions/libraries. Python is the typical go to beginner's language but I've never used it so I can't say anything about it other than what I've heard. Probably comparable to Java. As far as I know it's a slower language, the knowledge learned isnt as interchangeable, and it does a little too much for the dev. The speed of Java has become more comparable to C++ in later years btw. Still slower but it's not bad.
Alternatively, should new learners just jump into a low level language immediatley and build up from the fundamental principles? Asking because a lot of nudevs have asked me where to start and I've essentially told them a simplified version of what I said in the spoiler but I've always been worried about misleading them. I have a unique drive to learn things which most people don't have so processes that work for me often don't work for others.
 
Last edited:
What do kiwis think the best learner's first language is?
x86 Assembly, rawdog the processor.

Probably some flavor of basic. Anything imperative with no manual memory management should put you in a good position for understanding how programming works at a conceptual level. Depending on what you want to do, you'll eventually need to move to a system programming language and learn how memory actually works. You can make an entire career out of never learning how memory works, but you'll never rise above being a mediocre programmer.
 
What do kiwis think the best learner's first language is?
in my opinion id start them with something like pascal, its rigid and everything is clear. they can get a hang of what the basics of programming is and still create some fairly useful stuff. then its a matter of what they want to do. if theyre content in working on highlevel stuff and dont care much about lowlevel systems then something like lua or python. maybe JS if theyre doing webdev stuff and then something like c or c++ if they want to do low level stuff. But im not a professional so is suppose someone who works in the industry may have other opinions.
 
]Probably some flavor of basic. Anything imperative with no manual memory management should put you in a good position for understanding how programming works at a conceptual level.
in my opinion id start them with something like pascal, its rigid and everything is clear. they can get a hang of what the basics of programming is and still create some fairly useful stuff.
Pascal and BASIC are definitely dated. Pascal probably less so but either way it doesn't matter much for learning languages. I like the simplicity of the syntax of both, they have very clear terminology and conventions. Pascal has some weird stuff going on with it. It's not too much of a hurdle but it would be weird swapping over to the modern languages after that. I think BASIC wins for its extreme simplicity. Someone could definitely have some fun screwing around with it for a while before swapping to something legit. Most of the total newfags I've dealt with would be fine if they started by really comprehending basic crap like if statements and for loops anyway geg. Good answers thanks.
I should consider just suggesting lua at this point since it shares these benefits and it's a common scripting language.
 
x86 Assembly, rawdog the processor.

Probably some flavor of basic. Anything imperative with no manual memory management should put you in a good position for understanding how programming works at a conceptual level. Depending on what you want to do, you'll eventually need to move to a system programming language and learn how memory actually works. You can make an entire career out of never learning how memory works, but you'll never rise above being a mediocre programmer.
I think for learning, ARM is probably preferable. The reduced instruction set I think focuses attention
 
  • Like
  • Thunk-Provoking
Reactions: y a t s and bashe
What do kiwis think the best learner's first language is?
IMO some flavour of Java, Javascript, or Python (hell even v8+ PHP), especially for those with no prior understanding of what code is. The idea here is to get a grasp of how programs flow, basic data types, and core constructs like conditionals and loops. I'd immediately move anyone who quickly picks up on those concepts to C/C++ to get into memory management so they build an appreciation for just what higher level languages internally handle and abstract away. The key challenge is establishing a strong knowledge of the fundamentals before getting into the real meat of programming, something which higher level languages often speed up the process with given the ease of producing usable things. Already seen far too many devs screw up technical interviews because they glossed over the basic stuff in their learning in favour of the "interesting" concepts.
 
  • Agree
Reactions: Moonson
What makes code "jeet code" and how can I avoid making code like that?
imo the most pajeet code is that which tries to hammer a round peg into a square hole. They find all sorts of horrific ways to avoid learning something new and potentially complex, such as memory management or a proper systems language. For example, the React Native start menu shit from above or Electron apps that take up around 500 MB per binary.

There is nothing inherently wrong with being a beginner or being ignorant, but the main issue is these pajeet products are then used in production-level software and unleashed unto the public. Most of the time, they're collecting a paycheque for this slop.

>Why bother learning how to program UIs, understand memory management, better yourself, or learn anything other than fucking javascript if you don't have to? This attitude—this lack of care and inquisitiveness—is the epitome of imported, brown labor.
 
What do kiwis think the best learner's first language is?
I think your opinion really gets lost a bit in the weeds. It's not productive for example, for a beginner to worry about things like language speed. Even trying to find an "optimal" learning language in the first place is a bit of a trap. It's much more important to pick a language and stick with it through at least the first hurdles of "thinking like a computer" and nailing variables, flow control and basic principles behind function design.

If you really push me for a concrete suggestion I end up emphasizing how quickly typed code yields feedback. I started programming in VB6 and it was a good experience because the feedback was practically instant. Anything integrated like HTML/JavaScript or with a REPL like Python or Scheme
 
imo the most pajeet code is that which tries to hammer a round peg into a square hole. They find all sorts of horrific ways to avoid learning something new and potentially complex, such as memory management or a proper systems language. For example, the React Native start menu shit from above or Electron apps that take up around 500 MB per binary.

There is nothing inherently wrong with being a beginner or being ignorant, but the main issue is these pajeet products are then used in production-level software and unleashed unto the public. Most of the time, they're collecting a paycheque for this slop.

>Why bother learning how to program UIs, understand memory management, better yourself, or learn anything other than fucking javascript if you don't have to? This attitude—this lack of care and inquisitiveness—is the epitome of imported, brown labor.
terry had a word for this, niggerlicious
 
Back