Skip to content

u/pitiless

In this archive from Jul 2011 to Dec 2026

3
posts
185
comments
2
media
700
score

Frankly I wouldn't be especially interested in either, but as I said I can at least think of something useful to do with the least used functions. I can think of nothing useful I could do with the most used list - it answers a question that in 20+ years of using php I've never needed to ask.

1 points

I was intending to work in game Dev after uni (circa 2007) but decided against the it due to the work conditions being awful and there being fuck all job security.

20 years on I do not regret that decision one iota - the work I do is mundane and humdrum stuff; however I've consistently been well compensated; have worked fewer than 100 hours of overtime in the past 20 years and have maintened comparative job security.

I look at the industry today (and I have more experience than the above would suggest as my partner has been working as game dev) and it's just the biggest dumpster fire.

Basically you have to be so invested and committed to the idea of being a game dev that you're willing to sacrifice all other parts of your life to be in the industry. And for those sacrifices you will be poorly compensated, will be expected to do ungodly amounts of overtime and will (almost certainly) never feel like you have job security.

Not for me.

1 points

"baked in"? I'd say almost all languages other than PHP and JavaScript (processing requests/ dispatching request respectively).

PHP is pretty unique in how tightly integrated into the language the HTTP request/response flow is. Most other languages require 3rd party code of some kind to serve HTTP traffic, not so for PHP.

I don't see any problem with PHP keeping this capability, hell I'd say it's one of PHP's unique selling points. But it really is a shame that the abstractions the core language offers are so ugly and inelegant.

1 points

Id much rather work with typescript than PHP these days ( and before someone jumps on this I used php for over a decade from the dark days to 8)

I love PHP, and have more than 2 decades of experience with it, but TypeScript is just a lovely language to work with.

I'd 100% prefer to use TypeScript as a language, but also 100% prefer PHP's ecosystem. Using tools like psalm or phpstan narrows that gape a bit, but both are pretty limited in some key areas where TS excells.

4 points

We should have something akin to the Go backwards compatibility promise. Go with very limited exception has not broken backwards compatibility since 1.0 came out in 2012. Code written in 2012 is guaranteed to run on modern Go today. We upgrade our Go libraries when there is reason to and not because they have rotted on the vine.

I don't see how that's relevant to your broader point?

The fact that PHP written for 8.3 might not run on 8.4 is ridiculous.

Do you have any examples of this that you think people are likely to run into? The only scenario I can see where this would occur is if someone passes an invalid value for the $mode param of round().

This upgrade treadmill they have us on is churn and little more. Wasting days or weeks upgrading projects just to have the same exact final product is a waste of everyone's time, energy and most of all money.

What do you propose the alternative should be, and how would that alternative be achieved?

Unlike some other languages there is no multi-billion dollar company funding PHP's development. It's mostly done by a team of volunteers - the PHP team's resources are massively more limited/constrained when compared to what Google (Go), Oracle (Java) or Microsoft (C#) are able to throw at a problem.

Just be thankful that PHP takes B/C more seriously than Python did (see the still-ongoing multi-decade 2 -> 3 migration process).

6 points

It's not. Any time you work with pure HTML you have to deal with it's idiosyncrasies.

Okay, lets get specific. What are the idiosyncratic parts of the HTML spec do you have to fight with on a day to day basis that are resolved through the use of XML?

0 points

Yeah, that would be great. Instead of not knowing that you have an error in your code and only catching it 5 years later when some JS library fails for seemingly no reason...

In my 25 years of working on the web I've literally never had this scenario play out, which is not to say that it doesn't occur, but it's demonstrably not a major problem. However in the short period of time where XHMTL was in vogue I saw numerous "XML parse error"s on XHTML pages.

I think this speaks the fundamental problem with XHTML; it solved a problem that was almost purely academic, offered almost no benefit to people authoring web pages, and very created real problems on real websites.

This was all exacerbated by the nature of the early 2000s web; unlike today it was very common to allow end-users to insert snippits of markup into forums, or to allow customisation/styling on the early social media platforms (LiveJournal/MySpace). While "real" developers won't make markup mistakes often, and are very capable of resolving the times it does occur, XHTML made this a problem for end-users who aren't real devs.

1 points

Strong disagree.

XHTML failed, and was always destined to fail, through it's inheritance of XML's failure modes.

Likewise, HTML was successful, and was always destined to succeed precisely because of how tolerant HTML parsers are of fucked up markup.

XML isn't even a popular target for machine to machine communication these days - JSON won there because XML is just not that great a tool. IMO The one and only feature XML has in it's favour is XSDs.

Also IMO the one feature that killed people's desire to use XML is attributes. They make it so there's no simple way to map an XML document to common languages' data-structures. They also mean that as a schema designer I have to decide whether to create a child node or an attribute - with JSON it's just objects all the way down.

Turns out simple wins over correct, or worse is still better.

2 points

I don't have a definitive answer, but my assumption is that it's the same reason behind the array functions taking args in a different order from string functions; in the early days internal functions were mostly thin wrappers around C functions, and C does not allow you pass extra args without an error (this is enforced at compile time).

3 points

I don't really agree.

You should almost always avoid typing against mixed, but doing so is still better than omitting a type - by using it you're communicating an intent. In an otherwise well-typed codebase, the occasional use of mixed is an indicator that something unusual or low-level is occurring.

That being said, outside of low-level library code you almost certainly don't want to use mixed in public methods.

1 points

The ability to explain what you did and why did to others is what matters.

I'll just quote myself from another thread in this discussion

In conversation you could spend the time to describe how <this class right here> contains methods that allow you to create instances of <this other class family>, and that by convention in this system the only way those objects can be created. You can further elaborate that the rationale for this decision is that the constructor parameters for <this other class family> regularly change and it made it easier to make sure all calls were updated. Alternatively you could say <this class right here> is a Factory.

The utility of design patterns is that they're half 'solution template' and half jargon. Additionally many (perhaps most) design patterns do encapsulate at least some of the 'why';

  • The 'why' of the Factory pattern is that you want to centralize creation of an object/family of objects.
  • The 'why' of the Command pattern is that you want to be able to pass around an object that executes some kind of request.
  • The 'why' of an adapter is that you want to allow components with incompatible interfaces to be interoperable.

Of course there's the next layer of 'why' - the 'meta why' of why you want to centralize creation of objects (etc) and the place for that is comments, but the mere usage of a specific design alone gives a very strong clue as the why.

Frankly, I find it wild that the PHP community has this anti-intellectual attitude to these topics.

1 points

Deadlines are a very tricky thing in software, [.../

I agree with all of this, with the one addendum - that sometimes the correct call is ship worse code to hit a deadline. I'd hope most senior devs would have the experience to make good judgement calls when it comes to this type of decision.

What I look for in code is does it perform well enough, is it appropriately low coupling and extensible with clean interfaces, is it easily testable and covered by tests?

Here's the thing, two out of three of these are best achieved by the correct application of common design patterns & applying SOLID principles. E.g. what properties do you look for in a 'clean interface'? I'd argue that the 5 points of SOLID are the best yardstick we have to evaluate this. If you have a different set of heuristics to use I'd be interested in hearing what they are.

In the same vein, one of the main things you can do to make your code easily testable is use dependency injection (a design pattern). That way you can easily configure stubs/mocks/spys and isolate (at least some) tests from expensive and/or error prone operations like disk or network access.

Writing software is as much art as science, maybe more art a lot of the time, and there are always multiple, valid ways you could have tackled a problem.

Yep; really what we are is craftspeople - relying on mathematical (scientific) underpinnings but engaging in a task that dovetails that with aesthetics in many interesting ways. There is an objectively correct answer for what is the best sorting algorithm to use in a specific context, but almost everything around that is a result subjective taste and social conventions.

Based on the the way many people I've interacted with talk about design patterns there seems to be a common misunderstanding about why they're useful. In that view of the world, they are an prescriptivist list of 'things you must do to be a good software developer' that was handed down from some academic in an ivory tower.

Really, they're exactly the opposite; each design pattern is just a name that was given to a common solution to a common problem. They're half 'solution template' and half jargon (domain specific & meaning dense terminology). In conversation you could spend the time to describe how <this class right here> contains methods that allow you to create instances of <this other class family>, and that by convention in this system the only way those objects can be created. You can further elaborate that the rationale for this decision is that the constructor parameters for <this other class family> regularly change and it made it easier to make sure all calls were updated. Alternatively you could say <this class right here> is a Factory.

Likewise when reading code the common naming of design patterns can allow you build those very important mental abstractions more rapidly; you see <something>Decorator and you immediately have a mental model of how the class is assembled/composed.

1 points

I've also encountered senior devs who can talk the talk all day long with terminology word-salad but are absolutely sodding useless at writing clean code - and at the end of the day, that is the part which matters most.

I mean, you're not wrong, but it seems like you're framing this as a 'some seniors know the theory but are crap at the practical, some know the practical but are crap at the theory' as if it's a zero sum game.

This isn't the case. A senior should both be capable of delivering high quality code / solutions as well as being able to justify why the code is good quality - IMO this requires knowing the language of software development.

I don't think being able to describe what (for example) the factory pattern is, what problem it solves and when to apply it is a high bar to exceed for senior developer. Frankly this is exceedingly basic knowledge.

I'd like to re-frame this discussion; what knowledge / experience / expertise separates a senior from a mid level developer? Off the top of my head (based on my experience managing teams and being responsible for the hiring process for many years) I'd say:

  • Be able to delivery high quality code to a deadline.
  • The ability to communicate what is to be built and why in the correct terminology of our industry. (I.e. we'll use the observer here, because these classes are unrelated other than needing to have some state change observed; here we'll use this interface as it means it'll adhere to the Liskov Substitution Principle and so we can safely swap in different implementations at runtime; etc).
  • The foundation of good software design (/architectonic) skills.
  • An awareness of the business needs & deadlines behind a request and the skill to fit the solution appropriately.

Things that are "Brucey Bonuses", but aren't critical:

  • The ability to be a mentor to / to train less senior developers.
  • Strong/deep knowledge of at least one other programming language (my experience shown that devs who meet this criteria are, on average, better developers than those who have not).
  • Some familiarity with the operations side of things (i.e. familiar with the unix CLI, familiarity with (parts) of AWS, etc).
1 points

Yeah naming design patterns is just a poor interview question. There are many very good devs who will write code which someone else might look at and go oh yeah that's factory pattern, that's decorator pattern, that's observer pattern and the dev might never have even heard of any of those terms.

Counterpoint; programming is as much about communication (to your peers and future developers on the codebase) as much as it is about delivering software.

If a senior developer is not familiar with the common terminology used to communicate the intent behind why they're doing something then they're a senior 'in name only' IMO.

I see, very often, job titles being given as an acknowledgement of time served in the industry instead of being a marker of skill or knowledge level. There may be disciplines where this makes sense, but (again IMO) not in software development.

13 points

https://github.com/ptlis/shell-command

I was looking for a good package to deal with executing sub-processes and grabbed symfony/process as I'd had almost exclusively good experiences with Symfony components but was very unimpressed with what I found (this was 8 years ago so perhaps they've improved it since). In brief there was poor separation of concerns & the whole package was a big ugly stateful mess.

A review of alternatives (at the time) yielded no good alternatives so I wrote my own.

2 points

I don't buy this argument about a clock being only the time and never the date; looking at the clocks around me I see:

  • A time & date on my Phone's lock screen.
  • A time & date on my Phone's home screen.
  • A time & date on the task bar on my Windows desktop.
  • A time & date on the activities bar on my Linux desktop.

I really don't think this is something that would confuse any person who lives in the modern world and I would expect/hope that would include 100% of developers.

0 points

You're actually right; ABI does mean application binary interface.

It's basically what it sounds like too; broadly speaking an interface in code is a way of saying that two pieces of code can work together as long as they both 'fit' an agreed shape. An ABI is exactly the same thing with binary files / executables - as long as two binaries have a matching 'shape' they can talk together without issues.

5 points

Yeah, you're missing the point.

Firstly, PHP clearly considers warnings and notices to be specific types of errors - this can be seen through the effect of the error_reporting function (see on vs off) and the above example of how the error suppression operator 'hides' these error messages.

Secondly, a file failing to open is an error in most systems, irrespective of whether the message text says 'warning' or not.

More importantly than either of these two points is the fact there are parts of the standard library where properly handling errors requires the use of the @ operator right now, and that require you to verify the returned value is not false to properly handle failures. No exception, throwable or error is thrown to be caught.

As I demo'd above, if you want to use fopen in a production system you need to use the @ operator to suppress the message and you then need verify that the returned value is not false. Consequently there's a LOT of code out there, even modern well-designed code, that depends on the @ operator to properly function. Any change to change this behaviour will impact pretty much every non-trivial PHP program.

5 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.