Live data from Hacker News

Taking PHP Seriously

slack.engineering

541–550 of 673 posts

Re: Taking PHP Seriously

#541
post #494
post #435

Earlier quoted context omitted.

Eh, you can do rapid prototyping-type garbage code in any language you are proficient in, as you can do the endless-architeture-meeting, special snowflake beautiful code, enterprise-level everything documented and automatically tested continuos integration and deployment to the most popular containerized/virtualized environment for a reasonable price of $millions in PHP or even bash or powershell. V1 is usually shit…

I work in C# every day. I love the language, I love Visual Studio, I love the application lifecycle management features of the ecosystem. There's very little I don't like, or at least understand. I started my career as a PHP developer. Any web project you prototype in C# could be prototyped in PHP in a small fraction of the time.

And any PHP thing could be easily prototyped in C# using MVC framework or such. 0 to http-response time is easily comparable if not even faster to what you'd have with PHP. You don't even need IIS. C# is a fine language and I have enjoyed it thoroughly before returning to PHP after some years, but you also can breed monsters with it. Cheers!

Re: Taking PHP Seriously

#542
post #402

Write an API for my client app which returns user's data as JSON (or render HTML page for profile); You: { mysql_connect("host", "pass"); mysql_select_db("users"); $uid = $_GET[ "uid" ]; $res = mysql_query( "select * from users where uid = $uid" ); $ar = mysql_fetch_assoc( $res ); echo "name: " . $ar["name"] . ","; echo "location: " . $ar["location"]; ?> } Just call it http://domain.com/api.php?uid=USER_ID ( Yeah I k…

The way you write code I wouldn't trust you with any language really. You give 6 lines of code and it has display of all the worst practices that I haven't seen since I read a 13year olds tutorial on the language back in 2003.

I'm fairly certain that, that was exactly the parents' point - this is what you'd often see from a beginner in PHP.

Re: Taking PHP Seriously

#543
post #492

Earlier quoted context omitted.

If I wanted to embrace garbage every day I would have skipped college and went straight to being a bum. Life is too short to "embrace the garbage" every day.

To be fair, you could have also skipped college and become a PHP developer.

To be honest, the way you put it (/i read it/) sounds like becoming a bum is a better alternative.

Re: Taking PHP Seriously

#544

What I think most people are missing about PHP is the incredible ecosystem that emerged in the recent years (especially with Laravel) that helped to speed up the development of web apps by A LOT and removed all the annoying boilerplate. I know that nowadays there are a lot of fancier languages to write your next project, but I challenge anyone to find anyone that has a similar ecosystem that can do all the following…

You mentioned Laravel 20 times. You might want to slow down on that kool-aid. And I know you're not affiliated with them because I see this behavior all around the place, especially with unseasoned developers.

> What I think most people are missing about PHP is the incredible ecosystem that emerged in the recent years (especially with Laravel)

I would replace that last bit with: "especially with Symfony and Laravel". And composer, and all the changes made in 7.x, and lots of libraries that people build on top of it and made all of this it possible.

This is a good talk (Symfony's "creator") about the PHP ecosystem:

dotScale 2014 - Fabien Potencier - My Take on PHP https://www.youtube.com/watch?v=gpNbmEnRLBU

Re: Taking PHP Seriously

#545
post #16

I work on PHP at my day job (in a public company), before this, I came from Ruby, and .NET before that. I'm convinced the reason so many successful projects use PHP, is not because of any inherent nature of the language. I think it's the people who use it. They just don't care. A successful project needs to be started by someone that cares just enough, but not too much. If you're programming in PHP, you're not runnin…

[deleted]

Re: Taking PHP Seriously

#546
I'm a PHP programmer and it's great to see this because a lot of times I feel like PHP is limiting my ability to move forward in my career. I've been looking for jobs and it seems like having pretty much only PHP, jQuery and mySql on my resume isn't enough to get hired. I've been trying to figure out what I have to do to get noticed - is it worth cranking out a bunch of projects in PHP that won't impress anyone because it's just PHP, or or is it better to learn a language like Ruby and make a bunch of (shittier, because I'm not experienced with it) projects?

Re: Taking PHP Seriously

#547

Earlier quoted context omitted.

I don't think so. You either keep state between requests and therefore get problems like memory leaks (which often happen in large Ruby or NodeJS apps written by not very experienced developers) or you keep no state and have to do initialization on every request.

This is only true if your framework depends on global variables to manage request state. If your framework passes request state in as an argument to the request handler, then there is no state to reset. Don't use global variables and you don't have any of these problems.

How do you know whether other components (objects, modules) do not keep state between requests? Unless you 1) use language with pure stateless functions like Haskell or 2) delete everything after each request you cannot guarantee that. PHP uses latter approach.

With PHP you can see your program as a pure function whose result depends only on arguments. You don't have to care about memory leaks like you don't have to do memory management when you have a GC. And if you want more performance and less convenience you can always opt into running your own web server.

> Don't use global variables

If you have an object that is persisted between requests you already have some state that is saved.

Re: Taking PHP Seriously

#548

Earlier quoted context omitted.

This code doesn't look good to me. What is the benefit of inheriting objects from objects instead of inheriting classes? When we have distinct functions, classes and objects we can easily understand how they are supposed to be used: you can call a function, create an instance of a class, call a method of an object. With Javascript you cannot easily see whether you have a plain function or a constructor and how you sh…

It sounds like you're trying to write Javascript as if it were Java. I've worked with developers who did this (e.g. http://chriswarbo.net/blog/2014-03-12-trolled.html ) and I would advise that you instead try to write more idiomatic Javascript, or else use some kind of Java-to-Javascript compiler. Your critique of Javascript is basically "it's not Java". I could make a similar critique of Java not being StandardML, b…

I am trying to write a code that is readable and maintainable instead of building complex abstractions. That is where Java classes fit perfectly (unless you are a beginner who had just read a book on patterns and tries to use every one).

And I am not only person who needs classes in JS: https://github.com/search?l=JavaScript&q=class&type=Reposito...

I do not see any benefit in prototypes. It just makes code more complicated and buggy. I would happily use them if I knew a way to do it while keeping code simple.

> When we have distinct structures, signatures and functors we can easily understand how they are supposed to be used

Yet Javascript has neither of those.

> If you mean that mutating values should be avoided

No, I am ok with mutable values.

Re: Taking PHP Seriously

#549
post #390

Earlier quoted context omitted.

PHP devs aren't expensive. Even good ones. It's easier to reroll in another language and retrain or recruit? No. So you probably mean for a new project. So now you've more maintenance and learning curve unless you just happen to have enough skilled in $NEWTHING. Not really easier. PHP is an inconsistent mess, everyone knows that, but it's cheap, widely understood, and it's perfectly possible to write decent maintaina…

True, I have seen one startup fail early because he couldn't find any (cheap) Django devs. He might have stayed around another year with the funding he had if he had gone PHP.

Django devs are cheap, too.

Re: Taking PHP Seriously

#550

Earlier quoted context omitted.

The problems start when you notice that your untyped key-value store has a bunch of NaNs where you were expecting a number. At this point, all you can do is pray that those numbers weren't very important, in the grand scheme of things.

So when you do calculations with important numbers, you just push the results to the store without checking them and hope for the best? NaNs can happen in any language with floats, it's just that some languages also use exceptions in some situations.

You can check the result of every operation manually but it saves you time when the language does it.
Post reply on HN