Hacker News new | ask | show | jobs
by tyingq 3323 days ago
"The app itself is powered by Laravel, Vue.js, Socket.io, and Node"

Is there another Laravel other than the php one? Seems odd to roll out with both php and node.js. I don't know why you would need both.

Edit: Yes, I see each has it's strengths. But that has to drive a lot of doing the same thing twice, in two languages...they both interact with the same data. I would guess time-to-market is important at launch to react to things you missed. I would have settled on one or the other. Feels like premature optimization.

6 comments

Laravel 5.4 integrates with Vue. https://laravel.com/docs/5.4/frontend#writing-vue-components

Laravel can act as the API backend to the frontend (basically a set of REST endpoints that the frontend can talk to), or alternatively the Vue components are used only where heavy client-side interactions are required, while the rest of the pages are still served up by Laravel normally.

Nothing wrong with PHP, just use the right tool for the job, and the right tool is based on existing skills, time to market, requirements, etc. If PHP fits the bill, use PHP
That's not what I said though. I'm asking why php AND node.js. One or the other should suffice.

For websockets, as an example, HHVM+proxygen should be as performant as node. Or, node should be roughly as good as php for developer speed on the normal, not-websockets side of the house.

In a microservices architecture, you might have many languages. And if you have a PHP developer and a node.js dev, and you are trying to deliver as fast as possible, that could be a reason to split it up.
Writing everything twice for the speculative success of a brand new Reddit clone doesn't qualify as "deliver as fast as possible" to me.

Edit: For clarity, I mean there would be significant overlap in areas like data retrieval, sessions/auth, etc.

A Reddit like app would have read/write to and from the browser and to and from the database for many data structures. Users, admins, moderators, topic areas, topics, threads, users, etc. And different views depending on context. You see more of your own profile, less of others...and similar for moderated topic areas and so forth. So, 2 platforms means duplication of some of this data access, update, marshalling, acls, sessions, etc.

Assuming the node.js part is for the "real time posts", via websockets, it would need most of the above. Then, assuming php is handling the rest, including profile edit, rendering everything but the posts, etc...it also needs most of the above.

I seriously doubt they are cloning all of their features in 2 languages, I think they are just splitting up features into different tech stacks.
Probably just Laravel for their API and Node + Vue (if they aren't using laravel elixir for the frontend) so that they can more easily do server side rendering via express.
I have played around a bit with socket.io and the reason you use Node for it is that socket.io itself comes with a in built node server for backend. So it is much easier and faster to fire up a server to run socket.io using node.
Sure. Why would you though, not use node.js for the rest of the site? I'm not complaining about either php or node.js. I'm complaining about using both of them for a brand new site.

I assume that both would need to understand the concepts around: users, admins, moderators, topic areas, topics, threads, banning, moderating, vote counts, sessions, and so forth. And interacting with all of that both server<->browser and server<->database. Feels like a lot of duplicated classes, marshalling, etc.

I assume NodeJS is used just as a WebSocket server for their real-time events, doing that in PHP would be a bit uncomfortable.
doing that in PHP would be a bit uncomfortable.

Why? PHP works fine as a daemon, there are many servers written in pure PHP, as well as frameworks for "async" programming.

It is uncomfortable, sadly. At the very least PHP Ratchet is not quite integrated with Laravel and the easy route is to use Node.

https://github.com/laravel/echo

I am not saying that as an attack to PHP (or a defense of NodeJS), I am writing PHP daily, but when it comes to real-time (at least WS systems), PHP would be my last resort, mostly because it lacks any real support for such things, you'll have to force your way in.

I guess we come back to _just because you can doesn't mean you should_. :)

It seems like if it's real-time a lot of the page is dynamic applications you interact with through AJAX, and probably it was easier to do that and get acceptable performance in Node. The other functions (say, edit profile) could then be handled by Laravel more easily. At least that's what I'd guess.
Agreed. Also, I've never noticed someone using both a front-end framework AND jQuery simultaneously. Usually, at least in projects I've collaborated on, this is redundant. However, I've never used Vue.js, so perhaps this is standard?