From da4cd34238eb93adcf4e8665d86f86ddb4aa59db Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Sat, 9 Mar 2024 00:00:06 +0000 Subject: [PATCH] Add daily email for 2024-03-06 Types are optional --- source/_daily_emails/2024-03-06.md | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 source/_daily_emails/2024-03-06.md diff --git a/source/_daily_emails/2024-03-06.md b/source/_daily_emails/2024-03-06.md new file mode 100644 index 000000000..baa56f9e3 --- /dev/null +++ b/source/_daily_emails/2024-03-06.md @@ -0,0 +1,33 @@ +--- +title: Types are optional +date: 2024-03-06 +permalink: archive/2024/03/06/types-are-optional +tags: + - software-development + - php +cta: subscription +snippet: | + Types are optional in the programming languages I write most in. I like them, but I also like people can decide whether to use types or not. +--- + +The main programming languages I write are PHP and JavaScript. + +Both offer types where, as well as declaring a parameter or property, you can define what type it is - whether it's a string, array, boolean, etc. + +Adding types is optional. + +You don't need to add types to your PHP code, and you can choose to write plain JavaScript instead of TypeScript. + +Some people prefer simpler or cleaner code or less "visual debt". + +I like the extra clarity that types add. + +I like to be able to read some code and immediately know what types things should be. + +I like the clearer errors and messages if a different type is given than was expected. + +Tools like PHPStan know more about my code and give better recommendations than if I don't add types. + +I like the better autocompletion I get when writing code that has types. + +I like types, but I also like the flexibility of whether or not to add them and for Developers and development teams to make their own decisions based on their preferences.