« first day (1500 days earlier)      last day (3442 days later) » 

4:00 PM
How to fix PHP: Write a completely new language, with a compatibility layer for existing code.
Wait, didn't I just describe Hack? :D
 
Hack doesn't understand references. HHVM does, though.
I really wish references didn't exist ^^
 
guys
what's really good with PHP and creating reusable DAO layer
like, I don't want to hard-code methods to retrieve objects
e.g. 'getAllCreatedLaterThan($thisDate) {}
 
@LeviMorrison Let us build... a new world! A world free of weak typing, of references, of separate symbol tables! A brave new world of a brave new PHP, a language of clean design and practicality! Let it be the language of the people, the new language of the web! Let us build it, together!
 
@NewToMS "Reusable" and "DAO" should not generally go together. The API should be reusable, but some generic class that allows you to interact with multiple tables? Heaven's no.
 
(pls star)
 
4:03 PM
You probably should write methods for each use-case.
 
really
will that library then mature?
I guess the DAO would change often during the initial phases, but then at some point you'd have just about everything you need?
I think you just gave me peace of mind....
Before, I was thinking, one DAO per table (e.g. StockDao) that implemented one method per CRUD operation
 
SQL queries are just that, they are questions. They return answers.
 
but that made 'retrieve' really quirky, and would require other devs to know more about SQL than is ideally practical...
and I suppose with one method per specific query, I could optimize the queries far better
maybe I made it seem too broad
if you have something like, public class EmployeeDao implements IDataAccessObject
that's not generic, in the sense that it's confined to a particular table
I could still optimize the query within, but I'm talking about the where clause specifically
where ID = ?, first_name = ?, so on, so forth
 
Don't create classes for each table.
 
4:09 PM
 
@NewToMS Create classes that have boundaries that make sense in your use-case.
 
is it really better to create one method per query? e.g. getByfirstName()
getById
 
One method per use-case.
 
you can optimize the queries far more (i.e. select less fields) if you have one method per use-case
*
oh actually that's not true
sorry, I'm new. trying to put it all together.
 
Stop trying to be generic and just focus completely on only what you need and absolutely no more.
^^
 
4:10 PM
I guess this is a sin, but I want it to be robust enough so that people don't need to change this library often down the road
 
If the use-case changes you have to change something anyway.
 
Can anyone here tell me how to use pushstate so that google can crawl my ajax content within my website.Does this method work?
 
In my suggested way your changes would generally be contained to a single method.
 
so you ARE saying that a generic 'retrieve' works best ? E.g. employeeDao.retrieve($whereArray)
 
No, no.
 
4:11 PM
> It is easier to optimize correct code than to correct optimized code. Premature optimization actually hinders optimization in the long run.
 
@NewToMS Let's talk about use-cases. "I need to display this month's payroll data."
 
okay, so then you mean like, 'employeeDao.retrieveTerminatedEmployees()'
 
OK, my last email to internals is rather hyperbolic.
 
@NewToMS Yeah, that's a lot better.
 
> Errors in PHP are horrible to handle. There’s absolutely no question of this RFC being revived using errors, at all. If I must, I’ll wait until exceptions are inevitably approved for core in PHP 7. Assuming they actually are. If they aren’t, I might actually quit PHP...
 
4:13 PM
or in your use-case: 'payrollDao.retrieveByMonth($month)'
 
@AndreaFaulds You spend a lot of time on PHP. Maybe you should spend a bit less ^^
 
does anyone here use pushstate so that your website can we crawled by google?
 
@NewToMS Yes.
 
that sounds so intuitive and correct
why did I feel like it was so wrong haha
 
@LeviMorrison No, I should spend more. I spend too little on my big projects and too much on small ones.
 
4:14 PM
> I might actually quit PHP.
bit much ...
 
can I open up the 'node versus php' can of worms in here?
 
@NewToMS Because it doesn't follow "software reuse" and all that jazz.
 
@JoeWatkins Yes, probably :p
 
I looked heavily into node for my 99% IO webapp that needs to be blazing fast
but went with php instead
 
You mean 99% regurgitating database queries or some other kind of IO?
 
4:16 PM
well, the results are typically going to be cached in redis, but yeah, that
95% reads, 5% writes
 
I hate Node.js. I would never recommend it because of personal bias ^^
However, I probably wouldn't recommend a normal PHP setup for that either.
 
ThW
@NewToMS node.js is not "magically fast"
 
I don't think core exceptions is inevitable, I think it's sensible, but we don't act as a sensible individual, ever ...
 
I like it a lot, but I can't see how it's a better choice than php
especially optimized php
 
Using PHP in FastCGI format could work.
 
4:17 PM
Yeah, that's what I do, with nginx
and zend opcache
 
I'm not sure how PHP's FastCGI stuff works, but can you have things that persist between requests?
 
I'm more comfortable with that than with node stack, and it seems like that setup can be just as fast
 
what are your thoughts on eliminating an MVC router component and hard-coding requests to controllers through nginx / apache?
do you think that in a high-traffic setting, that would speed things up/cut down processing time? disclaimer: not doing that until I would need to, but still curious
hard-coding routes to controllers, rather**
 
4:21 PM
@NewToMS Rather than doing that you should focus on asynchronous database queries ^^
 
@AndreaFaulds I love that ...
 
with something like SOLR?
 
I'm not well informed about SOLR; I couldn't say.
 
aren't database queries inherently asynchronous considering that PHP-FPM is instantiated once per request?
 
wut ?
 
4:22 PM
thing's going to be constantly hit by different requests
MySQL I mean
 
@NewToMS wut ?
 
hm, maybe I misunderstood
 
I'm leaving ...
 
xD
sorry!
 
I'm leaving ...
 
4:22 PM
If you are instantiating one worker per request then you aren't getting the primary benefit of asynchronous queries ^^
 
but isn't contextual stuff like that outside of the realm of PHP?
 
@NewToMS yes, across different requests. For a single request, the queries are still synchronous. That said, asynchronous queries are best used, as Levi says, in a single-thread environment...
 
From the HTTP server's point of view, database requests mean you are mostly going to be waiting around.
So you need to "wait" efficiently.
 
what are the most common ways to accomplish something like that, in a single-threaded environment?
you can't send the response until the script is finished, thus, the query finished
And is something like this needed if I use a redis cache?
 
Each thread uses an event loop and accepts and responds to many different requests.
 
4:25 PM
Holy shit, it's dark already
 
You then wire up the dependency flows:
 
back
 
sun just setting here ... also, I really am leaving ...
lata
 
Still nothing done
 
Async database queries sound like a bad idea
connection pooling in PHP sucks
 
4:26 PM
Eh... I don't know if that's really true.
This is not a typical PHP workflow; I highly doubt that whatever you read about "connection pooling in PHP" is talking about this setup.
 
what's worse? a slight delay on one query (results cached for 24 hours in my case) and the rest are fetched from redis, or async queries along with inconsistent database behavior and state that can be caused by them?
I don't think that asnyc queries would be worthwhile without some sort of pooling mechanism, and from what I've read about PHP conn pooling, it's pretty brutal
 
To repeat myself:
> I highly doubt that whatever you read about "connection pooling in PHP" is talking about this setup.
To be honest, PHP is probably the wrong tool for this job ^^
 
21
Q: Persistent DB Connections - Yea or Nay?

Brian WarshawI'm using PHP's PDO layer for data access in a project, and I've been reading up on it and seeing that it has good innate support for persistent DB connections. I'm wondering when/if I should use them. Would I see performance benefits in a CRUD-heavy app? Are there downsides to consider, perhaps ...

is that what we're discussing?
 
Wait
Connection pooling?
Like...preserving database connections between each run of a script?
 
yeah
I don't see how you can have async queries be worthwhile without connection pooling
 
4:30 PM
^^ I think you both have a lot to learn about how async setups work.
 
but I hear that persistent connections (PDO's version of connection pooling) can leave the database in weird states
well, I'd totally understand that type of setup in Java or C# etc
 
It's drastically different from how PHP is widely used.
 
but in my PHP setup, one request is more or less tied to one query, and the results are almost always cached in redis
so I do think PHP is a good choice for it
In your opinion, Levi, what are the best web use-cases for PHP
a templating language only?
 
@NewToMS what are you trying to acomplish ?
Best use case for php is making money
 
There's such little overhead in processing the requests/responses with PHP/NGINX, I'm totally fine with SQL being the bottleneck, especially given that liek I mentioned, most queries/results will be cached for 24 hours
We'll say, an automobile REST API
 
4:34 PM
@NewToMS The absolute biggest reason to use PHP is because you already have PHP developers that you like ^^
 
where cars aren't added very often, but retrieved frequently
 
The next biggest reason is because you already have a lot of PHP code already.
 
check
but let's talk about speed!
using ASP.NET or a Java web framework seems like mega overkill for this
 
If you are selling software, you would use PHP because you think your customers would want or need PHP.
 
4:35 PM
SaaS
caffetamine
O__O
 
@NewToMS If you absolutely care about speed then PHP is probably not the best language to start a new project in.
 
end of the day, shooting for the smallest response time possible, and I believe PHP delivers that
 
it's a web app
 
@NewToMS no it most likely does not
 
4:37 PM
How the data is accessed and moved is far more important than the language used to do it.
 
it's an MVC REST api
 
buzz buzz buzz.. =]
 
^^ I'm going to guess it's actually not an MVC REST API and you just don't know it yet.
 
it is!
 
lulz
 
4:38 PM
Someone link Anthony's blog post please!
 
So my alternatives would be, ASP.NET, Spring 3, node.js, python, _______
 
@NewToMS Pro tip: use whatever you can support
 
I'm only providing the raw data. CRUD
I use other multi-threaded tools to get the data, independent of the REST API which serves it
no complex processing
link me this blog post please
 
4:41 PM
Well, yeah I agree with that
this is more of a 'C' rest API
the model isn't integrated like it historically should be in MVC apps, nor are there any views
but the hard requirements are a) must be web-based, b) must be fast
 
@NewToMS Why do you care about that fast so much
 
PHP with redis, opcache seems pretty good to me
 
Imho your requirements are off
 
because a LOT of people are going to use this
 
@NewToMS do you have any numbers ?
 
4:43 PM
@NewToMS Are you sure? How do you know that?
 
what is fast?
 
@NewToMS LOT of people has nothing to do with fast
 
I'm not going out of my way to make it fast ahead of time, so much as I am just trying to stick with a framework/language/platform that will enable it to scale
up to 1k reads per minute in some cases
needs to be virtually real-time
 
@NewToMS That is not much :P
 
well, that's just at the beginning :p
but the data is in-fact time-sensitive
can I rephrase the question? why NOT fast xP
 
4:44 PM
If the difference between 10ms and 20ms is an issue don't use php
 
I'm not parsing video streams
or running algorithms of any kind
request > cache check > serve from database if miss > done
 
lol this convo is going nowhere. Speed is relative.
 
I'm not trying to seem insulting, I think this is great :) it's nice being able to bounce ideas off of other devs
 
@NewToMS In 99.9999% of the cases you don't care about fast enough, but about maintainability
 
it's like House x)
 
4:46 PM
@NewToMS So you spend most of your time waiting. You need a setup that can wait around efficiently.
I don't think PHP is the best tool for that (though it can be done).
 
well, I suppose that also depends on the scope of the project
and what you're doing in between requests and responses
like I said, my data aggregation utility is a multi-threaded java app
 
is java.. fast?
 
which simply dumps complete records into the PHP API on an interval
that part isn't time sensitive
only the reads are, and those reads only need to be fast if the data exists already
 
@RonniSkansing Yes. It's just not "mind-numbingly squeeze every ounce of performance out of my hardware" fast like C and C++ can do.
 
@LeviMorrison I was just kidding.. most stuff is "fast" imo (maybe I am slow, so everything seems fast..)
 
4:49 PM
@NewToMS What are you aiming for in terms of response times?
 
My opinion is that, if requests needed to process data extensively, make other requests, or handle anything else than checking redis/SQL, then PHP is the wrong choice
unless you're creating static web-pages that use PHP as a templating system, of course
 
@NewToMS It sounds like you are selling some kind of base solution that other people can build on.
Is that true?
 
yes
 
Then build it in whatever language you think those people want it in.
End of story.
 
they will take the data acquired from my REST API and do all kinds of processing on their own systems with
well, they access via HTTP
 
4:51 PM
1 min ago, by PeeHaa
@NewToMS What are you aiming for in terms of response times?
 
Does 'as low as I can possibly get them' qualify as an answer? ha
 
@NewToMS No that is a stupid requirement
Are you a manager? @NewToMS
 
I figured
no :(
I just don't want to use a sledgehammer where I only need a little mallet
I think the stability benefit of using something more robust could be very minimal for a use-case like this
and sacrifice performance as a result
is PHP broken? am I missing something
 
My rule of thumb always is: If you don't a have problem, there is nothing to fix
 
ah okay, that's a little more reassuring
the PHP code is about 80% complete, and I'm not having any problems or encountering any weird behavior, and I think that this stack will deliver the performance metrics that I aim for
and as aforementioned, a completely separate utility actually harvests the data
Levi, thanks for your guidance on the 'one function per use case' suggestion. It didn't feel natural, but that's what I'm going to do
A lot of the use-cases will pop up early, requiring heavy modification of the data access layer, but as it matures, those modifications will diminish a lot
(for SQL I mean)
 
4:58 PM
@NikiC Do you think C99 or a simple port to C++ would be more realistic?
For PHP?
 
realistic in what way?
 
What I mean is that staying in C89 really sucks.
 
c++ requires a highly non-trivial amount of porting work
 
So if we upgrade to something else, what do you think would be more realistic?
 
c99 just means using more features
so no question, c99
 
4:59 PM
If you want a nicer language that still compiles fast, I'd suggest Go
 
@NikiC I'm not talking about switching to idiomatic C++; I mean getting a C++ compiler to compile it in C++ mode.
 
the Zend engine wouldn't be horrific to port to C++, but the rest would be a nightmare
 
I can't believe I just called Go "nice", but...
 
@AndreaFaulds compilation, it's one of the fastest out there
 
@ircmaxell I fixed my message, fast wasn't the word I meant to question :p
 
5:00 PM
@AndreaFaulds We're not interested in fast compilation, but fast code. Go is very slow.
 
@NikiC It is?
Let's rewrite PHP... IN RUST!
 
@AndreaFaulds Absolutely. It isn't meant for the C space.
I mean "very slow" relative to systems languages, not relative to Ruby ;)
 
@NikiC "very slow". relative to a lot of things
 
well, Go is a GC-powered language...
 
also, it's rare that you really need a systems-level language speed anyway
when you're building another programming language, sure
 
5:03 PM
@ircmaxell Oh, I've known that for a while. Like the generics argument I don't think it appeals at all to PHP Internals people and may actually even hurt my RFC by mentioning it.
 
fair enough
 
But I don't like Go anyway :P
 
@NikiC How come Go is slow, though? It's not that far from C...
 
5:08 PM
@AndreaFaulds garbage collected.
 
@NikiC That means we wouldn't have to do manual refcounting...
@LeviMorrison I've got it, I've thought of a better systems language...
PHP with Recki-CT! :-)
@ircmaxell ;)
 
Non-local performance is all about smart memory allocation and usage. You can have awesome math performance in the most dynamic languages, but anything involving non-local data will be slow in languages like Go or Java (which are not particularly dynamic, but use GC and manage memory for you).
 
@AndreaFaulds all you need to do is making PHPPHP compile with Recki ;-)
 
@bwoebi :p
 
I am working with XMPP + OPENFIRE + PHP + STROPHE.JS + GAB.JS
in my web chat window ,i hae opened iframe for each user conversation.
With In every iframe i load gab.js and strophe.js files.these files create connection for one:one conversation.
MY issue is STROPHE.JS is constantly create HTTP request for all users iframes.
URL : http://chat.go-quicky.com:5280/http-bind/
my browser requesting infinite calls to : chat.go-quicky.com:5280/…
and some giving 400 Bad Request
Please guide
 
5:12 PM
@NikiC slow, but you gain safety. You can drop to C or ASM, and gain a lot of speed, but lose a lot of safety (in several fronts)
@bwoebi that is being worked on
 
@ircmaxell Or you use Rust, which is both safe and fast - bounds check notwithstanding.
 
@ircmaxell long-term goal for end 2015 maybe? …
 
@NikiC I don't know
@bwoebi if I ever get time to make classes compile...
@Gordon ping?
 
@ircmaxell pong
 
do you have that article handy with the image of MVC with the service layer in there (the large model)?
or do you know the image I'm talking about?
 
I think that's what I was thinking about
but it's not what I needed...
hmmm
 
I am not aware of another one
 
yeah, I think that's the one
for some reason I remembered differently
 
new blog post going live in 20
 
... 19
 
18
 
...?
 
...19 (damn you NTP!)
 
5:45 PM
lol
nobody willing to keep counting? Ok, I guess I'll just wait the 13 more minutes
 
10
 
4 (chosen by fair dice roll)
 
Guaranteed to be random
 
ok, I was going to push publish if you counted down to 1, but now you'll just have to wait the last minute
 
6:05 PM
posted on November 24, 2014 by Anthony Ferrara

Last week, I wrote A Beginner's Guide To MVC For The Web. In it, I described some of the problems with both the MVC pattern and the conceptual "MVC" that frameworks use. But what I didn't do is describe better ways. I didn't describe any of the alternatives. So let's do that. Let's talk about some of the alternatives to MVC... Read more »

5
 
nice!
I think that some diagrams would go a long way. just a friendly suggestion!
 
As far as the solution there...
 
@ircmaxell Nice article, once again a cliff-hanger ending :p
You could follow up with a troll, "The best solution is: none! Use only functional programming for the web, and forget this OOP stuff. Personally, I'm changing careers."
 
that would be quite the strong troll
"SMLNJ or bust"
 
6:23 PM
@ircmaxell +1, a couple of 3 letter acronyms I can skip reading.. Thanks
and about the 3 in all things.. That is the rule of three (from fairy tales)
 
> Well, more on that next time.
ARG
THE SUSPENSE!
 
Huh, the first SQL database was Oracle.
 
@AndreaFaulds World of Warcraft was the first MMO.
(That's what you made me think of)
 
@LeviMorrison No, Oracle was actually the first SQL database released commercially.
@LeviMorrison WoW, on the other hand, was not the first MMO.
 
@AndreaFaulds Probably is the first MMO when you quantify it with something, just like you did with "released commercially".
^^
 
6:32 PM
@LeviMorrison Not at all, there are countless examples of MMOs predating WoW
@LeviMorrison Oracle really was the first SQL database, though.
Oh, wait, no.
That would be System R.
Oracle was the first commercial SQL database.
System R was a research project ^^
 
^^ WoW was the first MMO.
 
@LeviMorrison Hey, it wasn't that inaccurate of a statement.
 
@LeviMorrison WoW was the first graphical MMO. The first MMOs were MUCK, MUSH, MOO, or MUD telnet games.
 
@FlorianMargaine would you rather me take a year, write it as a book?
 
6:37 PM
@ChrisBaker hahahaha no
 
@ircmaxell well, if it's so hard that you can't explain it in a page, you probably don't understand it well enough :P
 
@AndreaFaulds hahahah yes? Online games, large persistent maps, multi-player.
 
@FlorianMargaine Tell that to every PHD or Masters thesis writer.
 
@ChrisBaker WoW was not the first graphical MMO... it had plenty of predecessors...
 
PhD have to develop, sure, but they usually can summarize in a couple of sentences
 
6:39 PM
EverQuest for starters...
 
Oh dear, what have I done?
 
Ultima Online...
 
@FlorianMargaine I can explain it in a page. I can explain it in a paragraph. I can explain it in a sentence. I can't explain why in that little space tho
 
@AndreaFaulds Hmm, you'd have to show me an earlier one, I guess. I worked a lot of late nights trying to get a graphical front-end that was worth looking at onto a MUD, and I remember when WoW hit the market, we all abandoned the attempts because it was what we were trying to make. I don't recall any other product even remotely similar on the market at the time.
 
@ChrisBaker Maze War
 
6:41 PM
@ChrisBaker WoW still isn't the "first graphical MMO"
First "good" MMO? Maybe, but that wasn't the claim.
 
Everquest... that's a good one. At the time that came out, warcraft was more RTS than MMO
 
@ircmaxell then explain in a paragraph, at least to give us an idea
Don't leave us hanging :P
 
Hmm, looks like Ultima Online might have it.
Anyway.
 
As far as "multiplayer" and "online" go there are certainly earlier games than Ultima Online.
The only thing that is in question, really, is how to quantify "massively".
 
6:47 PM
The narrower debate was the first -graphical- mmo. I would still maintain that some variation of telnet/MUD-type thing was the first MMO of any kind.
 
Hi Levi :) can you explain to me again, why a generic 'retrieve' on a DAO (say, StockDao) is a bad idea?
sorry, still wrestling with this :(
you tormented me over lunch
 
@NewToMS And what does retrieve() accept and return?
 
@ChrisBaker The realm online launched in 1996 - images /cc @AndreaFaulds
 
Ha, of course Sierra was in on the action! Nice find :)
 
I love MUDs. I recall hacking around with DikuMUD
 
7:01 PM
retrieve accepts an array of K/V pairs
that are parsed into a where clause, which is appended to an existing query that's specific to a stock table in SQL
 
@NewToMS Yuck.
 
allowing you to retrieve different combinations of Stock objects in a more dynamic sense, e.g. not pigeonholing me into creating one method per query - retrieveById($id), retrieveByLastUpdated($limit), so on so forth
would be something like stockDao.retrieve(['category' => 'finance', 'lastUpdated
fk
stockDao.retrieve(['category' => 'finance', 'lastUpdated' => DateTime->now()]);
 
You don't have "general" needs. You have specific needs; code for those.
Coding for needs you don't have is more time consuming, more error prone and if you do eventually have that need you probably got some detail wrong so you have to change it anyway
 
well, the whereArray support would be confined to what existed in the stock table, in this case. or am I still missing the point xD
and as the codebase grows quite large, I'm learning that there are quite a few 'general' needs
where I'm adding different functions to handle them as they pop up
 
@NewToMS What if you want to OR some things and AND some things, etc?
 
7:06 PM
I have a prototype for it
simple stack that parses it out so that it's wrapped correctly
 
7:30 PM
@AndreaFaulds and all Mac OS X users: any of you used a tool that generates and displays call graphs for C code that runs on Mac easily?
 
7:46 PM
@ircmaxell architecture is build on top on something, this can be any pattern. "Facades" in #laravel, DI and IOC for #symfony
Apart from Model-View-Controller, what application #pattern do you know? @ircmaxell made a list for you http://blog.ircmaxell.com/2014/11/alternatives-to-mvc.html #php #mvc
 
Super-special Room 11 sneak preview of something that's so WIP it's not on github yet: bitbucket.org/DaveRandom/pq-async/src /cc @rdlowrey @PeeHaa @Danack @Fabor @m6w6
3
@dchesterton I like your website :-)
 
user895378
@DaveRandom oh nice :)
 
It's using pecl/pq but the plan is to have it support ext/pg as well
 
:-)
 
@DaveRandom Awww, poor bitbucket. Hiding your code there until it is ready for github is like Glaxo-Smith doing experimental drug trials in some back corner of Cambodia. If you kill the whole village, the idea is that no one will notice.
 
7:56 PM
I like bitbucket in general, but people don't tend to watch it passively so it's good for "quiet" but open dev
 

« first day (1500 days earlier)      last day (3442 days later) »