The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.

[Programming] Initial commit

1679111228

Posts

  • LD50LD50 Registered User regular
    What I really want is for Microsoft to replace the shell with a Ruby environment.

  • bowenbowen Sup? Registered User regular
    Tomanta wrote: »
    The little I have done in PowerShell just makes me question if any of the designers had ever seen another programming language before. Seems like every design decision was "No, most languages do it this way so let's do something completely different."

    Listen apple can't be the only one who gets to do that.

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • This content has been removed.

  • EchoEcho ski-bap ba-dapModerator, Administrator admin
    Tomanta wrote: »
    The little I have done in PowerShell just makes me question if any of the designers had ever seen another programming language before. Seems like every design decision was "No, most languages do it this way so let's do something completely different."

    Ah yes, the Lipton approach.

  • TomantaTomanta Registered User regular
    Orca wrote: »
    Tomanta wrote: »
    The little I have done in PowerShell just makes me question if any of the designers had ever seen another programming language before. Seems like every design decision was "No, most languages do it this way so let's do something completely different."

    I honestly think a lot of it is trying to allow things to kinda-sorta-if-you-squint work like batch scripts or something, which of course fucks everything up and now you need to adjust for it

    I'm not saying it was the right decision, but there's gotta be some kind of logic behind it, however stupid the reasoning was

    Funny thing is I have two PowerShell scripts at work (because I couldn't get approval for Python and they suggested that for my use cases). I have to use a separate batch script to run them because I also don't have permission to run the PowerShell script by itself.

    While I could use it to automate more of my stuff I really don't want to.

  • EchoEcho ski-bap ba-dapModerator, Administrator admin
    *helps another team with an issue, updates sign*

    f85ak6d8hhml.png

  • jothkijothki Registered User regular
    I really need to actually make something with React, rather than just reading about it and trying small examples. I'm tempted to try an idle game? It seems like a good balance of interface design, data flow, and event handling, while being limited in scope but possibly expandable. Maybe I could hook a high score table to it once I get around to database servers?

  • dporowskidporowski Registered User regular
    Yes, but have you considered "don't touch React with someone else's 10' pole?"

  • jothkijothki Registered User regular
    dporowski wrote: »
    Yes, but have you considered "don't touch React with someone else's 10' pole?"

    I'd love to, but I'd love to be able to apply to jobs that have React experience as a prerequisite more.

  • jothkijothki Registered User regular
    edited August 2023
    Well, I've made the world's shittiest idle game. I suppose the next step on my journey of moderate discovery should be to try to host it on AWS (I've only used Azure before)?

    I've also managed to get myself back into playing Cookie Clicker, which could be argued to be anti-progress.

    jothki on
  • JasconiusJasconius sword criminal mad onlineRegistered User regular
    does your game involve a sql database...? because databases are gigabux on AWS these days. but i suppose it would fit in the free tier

    im not exactly sure what sort of journey you're on but learning to configure a basic stack on a cheap vm is probably as valuable as anything

    this is a discord of mostly PA people interested in fighting games: https://discord.gg/DZWa97d5rz

    we also talk about other random shit and clown upon each other
  • schussschuss Registered User regular
    Eh, they're not bad. Micro is less than 2 cents an hour.
    https://aws.amazon.com/rds/postgresql/pricing/

  • exisexis Registered User regular
    Apparently the author of Moq introduced code that scans your local git config and sends your email address off to a closed-source service without permission.

    I'm guessing a lot of companies (including mine), will be either capping versions or just disallowing Moq altogether. Which... given how widely we use it, is a huge PITA.

  • gavindelgavindel The reason all your software is brokenRegistered User regular
    exis wrote: »
    Apparently the author of Moq introduced code that scans your local git config and sends your email address off to a closed-source service without permission.

    I'm guessing a lot of companies (including mine), will be either capping versions or just disallowing Moq altogether. Which... given how widely we use it, is a huge PITA.

    Welp. So much for that.

    Book - Royal road - Free! Seraphim === TTRPG - Wuxia - Free! Seln Alora
  • jothkijothki Registered User regular
    schuss wrote: »
    Eh, they're not bad. Micro is less than 2 cents an hour.
    https://aws.amazon.com/rds/postgresql/pricing/

    Which would probably still be overpaying for my use case of just throwing something together to make sure that I can get it set up and have data flowing correctly, though I suppose I could shut it down when I'm not testing it.

    In this case it would be something like a high score table of me and whatever alternate names I want to set up, fed into some sort of pop-up interface that I don't even know how to make yet but couldn't be that difficult, right?

  • jothkijothki Registered User regular
    Oh hey, I have an actual React question that I'm having trouble digging up an answer for. For my idle game, I'm trying to use useEffect() to set up a function to automatically give money based on building counts at every tick, like so:
    useEffect(() => {
      const interval = setInterval(() => {
        earnMoney(money, setMoney, buildingcounts, gamedata.buildings);
      }, 1000);
      return () => clearInterval(interval);
    }, [money,buildingcounts,gamedata.buildings]);
    

    I'm facing an issue where if I don't include money and buildingcounts in the dependencies, then earnMoney won't recognize when those values have changed. However, if they are there, any change to any of the dependencies will result in the interval being reset, which is particularly noticeable if the player is spamming the button to get more money.

    What's the right pattern to use for this?

  • InfidelInfidel Heretic Registered User regular
    jothki wrote: »
    Oh hey, I have an actual React question that I'm having trouble digging up an answer for. For my idle game, I'm trying to use useEffect() to set up a function to automatically give money based on building counts at every tick, like so:
    useEffect(() => {
      const interval = setInterval(() => {
        earnMoney(money, setMoney, buildingcounts, gamedata.buildings);
      }, 1000);
      return () => clearInterval(interval);
    }, [money,buildingcounts,gamedata.buildings]);
    

    I'm facing an issue where if I don't include money and buildingcounts in the dependencies, then earnMoney won't recognize when those values have changed. However, if they are there, any change to any of the dependencies will result in the interval being reset, which is particularly noticeable if the player is spamming the button to get more money.

    What's the right pattern to use for this?

    Your game logic like earnMoney shouldn't be in your presentation layer (which is what React code here is).

    You'll want to find some other pattern for storing and interacting with game state, there's a lot of ways to go about it but the principle is you should not combine it here.

    OrokosPA.png
  • jothkijothki Registered User regular
    Infidel wrote: »
    jothki wrote: »
    Oh hey, I have an actual React question that I'm having trouble digging up an answer for. For my idle game, I'm trying to use useEffect() to set up a function to automatically give money based on building counts at every tick, like so:
    useEffect(() => {
      const interval = setInterval(() => {
        earnMoney(money, setMoney, buildingcounts, gamedata.buildings);
      }, 1000);
      return () => clearInterval(interval);
    }, [money,buildingcounts,gamedata.buildings]);
    

    I'm facing an issue where if I don't include money and buildingcounts in the dependencies, then earnMoney won't recognize when those values have changed. However, if they are there, any change to any of the dependencies will result in the interval being reset, which is particularly noticeable if the player is spamming the button to get more money.

    What's the right pattern to use for this?

    Your game logic like earnMoney shouldn't be in your presentation layer (which is what React code here is).

    You'll want to find some other pattern for storing and interacting with game state, there's a lot of ways to go about it but the principle is you should not combine it here.

    Inconvenient, but probably the useful sort of inconvenient, I suppose.

  • Ear3nd1lEar3nd1l Eärendil the Mariner, father of Elrond Registered User regular
    You're probably going to want some kind of state management, like Contexts, Redux, etc. Does this game have any 3d elements? If you are using something like ThreeJS, you'll probably want to use zustand to handle state because it's much faster than Redux or Contexts. If you aren't, then ignore the last sentence.

  • TelMarineTelMarine Registered User regular
    gavindel wrote: »
    exis wrote: »
    Apparently the author of Moq introduced code that scans your local git config and sends your email address off to a closed-source service without permission.

    I'm guessing a lot of companies (including mine), will be either capping versions or just disallowing Moq altogether. Which... given how widely we use it, is a huge PITA.

    Welp. So much for that.

    Reading through the Github issue comments was interesting. Bottom line, and I don't blame him, the guy wants to get paid for his hard work. I agree, and companies way too often take advantage of open source stuff because it's "free". It's been interesting to me to see how much open source is powering all these start-ups. The reality is though, if you wanna make money, then treat it as such. Reality is reality. Companies will do whatever is the cheapest and easiest thing, every time.

    3ds: 4983-4935-4575
  • Zilla360Zilla360 21st Century. |She/Her| Trans* Woman In Aviators Firing A Bazooka. ⚛️Registered User regular
    I CAN HAZ FIZZBUZZ?
    HAI
     I HAS A CHEEZBURGER ITZ 1
     IM IN YR LOOP UPPIN YR CHEEZBURGER WILE BOTH SAEM CHEEZBURGER AN SMALLR OF CHEEZBURGER AN 100
    	I HAS A THREE ITZ BOTH SAEM MOD OF CHEEZBURGER AN 3 AN 0
    	I HAS A FIVE ITZ BOTH SAEM MOD OF CHEEZBURGER AN 5 AN 0
    	EITHER OF THREE AN FIVE, O RLY?
    	YA RLY
    	THREE, O RLY?
    	 YA RLY, VISIBLE "FIZZ"!
    	OIC
    	FIVE, O RLY?
    	 YA RLY, VISIBLE "BUZZ"!
    	OIC
    	VISIBLE ""
    	NO WAI
    	VISIBLE CHEEZBURGER
    	OIC
     IM OUTTA YR LOOP
     KTHXBYE
    

  • Ear3nd1lEar3nd1l Eärendil the Mariner, father of Elrond Registered User regular
    I love LOLCODE, gets a good chuckle out of me every time.

  • PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    edited August 2023
    TelMarine wrote: »
    gavindel wrote: »
    exis wrote: »
    Apparently the author of Moq introduced code that scans your local git config and sends your email address off to a closed-source service without permission.

    I'm guessing a lot of companies (including mine), will be either capping versions or just disallowing Moq altogether. Which... given how widely we use it, is a huge PITA.

    Welp. So much for that.

    Reading through the Github issue comments was interesting. Bottom line, and I don't blame him, the guy wants to get paid for his hard work. I agree, and companies way too often take advantage of open source stuff because it's "free". It's been interesting to me to see how much open source is powering all these start-ups. The reality is though, if you wanna make money, then treat it as such. Reality is reality. Companies will do whatever is the cheapest and easiest thing, every time.

    You can't make money doing open source because unless you're an employee tasked to work on project X or I guess you're Linus nobody will pay you to do so. Being the maintainer of a popular library is probably the worst job in the world

    Phyphor on
  • EtheaEthea Registered User regular
    edited August 2023
    Even Linus was hired by a company to ensure Linux continued(transmeta) before he moved to the OSF( and now LSF ).

    The key part is that LSF is still a company, and even better a non-profit. Same thing has happened with python and the PSF. Companies love getting “something” for donations, so most of these foundations will tie the money to support or training.

    You will go insane talking with legal if you ever want to donate money directly to a individual developer.

    Ethea on
  • TelMarineTelMarine Registered User regular
    Phyphor wrote: »
    TelMarine wrote: »
    gavindel wrote: »
    exis wrote: »
    Apparently the author of Moq introduced code that scans your local git config and sends your email address off to a closed-source service without permission.

    I'm guessing a lot of companies (including mine), will be either capping versions or just disallowing Moq altogether. Which... given how widely we use it, is a huge PITA.

    Welp. So much for that.

    Reading through the Github issue comments was interesting. Bottom line, and I don't blame him, the guy wants to get paid for his hard work. I agree, and companies way too often take advantage of open source stuff because it's "free". It's been interesting to me to see how much open source is powering all these start-ups. The reality is though, if you wanna make money, then treat it as such. Reality is reality. Companies will do whatever is the cheapest and easiest thing, every time.

    You can't make money doing open source because unless you're an employee tasked to work on project X or I guess you're Linus nobody will pay you to do so. Being the maintainer of a popular library is probably the worst job in the world

    I bet. If you read the author's, "kzu", comments, eventually he says (me paraphrasing) "I want to write open source code every day and get compensated for it". Well...then you gotta treat it as a business and figure out a way to charge. This kinda stuff seems to come up every now and then, I'm surprised it doesn't happen more often. Other times it has blown up that I'm aware of was a popular Javascript library was handed over to someone who turned it malicious (events-mapper or something). I remember the debate there was people were admonishing the original creator, but in summary he said "fuck off I didn't want to maintain it anymore". Especially in this day and age where seemingly every random dependency bad actors are looking for exploits, it truly must be one of the hardest jobs.

    3ds: 4983-4935-4575
  • KupiKupi Registered User regular
    Hello fellow programmers! I am here with a gentle reminder: if you ever, at any time, write a program whose sole output upon failing is to say "Failed to do the thing", you are going straight to Hell. There are at least two different possible causes of failure for any program you're going to present to someone else and they need to be able to distinguish them.

    In my specific case, I'm trying to provide an icon for the MacOS build of an application, and MacOS has a special format for icon files called ICNS. Unless you want to trust an online conversion tool (I do not), you need to use the iconutil command-line tool to process a folder full of image files of various resolutions. Evidently this tool is extremely persnickety about the file format, file names, alpha channel, PPI settings, and so on. And if it fails, it says: "Failed to generate ICNS." Wrong format? Did I forget an alpha channel? Which file, specifically, is at issue? Dunno! Try again! Maybe read the docs (if you can find the right ones (the man page for iconutil does not mention the format requirements)).

    ... I did manage to get it to work, by meticulously resaving my icon files according to a schedule I found three entries down in a StackOverflow question on the subject (https://stackoverflow.com/questions/12306223/how-to-manually-create-icns-files-using-iconutil). Same as it ever was. But man am I ever left with a sour taste in my mouth.

    My favorite musical instrument is the air-raid siren.

    I'm "kupiyupaekio" on Discord.
  • LD50LD50 Registered User regular
    Kupi wrote: »
    Hello fellow programmers! I am here with a gentle reminder: if you ever, at any time, write a program whose sole output upon failing is to say "Failed to do the thing", you are going straight to Hell. There are at least two different possible causes of failure for any program you're going to present to someone else and they need to be able to distinguish them.

    In my specific case, I'm trying to provide an icon for the MacOS build of an application, and MacOS has a special format for icon files called ICNS. Unless you want to trust an online conversion tool (I do not), you need to use the iconutil command-line tool to process a folder full of image files of various resolutions. Evidently this tool is extremely persnickety about the file format, file names, alpha channel, PPI settings, and so on. And if it fails, it says: "Failed to generate ICNS." Wrong format? Did I forget an alpha channel? Which file, specifically, is at issue? Dunno! Try again! Maybe read the docs (if you can find the right ones (the man page for iconutil does not mention the format requirements)).

    ... I did manage to get it to work, by meticulously resaving my icon files according to a schedule I found three entries down in a StackOverflow question on the subject (https://stackoverflow.com/questions/12306223/how-to-manually-create-icns-files-using-iconutil). Same as it ever was. But man am I ever left with a sour taste in my mouth.

    It's important to remember any time you are interacting with Apple as a developer or as a consumer, that Apple hates you.

  • TelMarineTelMarine Registered User regular
    Does macOS have some equivalent of strace? maybe you can get lucky

    3ds: 4983-4935-4575
  • dporowskidporowski Registered User regular
    Admittedly, I've not done MacOS at all, but I'm a little surprised you don't just feed Xcode your images and let it do the rest. (Same way you do the other platforms.) In fairness they do have some particular requirements per-platform in terms of layering etc, but again, I'm used to Xcode just "handling it". Admittedly this is a definition of "handling it" that involves a hammer, the word "FUCK" and a black chicken, but still.

  • jothkijothki Registered User regular
    Ear3nd1l wrote: »
    You're probably going to want some kind of state management, like Contexts, Redux, etc. Does this game have any 3d elements? If you are using something like ThreeJS, you'll probably want to use zustand to handle state because it's much faster than Redux or Contexts. If you aren't, then ignore the last sentence.

    Anything remotely fancy would probably be overkill. This thing is as barebones as it gets.

    Would the best pattern to use be to create a class that runs the game entirely on its own (including scheduled intervals for gaining income) , pass the interface hooks into the top level of the react components, and then have the top level component set up its own scheduled polling on the game class? That wouldn't match the game loop exactly, but it would probably be close enough for my purposes.

    Thinking back to Cookie Clicker, it is noticeable that upgrades can take a little while to appear once you've unlocked them, and multiple ones will appear at once in batches. I'm guessing that's probably that sort of polling in action?

  • PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    Kupi wrote: »
    Hello fellow programmers! I am here with a gentle reminder: if you ever, at any time, write a program whose sole output upon failing is to say "Failed to do the thing", you are going straight to Hell. There are at least two different possible causes of failure for any program you're going to present to someone else and they need to be able to distinguish them.

    In my specific case, I'm trying to provide an icon for the MacOS build of an application, and MacOS has a special format for icon files called ICNS. Unless you want to trust an online conversion tool (I do not), you need to use the iconutil command-line tool to process a folder full of image files of various resolutions. Evidently this tool is extremely persnickety about the file format, file names, alpha channel, PPI settings, and so on. And if it fails, it says: "Failed to generate ICNS." Wrong format? Did I forget an alpha channel? Which file, specifically, is at issue? Dunno! Try again! Maybe read the docs (if you can find the right ones (the man page for iconutil does not mention the format requirements)).

    ... I did manage to get it to work, by meticulously resaving my icon files according to a schedule I found three entries down in a StackOverflow question on the subject (https://stackoverflow.com/questions/12306223/how-to-manually-create-icns-files-using-iconutil). Same as it ever was. But man am I ever left with a sour taste in my mouth.

    Output an error message? How user friendly, exit(1) is all anyone should need

  • dporowskidporowski Registered User regular
    Kupi wrote: »
    Hello fellow programmers! I am here with a gentle reminder: if you ever, at any time, write a program whose sole output upon failing is to say "Failed to do the thing", you are going straight to Hell. There are at least two different possible causes of failure for any program you're going to present to someone else and they need to be able to distinguish them.

    In my specific case, I'm trying to provide an icon for the MacOS build of an application, and MacOS has a special format for icon files called ICNS. Unless you want to trust an online conversion tool (I do not), you need to use the iconutil command-line tool to process a folder full of image files of various resolutions. Evidently this tool is extremely persnickety about the file format, file names, alpha channel, PPI settings, and so on. And if it fails, it says: "Failed to generate ICNS." Wrong format? Did I forget an alpha channel? Which file, specifically, is at issue? Dunno! Try again! Maybe read the docs (if you can find the right ones (the man page for iconutil does not mention the format requirements)).

    ... I did manage to get it to work, by meticulously resaving my icon files according to a schedule I found three entries down in a StackOverflow question on the subject (https://stackoverflow.com/questions/12306223/how-to-manually-create-icns-files-using-iconutil). Same as it ever was. But man am I ever left with a sour taste in my mouth.

    Soooooo okay I just tested this in a very half-assed manner locally, but.

    Completely new MacOS only project, Xcode 14 latest, you can just grab any old image--I used a jpg I had lying around--and as long as it's the right dimensions, you can drop it into the asset catalog and Xcode seems to just do the thing. (Or at least, I've got a running app with the icon I stuffed in, anyway.)

    I suspect this would be much prettier if I--as on iOS--used a properly vector PDF as the source so it scaled better, but yeah, for next time you can just make Xcode do it for you. Usually for assets you want a pdf at each resolution though, so 1024x1024, etc etc. NBD in my experience, though.

  • jothkijothki Registered User regular
    edited August 2023
    So I was thinking of maybe creating an interface that could represent either a locally-running game or a connection to a game server. Which led me to rediscover another one of Javascript's horrors, duck typing. I might implement an extended interface class anyway just out of spite.

    jothki on
  • DisruptedCapitalistDisruptedCapitalist I swear! Registered User regular
    edited August 2023
    Meh, admittedly I got my start in JS and recently in Python which both fo Duck typing, but it's always seemed intuitive to me.

    I don't want to have to import a duck class just to be a duck. Look at me! I'm quacking!

    Of course, JavaScript is the language which allows this delightful nonsense 1 + 1 + "1" == 21

    DisruptedCapitalist on
    "Simple, real stupidity beats artificial intelligence every time." -Mustrum Ridcully in Terry Pratchett's Hogfather p. 142 (HarperPrism 1996)
  • jothkijothki Registered User regular
    Of course, JavaScript is the language which allows this delightful nonsense 1 + 1 + "1" == 21

    That's actually something that I'm slightly okay with? Being able to do something like ("There are " + numAnimals + " animals") is something that many sane languages will let you get away with and is probably a net good, and that's nothing more than an extension of the logical typecasting principles. Heck, I just tested it out in C# and it did exactly the same thing.

  • DisruptedCapitalistDisruptedCapitalist I swear! Registered User regular
    edited August 2023
    Huh. I didn't think C allowed it, but maybe that's C++

    Edit: But I tried it in Python and it complained.

    DisruptedCapitalist on
    "Simple, real stupidity beats artificial intelligence every time." -Mustrum Ridcully in Terry Pratchett's Hogfather p. 142 (HarperPrism 1996)
  • TelMarineTelMarine Registered User regular
    edited August 2023
    Huh. I didn't think C allowed it, but maybe that's C++

    Edit: But I tried it in Python and it complained.

    Java will automatically convert ints and other objects to strings (I believe by calling its .toString() method) in a print statement or other cases

    TelMarine on
    3ds: 4983-4935-4575
  • SaerisSaeris Borb Enthusiast flapflapflapflapRegistered User regular
    Automatic X-to-string coercion is fine and good and sensible. Automatic string-to-X coercion is a horrific crime against maintainability. Some languages do not understand this.

    borb_sig.png
  • This content has been removed.

  • KupiKupi Registered User regular
    dporowski wrote: »
    Kupi wrote: »
    Hello fellow programmers! I am here with a gentle reminder: if you ever, at any time, write a program whose sole output upon failing is to say "Failed to do the thing", you are going straight to Hell. There are at least two different possible causes of failure for any program you're going to present to someone else and they need to be able to distinguish them.

    In my specific case, I'm trying to provide an icon for the MacOS build of an application, and MacOS has a special format for icon files called ICNS. Unless you want to trust an online conversion tool (I do not), you need to use the iconutil command-line tool to process a folder full of image files of various resolutions. Evidently this tool is extremely persnickety about the file format, file names, alpha channel, PPI settings, and so on. And if it fails, it says: "Failed to generate ICNS." Wrong format? Did I forget an alpha channel? Which file, specifically, is at issue? Dunno! Try again! Maybe read the docs (if you can find the right ones (the man page for iconutil does not mention the format requirements)).

    ... I did manage to get it to work, by meticulously resaving my icon files according to a schedule I found three entries down in a StackOverflow question on the subject (https://stackoverflow.com/questions/12306223/how-to-manually-create-icns-files-using-iconutil). Same as it ever was. But man am I ever left with a sour taste in my mouth.

    Soooooo okay I just tested this in a very half-assed manner locally, but.

    Completely new MacOS only project, Xcode 14 latest, you can just grab any old image--I used a jpg I had lying around--and as long as it's the right dimensions, you can drop it into the asset catalog and Xcode seems to just do the thing. (Or at least, I've got a running app with the icon I stuffed in, anyway.)

    I suspect this would be much prettier if I--as on iOS--used a properly vector PDF as the source so it scaled better, but yeah, for next time you can just make Xcode do it for you. Usually for assets you want a pdf at each resolution though, so 1024x1024, etc etc. NBD in my experience, though.

    At this point I'll cop to having made it harder for myself: I am dimly aware of XCode as That Thing You Use As A Mac Dev, but when the app store demanded that I create an Apple Account to get it I said "eh" and sought alternatives.

    I stand by the principle at the root of my frustration, even if I'm the proverbial guy trying to figure out if the glass bottle or the shoe is the better way to drive a nail.

    My favorite musical instrument is the air-raid siren.

    I'm "kupiyupaekio" on Discord.
Sign In or Register to comment.