3 ms·
I don't think it's capabilities were ever in doubt -- it had early adoption because it had capabilities that other languages didn't have/express well, not becau
by pphysch 3y ago
I don't think it's capabilities were ever in doubt -- it had early adoption because it had capabilities that other languages didn't have/express well, not because it was a particularly nice language to work with.
The OPs code is quite readable and I wouldn't mind maintaining it (vastly better than the real-world legacy PHP code I have to maintain), but my main takeaway is "this is like Python with Java syntax" (interestingly the opposite of Kotlin, i.e. Java with Python syntax).
- joeymckenzie 3y agoAppreciate the feedback! I'll be the first to admit I have a tendency to C#/Java-ify code in languages that I attempt to learn (could definitely argue it's a bad habit) due to nearly a decade of working with them. Any advice you might have to make things a bit more idiomatic to modern PHP? Always looking to improve the code however I can.
- munk-a 3y agoIt's my opinion (but one I strongly hold) that good maintainable code is modularized and clean - with strict types and a heavy emphasis on clean contracts between different components (since in an organization/large open source project many people will be contributing in parallel). It relies heavily on common patterns and styling for easy recognition and tries to do things in the least sneaky way possible. If you're aiming for this state of a codebase you'll lean heavily towards Object/Modular oriented styles which strongly resemble Java/C++ etc - even languages that express them in dramatically different manners (like OCaML) end up looking really familiar when built in a sustainable manner. There is a common visual expectation we have around code that promotes readability[1] and we'll form code in most languages to match that common visual expression. This is actually one reason I decidedly dislike python - since it's visual expression is encoded into the syntax evaluation of the language itself. Anyways the TL;DR is that, IMO, clean maintainable code looks like clean maintainable code and the language only minorly impacts this appearance. 1. That isn't to say this is necessarily the best visual expression - it could just have been chosen early on and then just ingrained in us all.
- pphysch 3y agoI completely disagree with this. The classic Java-style "enterprise OOP" code is a symptom of poor software design and papering over bad abstractions with more abstractions. There's a lot of this code also written in Python. However, I think Python's forced indentation and cleaner syntax is a boon because it makes bad code look bad and unreadable. Too often, variations in style conventions are used as a smokescreen for rubbish software.