Here it is, Whiskey-Exemption Thursday, and my weight is on-target so I can even have beer. The purpose of Thursday is to devote an evening to pushing the writing forward, and hang the consequences.
What have I been writing this fine evening? I’ve been trying to come up with the least-objectionable way to emulate Swift’s extensions to Protocols in php. The answer: there is no way.
Coding with php is coding with flint knives and bearskins; the power of php is in its wham-bam-thank-you-ma’am ability to do a quick task and then to go away.
Bless the movers behind php, they’re trying to evolve their language to catch up with the way people are using it these days. If they had known Drupal was coming along, they might not have been so quick-and-dirty before. Drupal might be slightly less awful as a result.
There are design patterns enabled by Swift that I get a little misty contemplating. Being able to add extensions (with executable code!) to protocols is enormously powerful. Having experienced that, I wanted to do the same thing in php, creating a trait “taggable” and having classes that used it automatically injected with the implementation. Injected, not inherited. Ain’t gonna happen.
At least now I’m writing prose about writing the code rather than writing the code itself. Progress, I guess.
One bourbon, one scotch, and one beer can make that time better spent ;).
What you describe at least sounds more engaging than trying to find decoupling capacitors these days. That’s OK, it’ll get better once the trade barriers are raised. Not.
I understand PHP, with more to learn. But want to move to another language. Swift, Python, or….just go straight to whiskey?
You really can’t go wrong with the whiskey option. The others depend on what you’re planning to build.
When I tell people I like to write software in Swift, they assume I’m writing code for iOS/watchOS/tvOS/yourMomOS. But I’m actually not; I’m writing sweet hot data services running on Linux. I have access to slightly-more-advanced tools for that purpose than you do, (or maybe I should say “slightly-more-experimental”), but if you are writing server software, you could start with Kitura (from IBM) or Vapor and enjoy all the power of Swift. I’ve met a couple of the people at IBM working on Kitura and they are really smart mo-fo’s.
To be fair to php, after some work I’ve found that traits, despite being a cut-and-paste shorthand, are reasonably useful for injecting capabilities into classes. Ham-fisted but effective all the same.
Nothing like extending a Swift Protocol, but it’ll get you down the road a way.