Earlier quoted context omitted.
With copy-on-write: $a = ['a']; $b = $a; $a and $b both point to the exact same bit of memory. Thus passing an array between functions is zero-cost. When you do: $b[] = 'b'; // append 'b' a new array is allocated, the old data copied to it, and 'b' appended to it (basically, but IIRC, it is a bit more optimized than that).
So basically what FP languages do?
PHP – The Right Way
301–310 of 349 posts
Re: PHP – The Right Way
#302Earlier quoted context omitted.
PHP share-nothing architecture is awesome. It's amazingly simple and it scales to arbitrary size.
Complicated frameworks means the “shared nothing architecture” is unusable and you have to use fcgi/fpm to get acceptable performances out of your website. At which point there’s little difference from .
Re: PHP – The Right Way
#303Earlier quoted context omitted.
> You need to have a really good mental model of how TS works to be able to make sense of what TS tries to tell you. Won't this sentiment hold true for Rust as well? You need to have a good mental model of how Rust works, with all its borrowings and lifetimes, to understand what its errors are trying to tell you, and especially how to fix the problem?
Actually no. Rust will teach you. The difference is that errors do a great job and telling you what went wrong and how you can fix it. You just fix one error after another and the borrow checker will guide you to the correct solution. For example you get an error like: error[E0433]: failed to resolve: use of undeclared type `Environment` --> src/main.rs:9:19 | | let mut env = Environment::new(); | ^^^^^^^^^^^ not fou…
Type 'Record' is not assignable to type 'T'.
'Record' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Record'. (2322)
Would you have figured out that the solution to the problem was to omit the - factually correct - return type of the method?
Rust is not just better at error messages, it's playing an entirely different game.Re: PHP – The Right Way
#304Earlier quoted context omitted.
For me, a "beginner friendly language" has these properties: * A welcoming, helping and open community. * Built-in guidance or enforcement away from The Wrong Way and towards The Right Way. E.g. by making the former hard to do and the latter easy. * Ecosystem of high-quality, properly designed libraries and sample code. I see this in e.g. Rust. But e.g. JavaScript or PHP fail on all my three points. As does my main l…
While I agree on your three points, I don't think I would recommend Rust to a beginner developer.
And I'm still not certain why not. You'll have a "hello world" in minutes. Even through something like Actix. Probably faster than your average "ruby on rails hello-world" or "react hello world". As those require a lot of up-front tooling to be set up.
I guess my reluctance is that Rust very early on requires knowledge of memory-management (borrower) and intricacies such as Result and Option.
While those are good to learn for a beginner at some point, that beginner probably wants to defer them to a moment that they have actual software deployed and dabble into multithreading, get runtime exceptions back and see the software crashing.
Still, I think languages that don't even allow you to think about such stuff, like Python, Ruby or JS, do the beginner a disservice: typing, shared-memory, runtime exceptions and undefined behaviour are a real thing, and a beginner should at least see that the libraries and examples all take these issues into consideration. Instead of waving it away with "we have tests to cover most of it. probably"
I'm Ruby dev, I deal with this daily; Learning Rust and using it in production has made me a much better Ruby dev.
Re: PHP – The Right Way
#305Earlier quoted context omitted.
Why do PHP developers insist on calling themselves artisans? Give me a call when PHP ditches backwards compatibility and cleans out all the shit from the standard library - 5845 global functions always available, most of which you are just supposed to know are shit... Just a nightmare.
Why would you care how many global functions there are in PHP? Just namespace your own functions and the whole "issue" will instantly disappear.
Re: PHP – The Right Way
#306Earlier quoted context omitted.
For me, a "beginner friendly language" has these properties: * A welcoming, helping and open community. * Built-in guidance or enforcement away from The Wrong Way and towards The Right Way. E.g. by making the former hard to do and the latter easy. * Ecosystem of high-quality, properly designed libraries and sample code. I see this in e.g. Rust. But e.g. JavaScript or PHP fail on all my three points. As does my main l…
#2: Strict Programming lang's. I often seen frustrate new programmers, specially young new programmers making them want to give up on programming all together so I don't know if I would call that beginner friendly, I certainly would not call rust beginner friendly I guess however we would need to define what a "beginner" target is, are we talking adults that want to learn programmed to change fields, or children want…
I was thinking about someone from school taking their first job. Or someone who has built a WordPress site and theme as a hobby and so on. I was not thinking about a 7-year old wanting to move a turtle around. Nor about an "arts student" looking if she may like webdev.
Though, a friend who has an after-school "tech" afternoon for young kids, includes a lot of arduino, adafruit and other hardware courses. Kids love it when some robot drives around the actual world, drawing lines. More than a virtual turtle drawing virtual lines. It requires C programming. He told me he has 8-year old kids writing some C.
Re: PHP – The Right Way
#307Earlier quoted context omitted.
> Because, suprisingly, Noone is forcing you to update immediately! Excuse me, where do you work? Do you not have a company policy about not using software that isn't actively receiving security updates?
PHP releases receive three years of updates :)
> Hell, there's still a lot of 5.x deployments out there that work just fine.
forgive my ignorance but I was under the impression 5.x isn't actively maintained anymore?
Re: PHP – The Right Way
#308It's a decent website - a useful collection of information and links to additional information, that can serve as a starting point to learn more. For those who use PHP, or for those who'd like to learn to use it, this might be useful resource. The same thing can't really be said of the comments in here though. I don't see how emotionally charged debates over what is the "best" or "worst" language, help anyone. It's a…
Re: PHP – The Right Way
#309It's a decent website - a useful collection of information and links to additional information, that can serve as a starting point to learn more. For those who use PHP, or for those who'd like to learn to use it, this might be useful resource. The same thing can't really be said of the comments in here though. I don't see how emotionally charged debates over what is the "best" or "worst" language, help anyone. It's a…
You're right, but you're missing the emotional damage many hackers of a certain age feel when they remember troubleshooting PHP problems, or constantly having to look things up, before they left for whatever their language of choice is now. People complaining about PHP are mostly just venting frustrations from 15 years ago.
Re: PHP – The Right Way
#310PHP is a language with various features that might make it attractive to certain people: • CGI-like execution model when used for the web, making resource leaks very difficult and encouraging scalable design • not only integers and floats, but also strings, lists and dictionaries as mutable value types (copy-on-write) — this is a big difference from JavaScript and Python • unusually for a dynamic “scripting” language…
I consider this a non-feature in JS. The global namespace is enormous and growing rapidly. As I recall, PHP’s global namespace is similarly enormous (and notorious for its inconsistencies and redundancies). I understand that there are ergonomic advantages to not having to import built-ins, but I think framing it as a feature deserves a healthy asterisk :)
> fibers, a way do asynchronous execution without every function in the callstack having to be aware of it
This isn’t built into JS, but there’s an implementation of it, mostly used and popularized by Meteor. Again it has some ergonomic benefits, but I think it can too easily hide/obscure deoptimizations—eg performing IO operations in sequence which would be better performed concurrently.