|
So I'm currently having to explain to people that killing Postgres processes will in fact slow down, rather than speed up, transaction rollbacks.
|
# ? Jan 8, 2014 20:10 |
|
|
# ? Jun 10, 2024 07:22 |
A new low has been reached. The newest API-of-the-month that I am working with has a method that requires a "location id" that represents a place somewhere in the world. This API stores all it's possible locations in a gigantic gently caress-off xml tree that goes Planet -> Continent -> Country -> County -> 'Place'. So Orlando, Florida would be Planet Earth -> North America -> USA -> Orange County -> Orlando and the location id would be something like 32805. Yes, Planet Earth is the first loving node in this tree, but that isn't even the best part. In order to actually find the location id you are searching for, instead of doing something sane like accepting county/place/etc as inputs, you provide a location id to search from, and the api returns everything on that branch to you. So Planet Earth is 1 and USA is 99. So if your location is in the USA, you provide 99 as the parent location and every location in the USA is given back in an xml, and you are expected to search through it. Not in the USA? Hope you know your location code or have twenty minutes to spare while you download the entire god drat database.
|
|
# ? Jan 8, 2014 23:11 |
|
Manslaughter posted:So Orlando, Florida would be Planet Earth -> North America -> USA -> Orange County -> Orlando Apparently they've never encountered cities that are in multiple counties. Or, worse, they expect you to know which county you're looking for. Or, double-worse, they've never encountered countries that don't have intermediary units between country and city. But hey, at least they're prepared for lunar and Mars colonies!
|
# ? Jan 8, 2014 23:43 |
|
Manslaughter posted:A new low has been reached. That doesn't sound like an API, that sounds like forfeit.
|
# ? Jan 8, 2014 23:55 |
|
https://github.com/marcusmoller/pyorpg-server/blob/master/src/database.pyPython code:
Bug Tracker posted:Database auto increment should start from 0, not 1.
|
# ? Jan 9, 2014 00:22 |
|
Manslaughter posted:A new low has been reached. After so many time-related horrors it's refreshing to see the other dimensions getting a run.
|
# ? Jan 9, 2014 02:22 |
|
Scaevolus posted:https://github.com/marcusmoller/pyorpg-server/blob/master/src/database.py I think the bug report completely missing the problem with this code really makes this one.
|
# ? Jan 9, 2014 05:37 |
|
I don't get it. Is the problem with how he tries to get the SQL entry, or with submitting the query?
|
# ? Jan 9, 2014 05:53 |
|
Pollyanna posted:I don't get it. Is the problem with how he tries to get the SQL entry, or with submitting the query? He gets a count of the rows in the table, then loops up to that count issuing a new query to get each row. This instead of, you know, just executing a single SELECT query on the database. It also makes the incredible assumption that the row ids are always continuous.
|
# ? Jan 9, 2014 06:14 |
|
Scaevolus posted:https://github.com/marcusmoller/pyorpg-server/blob/master/src/database.py From the same project: code:
|
# ? Jan 9, 2014 07:10 |
This all sounds like someone read a 25 year old book on writing a MUD in Turbo Pascal and thought everything sounded like a great idea. Smart enough go translate things from TP and block-structured files into Python and SQL, too dumb to realise why things were being done the way they were.
|
|
# ? Jan 9, 2014 12:01 |
|
Amberskin posted:Is it posible to back-translate (decompile) every posible chunk of bytecode? That is for sure not the case with old-school compiled code... the optimizations usually mangle the object code in ways that just make sense in assembly, but not in a high level language. Definitely not, I have personal experience with this. Turns out the Java stack is untyped, and the same location can hold an object or an integer or a boolean, and optimizing compilers will reuse stack locations, and decompilers don't have the faintest idea how to handle that and will produce horrible broken code that doesn't even compile
|
# ? Jan 9, 2014 12:42 |
|
This is technically not a horror and just - in my opinion - a badly designed language feature, but gently caress it regardless. Javascript's sort function.JavaScript code:
JavaScript code:
Let's see what the docs have to say: http://www.w3schools.com/jsref/jsref_sort.asp posted:The sort order can be either alphabetic or numeric, and either ascending or descending. Oh. So default sort order is alphabetic. But it can be numeric, yes? Okay what's the argument to swap that? http://www.w3schools.com/jsref/jsref_sort.asp posted:To perform a numeric sort, you must pass a function as an argument when calling the sort method. Wait, you said it can be alphabetic or numeric, descending or ascending, not that you have to manually do it yourself? http://www.w3schools.com/jsref/jsref_sort.asp posted:Example For something you have to do pretty often in a lot of algorithms in every topic, missing a language feature like this and making a user do that, is pretty to me. Edit: JavaScript code:
Edit2: That last sort returns an unsorted list in chrome devtools. Jewel fucked around with this message at 16:21 on Jan 9, 2014 |
# ? Jan 9, 2014 15:24 |
|
That is pretty backward, though to be fair you have to bear in mind it was never intended to be a general purpose programming language, just a way to script simple stuff in the browser, where arguably, at its inception, sorting a list of text options was probably a much more common use-case. E: well, your edited in final example certainly is interesting (but that's not the result I get in V8) ..btt fucked around with this message at 15:40 on Jan 9, 2014 |
# ? Jan 9, 2014 15:36 |
|
The - operator on non-numbers returns NaN, which certainly fucks with the sort function. Chalk up yet another place where a-b isn't a great comparator.
|
# ? Jan 9, 2014 15:52 |
|
A better result than php at least
|
# ? Jan 9, 2014 15:54 |
|
The horror is compounded by use of w3schools.
|
# ? Jan 9, 2014 16:36 |
|
Civil Twilight posted:The horror is compounded by use of w3schools. Oh yeah I did say "The docs" then linked to w3schools didn't I. Well. Still. It's the "recommended method" and it's garbage
|
# ? Jan 9, 2014 16:38 |
That's what typeof() is for. I actually like that the sorting is left to the developer, because you can't blame the language for doing it wrong/inserting crap data into your sort.
|
|
# ? Jan 9, 2014 16:44 |
|
I apologize in advance. So I've been dealing with a contracted (mostly JavaScript) developer at work for a few years now, because of some dumb Flash project he was brought in for originally, that's now spun out of control into him having influence all over poo poo. A landing page for an ad was not loading on the live site a bit ago, so I go to check the log and just curious, I open the file. This page is basically just a bunch of thumbnails that open the larger versions in a lightbox. (w/ my changes to obscure company specifics) php:<? $pagetitle = 'Redacted page title poo poo'; $meta_keywords = ''; $meta_desc = 'Redacted meta poo poo'; $pre_page_data="some-text-poo poo"; /// EDIT ABOVE define("LANDING",true); require($_SERVER['INCLUDES_LOCAL'].'/header.php'); //=============================================================== //-- BEGIN: Include Statements --------------------------------- //=============================================================== // Data Structures require_once(XX_LIBRARY_CORE.'/nodeInfo.php'); //=============================================================== //-- END: Include Statements ----------------------------------- //=============================================================== //=============================================================== //-- BEGIN: Import Statements ---------------------------------- //=============================================================== // Data Structures use _global\_core\nodeinfo\FabricNodeInfo; use _global\_core\nodeinfo\GalleryNodeInfo; // Displays //=============================================================== //-- END: Import Statements ------------------------------------ //=============================================================== //=========================================================== //-- BEGIN: Class: LandingStandardData --------------------- //=========================================================== class LandingStandardData{ // BEGIN: Data Memembers const MEDIA_IMG='img'; const MEDIA_HTML='html'; public $css=''; public $img; public $html; public $name; public $fuckingperson; public $description; public $media; // END: Data Memembers /*------------------------------------------------------- BEGIN: CONSTRUCTOR -------------------------------------------------------*/ // LandingStandardData: // Constructor function __construct(){ //trace("LandingStandardData: CONSTR"); } /*------------------------------------------------------- END: CONSTRUCTOR -------------------------------------------------------*/ /*------------------------------------------------------- BEGIN: DECONSTRUCTOR -------------------------------------------------------*/ // __destructor: // Deconstructs object. public function __destructor(){ //trace("LandingStandardData: DECONSTRUCTOR"); $this->css=NULL; $this->img=NULL; $this->html=NULL; $this->name=NULL; $this->fuckingperson=NULL; $this->description=NULL; $this->media=NULL; //parent::__destructor(); } /*------------------------------------------------------- END: DECONSTRUCTOR -------------------------------------------------------*/ } //=========================================================== //-- END: Class: LandingStandardData ----------------------- //=========================================================== // Detail $pfx_detail=CDN_IMG_SERVER . '/_images/_some-loving-path/' . $pre_page_data; // Fabric $pfx_fabric=CDN_IMG_SERVER . GalleryNodeInfo::PREFIX_IMAGE_FABRIC . FabricNodeInfo::PREFIX_IMAGE_SWATCH; $sfx_fabric='.jpg' . GalleryNodeInfo::RASTER_DATA_BITMAP_FABRIC; // Related $pfx_related=CDN_IMG_SERVER . '/_images/_some-loving-path/'; $pfx_related_thumb=$pfx_related.'thumbs/'; $rd_related_thumb=GalleryNodeInfo::RASTER_DATA_BITMAP_RELATED; // Video $pfx_video='/_data/video-data.php?video='; $sfx_video='&amp;autohide=1&amp;showinfo=0&amp;autoplay=1&amp;rel=0'; // Data Structures $data_redacted= array(); $data_related= array(); // BEGIN: redacted Mention Data //// item: redacted item name array_push($data_redacted, $ds=new LandingStandardData()); $ds->media=LandingStandardData::MEDIA_IMG; $ds->img='redacted.jpg'; $ds->name='Redacted Name'; $ds->fuckingperson='Redacted person name'; //// item: redacted item name array_push($data_redacted, $ds=new LandingStandardData()); $ds->media=LandingStandardData::MEDIA_IMG; $ds->img='redacted.jpg'; $ds->name='Redacted Name'; $ds->fuckingperson='Redacted person name'; //// item: FOS video //// item: redacted item name array_push($data_redacted, $ds=new LandingStandardData()); $ds->media=LandingStandardData::MEDIA_IMG; $ds->img='redacted.jpg'; $ds->name='Redacted Name'; $ds->fuckingperson='Redacted person name'; // END: redacted Mention Data // BEGIN: Related Data //// item: redacted item name array_push($data_redacted, $ds=new LandingStandardData()); $ds->media=LandingStandardData::MEDIA_IMG; $ds->img='redacted.jpg'; $ds->name='Redacted Name'; $ds->fuckingperson='Redacted person name'; //// item: redacted item name array_push($data_redacted, $ds=new LandingStandardData()); $ds->media=LandingStandardData::MEDIA_IMG; $ds->img='redacted.jpg'; $ds->name='Redacted Name'; $ds->fuckingperson='Redacted person name'; //// item: redacted item name array_push($data_redacted, $ds=new LandingStandardData()); $ds->media=LandingStandardData::MEDIA_IMG; $ds->img='redacted.jpg'; $ds->name='Redacted Name'; $ds->fuckingperson='Redacted person name'; //// item: redacted item name array_push($data_redacted, $ds=new LandingStandardData()); $ds->media=LandingStandardData::MEDIA_IMG; $ds->img='redacted.jpg'; $ds->name='Redacted Name'; $ds->fuckingperson='Redacted person name'; //// item: redacted item name array_push($data_redacted, $ds=new LandingStandardData()); $ds->media=LandingStandardData::MEDIA_IMG; $ds->img='redacted.jpg'; $ds->name='Redacted Name'; $ds->fuckingperson='Redacted person name'; //// item: redacted item name array_push($data_redacted, $ds=new LandingStandardData()); $ds->media=LandingStandardData::MEDIA_IMG; $ds->img='redacted.jpg'; $ds->name='Redacted Name'; $ds->fuckingperson='Redacted person name'; //// item: redacted item name array_push($data_redacted, $ds=new LandingStandardData()); $ds->media=LandingStandardData::MEDIA_IMG; $ds->img='redacted.jpg'; $ds->name='Redacted Name'; $ds->fuckingperson='Redacted person name'; //// item: redacted item name array_push($data_redacted, $ds=new LandingStandardData()); $ds->media=LandingStandardData::MEDIA_IMG; $ds->img='redacted.jpg'; $ds->name='Redacted Name'; $ds->fuckingperson='Redacted person name'; //// item: redacted item name array_push($data_redacted, $ds=new LandingStandardData()); $ds->media=LandingStandardData::MEDIA_IMG; $ds->img='redacted.jpg'; $ds->name='Redacted Name'; $ds->fuckingperson='Redacted person name'; //// item: redacted item name array_push($data_redacted, $ds=new LandingStandardData()); $ds->media=LandingStandardData::MEDIA_IMG; $ds->img='redacted.jpg'; $ds->name='Redacted Name'; $ds->fuckingperson='Redacted person name'; //// item: redacted item name array_push($data_redacted, $ds=new LandingStandardData()); $ds->media=LandingStandardData::MEDIA_IMG; $ds->img='redacted.jpg'; $ds->name='Redacted Name'; $ds->fuckingperson='Redacted person name'; //// item: redacted item name array_push($data_redacted, $ds=new LandingStandardData()); $ds->media=LandingStandardData::MEDIA_IMG; $ds->img='redacted.jpg'; $ds->name='Redacted Name'; $ds->fuckingperson='Redacted person name'; //// item: redacted item name array_push($data_redacted, $ds=new LandingStandardData()); $ds->media=LandingStandardData::MEDIA_IMG; $ds->img='redacted.jpg'; $ds->name='Redacted Name'; $ds->fuckingperson='Redacted person name'; //// item: redacted item name array_push($data_redacted, $ds=new LandingStandardData()); $ds->media=LandingStandardData::MEDIA_IMG; $ds->img='redacted.jpg'; $ds->name='Redacted Name'; $ds->fuckingperson='Redacted person name'; //// item: redacted item name array_push($data_redacted, $ds=new LandingStandardData()); $ds->media=LandingStandardData::MEDIA_IMG; $ds->img='redacted.jpg'; $ds->name='Redacted Name'; $ds->fuckingperson='Redacted person name'; //// item: redacted item name array_push($data_redacted, $ds=new LandingStandardData()); $ds->media=LandingStandardData::MEDIA_IMG; $ds->img='redacted.jpg'; $ds->name='Redacted Name'; $ds->fuckingperson='Redacted person name'; //// item: redacted item name array_push($data_redacted, $ds=new LandingStandardData()); $ds->media=LandingStandardData::MEDIA_IMG; $ds->img='redacted.jpg'; $ds->name='Redacted Name'; $ds->fuckingperson='Redacted person name'; // END: Related Data ?> <!-- BEGIN: appContainer --> <div id="appContainer" class="gallery"> <!-- BEGIN: rgnDetail --> <div id="rgnDetail" class="gallery-detail"> <section> <!-- BEGIN: scrnDetail --> <div id="scrnDetail" class="gallery-detail fos"> <!-- BEGIN: displaySet --> <div class="displaySet"> <!-- BEGIN: imageArea --> <div class="imageArea"> <div class="imageContainer"> <div class="thumbImg"> <span class="data"><img src="<?=$pfx_detail;?>.jpg" alt="" class="th_detail"></span> </div> <img class="scrolldown" src="<?= CDN_IMG_SERVER?>/_images/_global/instructions/scroll-down.png" width="43" alt="SCROLL DOWN" title="SCROLL DOWN"> </div> </div> <!-- END: imageArea --> <!-- BEGIN: fixedwidth --> <div class="fixedwidth abstract_top"> <!-- BEGIN: menubar --> <div class="menubar"> <!-- BEGIN: utilitynav --> <div class="utilitynav chromeGrey disabled"> <nav> <ul class="navigation"> <br class="clear" /> </ul> </nav> </div> <!-- END: utilitynav --> <!-- BEGIN: cartnav --> <div class="cartnav chromeGrey"> <nav> <ul class="navigation"> <br class="clear" /> </ul> </nav> </div> <!-- END: cartnav --> <div class="clear"></div> </div> <!-- END: menubar --> <div class="clear"></div> <!-- BEGIN: left column --> <div class="column2 left"> <!-- BEGIN: infoPanel --> <div class="infoPanel"> <? /* <!-- BEGIN: share --> <div class="data share"> <p><strong class="txt_lrg">Share</strong> <span class="txt_sm">this image.</span></p> include(INCLUDES.'/social-media-buttons.php'); <br class="clear" /> </div> <!-- END: share --> //*/ ?> <h1>Redacted Title</h1> <!-- BEGIN: copy --> <div class="copy"> <p>Redacted content. This poo poo expands in a single line WAY off the page.</p> <p>Redacted content. This poo poo expands in a single line WAY off the page.</p> <p>Redacted content. This poo poo expands in a single line WAY off the page.</p> </div> <!-- END: copy --> </div> <!-- END: infoPanel --> </div> <!-- END: left column --> <!--// BEGIN: right column //--> <div class="column2 right last"> <!--// BEGIN: redacted-mention //--> <div class="redacted-mention"> <!--// BEGIN: thumbDisplaySet //--> <ul class="thumbDisplaySet"> <? $html=''; $length=sizeof($data_redacted); for($i=0; $i<$length; $i++){ $ds=$data_redacted[$i]; $media=$ds->media; $lbd='data-light-box-type="'.$media.'" '; switch($media){ default: case LandingStandardData::MEDIA_IMG: $lbd.='data-light-box-url="'.$pfx_related.$ds->img.'" '; $copy='<h1 class="name"><a '.$lbd.'><span class="label">Redacted Text</span> “'.$ds->name.'”</a></h1>'; $copy.='<h2 class="fuckingperson" ><a '.$lbd.'>by '.$ds->fuckingperson.'</a></h2>'; break; case LandingStandardData::MEDIA_HTML: $lbd.='data-light-box-url="'.$ds->html.'" '; $copy='<h1 class="name"><a '.$lbd.'><span class="label">Video –</span></a></h1>'; $copy.='<h2 class="fuckingperson" ><a '.$lbd.'>'.$ds->description.'</a></h2>'; break; } $html.='<!--// BEGIN: item //-->'; $html.='<li class="thumbDisplayItem '.$ds->css.'">'; $html.='<section>'; $html.='<div class="thumb"><div class="thumbImg">'; $html.='<a '.$lbd.'><span class="data"><img src="'.$pfx_related_thumb.$ds->img.'" /></span></a>'; $html.='</div></div>'; $html.=$copy; $html.='</section>'; $html.='</li>'; $html.='<!--// END: item //-->'; } echo $html; ?> <br class="clear" /> </ul> <!--// END: thumbDisplaySet //--> </div> <!--// END: redacted-mention //--> </div> <!--// END: right column //--> <div class="clear"></div> </div> <!--// END: fixedwidth //--> <!--// BEGIN: relatedContainer //--> <div id="relatedContainer" class="dark"> <div class="related content fixedwidth abstract_btm"> <h2>More Bullshit Here</h2> <? /* <!--// BEGIN: thumbDisplaySet (video) //--> <ul class="thumbDisplaySet"> <!--// BEGIN: item //--> <li class="thumbDisplayItem video"> <section> <div class="thumb"><div class="thumbImg"> THIS IS A SINGLE LINE OF CODE THAT I'VE BROKEN UP FOR THE POST <a data-light-box-type="html" data-light-box-title="" data-light-box-url="/_data/video-data.php?video=redactedYouTubeID&amp;autohide=1&amp;showinfo=0&amp;autoplay=1&amp;rel=0"> <span class="data"> <img src="<?=$pre_related_thumb?>-vid.jpg"></span></a> END SINGLE LINE </div></div> </section> </li> <!--// END: item //--> <br class="clear" /> </ul> <!--// END: thumbDisplaySet (video) //--> //*/ ?> <!--// BEGIN: thumbDisplaySet (image) //--> <ul class="thumbDisplaySet"> <? $html=''; $length=sizeof($data_related); for($i=0; $i<$length; $i++){ $ds=$data_related[$i]; $lbd='data-light-box-type="img" data-light-box-url="'.$pfx_related.$ds->img.'"'; $html.='<!--// BEGIN: item //-->'; $html.='<li class="thumbDisplayItem">'; $html.='<section>'; $html.='<div class="thumb"><div class="thumbImg">'; $html.='<a '.$lbd.'><span class="data"><img src="'.$pfx_related_thumb.$ds->img.'" /></span></a>'; $html.='</div></div>'; $html.='<h1 class="name"><a '.$lbd.'>'.$ds->name.'</a></h1>'; $html.='<h2 class="fuckingperson" ><a '.$lbd.'>by '.$ds->fuckingperson.'</a></h2>'; $html.='</section>'; $html.='</li>'; $html.='<!--// END: item //-->'; } echo $html; ?> <br class="clear" /> </ul> <!--// END: thumbDisplaySet (image) //--> </div> </div> <!--// END: relatedContainer //--> </div> <!-- END: displaySet --> </div> <!-- END: scrnDetail --> </section> </div> <!-- END: rgnDetail --> </div> <!-- END: appContainer --> <? require(INCLUDES.'/footer.php'); ?> substitute fucked around with this message at 17:34 on Jan 9, 2014 |
# ? Jan 9, 2014 17:31 |
|
Manslaughter posted:That's what typeof() is for. I actually like that the sorting is left to the developer, because you can't blame the language for doing it wrong/inserting crap data into your sort. Allowing use of a caller-specified comparator function does not preclude the language from having sane default sort behavior.
|
# ? Jan 9, 2014 17:39 |
|
I think Javascript's default is about as sane as you can get once you decide that comparing values of different types is legal and meaningful. The obvious error-case for trying to do the "right" thing and aort numbers numerically is an array like [10, 2, '10', '2'], which wouldn't have a total ordering. PHP's solution of treating strings that happen to contain numbers as numbers is far more problematic.
|
# ? Jan 9, 2014 18:15 |
|
substitute posted:I apologize in advance. Jesus. You're dealing with an architecture astronaut with a bunch of cargo cult poo poo thrown in for good measure.
|
# ? Jan 9, 2014 18:17 |
|
..btt posted:A better result than php at least http://php.net/natsort
|
# ? Jan 9, 2014 18:26 |
|
Bognar posted:He gets a count of the rows in the table, then loops up to that count issuing a new query to get each row. This instead of, you know, just executing a single SELECT query on the database. It also makes the incredible assumption that the row ids are always continuous. Oh. That looks like he's just thinking in terms of Python. I can see someone doing that if they don't understand SQL/how to query SQL from Python correctly. Wait, no, he's got an actual query there. I have no idea then
|
# ? Jan 9, 2014 18:27 |
|
One of the owners of my firm hired some web dev company to do something which would have taken me 4-5 hours to do, without checking in with me before doing this. They billed us $25k and when I went to sign up for the site to give it a test, they emailed me my password in plaintext, then emailed it to me in plaintext again when I requested a password reset. Hoorayyyyyy
|
# ? Jan 9, 2014 20:37 |
|
McGlockenshire posted:Jesus. Thanks for that reference. I didn't know that term, but the concept is SO familiar...
|
# ? Jan 9, 2014 23:42 |
Today's ibuprofen brought to you buy a javascript library that automatically grabs config files based on the user's language (ex. "en-US.js") and a web application that doesn't allow you to upload files with a hyphen in the name for an unknown reason (ex. "en-US.js"). Put em together in one room and it's a crazy wacky sitcom coming this summer on fox!
|
|
# ? Jan 9, 2014 23:55 |
|
Why are you uploading the javascript files via a web application?
|
# ? Jan 10, 2014 00:03 |
|
Plorkyeran posted:I think Javascript's default is about as sane as you can get once you decide that comparing values of different types is legal and meaningful. The obvious error-case for trying to do the "right" thing and aort numbers numerically is an array like [10, 2, '10', '2'], which wouldn't have a total ordering. It would if you ordered values of different types by comparing typeof lexographically
|
# ? Jan 10, 2014 00:07 |
|
Also,code:
|
# ? Jan 10, 2014 00:11 |
|
Steve French posted:Also, Numbers sort lower than strings, "10" sorts lower than "2" (it's not a natural sort). Seems sane? code:
|
# ? Jan 10, 2014 00:42 |
|
Jewel posted:This is technically not a horror and just - in my opinion - a badly designed language feature, but gently caress it regardless. Javascript's sort function. They were probably emulating Perl behavior or other old programming language behavior.
|
# ? Jan 10, 2014 00:45 |
|
NFX posted:Numbers sort lower than strings, "10" sorts lower than "2" (it's not a natural sort). Seems sane? Sorry, my sarcasm wasn't sufficiently clear. I think it's much more sane behavior than JavaScript's given the posed constraint that it doesn't fail altogether (which IMO is the best behavior, you shouldn't be sorting on heterogenous collections without specifying a comparator yourself)
|
# ? Jan 10, 2014 00:47 |
|
McGlockenshire posted:Jesus. As Amberskin said, thank you for this term. It's perfect. I'm sharing it with the new developer in my shared office tomorrow. He'll love that.
|
# ? Jan 10, 2014 01:10 |
|
Steve French posted:Sorry, my sarcasm wasn't sufficiently clear. I think it's much more sane behavior than JavaScript's given the posed constraint that it doesn't fail altogether (which IMO is the best behavior, you shouldn't be sorting on heterogenous collections without specifying a comparator yourself) Python lets you compare values of different types, but doesn't give meaningful results. The implicit conversions are what makes it impossible to have a sane default array sort (and JS's choice is at least consistent, unlike most of the obvious options).
|
# ? Jan 10, 2014 01:43 |
Steve French posted:Why are you uploading the javascript files via a web application? The javascript files are actually stored as base 64 strings in a sql database. Yep.
|
|
# ? Jan 10, 2014 01:55 |
|
Except that sorting an array of integers lexicographically is not sane. Maybe giving not-meaningful results when sorting a heterogeneous array when an explicit comparator is not given, as python does, is not sane either. However, I care a lot more about behavior when doing something reasonable (e.g. sorting an array of integers), than I do about behavior when doing something unreasonable (e.g. sorting an array of varying types without explicitly defining a comparison function for sorting. Furthermore, it's not really clear that in the general case JavaScript's behavior is meaningful either. When the specific example is all numbers, either as integers or strings, yeah, JavaScript looks like it behaves reasonably (at the expense of sanity when sorting just numbers). But what is a meaningful sort of the following, and what would you expect JavaScript to return? [1, 2, 5, 3,[3, 4], { "foo": "baz" }, { "foo": "bar" }, "things", 56.23, "[object Object]", "[object Objecs]"].sort()
|
# ? Jan 10, 2014 01:58 |
|
Manslaughter posted:The javascript files are actually stored as base 64 strings in a sql database. Yep. God, just give up at this point. You're living in a tdwtf article.
|
# ? Jan 10, 2014 02:36 |
|
|
# ? Jun 10, 2024 07:22 |
|
Manslaughter posted:The javascript files are actually stored as base 64 strings in a sql database. Yep. Got a good laugh out of that one
|
# ? Jan 10, 2014 02:52 |