Hacker News new | ask | show | jobs
by 9dev 3 days ago
yet at the same time, you can do stuff like this in PHP:

  $result = '  PHP 8.6  '
    |> trim(...)
    |> strtolower(...)
    |> str_replace(' ', '-', ?)
    |> (fn(string $s): string => match ($s) {
        'php-8.6' => 'New hotness!',
        default   => 'Something else',
    });
People always seem to get hung up on the standard library and the runtime, but the language itself is amazing by now.
4 comments

I still like and enjoy PHP. But after PHP2Shell I am done with it and any other scripting languages for future server-side web projects.

I think scripting languages tend to represent too great an attack surface, for humdrum reasons (like over-capable default configurations).

So I welcome this effort (not least because I quite like Go)

Funny, I saw a comment here on another thread postulating that scripting languages / languages with runtimes would be more popular in the feature because of the fast time to patch vulnerabilities on running machines, whereas with Rust and the like you'd have to deal with long compile times...
I've got bad news for you if one hard to exploit vulnerability on the language is the Rubicon to you
I look at that and "amazing" is not how I'd describe what I'm seeing.
Piping is an amazing language feature, but it can be easier or harder to read based on the syntax.
Hmm... many other "modern" languages can do the same thing.
The only other languages with similar features I know of would be F#, Elixir, probably OCaml. I wouldn't call that "many". Also, it's besides the point I was making; PHP is a capable, JIT-compiled scripting language by now, including a fully optional, gradual, yet runtime-enforced type system; fibers/green threads, generators, streams, FFI, pluggable SAPIs, etc.; great performance, especially so with JIT and opcode caching enabled; and a lot more. On top of that, you get an extremely well-maintained ecosystem with a single, standard package manager that avoids many of the supply chain security issues of other ecosystems, several healthy application servers and widely used frameworks, ubiquitous tooling and integrations...

There's a lot to criticise about PHP, but also a lot to like.

You hanging on the syntax. Many programming languages provide functional primitives, which is what you're talking about. Yes, the |> operator is specific to some languages.
Thats pure lol. Looks like a pipe ala ocaml would be a REALLY bad fit for the php stdlib.