739
average day in NPM land (programming.dev)
you are viewing a single comment's thread
view the rest of the comments
[-] ChaoticNeutralCzech@feddit.org 136 points 1 month ago* (last edited 1 month ago)

If you think is-number can be replaced with a one-liner, you don't have the enterprise code mindset. What if the world gets more inclusive and MMXXIV, ยฝ and โ ผโ  become recognized as numbers? ๐’๐“†พ were numbers in the past but what if people start assigning numeric value to other characters? Are ๐Ÿ–๐Ÿ”Ÿ๐Ÿ’ฏ๐Ÿ†ข๐Ÿ‚ต๐Ÿ€Œ๐Ÿ… numbers of the future???
/s

I'm not even all kidding, Regex implementations are split on whether "ูฃ" matches \d.

[-] modeler@lemmy.world 34 points 1 month ago

All junior devs should read OCs comment and really think about this.

The issue is whether is_number() is performing a semantic language matter or checking whether the text input can be converted by the program to a number type.

The former case - the semantic language test - is useful for chat based interactions, analysis of text (and ancient text - I love the cuneiform btw) and similar. In this mode, some applications don't even have to be able to convert the text into eg binary (a 'gazillion' of something is quantifying it, but vaguely)

The latter case (validating input) is useful where the input is controlled and users are supposed to enter numbers using a limited part of a standard keyboard. Clay tablets and triangular sticks are strictly excluded from this interface.

Another example might be is_address(). Which of these are addresses? '10 Downing Street, London', '193.168.1.1', 'Gettysberg', 'Sir/Madam'.

To me this highlights that code is a lot less reusable between different projects/apps than it at first appears.

load more comments (22 replies)
this post was submitted on 31 Jul 2024
739 points (99.3% liked)

Programmer Humor

19187 readers
1192 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS