samdark blog ☕️
1.34K subscribers
81 photos
116 links
Notes taken by Alexander Makarov, lead of Yii framework, CTO of Twindo.ai and a long term IT engineering manager.

- Official Yii updates: www.yiiframework.com
- Consulting: asapirl.com
Download Telegram
📖 The technical books that affected me

That's not the full list, of course.

🔸Designing Data-Intensive Applications - Applications Kleppmann, Martin
🔸Object Design Style Guide - Noback, Matthias
🔸Principles of Package Design: Creating Reusable Software Components - Noback, Matthias
🔸 Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development - Larman, Craig
🔸Mastering Regular Expressions - Friedl, Jeffrey E.F.
🔸Phparchitect's Zend PHP 5 Certification Study Guide - Shafik, Davey
🔸Essential PHP Security - Shiflett, Chris
🔸Http Developer's Handbook - Shiflett, Chris
🔸Pro Git - Chacon, Scott

#books
Crowd behavior patterns visualized

I love good visualizations. When these are gamified, these are even better. This one is perfect.

https://ncase.me/crowds/

#psychology
🛠 PhpStorm added support PER coding style

PHP coding style I've participated in creating as part of PHP-FIG is now supported in PhpStorm EAP.

#php #phpstorm #codingstyle
📕 Situational awareness. The decade ahead.

Predictions about AI development in the next decade by ex-OpenAI employee Leopold Aschenbrenner.

Quite interesting read. Not sure we'll see AGI and ASI in the next 5 years but it would definitely be very interesting times.

https://situational-awareness.ai/wp-content/uploads/2024/06/situationalawareness.pdf

#ai #agi #asi
📊 How many developers are using each
leading programming language in Q1 2024?


Interesting stats. Especially since they have use-cases considered.

https://dashboard-tool-report.cdn.prismic.io/dashboard-tool-report/ZmMmh5m069VX1jxc_-W.Kodluyoruz-Programminglanguagecommunities.pdf

#php #stats
💰Who's making money on AI?

Regardless if LLM/AI will be stuck because of one of limitations or not, nVidia is the main beneficiary. Same as in California Gold Rush they're providing supplies. Smart.
⚡️PHP performance: in_array → array_key_exists

Let's imagine we need to process each user exactly once:

$processedIds = [];

foreach ($users as $user) {
if (in_array($user['id'], $processedIds)) {
continue;
}

// send an email to user

$processedIds[] = $user['id'];
}


 The complexity of in_array is O(n) and that's not great considering foreach which makes it O(n²). Is it possible to optimize? Yes:

$processedIds = [];

foreach ($users as $user) {
if (array_key_exists($user['id'], $processedIds)) {
continue;
}

// send an email to user

$processedIds[$user['id']] = 1;
}


We've reverted array so IDs are now keys. The complexity of array_key_exists is close to O(1) so total complexity is now O(n).

#php #in_array #array_key_exists #performance
👷Microservices are not silver bullet

👎 You likely don't need microservices if:

1. You aren't ready to handle increased complexity: more infrastructure💰, more error handling, extra tools for debugging and logging 🧠
2. You aren't familiar with bounded contexts and think that "micro" in a microservice is about "doing one job" 🤯
3. You have no problems that microservices solve.

👍 You likely need microservices if:

1. You have multiple teams working on the same code base and there are constant conflicts. Responsibilities are not clear 😖
2. Some parts of the systems have slightly different performance and durability requirements ⚡️
3. The system overall is too complex so you need big abstractions 🧠
4. You want part of the system to use different tech stack.

#microservices #architecture
🐧 Switching to Linux

A few month ago I've switched from Windows 11 to Linux as my primary OS for work. The goal was to have better Docker host than WSL. I've tried Ubuntu but it didn't work well with my hardware, especially nVidia despite installing proprietary drivers: 100% CPU load all the time. Might be the driver itself, might be wayland. So I've tried Pop!_OS and it worked well right out of the box.

After a while, despite some rough edges, it is pretty good:

1. Window manager overall is fine and doesn't require much tweaking.
2. Hardware support is good. No fatal issues. Audio, mic, nVidia, USB devices etc. are fine.
3. DPI scaling is way better in Windows. Fractional scaling is basically not usable so I've got used to 200% with some font size adjustments.
4. There are some problems with suspend mode. Sometimes when you're out of it, there's no Internet (LAN works well), one or two times monitors didn't pick up, sometimes USB sound is missing. Usually solved with a reboot. Inconvenient but not critical.
5. Installing software isn't as straightforward as on Windows or MacOS. Sometimes you have to read logs, install missing dependencies and/or fix permissions.
6. Pop!_OS uses flatpak. It feels like apps management in MacOS and is alright so far.
7. Gnome terminal is alright. Not as good as Windows terminal but good enough.
8. OS login screen doesn't focus on input by default.
9. Setting up keyboard layout is tricky. Spent a few days on it. Result is awesome but it wasn't straightforward at all.
10. Lost gaming. I didn't play for more than a year anyway.
11. Wine works well for many Windows apps.
12. Missing some Total Commander awesomeness but Nautilus + console are OK as well.
13. Missing Photoshop and Camera RAW. Darktable and gimp are alright but I'm not used to these.

And finally, Docker is perfect if you don't use Docker desktop.

#linux #popos #ubuntu #windows
📃 Enforcing licenses in PHP project

It is important for commercial projects, especially involving investors, to take care of not violating any licenses. Thus, likely avoiding proprietary packages, packages with viral licenses such as GPL and packages with no license.

Checking all the licenses by hand isn't a good option. Luckily, there's very handy Composer License Manager.

{
"extras": {
"arokettu/composer-license-manager": {
"licenses": {
"allowed": ["MIT", "LGPL-*"],
"forbidden": ["GPL-3.0", "AGPL-*"],
"allow-empty": false
},
"packages": {
"allowed": ["mycompany/*"]
},
"enforced": true
}
}
}


In the above composer.json, we allow MIT and LGPL, deny GPL and AGPL as viral, allow all packages from our own mycompany and enforce checks so composer won't install if there are packages that do not comply with what's allowed.

#licenses #composer #php
💎 Refined GitHub

Recently tried this browser extension and it's wonderful. It adds lots of small enhancements to GitHub UI: a bit more packed elements, additional info, useless stuff moved to less prominent places, extra colors etc.

Enhancements are configurable. I've turned off two:

1. Whitespace display in diffs. Makes it too cluttered.
2. Whole-line "show more" buttons. These are flashing bright-blue and that's annoying.

The rest enhancements fit me well. Using it daily now.

https://github.com/refined-github/refined-github

#github
💎 lazydocker

A pseudo-graphic gui for Docker you can install at your server. Despite I've got used to docker CLI, this tool is simply way faster to deal with.

My favorite features are:

1. Container stats with graphs.
2. Browsing image layers.
3. Quickly viewing logs / getting to container shell.

https://github.com/jesseduffield/lazydocker

#docker #tools
📦 Context and events

Events within a single service are very attractive conceptually. They potentially allow you to reduce coupling to a minimum, so you can even move functionality to another system in the future.

The problem is that when you introduce events within the same bounded context or module (i.e., something that is conceptually whole), they reduce cohesion, so it's easy to produce a system where abstraction is more complicated than the original.

I've seen the problem when events were used for obviously sequential processes within the same context. Cohesion drops a lot since now parts of the whole are communicating with an extra layer — events. It's very hard to read code like that. Also, coupling isn't removed, it just becomes "temporal coupling," i.e., dependent on the order of the events. Overall, it brings severe testing and maintenance issues.

#events #cohesion #coupling #complexity
Please open Telegram to view this post
VIEW IN TELEGRAM
📕 Object Design Rebecca Wirfs-Brock and Alan McKean

Software design classics in PDF. For free.

https://www.informit.com/promotions/object-design-142314

#books
📚Framework for describing patterns

Chris Richardson proposed a format for describing patterns and writes about its advantages and disadvantages.

To me it looks like a good research / documentation framework.

https://microservices.io//post/architecture/2024/08/08/pattern-format-hype-antidote.html

#docs
Channel name was changed to «samdark blog ☕️»
🗒 State of Generics and Collections in PHP

Arnaud Le Blanc, Derick Rethans, and Larry Garfield summed up possible approaches to generics/collections in PHP.

https://thephp.foundation/blog/2024/08/19/state-of-generics-and-collections/

#php #rfc
👍 Great neural networks, ML and LLM video series

Very good visualization and explanations. Must see.

https://www.youtube.com/playlist?list=PLZHQObOWTQDNU6R1_67000Dx_ZCJB-3pi

#ml #llm #ai