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/
Options

[Programming] Reinventing equality, one language at a time

194969899100

Posts

  • Options
    dporowskidporowski Registered User regular
    halkun wrote: »
    For me, if the "if" is only one line, I will bracket it up too. It keeps things from "leaking". Also, it reminds me of my BASIC days. If "else" only has one line, I'll bracket it too.
    if (foo) {bar()} else {baz();}
    

    I should be using a ternary, but I can't parse those right

    I had the worst time with them (so simple seeming, right?) until I hit on:

    Question ? Yes : No (At least the Swift pattern). Something in my brain went "Ooooooh okay!" then.

  • Options
    SeolSeol Registered User regular
    dporowski wrote: »
    halkun wrote: »
    For me, if the "if" is only one line, I will bracket it up too. It keeps things from "leaking". Also, it reminds me of my BASIC days. If "else" only has one line, I'll bracket it too.
    if (foo) {bar()} else {baz();}
    

    I should be using a ternary, but I can't parse those right

    I had the worst time with them (so simple seeming, right?) until I hit on:

    Question ? Yes : No (At least the Swift pattern). Something in my brain went "Ooooooh okay!" then.
    I like to format them as:
    Question
        ? Yes
        : No
    

  • Options
    Monkey Ball WarriorMonkey Ball Warrior A collection of mediocre hats Seattle, WARegistered User regular
    I love the ternary operator, but I get why they are controversial, and if I am working under a style guide or a language that forbids them, I can live with that.

    "I resent the entire notion of a body as an ante and then raise you a generalized dissatisfaction with physicality itself" -- Tycho
  • Options
    UselesswarriorUselesswarrior Registered User regular
    Just use languages that treat the if as an expression, problem solved :)

    Hey I made a game, check it out @ http://ifallingrobot.com/. (Or don't, your call)
  • Options
    JasconiusJasconius sword criminal mad onlineRegistered User regular
    edited February 2019
    entering week 3 of a major field test.... 99.89% crash free sessions

    aka 1 crash after 2.2 weeks of heavy use in primitive conditions

    looks like the hardest longest rewrite of my life has paid off

    Jasconius on
  • Options
    tyrannustyrannus i am not fat Registered User regular
    I'm reading about the history of gets, the morris worm, scanf, fgets, and getline in C

    and it just seems like programmers went from thinking "there's no way the user will be that much of a jerk" to "the user is a total jerk holy shit"

  • Options
    DehumanizedDehumanized Registered User regular
    edited February 2019
    For fun I looked at the morris worm source* and found this declaration and comment:

    https://github.com/arialdomartini/morris-worm/blob/master/worm.c#L26
    object objects[69];				/* Don't know how many... */
    

    nice

    *it's probably actually a decompilation, not the original source

    Dehumanized on
  • Options
    GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    edited February 2019
    I love the ternary operator, but I get why they are controversial, and if I am working under a style guide or a language that forbids them, I can live with that.

    I don't mind them for simple things, but if you're nesting a bunch of code in a ternary I think they are messy and become hard to read very fast.

    e: And yes, if's as expressions is a nice language feature.

    GnomeTank on
    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
  • Options
    tyrannustyrannus i am not fat Registered User regular
    For fun I looked at the morris worm source* and found this declaration and comment:

    https://github.com/arialdomartini/morris-worm/blob/master/worm.c#L26
    object objects[69];				/* Don't know how many... */
    

    nice

    *it's probably actually a decompilation, not the original source

    Nice

  • Options
    templewulftemplewulf The Team Chump USARegistered User regular
    edited February 2019
    tyrannus wrote: »
    For fun I looked at the morris worm source* and found this declaration and comment:

    https://github.com/arialdomartini/morris-worm/blob/master/worm.c#L26
    object objects[69];				/* Don't know how many... */
    

    nice

    *it's probably actually a decompilation, not the original source

    Nice
    https://youtu.be/mXp9JsKy-1o
    ?

    templewulf on
    Twitch.tv/FiercePunchStudios | PSN | Steam | Discord | SFV CFN: templewulf
  • Options
    templewulftemplewulf The Team Chump USARegistered User regular
    GnomeTank wrote: »
    I love the ternary operator, but I get why they are controversial, and if I am working under a style guide or a language that forbids them, I can live with that.

    I don't mind them for simple things, but if you're nesting a bunch of code in a ternary I think they are messy and become hard to read very fast.

    e: And yes, if's as expressions is a nice language feature.

    I think they're great for expressions, like the rvalue in an assignment or a cout.

    Basically, if I'm going to do the same action and the conditional just determines what value I pass into the action, a ternary helps make the "verbs" clear.

    Twitch.tv/FiercePunchStudios | PSN | Steam | Discord | SFV CFN: templewulf
  • Options
    PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    Ternaries are great until you abuse them

  • Options
    bowenbowen How you doin'? Registered User regular
    Oh you saw the 6 level deep ternary I used the other day then?

    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
  • Options
    DehumanizedDehumanized Registered User regular
    int median(int a, int b, int c) {
        return (a<b) ? (b<c) ? b : (a<c) ? c : a : (a<c) ? a : (b<c) ? c : b;
    }
    

  • Options
    TelMarineTelMarine Registered User regular
    bowen wrote: »
    Oh you saw the 6 level deep ternary I used the other day then?

    I sometimes feel like people take "concise" way too far and forget about readability.

    3ds: 4983-4935-4575
  • Options
    dporowskidporowski Registered User regular
    edited February 2019
    TelMarine wrote: »
    bowen wrote: »
    Oh you saw the 6 level deep ternary I used the other day then?

    I sometimes feel like people take "concise" way too far and forget about readability.

    I feel a mention of https://en.wikipedia.org/wiki/Obfuscated_Perl_Contest is topical.

    Edit: Or worse, from the C inspiration for it:
    B,i,y,u,b,I[411],*G=I,x=10,z=15,M=1e4;X(w,c,h,e,S,s){int t,o,L,E,d,O=e,N=-M*M,K
    =78-h<<x,p,*g,n,*m,A,q,r,C,J,a=y?-x:x;y^=8;G++;d=w||s&&s>=h&&v 0,0)>M;do{_ o=I[
    p=O]){q=o&z^y _ q<7){A=q--&2?8:4;C=o-9&z?q["& .$  "]:42;do{r=I[p+=C[l]-64]_!w|p
    ==w){g=q|p+a-S?0:I+S _!r&(q|A<3||g)||(r+1&z^y)>9&&q|A>2){_ m=!(r-2&7))P G[1]=O,
    K;J=n=o&z;E=I[p-a]&z;t=q|E-7?n:(n+=2,6^y);Z n<=t){L=r?l[r&7]*9-189-h-q:0 _ s)L
    +=(1-q?l[p/x+5]-l[O/x+5]+l[p%x+6]*-~!q-l[O%x+6]+o/16*8:!!m*9)+(q?0:!(I[p-1]^n)+
    !(I[p+1]^n)+l[n&7]*9-386+!!g*99+(A<2))+!(E^y^9)_ s>h||1<s&s==h&&L>z|d){p[I]=n,O
    [I]=m?*g=*m,*m=0:g?*g=0:0;L-=X(s>h|d?0:p,L-N,h+1,G[1],J=q|A>1?0:p,s)_!(h||s-1|B
    -O|i-n|p-b|L<-M))P y^=8,u=J;J=q-1|A<7||m||!s|d|r|o<z||v 0,0)>M;O[I]=o;p[I]=r;m?
    *m=*g,*g=0:g?*g=9^y:0;}_ L>N){*G=O _ s>1){_ h&&c-L<0)P L _!h)i=n,B=O,b=p;}N=L;}
    n+=J||(g=I+p,m=p<O?g-3:g+2,*m<z|m[O-p]||I[p+=p-O]);}}}}Z!r&q>2||(p=O,q|A>2|o>z&
    !r&&++C*--A));}}}Z++O>98?O=20:e-O);P N+M*M&&N>-K+1924|d?N:0;}main(){Z++B<121)*G
    ++=B/x%x<2|B%x<2?7:B/x&4?0:*l++&31;Z B=19){Z B++<99)putchar(B%x?l[B[I]|16]:x)_
    x-(B=F)){i=I[B+=(x-F)*x]&z;b=F;b+=(x-F)*x;Z x-(*G=F))i=*G^8^y;}else v u,5);v u,
    1);}}
    


    That is (or at least is an excerpt of) a chess engine.
    #define _ -F<00||--F-OO--;
    int F=00,OO=00;main(){F_OO();printf("%1.3f\n",4.*-F/OO/OO);}F_OO()
    {
                _-_-_-_
           _-_-_-_-_-_-_-_-_
        _-_-_-_-_-_-_-_-_-_-_-_
      _-_-_-_-_-_-_-_-_-_-_-_-_-_
     _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
     _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
    _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
    _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
    _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
    _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
     _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
     _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
      _-_-_-_-_-_-_-_-_-_-_-_-_-_
        _-_-_-_-_-_-_-_-_-_-_-_
            _-_-_-_-_-_-_-_
                _-_-_-_
    }
    

    The above calculates pi by examination of its own area.

    dporowski on
  • Options
    EchoEcho ski-bap ba-dapModerator mod
    "Hey Echo, can you check out this customer's javascript?"

    *goes to BDSM site during work hours*

  • Options
    bowenbowen How you doin'? Registered User regular
    TelMarine wrote: »
    bowen wrote: »
    Oh you saw the 6 level deep ternary I used the other day then?

    I sometimes feel like people take "concise" way too far and forget about readability.

    I was not proud of it but I wanted to do it just because

    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
  • Options
    JasconiusJasconius sword criminal mad onlineRegistered User regular
    this is a shot in a million, but in MSSQL Server, has anyone ever heard of a situation where an MSSQL Server database could fail to properly execute a stored procedure due to the weight of the parameters sent to the procedure, and do so without any apparent error?

    We've got a legacy stack that stores images in an MSSQL instance, and about one in a thousand or so times, the images will fail to record (it will just make an empty row with a primary key and no other data)

    We've put NUMEROUS layers of "make sure these images exist, have bytes, etc" between the client application and the database, but we still get occasional random empty rows

  • Options
    CampyCampy Registered User regular
    int median(int a, int b, int c) {
        return (a<b) ? (b<c) ? b : (a<c) ? c : a : (a<c) ? a : (b<c) ? c : b;
    }
    

    Hail Hydra?

  • Options
    InfidelInfidel Heretic Registered User regular
    Jasconius wrote: »
    this is a shot in a million, but in MSSQL Server, has anyone ever heard of a situation where an MSSQL Server database could fail to properly execute a stored procedure due to the weight of the parameters sent to the procedure, and do so without any apparent error?

    We've got a legacy stack that stores images in an MSSQL instance, and about one in a thousand or so times, the images will fail to record (it will just make an empty row with a primary key and no other data)

    We've put NUMEROUS layers of "make sure these images exist, have bytes, etc" between the client application and the database, but we still get occasional random empty rows

    Hmmmm, not really gonna happen at that level silently.

    You sure it’s the SP actually inserting the empty row?

    OrokosPA.png
  • Options
    PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    dporowski wrote: »
    TelMarine wrote: »
    bowen wrote: »
    Oh you saw the 6 level deep ternary I used the other day then?

    I sometimes feel like people take "concise" way too far and forget about readability.

    I feel a mention of https://en.wikipedia.org/wiki/Obfuscated_Perl_Contest is topical.

    Insert obligatory "isn't all Perl obfuscated?" joke

  • Options
    zeenyzeeny Registered User regular
    Phyphor wrote: »
    dporowski wrote: »
    TelMarine wrote: »
    bowen wrote: »
    Oh you saw the 6 level deep ternary I used the other day then?

    I sometimes feel like people take "concise" way too far and forget about readability.

    I feel a mention of https://en.wikipedia.org/wiki/Obfuscated_Perl_Contest is topical.

    Insert obligatory "isn't all Perl obfuscated?" joke

    The exact quote is: "The only language that looks the same before and after RSA encryption."

  • Options
    DelzhandDelzhand Hard to miss. Registered User regular
    I'm working with software that uses the ugliest possible code conventions:
    define('Sensors'
    ,	[
    		'Sensors.DataExtractor'
    	,	'SC.Configuration'
    
    	,	'jQuery'
    	,	'underscore'
    	,	'Backbone'
    	]
    ,	function (
    		SensorsDataExtractor
    	,	Configuration
    
    	,	jQuery
    	,	_
    	,	Backbone
    	)
    {
    	// code goes here
    });
    
    

    I believe this is called "i care more about clean git commits than readable code"...

  • Options
    EchoEcho ski-bap ba-dapModerator mod
    MY EYES

    That's one of those teeny things I like about Go, it actually requires a trailing comma on the last item in a multi-line array/whatever.
    things = [
      a,
      b,
      c,
    ]
    

  • Options
    JasconiusJasconius sword criminal mad onlineRegistered User regular
    Infidel wrote: »
    Jasconius wrote: »
    this is a shot in a million, but in MSSQL Server, has anyone ever heard of a situation where an MSSQL Server database could fail to properly execute a stored procedure due to the weight of the parameters sent to the procedure, and do so without any apparent error?

    We've got a legacy stack that stores images in an MSSQL instance, and about one in a thousand or so times, the images will fail to record (it will just make an empty row with a primary key and no other data)

    We've put NUMEROUS layers of "make sure these images exist, have bytes, etc" between the client application and the database, but we still get occasional random empty rows

    Hmmmm, not really gonna happen at that level silently.

    You sure it’s the SP actually inserting the empty row?

    We are reasonably certain, because the table also contains other data, which is consistent and traceable. We know this data comes from our users, and there is only one way our users can interact with this server.

    In addition to the numerous checks on the client application which sends the images over, on the ASP.NET code that actually calls the SP, we've written a check which verifies that the param is in fact not null and has bytes at the exact moment prior to calling the SP

    and yet, every so often, we see rows where these columns end up NULL

  • Options
    djmitchelladjmitchella Registered User regular
    Someone's made a 3d engine in pure CSS. (yes, just CSS, no JS or anything. It works much the way you'd expect, except that he put a bunch of extra effort into get lightmaps and shadows to work, and it looks a lot more impressive as a result):

    https://keithclark.co.uk/labs/css-fps/nojs/

  • Options
    DisruptedCapitalistDisruptedCapitalist I swear! Registered User regular
    edited February 2019
    It stutters a bit at first in Firefox, but otherwise seems to run smoothly.

    For a good laugh, check it out in Edge.
    bugktv3aacav.jpg

    DisruptedCapitalist on
    "Simple, real stupidity beats artificial intelligence every time." -Mustrum Ridcully in Terry Pratchett's Hogfather p. 142 (HarperPrism 1996)
  • Options
    SaerisSaeris Borb Enthusiast flapflapflapflapRegistered User regular
    If I'm not mistaken, that was made in 2013. And Edge still handles it terribly.

    borb_sig.png
  • Options
    bowenbowen How you doin'? Registered User regular
    I want to say edge handles it better than firefox

    firefox is technically correct but it runs like utter ass

    edge runs fine it just doesn't support some very unused CSS texture mapping that breaks 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
  • Options
    SpawnbrokerSpawnbroker Registered User regular
    Well, let the grind begin. I am reading The Algorithm Design Manual by Skiena currently. Anyone have any interview study tips for someone looking to work for a company that starts with G and rhymes with frugal?

    I expect this will take me a few months before I'm ready. Current plan is to make it through Skiena and possibly pick up Crack the Coding Interview. My initial goal is to be able to do leetcode hards in 45 minutes, possibly cut it down to 30 minutes if I can.

    Steam: Spawnbroker
  • Options
    Monkey Ball WarriorMonkey Ball Warrior A collection of mediocre hats Seattle, WARegistered User regular
    bowen wrote: »
    I want to say edge handles it better than firefox

    firefox is technically correct but it runs like utter ass

    edge runs fine it just doesn't support some very unused CSS texture mapping that breaks it

    Oh wow. I just assumed that's how it was, because lol CSS. But, yes, it runs much smoother in Chrome than Firefox.

    Cmon Firefox, you need to step it up a notch!

    "I resent the entire notion of a body as an ante and then raise you a generalized dissatisfaction with physicality itself" -- Tycho
  • Options
    vamenvamen Registered User regular
    Quick advice from you folks:

    I'm only just getting into programming, partly because my boss left. He built our web tools and now I'm the only one left in my department. So I'm frantically trying to figure stuff out. It's good in a way because I've been wanting to learn to program, but his way was pretty old school - the most recent web app was built with VB and ASP and it uses frames - and I don't particularly want to put my efforts into learning older tech. But I have to to keep stuff running!

    Anyway, I found a function in the DAO.vb file (which I guess is what ends up in the DLL?) that I need to make a minor change to, but I don't want to deploy the whole solution to the web server because I have no idea if it had any undeployed changes that would break things.
    (I should also mention he didn't use source control OR a test server. I've created a test site and am seeing about versioning)

    Anyway, all I want to do is get the minor change out to the server by itself. Is there a way to do that? You can't seem to right-click > publish (I'm using Visual Studio) like you can with the asp files. I tried to build and then just drop the DLL over the old DLL on the server (on the test one, mind), but no dice.

    I'm sure it's something very easy and obvious but I just don't have the knowledge structure/building blocks to understand it yet.

    Thanks!

  • Options
    bowenbowen How you doin'? Registered User regular
    If it's old ASP you have to deal with IIS stuff to redeploy it I think. Restarting IIS sometimes does what you need it to do I think.

    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
  • Options
    CampyCampy Registered User regular
    bowen wrote: »
    If it's old ASP you have to deal with IIS stuff to redeploy it I think. Restarting IIS sometimes does what you need it to do I think.

    IIS restart should indeed do what you want once you've got the DLL in the right place.

    With regards to the unknown amount of undeployed changes that could screw with things, you might want to look into the testing technique known as Golden Master. It's a bit of a ball ache and time consuming to run, but it's your best bet at testing legacy code. Especially since you have no versioning available.

  • Options
    vamenvamen Registered User regular
    I don't know how to tell if it's old SAP or not, but I can say that I've deployed the whole project on the test server and it worked okay and my changes were reflected, I just don't want to do it on the live server that way because of the aforementioned chance of untested changes that were being made.

    Or maybe I'm misreading and you mean if I manually drop the DLL out there I'll need to restart the IIS?

    I'll give that Golden Master a google and see what it's about, thanks!
    I also noticed there is an option in VS where I can right-click and "replace file with server version" so I could probably just do that to the ASP files and be pretty safe if it works as it sounds.

  • Options
    KhavallKhavall British ColumbiaRegistered User regular
    edited February 2019
    So this is more macro construction than programming, but man am I happy with the kludged together thing I just built in LaTeX.

    I'm building a "State of the Art" survey for my research, and there are a few requirements.
    1: I need a table that has all of the systems that I survey examined in the taxonomy that I'm creating.
    2: Those systems should be numbered, so that I can reference them elsewhere in the text.
    3: I need a way of noting when I'm referencing the systems from the table that's distinct from a normal citation (e.g. saying "The system seen in x (# on the table)")

    The way that a colleague of mine did it was to have the system number circled, so that it's easy to tell when I'm referencing a system that's on the table.


    So because I hate doing the tiny stuff like cross-checking the number of the system to make sure that I'm referencing correctly, I wanted something that would:
    1: Automatically keep track of each system's row number in the table.
    2: Be able to reference that number elsewhere in the document
    3: Not be a pain in the ass to use.

    The end result is like 12 macros linked together where I just need to type in "\tableref{Title}{RefTitle}", where the reftitle is the more easily-referenced title (e.g. "Full Name of System" might be shortened to "Sys"). The \tableref macro uses a different circle-drawing macro that uses the normal \ref command with the keyword to reference the output of the macro that the table runs that references the built-in row-counting macro. It's a horribly beautiful mess of stuff

    It's going to hopefully save at least the hour and a half that I spent making it.

    Khavall on
  • Options
    Monkey Ball WarriorMonkey Ball Warrior A collection of mediocre hats Seattle, WARegistered User regular
    edited February 2019
    I have very fond memories of carefully crafting math homework LaTex files in college, because my whole life every math homework I've ever turned in has been barely readable chickenscratch, but I found LaTex and xypic and now LOOK HOW BEAUTIFUL THE MATH IS, EVERYONE HAIL OUR FEARLESS LEADER DONALD KNUTH.

    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
  • Options
    Stabbity StyleStabbity Style He/Him | Warning: Mothership Reporting Kennewick, WARegistered User regular
    I have very fond memories of carefully crafting math homework LaTex files in college, because my whole life every math homework I've ever turned in has been barely readable chickenscratch, but I found LaTex and xypic and now LOOK HOW BEAUTIFUL THE MATH IS, EVERYONE HAIL OUR FEARLESS LEADER DONALD KNUTH.

    I did my Algorithms and AI classes with Word's equation tool. Probably should've learned LaTex instead :\

    Stabbity_Style.png
  • Options
    Monkey Ball WarriorMonkey Ball Warrior A collection of mediocre hats Seattle, WARegistered User regular
    edited February 2019
    I have very fond memories of carefully crafting math homework LaTex files in college, because my whole life every math homework I've ever turned in has been barely readable chickenscratch, but I found LaTex and xypic and now LOOK HOW BEAUTIFUL THE MATH IS, EVERYONE HAIL OUR FEARLESS LEADER DONALD KNUTH.

    I did my Algorithms and AI classes with Word's equation tool. Probably should've learned LaTex instead :\

    Earlier on I did that as well. It will do quite well in a pinch. But later my linear algebra prof introduced me to LaTeX and I never looked back.

    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
This discussion has been closed.