Technical & Scientific > Programming

Fuck you PHP!

<< < (3/5) > >>

ober:
@tgm What do you have against semicolons?  :)  I really don't mind Java.  Especially now that we're jumping up to Java 8.  6 was a little more painful.  Next step is to start bringing more external libraries in.  We'll get there.  We move kinda slow because we're in a regulated industry and we have a massive codebase.

@micah - My 9-5 stuff is a SaaS web platform in the clinical trial industry.  Java as the backend, JSTL/JSP as the front end.

hans:
The root of many evils is a misplaced semi-colon.

Mike:

--- Quote from: micah on November 18, 2016, 03:18:54 PM ---what kind of app/software are you guys working on now adays anyway with all your java and python tomfoolery.

I live in PHP because everything for me is web apps and web sites. Not much heavy lifting stuff going on or rendering anything that's not being sent to a web browser.

--- End quote ---

The Python app acts as a RESTful API to the front end which will eventually replace our legacy system.  Additionally, we have it running as an intermediary between our legacy system and our cXML vendors.  And it is working as an intermediary between our new SIS vendor and our legacy system.  For the front end we are looking at using Angular 2 as a JS framework and essentially building a JS application that uses the REST backend provided by Python.

We started doing the split backend / frontend road last year before we pivoted our long term approach and are just now getting back to it.  But what we did discover is that it rocks!  Everything is cleanly separated and the APIs tend to do smaller operations that are specific.  And you can totally change the front end without the backend code getting involved.

We also started using jade to build the HTML for the front end and that was pretty awesome (once you got used to it).  Building HTML was super fast and you didn't have to worry about missing closing tags.

Mike:
So this one isn't a PHP issue but it was written into our legacy system which is written in PHP.  In the system there is a "There are XYZ others online" which is suppose to give you a count of how many others users have been active within a certain amount of time.  We have a table with a datetime column called LastActive that gets update with each page hit.  So the query does a count with the condition `WHERE NOW() - LastActive < (55 * 60)`.  So immediate thought is "whats the units of that?  Looks like 55 minutes".  Last night we did some maintenance and were checking to make sure the system was quiet and the counter was showing a very different number from our own database queries.  Turns out subtracting two datetimes like the query does is completely worthless.  Here is the output that proved it to me:


--- Code: ---+---------------------+---------------------+--------------------+
| LastActive          | NOW()               | NOW() - LastActive |
+---------------------+---------------------+--------------------+
| 2016-11-22 21:59:59 | 2016-11-22 22:25:40 |               6581 |
| 2016-11-22 22:00:00 | 2016-11-22 22:25:40 |               2540 |
+---------------------+---------------------+--------------------+

--- End code ---

So one second difference in LastActive but thousands different in the result.

Well, I figured out why.

Take `2016-11-22 21:59:59` and `2016-11-22 22:25:40` and remove all non-numeric characters. from each.  You know have `20161122215959` and `20161122222540` which you now do the math on.  Giving you 6581.

Even before I figure that out I ended up changing the query to the much more sane `WHERE LastActive >= NOW() - INTERVAL 15 MINUTE`

Mike:
Yet more PHP hate:


php > echo (int) '124hello845';
124


Seriously, fuck you PHP.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version