- Users who build personal alternatives.
- Hobbyists who clone a few apps each year for personal use and release their versions as open source (I am an example of that).
- Businesses that systematically identify promising apps, reproduce their visible functionality, and compete through stronger distribution and marketing.
Monday, August 3, 2026
Cloning an app with AI
Wednesday, May 6, 2026
Database indexing
Binary search is O(log n) but it only works on sorted data. Suppose you have a customer database and want to find customers whose ages are between 25 and 30. If the database is naturally ordered by customer creation date, you would first need to sort the data by age before performing a binary search to locate the rows corresponding to ages 25 and 30. For a large database, sorting the entire dataset can be time consuming.
A better approach is to create indexes on specific columns. An index on the age column, for example, would contain only two fields: age and customer ID. Because this index is smaller than the full table, it is faster to sort and search. When a query for customers aged between 25 and 30 is executed, the database can perform a binary search (or similar efficient lookup) on the index to find the relevant customer IDs, and then use those IDs to retrieve the full records from the main table.
The downside of indexing is slower write performance. Each time a user creates an account or places an order, the database must update not only the main table but also all associated indexes. Having too many indexes can make write operations, such as clicking a “Save” button, feel slower. Additionally, indexes consume storage space, and at large scale, the total size of the indexes can even exceed that of the actual data.
Tuesday, July 15, 2025
How to write a software issue
If a software problem report or issue describes a large goal or vision, it should be documented as part of a concept of operations or a specification. If you can’t write clear acceptance criteria, or if a developer can’t reasonably complete it in 1–3 working days, it’s probably too big and needs to be split.
Large issues often depend on knowledge of many parts of the system, while smaller ones usually touch just one area. Smaller issues are easier to test, review, and merge. A smaller scope also makes it easier to prioritize and adjust based on feedback.
Smaller, well-defined tasks are much better candidates as a “first issue” for a newcomer because they feel more approachable. It’s also much clearer when the work is done and what the expected result is. A newcomer can complete the work, submit a pull request, and get feedback quickly — which builds confidence and keeps them engaged.
Monday, June 2, 2025
Non-Functional Requirements
When building software, we define two types of requirements:
- Functional: What the system should do (e.g., login, payment).
- Non-functional: How well it should do it (e.g., speed, copy protection, security, scalability).
Without this distinction, you risk neglecting important aspects of system quality that don’t show up in features alone. You can implement a feature that works but still fails the user if it’s slow, insecure, or unreliable. Performance is considered non-functional because it affects user experience but doesn’t define what the system does.
It is similar to the frontend-backend layers but not exactly. Frontend-backend is about where things happen. Functional vs. non-functional is about what vs. how well. But there's overlap — non-functional requirements often live in the backend, yet both layers can have them.
In the beginning of a project, non-functional requirements are often forgotten because
- They’re abstract and harder to measure
- Not visible in UI
But ignoring them leads to rework, failure at scale, and unhappy users. Functional requirements get you a working, minimum viable product. Non-functional requirements make it usable, scalable, and successful.
Wednesday, May 21, 2025
In PHP, "false" can be true
All values loaded from an environment (.env) file using vlucas/phpdotenv are treated as strings, regardless of how they appear in the file. Even if your .env file contains IS_IN_SANDBOX_MODE = false, $_ENV['IS_IN_SANDBOX_MODE'] will be "false". The following condition would evaluate to true, even though the variable in the .env file is set to false, because "false" is a non-empty string and thus truthy in PHP:
if (IS_IN_SANDBOX_MODE) --> if ("false") --> true
This is a common gotcha when working with environment variables in PHP. To address this, you can use:
define('IS_IN_SANDBOX_MODE', filter_var($_ENV['IS_IN_SANDBOX_MODE'],
FILTER_VALIDATE_BOOLEAN));
Note that FILTER_VALIDATE_BOOLEAN will return null for values like "True", "FALSE", "TRUE", etc. if (null) evaluates to false. It will return true for "true" (lowercase), "1", "on", or "yes". It will return false for "false" (lowercase), "0", "off", "no", or an empty string "".
Alternatively, my personal preference (because it makes the string conversion explicit):
define('IS_IN_SANDBOX_MODE', $_ENV['IS_IN_SANDBOX_MODE'] === 'true');
Or, when using it in a condition:
if (IS_IN_SANDBOX_MODE === 'true')
Wednesday, May 7, 2025
React Native Parameter Passing
1. Direct Props Passing:
interface AddressInfoProps {
cartItems: CartItem[];
discountPrice: number;
}
const AddressInfo: React.FC<AddressInfoProps> = ({ cartItems, discountPrice }) => {
// Component implementation
};
2. Navigation Route Parameters:
import { useRoute, RouteProp } from '@react-navigation/native';
type AddressInfoRouteProp = RouteProp<{
AddressInfo: {
cartItems: CartItem[];
discountPrice: number;
};
}, 'AddressInfo'>;
const AddressInfo: React.FC = () => {
const route = useRoute<AddressInfoRouteProp>();
const { cartItems, discountPrice } = route.params;
// Component implementation
};
Option 1 is simpler, but it lacks built-in mechanisms to persist state when navigating back and forth between screens. You must always explicitly pass the parameters, meaning the developer is responsible for state persistence. Use it when the component is part of a larger component hierarchy where the parent already has the necessary data to pass down.
Use route parameters (Option 2) when the component represents a screen in your navigation flow—i.e., when backward and forward navigation is expected. With Option 2, the React Native navigation system handles state automatically. If the user navigates to another page and then presses the back button, the screen will re-render with its previous state.
Other options:
Context API: Best for data needed by many components at different nesting levels, but avoid for frequently changing data as it can cause unnecessary re-renders
State Management Libraries (Redux, MobX, Zustand, Jotai): Best for complex applications with lots of shared state and interactions between different parts of the app
URL Parameters: Best for web applications where maintaining bookmarkable state is important
Local Storage: Best for persisting data between app sessions like login status
Monday, May 5, 2025
Storing auth tokens on mobile
React Native AsyncStorage is a simple key-value storage system that saves data as plain text. This means that anyone with access to the device or its backups can potentially read your auth tokens, API keys, or other sensitive data if you use AsyncStorage.
Storing sensitive data unencrypted can also violate Google Play and AppStore guidelines which might result in your app being rejected. Reviewers might run basic security tests that could expose unencrypted token storage.
SecureStore is Expo's abstraction layer that leverages the native security infrastructure of both iOS and Android platforms. SecureStore automatically encrypts all data before storage and provides a unified API that works identically on both iOS and Android. While SecureStore has slightly more overhead due to encryption/decryption operations, the performance impact is negligible for typical use cases like token storage. The security benefits far outweigh any minor performance considerations.
Wednesday, March 5, 2025
Converting a web app to mobile
- Apple App Review Guidelines Rule 4.2 explicitly states that apps should include features, content, and UI elements that elevate them beyond being just a repackaged website.
- Google Play Store: While generally more lenient than Apple, Google still requires apps to provide a reasonably engaging user experience.
- Add native functionality such as push notifications or device camera integration.
- Implement offline capabilities that aren't available in the web version.
Monday, February 10, 2025
Memory cost of image conversion
A PNG needs 3 bytes for RGB and 1 byte for alpha = 4 bytes per pixel. For a 5637x5637 PNG with RGBA colors, we need 5637 * 5637 * 4 bytes per pixel = ~127MB just for the uncompressed pixel data alone. The file size of that PNG is 6MB.
JPEG files typically don't have an alpha channel, so they need 3 bytes per pixel. For a 5637x5637 JPEG, memory needed would be 5637 * 5637 * 3 = ~95MB. The actual file size of the JPEG could range from:
- High quality (90%): 2-8MB
- Medium quality (70%): 1-4MB
- Low quality (50%): 500KB-2MB
- A user could upload a highly compressed 2MB PNG that's 10000x10000 pixels - this would need ~400MB RAM to process.
- Another user could upload a poorly compressed 10MB JPEG that's 1000x1000 pixels - this would only need ~3MB RAM to process.
Considering that current mobile cameras can typically capture 16MP images, the decompressed image would require approximately 16e6 pixels × 4 bytes/pixel / 1024 / 1024 = 61MB of memory. Additional couple of MB memory may be needed as a buffer for libraries like PHP GD, which might use it for copying bytes.
Here are details from my web app of processing a 16MP JPEG with GD functions (total 172MB, calculated with memory_get_peak_usage):
- imagecreatefromjpeg: +68MB
- imagewebp: 130MB (+62MB)
- resizeWebP:
- imagecreatefromwebp: 140MB (+10MB)
- imagecreatetruecolor: 156MB (+16MB)
- imagewebp: 172MB (+16MB)
Converting images to WebP saves disk space and speeds up the web app in the long run, but it consumes a lot of RAM in the short run.
Monday, December 23, 2024
Why Software Project Estimation Is Difficult
In my experience, the following factors make software project effort/cost estimation difficult:
- It is much easier to estimate for the happy path which leaves gaps in specifications for logging, handling edge/error/timeout cases and exceptions.
- It is common to overlook non-functional requirements like performance, security, copy protection, scalability. They often become the reason a project fails at scale, even if it succeeds at first.
- Requirement/design changes due to new information after first user (alpha/beta) tests.
- Not taking into account code clean up effort as the project complexity increases.
- Changes in libraries and frameworks at least once a year, necessitating unplanned rework.
Every if, switch, or loop condition can introduce new paths through the code. If a function has n independent Boolean conditions, the number of possible paths is up to 2^n. If a function takes multiple parameters, the combinations of edge values increase multiplicatively. 1 input has usually at least 3 edge cases, n inputs would have at least 3^n edge case combinations. If the function depends on or alters internal state, interacts with external systems, or uses asynchronous logic, you must test for edge timing, race conditions, resource exhaustion, etc. Edge cases scale faster than linearly with added logic, often closer to exponential or combinatorial growth depending on interaction depth.
Handling error cases and edge conditions often takes much more effort than the happy path due to the need for additional logic, testing, and debugging. If edge cases are not considered early, addressing them later can introduce costly redesign efforts. Unfortunately, the number and complexity of edge cases grow as the project progresses, especially if new scenarios are discovered during development or testing. Handling one error case might introduce or expose others, creating a chain of additional considerations that were not part of the original estimate.
Neglecting regular code cleanup leads to the accumulation of technical debt, which increases the time and effort required to implement similar features later in the project. New developers joining the team may struggle to understand and contribute to the codebase, further slowing development. Additionally, the effort required to fix bugs, integrate new systems, or perform upgrades can grow exponentially over time.
APIs, libraries and frameworks are typically updated every six months, and programming languages undergo significant changes every few years. While these updates bring improvements, they can impact project timelines.
All these factors can make your initial effort/time estimation 10 times less than the actual cost in the end. A rule of thumb you can use is to estimate effort/time for the happy path and multiply that by 10 to get a realistic number.
Monday, December 2, 2024
Interpreted vs compiled programming languages
With an interpreted language like Python or PHP, if you notice a bug in the web app API logic or the UI script, you can fix it and test the change immediately. This is much faster than stopping to recompile and deploy every time, as would be required in a compiled language.
Without compiled binaries, the same source code can be deployed on multiple platforms without adjustments, as long as the runtime environment is consistent.
Many modern web frameworks (e.g., Flask, Laravel Vite) have features like "hot reloading," which automatically detect changes in code and reload the application without restarting. This is much easier to implement in interpreted environments.
While these advantages are significant, they may come at the cost of runtime performance and error detection, as compilation often catches errors early. However, for most web applications, the increased development speed and flexibility usually outweigh these trade-offs.
Friday, November 29, 2024
Base64 encoding
Base64 encoding ensures that the output only contains characters from a specific, limited set of 64 characters, which are: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
It is safe for most text-based systems because none of the potentially problematic characters (\, \0, \n, \r, \x1a, ', ") appear in the output. Note that \x1a is the hexadecimal representation of the ASCII control character SUB (substitute). It is a non-printable character with the decimal value 26 in the ASCII table. If included in a text string, \x1a is typically invisible and may disrupt processing, especially in legacy systems that interpret it as EOF.
Example:
Base64 encoding increases the size of the input data by approximately 33%. Specifically: For every 3 bytes of input, base64 adds 4 characters. For example if input JSON is {"customer_id":123,"email":"user@example.com","nonce":"d1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6"}, which is 94 characters, the output will be eyJjdXN0b21lcl9pZCI6IDEyMywgImVtYWlsIjogInVzZXJAZXhhbXBsZS5jb20iLCAibm9uY2UiOiAiZjVkMGMzZGY3ZTM3ODQ2NWQ0NjhkMTdjZTRhNGNlMzIifQ==, which is 128 characters. Note the "==" characters at the end. These are used for padding which ensures the length of the encoded string is a multiple of 4. If your database column to hold the token is VARCHAR(255), assuming a max customer_id of "999 999 999", max email size should not exceed 111 characters.
Email max lengths [RFC 5321, Simple Mail Transfer Protocol]:
- Local part (before the @): Up to 64 characters (octet = byte).
- Domain part (after the @): Up to 255 characters.
Total length: The maximum length of a valid email address is 320 characters, but this is extremely rare in practice.
Music: Barış Manço - Dönence
Thursday, November 28, 2024
Concept of Operations
Sunday, November 17, 2024
Data Transfer Objects
Data Transfer Objects (DTOs) decouple the internal structure of your models, entities, or database schema from the data exposed to the external world (e.g., APIs, front-end). They serve as a contract for the data being transferred, which helps ensure that changes in your data layer don't inadvertently affect the consumer.
Another benefit of DTOs is to enforce structured data and eliminate errors from missing [string] keys. By using a constructor, you control how the raw data is mapped. If a key is missing, you can provide a default value or handle the absence gracefully or you can add validation logic centrally in constructor. Using DTOs allows tools like PhpStorm or VSCode to identify missing properties during development. When working with arrays, typos in keys can go unnoticed until runtime, with DTOs you are using object fields which don’t have this weakness. Example without DTO (note the usage of error prone string keys):
private function prepareProductDetails(array $product): array {
$product['photos'] = $this->processProductPhotos($product['photos']??[]);
$product['tr_currency_formatted'] = isset($product['deposit'])
?Currency::formatTRY($product['deposit'])
return $product;
}
With DTO:
class ProductDetailsDTO {
public array $photos;
public ?float $deposit = null;
public ?string $tr_currency_formatted = null;
public function __construct(array $data) {
$this->photos = $data['photos'] ?? [];
$this->deposit = $data['deposit'] ?? null;
}
public function setFormattedCurrency(callable $formatter): void {
if ($this->deposit !== null) {
$this->tr_currency_formatted = $formatter($this->deposit);
}
}
}
Note the usage of object fields instead of string keys:
private function prepareProductDetails(array $product): ProductDetailsDTO {
$productDTO = new ProductDetailsDTO($product);
$productDTO->photos = $this->processProductPhotos($productDTO->photos);
$productDTO->setFormattedCurrency(fn($amount) =>
Currency::formatTRY($amount));
return $productDTO;
}
Saturday, October 19, 2024
Using UI with AI
17.02.2025: Open source AI models like DeepSeek open the door to self hosted AI. You will need a powerful server with lots of RAM and GPU. The key will be maximizing GPU VRAM, as this is the primary bottleneck for running large models. For efficient inference, the entire model (or as much of it as possible) needs to reside in VRAM. Such servers might cost more than AI API calls if you use a cloud server. One solution might be to have your own physical server to run the AI model and use the cloud server for the web app, which makes API calls to the AI on your server. You will also need to host a speech to text model.
19.06.2025: Desktop AI Compared
Sunday, October 13, 2024
Evaluating fairness of an Investment/Shareholders' Agreement
- Board representation (a seat on the board).
- Veto rights on major financial decisions (e.g., capital raises, mergers, or asset sales).
- Approval rights over key hires or changes in the business direction.
- Liquidation preferences to get paid first in case of a company exit.
Does the contract reflect a balanced distribution of power? If not, what share percentage would correspond to the class B shareholder's power? Is this normal for an initial investor in the startup, considering that convincing the first investor is often the most difficult?
- Even though the class A shareholder (founder) appoints the board member, any change in the board representative requires class B shareholder (investor) approval.
- Class A shareholder cannot transfer shares without class B consent for 3 years, while class B share holder is free to transfer to affiliates or related parties without restriction.
- Important strategic decisions need approval from the Steering Committee, where both A and B share holders have one representative each. Any deadlock in this two-person committee could give the B shareholder veto power over important business decisions.
- Do we agree that the founder/CEO of an ambitious startup with rapid growth goals needs to be able to act quickly, requiring minimal approval/bureaucracy?
- To fund rapid growth, we most probably will need other investors. Can we foresee that this agreement might irritate potential investors, lower the company's value, and lead them to request the same privileges?
- If the same privileges are granted to other investors, would reaching an agreement on any matter outside of routine business—especially considering the potential for irrational behavior (such as ego conflicts, etc.)—become practically impossible?
Sunday, September 22, 2024
What tech to use when you are just starting
| # | complex | simple |
|---|---|---|
| 1 | Mobile app | Progressive Web App (PWA) |
| 2 | MySQL/PostgreSQL | SQLite |
| 3 | Queue worker | defer() |
| 4 | Broadcast with events | Echo whisper |
| 5 | Mailgun | PHPMailer + gmail |
| 6 | ElasticSearch | SQL queries |
Friday, September 20, 2024
The role of the CTO
The role of the Chief Technology Officer (CTO):
- Understand business goals, assess feasibility, and set technical priorities accordingly. Create a technical roadmap.
- In the early stages of the company, be the lead engineer. As the company grows, hire technical personnel, provide guidance to the team.
- Review team outputs (code & documentation), ensure effort is aligned with priorities and outputs are clean and of high quality.
- Review tests and verify that important test cases are included.
- In case of personnel loss, temporarily fill the gap until a replacement is hired.
- Oversee IT, CI/CD infrastructure and security.
- Stay updated with technological trends.
- Represent the company's technological vision to partners, investors, or at industry events.
Thursday, September 19, 2024
Financial projection for startups
Friday, August 30, 2024
Why use SQLite?
SQLite is optimized for situations where the workload is predominantly reads with occasional writes, making it ideal for small to medium-sized applications. SQLite is very efficient and can operate comfortably within a few megabytes of RAM.
For highly concurrent environments where many users need to write to the database simultaneously, SQLite might not be the best choice, and a more robust client-server database like MySQL or PostgreSQL would be more appropriate. Recommended RAM for light use for MySQL is 1GB and for PostgreSQL 2GB, which is about 1000 times more than SQLite.
SQLite is an embedded database that runs in the same process as the application using it. This means it doesn’t require a separate server process to manage database connections, unlike MySQL, which operates as a server and listens for incoming connections on a specific port (e.g. 3306). SQLite databases are stored as files on the local filesystem. When an application wants to interact with an SQLite database, it directly accesses the database file without needing to communicate over a network. So with SQLite, if you run multiple apps, there won't be problems like port conflicts or the need for containers.
SQLite doesn't require authentication mechanisms like usernames and passwords. The database file is accessed directly without any user credentials.
If you want to use a cheap (5$/month) VPS with 512GB RAM, SQLite is your only option. It is not just a toy, it is used in popular apps like nomadlist, see Pieter Levels video. You can optimize SQLite even further.
Music: Mike Oldfield - Sentinel