|
tef posted:'we don't write cgi-scripts any more'
|
# ? Dec 9, 2010 16:30 |
|
|
# ? Apr 27, 2024 14:11 |
|
Hell yeah, php.png going into the archives.
|
# ? Dec 9, 2010 16:30 |
|
tef posted:Reminds me of Javascript's if([0]&&[0]==false)
|
# ? Dec 9, 2010 16:33 |
|
Janin posted:speak for yourself goondolences, bro
|
# ? Dec 9, 2010 17:42 |
|
The Reaganomicon posted:Reminds me of Javascript's if([0]&&[0]==false) What would you expect the logical and of two arrays to be?
|
# ? Dec 9, 2010 18:17 |
|
Munkeymon posted:What would you expect the logical and of two arrays to be? I'd expect an array, in a boolean context, to evaluate as bool(array.length). Javascript has this lovely thing where one item arrays are equivalent to array[0].
|
# ? Dec 9, 2010 18:28 |
|
Munkeymon posted:What would you expect the logical and of two arrays to be? I would expect it to be consistent. a&&b is true iff both a and b are true. [0]&&[0] is false, thus [0] must be false. But if([0]) is true. As an aside, I understand where this comes from, but holy poo poo Boole is spinnin' in he grave.
|
# ? Dec 9, 2010 18:39 |
|
interncodecode:
|
# ? Dec 9, 2010 19:22 |
|
tef posted:I gave half a talk on php last night to a local techie startup group - the first half was a php apologist - my talk wasn't so flattering: 'php: a great way to write cgi scripts' and 'we don't write cgi-scripts any more' I was really hoping that this matrix was asymmetric, because that would have just been icing on the cake.
|
# ? Dec 9, 2010 19:31 |
From 2 pages ago, but I had to comment on this.Xenogenesis posted:OT: I present beautiful handwritten SQL for a small Rails app: Seriously. What is that subquery supposed to be doing at all? The join in it being a no-op doesn't exactly help. Join on (blah and foo < s3.judgement). Where s3.judgement is null.
|
|
# ? Dec 9, 2010 20:41 |
|
Holy balls I noticed that 0 == "" and 0 == null in PHP. Also "string" == 0 in PHP. This is literally the worst thing created. At least Perl has some hosed up logic behind it's typeless crazytown. img-php.png indeed.
|
# ? Dec 9, 2010 20:43 |
|
NotShadowStar posted:Holy balls I noticed that 0 == "" and 0 == null in PHP. Also "string" == 0 in PHP. There is some logic behind it. 0 and "" are basically seen as 'empty', and 'null' can also be empty when doing the type juggling thing. You can use '===' for strict comparisons, is_null() for null values, length of the string, etc. As for "string" == 0, this is because when you use loose comparison, it will try to read strings as numbers. As an example "43.2" == 43.2. When it hits a word it can't handle, it gives '0', as in 'not a string'. Generally speaking, this is used so you can write php:<? if ($any_data_structure) return "data structure contains something"; else return "data structure is empty"; ?> This is pretty terrible in a lot of cases, but that kind of type juggling crap is what makes PHP very quick to use for web stuff. You can take a string parameter from $_POST or $_GET and compare it to a number or whatever and still get what you want. Note that you can also cast "324" as an int and it will do the type conversion for you. I would hate going back to PHP for my job, but for quick projects where you don't give a poo poo (which is a lot of web dev stuff on low budget), it's a perfect chainsaw language.
|
# ? Dec 9, 2010 21:06 |
|
The Reaganomicon posted:I would expect it to be consistent. a&&b is true iff both a and b are true. [0]&&[0] is false, thus [0] must be false. But if([0]) is true. Ah poo poo - I didn't think about it and just checked that [0] == false, which I actually find much more confusing than if([0]) being true. I guess I need to go reread the part of the spec dealing with type manging. king_kilr posted:I'd expect an array, in a boolean context, to evaluate as bool(array.length). Javascript has this lovely thing where one item arrays are equivalent to array[0]. But you can set array.length to whatever you want, so having a length doesn't even mean there's anything in there. The fact that there's a non-null, non-undefined object that I can ask about a length property would mean that it ought to be true in a boolean context (in Javascript - if you are reading this, please don't apply that as a blanket statement to all languages or to your language of choice). Also: code:
|
# ? Dec 9, 2010 21:14 |
|
The whole "omg PHP type-juggling" thing is a bit of a dead horse isn't it? Yeah it's not always terribly consistent, it's meant to allow you to Get poo poo Done quickly. It's not necessarily optimised for that, but it doesn't do too badly. It does give you ways to compare things carefully when you need to do so. The main comparison-operator complaint I have about PHP is that if you want to check whether a variable exists and is null, you have to use array_key_exists($var, $GLOBALS). You can't use isset() (because it returns false if the variable is set but is null) and you can't use is_null() (because it returns true if the variable doesn't exist) (you still shouldn't use is_null even if it didn't do this, mind, because it will cause unset variable notices).
|
# ? Dec 9, 2010 21:21 |
|
NotShadowStar posted:Holy balls I noticed that 0 == "" and 0 == null in PHP. Also "string" == 0 in PHP. code:
|
# ? Dec 9, 2010 21:21 |
|
McGlockenshire posted:
The result depends on the other side of the comparison and is always consistent with regards to that. It also supports === as a strict comparison operator. php:<? php > var_export( "string" === 0 ); false php > var_export( (bool)"string" ); true php > var_export( true === 0 ); false ?>
|
# ? Dec 9, 2010 21:24 |
|
We'll stop bitching about PHP when people stop writing PHP applications.
|
# ? Dec 9, 2010 21:29 |
|
Munkeymon posted:Also: Not sure why this is confusing. Surely its just creating two separate arrays and comparing them by reference.
|
# ? Dec 9, 2010 21:30 |
|
A conversation today reminded me of this ... thing of wonder. A product we're phasing out has a core (ahem) generic container class used to store all kinds of things. A core container class that masquerades as a vector. Taking a method at random shows the jewels within. code:
Spectral Elvis fucked around with this message at 21:34 on Dec 9, 2010 |
# ? Dec 9, 2010 21:32 |
|
Hammerite posted:The whole "omg PHP type-juggling" thing is a bit of a dead horse isn't it? Yeah it's not always terribly consistent, it's meant to allow you to Get poo poo Done quickly. It's not necessarily optimised for that, but it doesn't do too badly. It does give you ways to compare things carefully when you need to do so. You are claiming to be a painter but all you do is cover walls in your own faeces because you can't get the paint cans open.
|
# ? Dec 9, 2010 21:38 |
|
tef posted:You are claiming to be a painter but all you do is cover walls in your own faeces because you can't get the paint cans open. If you want to slate PHP, I can think of at least 10 things that are more worthy of criticism than type-juggling.
|
# ? Dec 9, 2010 21:48 |
|
Hammerite posted:If you want to slate PHP, I can think of at least 10 things that are more worthy of criticism than type-juggling. Indeed. Beside the PHP Truth table in my cubicle I have a list that goes: strpos: haystack, needle array_search: needle, haystack link: name, target etc., etc.
|
# ? Dec 9, 2010 21:56 |
|
Hammerite posted:If you want to slate PHP, I can think of at least 10 things that are more worthy of criticism than type-juggling. I have done many many times http://forums.somethingawful.com/showthread.php?threadid=2803713&userid=0&perpage=40&pagenumber=140#post382500354 This is the list of stuff that's wrong behind the inconsistently named library, with inconsistent function arguments, functions that work differently across platforms, the grammar being crippled, the type safety, the object system, the reference system, the vm itself. php handles writing cgi scripts but doesn't handle any of the features of a modern web application. people say 'hurr' it is a language 'hurr' that mostly is embedded in apache and by default just accepts text until <?php. it is a templating language for cgi scripts. php is a domain specific language, just a level much lower than you'd get with a general purpose language and framework. php: a templating language so unfit for purpose that it spawned template libraries for it tef fucked around with this message at 22:02 on Dec 9, 2010 |
# ? Dec 9, 2010 21:57 |
|
tef posted:php handles writing cgi scripts but doesn't handle any of the features of a modern web application Seriously, CGI is a dead-simple way to get basic dynamic webpages working. It doesn't need any huge runtime libraries, any virtual machines; just compile your page, scp it, and it'll work on anything from a reflashed router to shared hosting to clusters. Also, PHP (as far as I know) can't be used to write CGI pages; it depends on an Apache/nginx/whatever module that runs the scripts themselves. I suppose you could write a CGI page using the PHP interpreter, but that's even worse than just plain ol' php Finally, CGI can do everything a modern "web application" (I hate that loving marketing phrase) can; its only disadvantage is performance, and that's solved easily by using FastCGI
|
# ? Dec 9, 2010 22:32 |
|
How'd the talk go btw tef? Also I will read the dns thing you wrote up when I get the chance, probably this weekend (doing interview prep for a Real Engineering(tm) opportunity atm)
|
# ? Dec 9, 2010 22:34 |
|
quote:Also, PHP (as far as I know) can't be used to write CGI pages; it depends on an Apache/nginx/whatever module that runs the scripts themselves. I suppose you could write a CGI page using the PHP interpreter, but that's even worse than just plain ol' php The CGI-style is the default implementation on alot of platforms. Was so common they invented fast cgi to handle it. PHP: a retarded tool for retarded people from a retarded age.
|
# ? Dec 9, 2010 22:39 |
|
Otto Skorzeny posted:How'd the talk go btw tef? Also I will read the dns thing you wrote up when I get the chance, probably this weekend (doing interview prep for a Real Engineering(tm) opportunity atm) it went well we mostly went hay, use the right tool for the job, and the talks contrasted well I mostly got asked how do you give a talk for 20 minutes without breathing. the video will be posted this week. the ddns thing needs *a lot* more work and I'm gonna work on that when I finish my actual work and stop being distracted by writing an article on parsing.
|
# ? Dec 9, 2010 22:50 |
|
Janin posted:that's the second time you've dissed cgi, and I'mma let you continue, but PHP is the worst horror of all time just sayin, modern web apps are more than just cgi, and php is barely that. ain't dissin on cgi, it's good for what it does. what i'm sayin is that you don't want to be writing in php any more than you want to be writing in c bindings for cgi, it's a lot of effort.
|
# ? Dec 9, 2010 22:51 |
|
Nevett posted:Not sure why this is confusing. Surely its just creating two separate arrays and comparing them by reference. That was in response to his second sentace quote:Javascript has this lovely thing where one item arrays are equivalent to array[0].
|
# ? Dec 9, 2010 22:59 |
|
nielsm posted:From 2 pages ago, but I had to comment on this. Hahaha, you wish that join was useless. The self join makes sure all the records on the left had a higher judgement than those on the right. The WHERE s3.judgement IS NULL removes all the rows from which there was a higher judgement. Basically it's selecting the highest judgements from the table without using group by and aggregate functions (so I can actually get the ids I need). I don't know how I live with myself either.
|
# ? Dec 10, 2010 00:10 |
|
NotShadowStar posted:Holy balls I noticed that 0 == "" and 0 == null in PHP. Also "string" == 0 in PHP. But "" != "string." a=b, b=c, but a!=c So transitivity is apparently not a property of the == operator. Also the case with "php", "0" and 0. Edit: I know why this is the case, but it just seems so wrong.
|
# ? Dec 10, 2010 00:26 |
|
HappyHippo posted:So transitivity is apparently not a property of the == operator.
|
# ? Dec 10, 2010 00:36 |
|
== and === is a horror in any language. There is never any need to do == because of the hosed-up ness of it all. Same with Javascript. http://developer.yahoo.com/yui/theater/video.php?v=crockonjs-2 quote:We have equality operators. Unfortunately they do type coercion, and they do type coercion before they compare things for equality, and that coercion can cause false positives, which is a bad thing. So I recommend to always use the triple equal operator instead, which is unfortunate, because it’s uglier, but you have to. The reason for that is… Try to find the pattern in here. There’s no transitivity at all. Transitivity says that if A and B are equal, and B and C are equal, then A and C should be equal, but they’re not. Again, we’ve got these mathematical absurdities going on where transitivity doesn’t hold, and it should. My expectation is that all of these should produce false, because in every case what’s on the left side is different than what’s on the right side. With the triple equal operator, it does the right thing; you actually get false in all the cases. So I recommend that you always, always use the triple equal operator. There might be times when you think you want the type coercion, but you should only do that if you actually understand what the type coercion will do, and I challenge anybody looking at this to guess what the conventions are.
|
# ? Dec 10, 2010 02:10 |
|
Apparently in MySQL 'a' = 'b' is false, but 'a' = 'b' = 'c' is true.
|
# ? Dec 10, 2010 02:15 |
|
Sounds like php is terrible and should never be used. What is the ultimate language to use for the web.
|
# ? Dec 10, 2010 02:54 |
|
Easy Mac posted:Sounds like php is terrible and should never be used. What is the ultimate language to use for the web. LISP MOTHERFUCKER THE ANSWER IS ALWAYS LISP
|
# ? Dec 10, 2010 02:56 |
|
Mr. Wynand posted:LISP MOTHERFUCKER THE ANSWER IS ALWAYS LISP basically the answer is: it depends. php may be terrible, but knowing the flaws of a tool allows you to apply it well if needed. most of the time all you're doing is writing a database skin so what the gently caress does it really matter
|
# ? Dec 10, 2010 03:16 |
Xenogenesis posted:Hahaha, you wish that join was useless. I see now why it works... I simply forgot to consider the case of the join failing to find any matches. Also PHP is fine to use as long as you know why it sucks. Its design still makes more sense than mIRC Script.
|
|
# ? Dec 10, 2010 12:40 |
|
nielsm posted:Also PHP is fine to use as long as you know why it sucks. Its design still makes more sense than mIRC Script. Amazingly, I am in agreement. Man, mIRC script, I haven't been concatting strings to make arrays in ages.
|
# ? Dec 10, 2010 14:24 |
|
|
# ? Apr 27, 2024 14:11 |
|
nielsm posted:Also PHP is fine to use as long as you know why it sucks. Its design still makes more sense than mIRC Script. There's a huge logical inconsistency in this statement.
|
# ? Dec 10, 2010 16:15 |