|
Internally, the Boehm GC hack is extremely clever, but extremely awful. There's papers on the implementation details. It's everything C was not designed to do.
|
# ? Jul 4, 2012 19:10 |
|
|
# ? Apr 19, 2024 16:39 |
|
Suspicious Dish posted:Yeah, so the guy just doesn't understand conservative stack scanning. Given that the register is swamped before the GC is called, I don't see any other way around it, other than taking an explicit root. Does the C standard promise a scannable stack? Serious question, I don't know much about this stuff.
|
# ? Jul 4, 2012 21:17 |
|
It doesn't even promise a stack.
|
# ? Jul 4, 2012 21:29 |
|
Suspicious Dish posted:Without conservative stack scanning, creating a new object could call a GC. Since the temporary strings aren't referenced by any object, it would get collected. The alternative is an explicit root API, to let the GC know that it should not be collected. It would look like this: So instead the alternative being chosen is ... rooting objects not by using any sane API or anything, but instead by making sure you have a pointer to them somewhere on the stack. Honestly I don't see how that's any better. You still need to be explicit about rooting your objects, but instead of being testable you now have to worry about forgetting to root an object, having it work just fine on your machine, and then silently break in some later build.
|
# ? Jul 4, 2012 21:50 |
|
Otto Skorzeny posted:Ray Kurzweil is perhaps the most talented masturbator to have ever lived, show some respect! Yeah, but in our lifetimes we will have constructed machines that masturbate quantitatively and qualitatively better than any human could even imagine!
|
# ? Jul 4, 2012 22:07 |
|
I found a rather hilarious coding horror today in our website's ordering process. For a few fields empty strings were being replaced by 0. This is particularly strange because I haven't made any changes to how the website places orders for a few months, and have never had a reason to touch the fields that were breaking. When I did some digging, I found this line of code in each of the affected fields: substr(trim($this->ShippingContact),0,25) In this case, if trim() returned an empty string, then substr would be confused since there isn't a "0" position in an empty string. This makes substr return boolean false, which then gets passed into our database as if it were a bit field, making it 0. Note that this is all in PHP, and once again this line of code hasn't changed for probably 2 years since we released this latest version. This bug, thanks to PHP being the horror that it is, should have been existent for the entire time. Why did it suddenly start breaking? This weekend we changed how our database class works. We had a function that builds insert and update statements based on an array of values. Basically it just made it really easy to do prepared statements, and until a few months ago I never looked into that code. The person who wrote the function actually just made a loop create a concatenated SQL query, and wasn't actually using prepared statements! Since it was building queries from scratch, rather than preparing them like it should have been, it was also manually escaping quotes. $field_data = str_replace("'", "''", $field_data); Apparently substr() can't tell that an empty string should stay an empty string, but str_replace() can tell that boolean false should be an empty string after all the single quotes were removed from the... boolean false? So a horror in PHP revealed a horror in our code, which then revealed even more horrors in PHP! It's a horrorception!
|
# ? Jul 5, 2012 16:47 |
|
Frozen-Solid posted:In this case, if trim() returned an empty string, then substr would be confused since there isn't a "0" position in an empty string. This makes substr return boolean false, which then gets passed into our database as if it were a bit field, making it 0. Why in the world would substr ever return anything that wasn't a string? This is a horror in itself.
|
# ? Jul 5, 2012 17:07 |
|
Ari posted:Why in the world would substr ever return anything that wasn't a string? This is a horror in itself. Because the core of PHP was designed before exceptions were added, and because the PHP core devs think that adding exceptions to the core functions would break the world, core functions tend to return false or null when something goes awry. It happens that substr returns false when you give it bogus arguments.
|
# ? Jul 5, 2012 17:33 |
|
When using PHP it should be mandatory to check all functions returns against === false. Because of PHP's 'creative' tendencies with false,null,0 and empty string the only way to be sure is ===, == does not cut it.
|
# ? Jul 5, 2012 17:37 |
|
Sometimes the return value changes between versions for those error cases https://bugs.php.net/bug.php?id=50696
|
# ? Jul 5, 2012 18:45 |
|
McGlockenshire posted:Because the core of PHP was designed before exceptions were added, and because the PHP core devs think that adding exceptions to the core functions would break the world, core functions tend to return false or null when something goes awry. ...and str_replace() doesn't.
|
# ? Jul 5, 2012 18:46 |
|
qntm posted:...and str_replace() doesn't. code:
|
# ? Jul 5, 2012 18:52 |
|
Frozen-Solid posted:In this case, if trim() returned an empty string, then substr would be confused since there isn't a "0" position in an empty string. This makes substr return boolean false, which then gets passed into our database as if it Note that this is also a design flaw; pretty much every other substring operation in the world permits a substring to begin immediately after the last character. The basic bug here is that PHP's library design fears and loathes the empty string.
|
# ? Jul 5, 2012 19:07 |
|
I love how this thread always comes back to PHP.
|
# ? Jul 5, 2012 19:09 |
|
PHP is a great example of mediocrity at work... Some dude created his own templating system, some other dudes hack on it, wanna-be coders everywhere adopt it en-masse. Popularity used as proof that it's great. For reference I saw all sorts of similar horrors from coders back when I was doing ASP classic/VBScript... Including a whole host of Byzantine logic and "fun" type coercion crap. The difference is that VBScript was designed as a language by people who knew what they were doing so it produces far fewer WTFs from the platform and language itself. Did you love the mixing of logic and presentation in Classic ASP, but hate all that useless language design? PHP: Party like its 1998!
|
# ? Jul 5, 2012 23:43 |
|
Did you know that PHP has closures?PHP code:
|
# ? Jul 5, 2012 23:52 |
|
Suspicious Dish posted:Did you know that PHP has closures? But the error will only be a warning, and who looks at those in PHP?
|
# ? Jul 6, 2012 00:02 |
|
Suspicious Dish posted:Did you know that PHP has closures? There is no horror here. Functions always have isolated scope in PHP. The use clause when creating a closure expressly defines what specific parts of the outside scope are made available to the closure. You can even decide whether or not the scope binding is done at define time or at call time. The "error" is a Notice, the same Notice you get whenever doing anything with an uninitialized variable, closure, function or otherwise.
|
# ? Jul 6, 2012 00:31 |
|
Suspicious Dish posted:Did you know that PHP has closures? I wonder if PHP's closures are as useful and well written as its anonymous functions. For reference, if you call create_function() PHP uses eval() to create a function called __lambda_func_. It's all the functionality of eval() with no advantages whatsoever.
|
# ? Jul 6, 2012 00:35 |
|
Kim Jong III posted:I wonder if PHP's closures are as useful and well written as its anonymous functions. You shouldn't have to use create_function anymore since functions are first-class citizens in PHP now. php:<? $func1 = create_function('$a,$b','return $a+$b;'); $func2 = function($a,$b) { return $a+$b; }; echo $func1(3,4) . "\n"; echo $func2(3,4) . "\n"; ?>
|
# ? Jul 6, 2012 06:33 |
|
Thermopyle posted:I love how this thread always comes back to PHP. Ender.uNF posted:PHP is a great example of mediocrity at work... Some dude created his own templating system, some other dudes hack on it, wanna-be coders everywhere adopt it en-masse. Popularity used as proof that it's great. http://otherwise-than-code.blogspot.com.au/2012/07/complex-made-easy-or-debate-over-php.html
|
# ? Jul 6, 2012 08:17 |
|
Thermopyle posted:I love how this thread always comes back to PHP. Well, a lot of people use PHP, and many of those people use Git, so it's the best platform ever.
|
# ? Jul 6, 2012 13:09 |
|
quote:In fact, it evolves much faster than any other language or web platform. quote:It took some time, but PHP 5.4 also comes with some nice syntactic sugar that makes the whole experience better than ever: yes, PHP supports [] to define arrays; yes, PHP supports calling a method on a newly created object ((new Foo())->bar());
|
# ? Jul 6, 2012 13:53 |
Aleksei Vasiliev posted:
Doesn't this just mean "they're working overtime attempting to cover up all the terribleness while accidentally breaking things all the time"?
|
|
# ? Jul 6, 2012 14:10 |
|
Seriously the only good thing about php is its ubiquitous deployment that "works enough" out of the box. Everything else it does is done better elsewhere. That whole anti-rant screams "this is the only tool I know and I will defend it to my death"
|
# ? Jul 6, 2012 14:41 |
|
Aleksei Vasiliev posted:what the gently caress, this is a feature? Isn't this 100% normal for any OO language? Why wasn't it available as soon as objects were?
|
# ? Jul 6, 2012 14:44 |
|
Aleksei Vasiliev posted:what the gently caress, this is a feature? Isn't this 100% normal for any OO language? Why wasn't it available as soon as objects were? I love how pretty much the only good thing that can be said about PHP is when functionality is added that should have existed in the first place.
|
# ? Jul 6, 2012 16:26 |
|
Civil Twilight posted:Well, a lot of people use PHP, and many of those people use Git, so it's the best platform ever. When your defense of a language starts with "PHP is the most common serverside scripting language. PHP must have done something right, no?" it's not looking good. quote:Almost all major PHP libraries, frameworks, and products are now using Git, including PHP itself.
|
# ? Jul 6, 2012 16:57 |
|
Steampunk Hitler posted:http://otherwise-than-code.blogspot.com.au/2012/07/complex-made-easy-or-debate-over-php.html quote:Since Google often lies nearby so do the solutions to even your most obscure problems with PHP, and so PHP is easy. I don't have any experience with PHP, but I do with another language with a similarly large and "skilled" userbase, VB6. This statement is not true. There may be solutions to even your most obscure problems, but you will never find them, because they are hidden amongst tens of thousands of posts by idiots who lack even the most basic understanding of programming or the language they are using, with responses floundering about with random guesses that rarely succeed at resolving the actual problem.
|
# ? Jul 6, 2012 17:16 |
|
php does have a problem, and that problem is w3schoolsan awesome commenter posted:Imperfection can be a great concept. Might sound stupid, but we as humans have learned to deal with imperfection pretty well. That's why we started to use tools. Fast forward to today, I think it still helps us to learn and to progress. Probably that's one part of what has been done right. There ain't no true problems as there ain't no true solutions. Sorry for getting a bit philosophical here. I really enjoy that the discussion is coming on a meta level at larger scale now, that feels like fresh air.
|
# ? Jul 6, 2012 17:23 |
|
That Google argument is pretty great since the vast majority of solutions you can easily find on Google to problems are flawed in some way, often a way that isn't immediately obvious. Lowercasing a String in Java with toLowercase() can break your app if you rely on it to act like the String is English, not Turkish; reading/writing a text file without defining an encoding will only work fine if you're working solely in ASCII; various other things I can't remember off the top of my head but I know are rarely discussed in tutorials/answers and that will break stuff I've written under certain conditions if I hadn't known about them. easy example of that I found in 15s: Java Traps: Big Decimal Selected excerpt posted:double d1 = 2.2;
|
# ? Jul 6, 2012 17:29 |
|
Is that still the case? That article's talking about an 8 year old version of Java.
|
# ? Jul 6, 2012 17:43 |
|
Aleksei Vasiliev posted:various other things I can't remember off the top of my head but I know are rarely discussed in tutorials/answers and that will break stuff I've written under certain conditions if I hadn't known about them. To be fair, that constructor quirk is at least noted in the javadocs: http://docs.oracle.com/javase/6/docs/api/java/math/BigDecimal.html#BigDecimal(double).
|
# ? Jul 6, 2012 17:43 |
|
Zorro KingOfEngland posted:To be fair, that constructor quirk is at least noted in the javadocs: http://docs.oracle.com/javase/6/docs/api/java/math/BigDecimal.html#BigDecimal(double). (Also I only spent 15s reading his post, too, so I might have missed if he actually recommends a proper fix )
|
# ? Jul 6, 2012 17:49 |
|
Ah, the elusive "not really a horror, just covers a use case you didn't think of".
|
# ? Jul 6, 2012 17:50 |
|
Aleksei Vasiliev posted:Lowercasing a String in Java with toLowercase() can break your app if you rely on it to act like the String is English, not Turkish; reading/writing a text file without defining an encoding will only work fine if you're working solely in ASCII; various other things I can't remember off the top of my head but I know are rarely discussed in tutorials/answers and that will break stuff I've written under certain conditions if I hadn't known about them. Java has many problems, but the fact that most developers seem to not understand character encoding is not one of them.
|
# ? Jul 6, 2012 17:52 |
|
Zombywuf posted:Java has many problems, but the fact that most developers seem to not understand character encoding is not one of them. The point he's making is that "solutions to any of the problems you'll have are just a google away, so it's easy" is bullshit, because the solutions you'll find will be written by programmers who (for example) do not understand character encoding.
|
# ? Jul 6, 2012 17:55 |
|
Aleksei Vasiliev posted:what the gently caress, this is a feature? Isn't this 100% normal for any OO language? Why wasn't it available as soon as objects were? Same reason foo(1,2,3)[0] was a syntax error until recently. the grammar is a mess.
|
# ? Jul 6, 2012 18:41 |
|
Steampunk Hitler posted:http://otherwise-than-code.blogspot.com.au/2012/07/complex-made-easy-or-debate-over-php.html quote:The array in PHP does everything. Need an array in PHP? Use array. Need a map in PHP? Use array. Need a set in PHP? Use array. PHP arrays are the ultimate one-size-fits-all data structure. ...and so PHP is complex Lua's table is a similar "one-size-fits-all data structure", and JavaScript's objects/arrays aren't far off. There's no inherent complexity here. PHP suffers from impossibly unintuitive interactions between library functions and its one true data structure.
|
# ? Jul 6, 2012 18:46 |
|
|
# ? Apr 19, 2024 16:39 |
|
Lua's tables are significantly more one-size-fits-all, since there outright aren't any other data structures (other than closures). However, Lua doesn't really suffer from the specific problem he's talking about. The problem is that there's a basic data structure which tries to do everything, but doesn't come close to doing everything since it isn't actually an object. In Lua, there's no temptation to implement a set with a table plus array_unique, since you can just override __newindex in the metatable for the same initial amount of effort and have a real set. I do think he's overstated the degree to which it's a problem, though. PHP's arrays are pretty obviously the result of a bunch of features being crammed in rather than any sort of design, but the end result isn't all that bad.
|
# ? Jul 6, 2012 19:14 |