As was foretold, we've added advertisements to the forums! If you have questions, or if you encounter any bugs, please visit this thread: https://forums.penny-arcade.com/discussion/240191/forum-advertisement-faq-and-reports-thread/

[Programming] Reinventing equality, one language at a time

19495969799

Posts

  • thatassemblyguythatassemblyguy Janitor of Technical Debt .Registered User regular
    Python 2. It was great for what it needed to be at the time, but I am glad it is dying. I hate that it will still be used quite extensively in some businesses well past the Jan 1, 2020 date.

    Python 3.6+ has some massive improvements to string formatting capabilities where you can do crazy things to and with an object that doesn't solely rely on overriding __format__ which only passes the format_spec as a string that you have to hand-parse from the format mini-language on your own (super fragile!).

  • xraydogxraydog Registered User regular
    What do you guys think of go? Started playing around with it. Neat little language. It's like a modern day C. Doing .NET for so many years the simplicity of it feels great.

  • EchoEcho ski-bap ba-dapModerator mod
    edited March 2019
    xraydog wrote: »
    What do you guys think of go? Started playing around with it. Neat little language. It's like a modern day C. Doing .NET for so many years the simplicity of it feels great.

    It's what I've been writing at work for the past two years. It's awesome for microservices.

    Echo on
  • GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    xraydog wrote: »
    What do you guys think of go? Started playing around with it. Neat little language. It's like a modern day C. Doing .NET for so many years the simplicity of it feels great.

    Not sure Go is really modern day C, that crown goes to Rust. Go's big offering to the world, and why I think it's important and you should definitely learn it, is relatively simple ways to solve complex concurrency and vertical scaling issues, while keeping the language itself simple and easy to learn.

    If they would just fix a couple of the edge case deadlocking issues and maybe bit some ownership/borrowing mechanisms from Rust, just for cross-go-func data, it'd be nearly perfect as a language to write complex concurrent code in.

    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • Monkey Ball WarriorMonkey Ball Warrior A collection of mediocre hats Seattle, WARegistered User regular
    edited March 2019
    xraydog wrote: »
    What do you guys think of go? Started playing around with it. Neat little language. It's like a modern day C. Doing .NET for so many years the simplicity of it feels great.

    I'm a huge fanboy of Go. I do all my personal stuff in it. It's the benchmark I compare other languages with. Once you get used to a few syntactic quirks, it is one of the most terse-but-readable languages out there.

    No generics / type parameterize is a flaw (though an understandable one given that Go really needs a custom syntax for it to feel idiomatic. Nobody wants to recreate the angle bracket hell you get in Java).

    Error handling is a bit obtuse, though far better IMHO than exceptions. Both issues are being actively worked on for Go 2, which is still years away.

    No inheritance is kinda weird, but you get used to it, and isn't really needed in the same way generics are.

    Monkey Ball Warrior on
    "I resent the entire notion of a body as an ante and then raise you a generalized dissatisfaction with physicality itself" -- Tycho
  • EchoEcho ski-bap ba-dapModerator mod
    I've had one situation where I felt I was missing generics, and I've never felt I missed class-based inheritance.

  • Monkey Ball WarriorMonkey Ball Warrior A collection of mediocre hats Seattle, WARegistered User regular
    Echo wrote: »
    I've had one situation where I felt I was missing generics, and I've never felt I missed class-based inheritance.

    A lot of the need is removed by having effectively generic types built in (maps, arrays/slices, chans)

    "I resent the entire notion of a body as an ante and then raise you a generalized dissatisfaction with physicality itself" -- Tycho
  • GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    I want generics in Go constantly, but I also understand why it doesn't have them.

    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • Monkey Ball WarriorMonkey Ball Warrior A collection of mediocre hats Seattle, WARegistered User regular
    edited March 2019
    Rob Pike is the only person I trust to pull off generics in Go correctly, and even then I'm not entirely sure he can.

    Monkey Ball Warrior on
    "I resent the entire notion of a body as an ante and then raise you a generalized dissatisfaction with physicality itself" -- Tycho
  • EchoEcho ski-bap ba-dapModerator mod
    Also Go has the best mascot.

    Or at least had until they changed the logo to Generic McGenericFace.

    8lywkdtnq85e.jpg

  • a5ehrena5ehren AtlantaRegistered User regular
    lol got fuckin wrekt by a code screen for a job.

    1 hour time limits are bad, I knew I was fucked when it took me 10 minutes to find+translate the common denominator algorithm from wikipedia to code.

  • bowenbowen How you doin'? Registered User regular
    Who the fuck needs to find a common denominator and why would anyone need to use those formulas on the regular that haven't already been in use by the business forever?

    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
  • bowenbowen How you doin'? Registered User regular
    If they just wanted to see you use recursion have you build a file tree or something that's easy to bang out in an hour instead of spending 30 minutes of that cross referencing formulas and such.

    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
  • a5ehrena5ehren AtlantaRegistered User regular
    That was actually just one of three problems I had an hour to solve. It was like taking a 200-level CS test without any prep.

    Given that this is a mega-corp but not a FAANG, I'm assuming that they either don't actually look at the results or everyone that works there cheated.

  • a5ehrena5ehren AtlantaRegistered User regular
    I also fucked up the code in other ways, like forgetting that scanf is a thing since no one in the right-thinking universe would ever use it in production code.

  • PrimePrime UKRegistered User regular
    I could do with some help. I've been given a task to take a data file full of data, basically dumped from a datatable or something similar by the looks of it, which I need to be able to rebuild in code (C#)

    When I run it through:

    File.ReadAllLines(filePath);

    I get an array for each "row" is there present. I use the first row to build my table columns, and all subsequent rows are the data for the table. I've really struggled to separate the data rows in a reliable way that can be used in a 1 for 1 mapping with the columns.

    After a bit of research I think the answer I'm looking for is using a RegularExpression on each line containing the table data to split the data for inserting. Where I'm coming unstuck is I cant find a pattern that works for all cases.

    I at first I tried using:

    Regex.Split(readLine, [ ]{2,])

    But then I get missing columns, the ones that contain nothing but empty space as data, and because im re-building the data from this datafile I dont know what columns are the ones missing data so cant treat missing data as empty either.

    Any suggestions?

  • a5ehrena5ehren AtlantaRegistered User regular
    Is there a standard delimiter in the data? This kind of thing is better handled by "tokenizing" the data (whatever the C# equivalent of strtok is), not regexing it.

  • PrimePrime UKRegistered User regular
    No, its not delimited in anyway. Its an infuriating task.

  • BlazeFireBlazeFire Registered User regular
    Prime wrote: »
    No, its not delimited in anyway. Its an infuriating task.

    When you look at the data, how do you tell where one column starts and the next starts?

  • bowenbowen How you doin'? Registered User regular
    usually they're comma delimited or tab delimited so you just do something like:
    var splitLine = string.Split(',');
    

    Then you join shit back up if you detect quotes if it's a text field that can have commas in it.

    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
  • bowenbowen How you doin'? Registered User regular
    There's literally no way to get data out of a non delimited file unless things are also 0 packed and it's in binary or something.

    I guess sometimes they're space delimited but you're going to get a LOT of error if there's any text fields.

    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
  • LD50LD50 Registered User regular
    a5ehren wrote: »
    lol got fuckin wrekt by a code screen for a job.

    1 hour time limits are bad, I knew I was fucked when it took me 10 minutes to find+translate the common denominator algorithm from wikipedia to code.

    I would do this (and probably not get the job):
    def common_denominator(x, y)
      x.gcd(y)
    end
    

    or
    #include <boost/math/common_factor.hpp>
    //boilerplate goes here
    boost::math::gcd(x, y);
    

  • PrimePrime UKRegistered User regular
    edited March 2019
    Heres an example of the data read from the file

    " 1 88 59 74 53.8 0.00 F 280 9.6 270 17 1.6 93 23 1004.5"

    there are 17 columns in total, 2 in this data example are empty space (the forum post seem to kill the additional empty spaces). No delimiter to use, which I would have had no problem resolving.

    The task has been set to test out something called, Data Wrangling/Data Munging. First time I've ever come across it or the term.

    Prime on
  • BlazeFireBlazeFire Registered User regular
    Prime wrote: »
    Heres an example of the data read from the file

    " 1 88 59 74 53.8 0.00 F 280 9.6 270 17 1.6 93 23 1004.5"

    there are 17 columns in total, 2 in this data example are empty space (the forum post seem to kill the additional empty spaces). No delimiter to use, which I would have had no problem resolving.

    The task has been set to test out something called, Data Wrangling/Data Munging. First time I've ever come across it or the term.

    How do you know which column is blank from the datatable?

  • kimekime Queen of Blades Registered User regular
    Prime wrote: »
    Heres an example of the data read from the file

    " 1 88 59 74 53.8 0.00 F 280 9.6 270 17 1.6 93 23 1004.5"

    there are 17 columns in total, 2 in this data example are empty space (the forum post seem to kill the additional empty spaces). No delimiter to use, which I would have had no problem resolving.

    The task has been set to test out something called, Data Wrangling/Data Munging. First time I've ever come across it or the term.

    If the data types are consistent and not sequentially the same, you could split on spaces then (if the count is improper) do another run through of the data to find the incorrect type and insert an empty value before that one.

    It looks like that is not the case here, and like half of these are ints. In which case it seems like close to impossible to guarantee a "correct" answer

    Battle.net ID: kime#1822
    3DS Friend Code: 3110-5393-4113
    Steam profile
  • bowenbowen How you doin'? Registered User regular
    Prime wrote: »
    Heres an example of the data read from the file

    " 1 88 59 74 53.8 0.00 F 280 9.6 270 17 1.6 93 23 1004.5"

    there are 17 columns in total, 2 in this data example are empty space (the forum post seem to kill the additional empty spaces). No delimiter to use, which I would have had no problem resolving.

    The task has been set to test out something called, Data Wrangling/Data Munging. First time I've ever come across it or the term.

    The space seems significant but I don't see a pattern to match to. At first I thought they were space padded but they're random. Is this a line from the file or one you just made up on the spot? Without a pattern there's no way to write an algorithm.

    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
  • bowenbowen How you doin'? Registered User regular
    edited March 2019
    like I'm seeing some columns with one space around them, some with two spaces around them, others with three spaces around them.

    The fact that some have two spaces means that the data is not consistently aligned or padded to anything. And the only way that would work is if the padding gets applied to another column. But then sometimes there's two sets with two spaces around them which would make that not work too (17 and 1.6 in particular).

    Like sure you can convert a delimited file but this data is fucking garbage and whatever you get out of it, if anything, is garbage. Munging is just a fancy word for conversion and import.

    bowen on
    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
  • PrimePrime UKRegistered User regular
    edited March 2019
    bowen wrote: »
    Prime wrote: »
    Heres an example of the data read from the file

    " 1 88 59 74 53.8 0.00 F 280 9.6 270 17 1.6 93 23 1004.5"

    there are 17 columns in total, 2 in this data example are empty space (the forum post seem to kill the additional empty spaces). No delimiter to use, which I would have had no problem resolving.

    The task has been set to test out something called, Data Wrangling/Data Munging. First time I've ever come across it or the term.

    The space seems significant but I don't see a pattern to match to. At first I thought they were space padded but they're random. Is this a line from the file or one you just made up on the spot? Without a pattern there's no way to write an algorithm.

    Thats a line from the file.

    edit: ha, just found this online. It must be what this is based off because the data is too similar not to be:

    codekata.com/kata/kata04-data-munging/

    I'll work through it and see what their solution was because I've been banging my head against a desk for the last few hours

    Prime on
  • bowenbowen How you doin'? Registered User regular
    edited March 2019
    Prime wrote: »
    bowen wrote: »
    Prime wrote: »
    Heres an example of the data read from the file

    " 1 88 59 74 53.8 0.00 F 280 9.6 270 17 1.6 93 23 1004.5"

    there are 17 columns in total, 2 in this data example are empty space (the forum post seem to kill the additional empty spaces). No delimiter to use, which I would have had no problem resolving.

    The task has been set to test out something called, Data Wrangling/Data Munging. First time I've ever come across it or the term.

    The space seems significant but I don't see a pattern to match to. At first I thought they were space padded but they're random. Is this a line from the file or one you just made up on the spot? Without a pattern there's no way to write an algorithm.

    Thats a line from the file.

    edit: ha, just found this online. It must be what this is based off because the data is too similar not to be:

    codekata.com/kata/kata04-data-munging/

    I'll work through it and see what their solution was because I've been banging my head against a desk for the last few hours

    Like I said, there's no uniformity so you can't write an algorithm to consume it.

    You maybe could cheat this in this specific space by matching up to the datatype of the column and trying to work your way around it. You're going to lose that last row, but 90% of that file should work.

    But you know the width of the columns, so you have to use that in this case. It requires manual and user input to work, there's no way to write an algorithm for this without hard coding some assumptions.

    bowen on
    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
  • a5ehrena5ehren AtlantaRegistered User regular
    LD50 wrote: »
    a5ehren wrote: »
    lol got fuckin wrekt by a code screen for a job.

    1 hour time limits are bad, I knew I was fucked when it took me 10 minutes to find+translate the common denominator algorithm from wikipedia to code.

    I would do this (and probably not get the job):
    def common_denominator(x, y)
      x.gcd(y)
    end
    

    or
    #include <boost/math/common_factor.hpp>
    //boilerplate goes here
    boost::math::gcd(x, y);
    

    Yeah, I did briefly think about switching languages (your python one is actually valid, boost wouldn't have worked with their g++ compile options), but thought I'd be better off doing it in C since I'm most familiar with it.

    That was probably a mistake, since it probably would have taken me less time to lookup Python3 or Java syntax questions then I spent fighting with their asinine double-pointer return value.

  • LD50LD50 Registered User regular
    a5ehren wrote: »
    LD50 wrote: »
    a5ehren wrote: »
    lol got fuckin wrekt by a code screen for a job.

    1 hour time limits are bad, I knew I was fucked when it took me 10 minutes to find+translate the common denominator algorithm from wikipedia to code.

    I would do this (and probably not get the job):
    def common_denominator(x, y)
      x.gcd(y)
    end
    

    or
    #include <boost/math/common_factor.hpp>
    //boilerplate goes here
    boost::math::gcd(x, y);
    

    Yeah, I did briefly think about switching languages (your python one is actually valid, boost wouldn't have worked with their g++ compile options), but thought I'd be better off doing it in C since I'm most familiar with it.

    That was probably a mistake, since it probably would have taken me less time to lookup Python3 or Java syntax questions then I spent fighting with their asinine double-pointer return value.

    The python code is also valid in ruby.

  • zeenyzeeny Registered User regular
    Actually writing a recursive fn to find the gcd is shorter than the "boost" version. hth.

  • bowenbowen How you doin'? Registered User regular
    Also I did lie, there is a way to parse this data but you still have to be prepared to deal with errors and junk data and throwing out rows that don't match anything. The hint I'll give you @Prime figure out if there's a length(s) you can use to reliably parse data excluding that last row which isn't data but a summary (because this is a report and not a data dump, you see).

    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
  • JasconiusJasconius sword criminal mad onlineRegistered User regular
    oh shit i accidentally just typed "nano nano myfile.ext" and i think.... i just opened a portal to another world??? what just happened?

    nothing a little ctrl+x can't solve, but i'm scared

  • LuvTheMonkeyLuvTheMonkey High Sierra Serenade Registered User regular
    It started a copy of Overwatch and Nanoboosted nano

    Molten variables hiss and roar. On my mind-forge, I hammer them into the greatsword Epistemology. Many are my foes this night.
    STEAM | GW2: Thalys
  • Monkey Ball WarriorMonkey Ball Warrior A collection of mediocre hats Seattle, WARegistered User regular
    Out of blind loyalty to my alma mater I always make a symbolic link from nano to pico.
    ok that is a lie I actually just use vim

    "I resent the entire notion of a body as an ante and then raise you a generalized dissatisfaction with physicality itself" -- Tycho
  • bowenbowen How you doin'? Registered User regular
    Did they remove the link? I remember pico used to open nano on most systems.

    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
  • Monkey Ball WarriorMonkey Ball Warrior A collection of mediocre hats Seattle, WARegistered User regular
    edited March 2019
    I was just kidding, but IIRC on the UW boxes at least that sim link did actually exist. I'm not aware of any distributions that came that way though. If anything it was the other way around.

    Monkey Ball Warrior on
    "I resent the entire notion of a body as an ante and then raise you a generalized dissatisfaction with physicality itself" -- Tycho
  • MadpoetMadpoet Registered User regular
    Jasconius wrote: »
    oh shit i accidentally just typed "nano nano...
    henhvipa732i.jpg
    Approves

  • schussschuss Registered User regular
    Is it a fixed length file? Sounds like it is. There should be a decide of position->field.
    Data wrangling/munging is basically just another term for the transform step of ETL (extract transform load).
    This is an exceptionally mature space with a lot of options. I'll warn you though, most data stuff in code will be python or Java. You can use JS, but don't. C, COBOL and Scala also exist, but generally are only used for highly performant use cases that involve thousands of transactions/second because of the additional complexity vs higher level languages.

This discussion has been closed.