Today I Learned - Rocky Kev

TIL that PHP has an abandoned Gender Library

POSTED ON:

TAGS:

This extension, in short, tries to guess the gender of first names. As its introduction says:

Gender PHP extension is a port of the gender.c program originally written by Joerg Michael. The main purpose is to find out the gender of firstnames. The current database contains >40000 firstnames from 54 countries.

so @rphsoftware alerted me that PHP has a "Gender" class which has constants for all 109 genders, which are and I quote:

FEMALE
MOSTLY FEMALE
MALE
MOSTLY MALE
UNISEX
COUPLE
NOT FOUND
ERROR
ANY
BRITAIN
IRELAND
USA
SPAIN
PORTUGAL
ITALY
MALTA

It returns a value that looks like this.

const integer IS_FEMALE = 70 ;
const integer IS_MOSTLY_FEMALE = 102 ;
const integer IS_MALE = 77 ;
const integer IS_MOSTLY_MALE = 109 ;
const integer IS_UNISEX_NAME = 63 ;
const integer IS_A_COUPLE = 67 ;
const integer NAME_NOT_FOUND = 32 ;
const integer ERROR_IN_NAME = 69 ;

How are those numbers determined?
Math from decades of demographic data?
AI algorithm?

Nope! These are magic numbers randomly made up!

Fortunately, this isn't a PHP Core thing.
This is in PECL, which is the rubygems/npm equivalent for PHP.

REFERENCE:
Foone's hilarious breakdown:
https://threadreaderapp.com/thread/1343285800369147904.html

https://www.sitepoint.com/theres-a-gender-extension-for-php/


Related TILs

Tagged:

TIL how NGINX knows to look for index.html vs index.php

What happens when visitor hits /foo/bar URL?

TIL php-fpm

PHP runs as a separated service when using PHP-FPM. By using this PHP version as language interpreter, requests are processed through a TCP/IP socket; so that the Nginx web server only handles the HTTP requests and PHP-FPM interprets the PHP code. The fact of having two separate services is key for increasing efficiency.

TIL the difference between single-threaded & multi-threaded architecture

For web dev, we don't need it. We're not bottle-necked by the processing power. We're instead bottlenecked by the ability to read files/databases. We can simulate multi-threading (and improve our app's performance) using async/await.