Discussion in 'General Chatter' started by Morven, Feb 26, 2015.

  1. Morven

    Morven In darkness be the sound and light

    I've been using two free books, which are the first two listed on the page on the Haskell site: "Learn You a Haskell for Great Good", which is a friendly and somewhat humorous read but might annoy some; and the O'Reilly book whose name I forget. Both are free on the Web but cost if you want paper.

    I do have an unfair advantage in that my freshman year of Computer Science used Miranda as it's teaching language, and Miranda can be considered "Haskell Lite". It doesn't have Haskell's imperative constructs for IO, nor monads, nor most of the advanced typing features, but the basic style is very similar.
  2. Exohedron

    Exohedron Doesn't like words

    Thanks! I've gotten pretty deep into type theory and category theory from the mathematical logic side, so for me the later stuff will probably actually be easier than the beginning stuff.
  3. Morven

    Morven In darkness be the sound and light

    Then I suspect it'll suit you quite well.

    In general I'm enjoying its conciseness. Type inference means there's much less need to tell the system what you're doing because it can work it out. And the general idiom of the language appears to be one of elegantly expressed, minimalist solutions.

    Also, the community seems super helpful and very keen on showing people how to do things.
  4. winterykite

    winterykite Non-newtonian genderfluid

    Python global/local variables stuff

    I've been writing a small text based adventure (300-ish lines) in python since a few hours, and I've finally gotten all the missing : and = sorted out, but it keeps erroring out because it apparently can't find a variable - or, rather, it assumes "chased" is a local variable (which it can't find), whereas it's a global variable.
    I've tried having the list of global variables both above and below the functions, and neither works ::/ probably some dumb newbie mistake, but....
    (Warning: I haven't documented/commented this file at all.)
  5. WithAnH

    WithAnH Space nerd

    global chased
    inside the function, right after the def line.
  6. winterykite

    winterykite Non-newtonian genderfluid

    @WithAnH thank you, worked like a charm!
    (and i just noticed, I need to loop the start() room, otherwhise it just terminates. whoops.)
  7. WithAnH

    WithAnH Space nerd

    Let me know if you have any other problems - I'm happy to help!
  8. winterykite

    winterykite Non-newtonian genderfluid

  9. strictly quadrilateral

    strictly quadrilateral alive, alive, alive!

    I like it. It's certainly better than anything I've made. I will admit that I cheated, but only out of habit.
  10. albedo

    albedo metasperg

  11. Morven

    Morven In darkness be the sound and light

  12. ADigitalMagician

    ADigitalMagician The Ranty Tranny

    For the record: This is NOT best practices. Try to either pass in the needed value (And return any values that change) or, for games, I like passing in a dictionary/object that holds necessary game states.
    • Like x 1
  13. Lissa Lysik'an

    Lissa Lysik'an Dragon-loving Faerie

    Globals in any language are a "bad thing". One reason is because it is VERY easy to lose track of where they could be modified and bugs from "it got changed in function Z in file A but I forgot that file A even exists" are REALLY hard to track down. Pass objects that contain the data structures you need - then you know where it came from and where it might get changed. In the languages I use, pass by const is preferred if you just want to look at the data and not change it, so you can't accidentally change it. And since it's const, if you even TRY to change it the compiler says "uh uh, you promised you weren't going to mess with that, you can't go back on your word now" and barfs and you see right away that you goofed.
    • Like x 1
  14. winterykite

    winterykite Non-newtonian genderfluid

    Im on ex37 of Learn Python The Hard Way, I'm not that far into python yet ::D
    (and I needed some of the variables to not disappear / get rebooted to the starting value when the room is left/entered a second time)
  15. Morven

    Morven In darkness be the sound and light

    Doesn't matter so much at that stage, but best to keep it in mind that it's really not the best way when you get into more complicated things. In general, global state means that things are harder to reason about, harder to debug, harder to test, and kinda messier.
  16. winterykite

    winterykite Non-newtonian genderfluid

    ::3 I'll keep that in mind
    In Java I would've fed everything to a set of objects and called it a day

    But yeah, I suspect it's only working at this point because I have less than 400 lines of actual code and it's pretty simple and straightforward.
  17. ADigitalMagician

    ADigitalMagician The Ranty Tranny

    You posted the code right?

    In general, anything that might be "global" I pass into containing functions. Big example with Pygame (A games library in Python), is the Surface that represents the display. Since you draw to it constantly, you need to have it in every function that draws. So things like game loops. So my method is to instantiate it as part of the if __name__ == "__main__" and then pass it into the game loop functions.

    def main(display):
        while true:
    if __name__ == "__main__":
        screen = pygame.display.set_mode(resolution)
  18. albedo

    albedo metasperg

    • Like x 2
  19. AbsenteeLandlady123

    AbsenteeLandlady123 Chronically screaming

    So I'm teaching myself Ruby with CodeAcademy, and I have Learning Ruby The Hard Way bookmarked for reference and further reading. Through trial and error and referencing other people's code on the Q&A forum I managed to make a histogram program thing for the course.

    puts "Hello, I need input from you."​
    text = gets.chomp
    words = text.split()
    frequencies =
    words.each {|value| frequencies[value] += 1}

    frequencies = frequencies.sort_by do |word, count|
    frequencies.each do |word, count|
    puts word + " " + count.to_s

    frequencies.each do |word, count|
    puts word + " " + count.to_s
    I'm proud of myself c:
    • Like x 3
  20. albedo

    albedo metasperg

    So, folks that have internetted/programmed for much longer than me... I've heard a lot about how back before the "Eternal September" (when non-specialists started getting internet access en masse), everything was civilized and everyone was inducted into a common culture. Chivalry and common social norms ruled the land! Everyone used proper grammar! It wasn't like these trolly places of today!

    Some of the things those oldschool folks day about the Usenet days reminds me of the fedora crowd today. And I understand that Usenet users, being mostly college programming students/professors/professionals, were mostly middle-class white dudes.

    Was it really a cool culture, for the most part? Or was there a lot of fedora nonsense that the fedoras of today see through rose-tinted lenses?
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice