<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Behram Bazo on Medium]]></title>
        <description><![CDATA[Stories by Behram Bazo on Medium]]></description>
        <link>https://medium.com/@bazobehram?source=rss-9b4c8c153c46------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*scbvozd0Cn8VgKnOLg_58A.png</url>
            <title>Stories by Behram Bazo on Medium</title>
            <link>https://medium.com/@bazobehram?source=rss-9b4c8c153c46------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 03:10:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bazobehram/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Your AI. Your Devices. Your Control. — Why I Built CommandCore]]></title>
            <link>https://medium.com/@bazobehram/your-ai-your-devices-your-control-why-i-built-commandcore-6ade8118891e?source=rss-9b4c8c153c46------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ade8118891e</guid>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[self-hosting]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Behram Bazo]]></dc:creator>
            <pubDate>Tue, 17 Nov 2026 07:10:02 GMT</pubDate>
            <atom:updated>2026-11-17T07:10:02.865Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How I connected ChatGPT and other AI clients to my own computers — without giving them unlimited access.</em></p><p>I wanted to manage real projects from anywhere, even with just a phone in my hand. The answer wasn’t another chatbot or another remote desktop app. It was a way to connect the AI I use to the machines I already own.</p><p><a href="https://youtu.be/kRVtG7oW1aQ"><strong>Watch the full walkthrough</strong></a> · <a href="https://commandcore.app/"><strong>Try the website</strong></a> · <a href="https://github.com/bazobehram/commandcore"><strong>Explore the open-source repository</strong></a></p><blockquote><em>Screenshots are taken from the actual CommandCore website or my demonstration video. The public website hero contains an illustrative product preview, not a screenshot of a live device session. The project is still in its release-candidate phase; this article is a demonstration of the idea and the working integration, not a claim that every platform and feature is production-ready.</em></blockquote><figure><img alt="CommandCore homepage with the slogan “Your AI. Your devices. Your control.” and illustrative device cards." src="https://cdn-images-1.medium.com/max/1024/0*FAeZtlBSDDOzJOxS.png" /></figure><p><em>The CommandCore website as it appeared in November 2026. The device cards in its hero are explicitly labeled an illustrative preview.</em></p><figure><img alt="Architecture screen from the CommandCore video walkthrough." src="https://cdn-images-1.medium.com/max/854/0*tCKSaT1yUgOPlhln.jpg" /></figure><p><em>The project’s architecture explained in my real walkthrough. </em><a href="https://youtu.be/kRVtG7oW1aQ?t=40"><em>Watch this moment</em></a><em>.</em></p><h3>The problem: my AI was in one place, my computers in another</h3><p>I spend an enormous amount of time researching, writing code, developing ideas, and building projects. But I am not always sitting in front of a desk.</p><p>Sometimes I am walking. Sometimes I am traveling. Sometimes the only device in my hand is my phone.</p><p>But I kept running into a frustrating separation: an AI assistant could help me think through a problem, but the machines holding the relevant files, services, and tools were somewhere else.</p><p>That should not stop the work.</p><p>I already have computers that can do things: a home server that runs my applications, a workstation I use for AI development, and other machines that have their own roles. The hardware exists. The software exists. The files, projects, terminals, and services exist. The missing piece was a way for my AI assistant to reach the right machine, with the right permission, at the right moment.</p><p>I did not want a different remote-control integration for every computer, or to keep moving project files into whichever chatbot happened to be open. I also did not want to solve the problem by handing an assistant the equivalent of unrestricted administrator access to everything I own.</p><p><strong>I wanted to speak to an AI agent and have it work on my own devices — without giving up ownership of the devices or control over what the agent is allowed to do.</strong></p><p>That is why I started building <strong>CommandCore</strong>.</p><h3>One AI conversation. Multiple machines.</h3><p>Imagine asking your assistant to check your server’s health while you are away from home.</p><p>You could go further:</p><ul><li>Ask which computers are connected and what each one can do.</li><li>Inspect a project directory, a running service, or a failed job.</li><li>Read a log, identify a problem, and review a proposed fix.</li><li>Authorize an operation on one selected machine, rather than handing the AI unrestricted access to your entire network.</li></ul><p>The essential point is that <em>the AI client and the computer doing the work are separate.</em> The assistant is not a magical superuser inside my network.</p><p>The agent is not magically running inside ChatGPT. CommandCore sits between the AI client and your enrolled machines. It authenticates requests, selects the right device, checks permissions, routes operations, and records the result.</p><figure><img alt="CommandCore workspace showing multiple enrolled machines." src="https://cdn-images-1.medium.com/max/854/0*uUZkzM3AUQdlp_AZ.jpg" /></figure><p><em>Figure 2. The real Workspace device view from the demonstration. The screenshot shows several distinct machines rather than one generic remote terminal. </em><a href="https://youtu.be/kRVtG7oW1aQ?t=340"><em>Video moment</em></a><em>.</em></p><p>My setup includes machines with different jobs. The homeserver is a place to run personal services and projects; an AI workstation is a separate resource for heavy model work. CommandCore gives me a single place to reach them without pretending they are the same computer.</p><p>The distinction matters. A device may be online but have no desktop session. Another may offer a terminal but not a browser. Another may be able to perform a read-only inspection but not alter services. The interface should expose the <em>actual</em> capabilities and authority of each machine.</p><h3>The architecture: AI clients connect to CommandCore, not directly to every device</h3><p>CommandCore uses <strong>Model Context Protocol (MCP)</strong> as its AI-facing integration. That matters because the design is not tied to a single model vendor.</p><p>The intended flow is simple:</p><pre>ChatGPT / Claude / Gemini / Codex / another MCP client<br>                         |<br>                 HTTPS + OAuth/OIDC<br>                         |<br>                  CommandCore MCP<br>               identity · device grants<br>               permissions · jobs · audit<br>                         |<br>                 authenticated outbound WSS<br>                         |<br>                enrolled device Agents<br>                         |<br>              files · shell · processes · Git<br>                   system information</pre><p>Every managed device runs an Agent that establishes an <strong>outbound</strong> connection to CommandCore. You do not need to expose an inbound SSH or shell port on every machine just to make it reachable by the AI client.</p><p>The server holds the registry, device grants, job routing, and audit records. The Agent holds its own device identity and enforces a local maximum permission level. A selected device can be addressed through a logical selection handle rather than relying on the assistant to remember hostnames.</p><figure><img alt="CommandCore architecture shown in the video walkthrough." src="https://cdn-images-1.medium.com/max/854/0*GBJkUfDMevIfytco.jpg" /></figure><p><em>Figure 3. The architecture presented in the real walkthrough, with a demonstration view rather than a generated illustration. </em><a href="https://youtu.be/kRVtG7oW1aQ?t=960"><em>Video moment</em></a><em>.</em></p><p>The <a href="https://github.com/bazobehram/commandcore/blob/main/docs/ARCHITECTURE.md">architecture reference</a>, <a href="https://github.com/bazobehram/commandcore/blob/main/docs/MCP_CONTRACT.md">MCP contract</a>, and <a href="https://github.com/bazobehram/commandcore/blob/main/docs/DEVICE_PROTOCOL.md">device protocol</a> document these boundaries in more detail.</p><h3>What it looks like in a real AI conversation</h3><p>Here is where the idea stops being a diagram.</p><p>In the demonstration, I move from the CommandCore interface to an AI conversation and work with connected machines. The model can request the list of authorized devices, select one, inspect its state, and request an operation through the MCP tools.</p><figure><img alt="ChatGPT interaction displaying connected-device information." src="https://cdn-images-1.medium.com/max/854/0*qy7zqQdZA5QMM4Sa.jpg" /></figure><p><em>Figure 4. A real AI-client interaction showing connected-device information. </em><a href="https://youtu.be/kRVtG7oW1aQ?t=480"><em>Video moment</em></a><em>.</em></p><p>That is different from an assistant merely telling me what command I should copy into a terminal.</p><p>I can ask the assistant to perform an authorized operation, and the system can return the execution result. The AI is the conversational interface; CommandCore is the permissioned path to the computer.</p><figure><img alt="CommandCore tool execution shown in the demonstration." src="https://cdn-images-1.medium.com/max/854/0*ak-4RiREYiKT5e4t.jpg" /></figure><p><em>Figure 5. A real execution step from the walkthrough. An operation is a visible action with results, not an invisible promise that the AI handled something. </em><a href="https://youtu.be/kRVtG7oW1aQ?t=640"><em>Video moment</em></a><em>.</em></p><figure><img alt="A demonstration session showing a remote operation and its result." src="https://cdn-images-1.medium.com/max/854/0*V-ldXMU3XaXso4rg.jpg" /></figure><p><em>Figure 6. A second live workflow: inspect what the assistant requested and what the remote system returned. </em><a href="https://youtu.be/kRVtG7oW1aQ?t=800"><em>Video moment</em></a><em>.</em></p><p>One of my strongest preferences is that a tool should <strong>show its work</strong>. If it executes a command, I want the action and its result to be inspectable. If something is blocked by policy, I want an understandable explanation. If a long-running process is still active, I want a real status, not an invented success message.</p><p>That is why activity visibility and managed jobs are part of the project, rather than an afterthought.</p><h3>Control is not the same as unrestricted access</h3><p>Remote execution is powerful. An AI capable of reading files, operating a terminal, and changing services should not receive unlimited privileges simply because it authenticated.</p><p>CommandCore has three permission profiles:</p><p><strong>READ_ONLY:</strong> Inspect permitted state and files.</p><p><strong>STANDARD:</strong> Work with the authority of the Agent’s operating-system user.</p><p><strong>FULL_CONTROL:</strong> Explicitly opt into selected privileged operations through a locally controlled helper.</p><p>The effective authority is the intersection of the <strong>OAuth execution scope</strong>, the <strong>account-to-device grant</strong>, the <strong>server permission profile</strong>, and the <strong>device-local ceiling</strong>.</p><p>That last boundary is important. A server-side request should not be able to raise a device’s local maximum permission without the corresponding local authorization.</p><p>A connected device is also not automatically available to every authenticated user. Enrollment and account access are separate decisions.</p><p>On Linux, the normal Agent stays unprivileged. Privileged operations use a separate local helper with additional checks when FULL_CONTROL is explicitly configured.</p><p>The security documentation goes deeper into <a href="https://github.com/bazobehram/commandcore/blob/main/docs/SECURITY_MODEL.md">device identity</a>, <a href="https://github.com/bazobehram/commandcore/blob/main/docs/PERMISSIONS.md">permissions</a>, the <a href="https://github.com/bazobehram/commandcore/blob/main/docs/THREAT_MODEL.md">threat model</a>, and <a href="https://github.com/bazobehram/commandcore/blob/main/docs/AGENT_UPDATE.md">signed Agent updates</a>.</p><p><strong>A note I do not want to hide:</strong> STANDARD access is already powerful. It has the authority of the user running the Agent. Anyone deploying this should choose the Agent account and device grants deliberately, particularly on important machines.</p><h3>Why self-hosting matters to me</h3><p>I run personal tools and services on my own infrastructure. I wanted the control plane to fit that approach too.</p><p>CommandCore is self-hostable. The server, Agent, protocol implementation, and deployment tooling live in the open-source repository. You decide where the server runs, what domain it uses, which OAuth provider protects it, and which devices are enrolled.</p><p>The public website is a starting point:</p><p><a href="https://commandcore.app/"><strong>commandcore.app</strong></a></p><p>The source and deployment documentation are here:</p><p><a href="https://github.com/bazobehram/commandcore"><strong>github.com/bazobehram/commandcore</strong></a></p><figure><img alt="CommandCore workflow showing the AI action and device context." src="https://cdn-images-1.medium.com/max/854/0*9urammWPrX82iXDO.jpg" /></figure><p><em>Figure 7. Real work inside the demonstrated system. The goal is to keep both the AI action and the device context visible. </em><a href="https://youtu.be/kRVtG7oW1aQ?t=1130"><em>Video moment</em></a><em>.</em></p><h3>Step 1: Start with a local server installation</h3><p>For an operator comfortable with Linux and Docker Compose, the repository’s local evaluation path starts with:</p><pre>git clone https://github.com/bazobehram/commandcore.git<br>cd commandcore<br>cp .env.example .env<br># Generate two *different* secrets:<br>./scripts/generate-secret.sh<br>./scripts/generate-secret.sh<br># Put them in .env as COMMANDCORE_API_TOKEN<br># and COMMANDCORE_PANEL_SESSION_SECRET.<br># Configure your deployment URLs in .env.<br>docker compose up -d --build<br>docker compose ps<br>curl -fsS http://127.0.0.1:8787/healthz</pre><p>This is the <strong>server</strong>, not yet an enrolled device. Starting the server does not automatically grant an AI agent control of that server or any other machine.</p><p>Also, a passing local health check is <strong>not</strong> proof that a secure remote deployment is complete. External access needs HTTPS/WSS, correct public URLs, a compatible OAuth/OIDC provider, properly configured grants, and a real acceptance test.</p><p>Follow the canonical <a href="https://github.com/bazobehram/commandcore/blob/main/docs/SELF_HOSTING.md">self-hosting guide</a>, <a href="https://github.com/bazobehram/commandcore/blob/main/docs/INSTALLATION.md">installation guide</a>, and <a href="https://github.com/bazobehram/commandcore/blob/main/docs/INSTALLATION_READINESS.md">installation-readiness notes</a> for current details.</p><h3>Step 2: Enroll a Linux device</h3><p>A configured deployment <strong>may</strong> publish a signed Linux installer at:</p><pre>curl -fsSL https://YOUR-COMMANDCORE-DOMAIN/install/linux \<br>  | sh -s -- --server https://YOUR-COMMANDCORE-DOMAIN</pre><p>This is not a universal installer at the public demo website. The deployment operator must first publish the signed release feed and pinned installer. A fresh default Compose server can legitimately return <strong>404</strong> for that path.</p><p>If you are evaluating the software from source instead, the documentation describes a reviewed-checkout workflow for a Linux Agent. Enrollment requires the operator to approve the device and separately grant access.</p><p><a href="https://github.com/bazobehram/commandcore/blob/main/docs/INSTALLATION.md"><strong>Read the full Linux Agent installation guide</strong></a></p><h3>Step 3: Connect your AI client over MCP</h3><p>For a properly configured deployment, use its MCP URL:</p><pre>https://YOUR-COMMANDCORE-DOMAIN/mcp</pre><p>Authenticate through the configured OAuth flow, start with the narrowest practical scope, and grant only the devices needed.</p><p>A good first acceptance sequence is: inspect your authenticated identity; list devices; select a harmless test device; inspect system information; read a safe file such as /etc/hostname; confirm that the audit trail shows the correct account and machine.</p><p>If you use ChatGPT, start with the <a href="https://github.com/bazobehram/commandcore/blob/main/docs/clients/CHATGPT.md">ChatGPT integration guide</a>. Separate guides exist for <a href="https://github.com/bazobehram/commandcore/blob/main/docs/clients/CLAUDE.md">Claude</a>, <a href="https://github.com/bazobehram/commandcore/blob/main/docs/clients/GEMINI.md">Gemini</a>, <a href="https://github.com/bazobehram/commandcore/blob/main/docs/clients/CODEX.md">Codex</a>, and <a href="https://github.com/bazobehram/commandcore/blob/main/docs/clients/GENERIC_MCP.md">generic MCP clients</a>.</p><h3>Could I install CommandCore with an AI agent?</h3><p>This is one of the more interesting possibilities.</p><p>If a capable coding agent already has access to the intended server, I should be able to ask it to inspect the machine, clone the project, read the documentation, configure the deployment, and verify the result.</p><p>The repository includes an AGENTS.md file and a dedicated <a href="https://github.com/bazobehram/commandcore/blob/main/docs/AGENT_ASSISTED_INSTALL.md">agent-assisted installation guide</a>.</p><p>A compact starting prompt is:</p><blockquote><em>Clone </em><a href="https://github.com/bazobehram/commandcore.git"><em>https://github.com/bazobehram/commandcore.git</em></a><em> and read AGENTS.md. Inspect this Linux machine, then prepare a local-only CommandCore installation using the documented Docker Compose workflow. Generate unique secrets, keep the application on loopback, do not expose new public ports or enable FULL_CONTROL, and verify /healthz. Report exactly what worked and what still requires my approval.</em></blockquote><p>For a real internet-facing installation, the agent must also stop for decisions it cannot make on your behalf: DNS ownership, OAuth provider configuration, MFA, account consent, and permission grants.</p><p>That is not a limitation to work around. Those are the boundaries that keep the infrastructure yours.</p><h3>What is ready today — and what is not?</h3><p>I want the project to be useful, but I also want to be precise about the current release status.</p><p>As documented in the repository’s <strong>0.9 release-candidate</strong> family:</p><ul><li><strong>Linux x86_64 and ARM64</strong> are the primary candidate platforms; the Rust Agent is the preferred native runtime.</li><li><strong>Windows</strong> is still a preview, with important real-runtime lifecycle acceptance work remaining.</li><li><strong>macOS</strong> does not yet have a supported Agent release.</li><li><strong>Interactive desktop control</strong> is experimental, not a stable platform promise.</li><li>The <strong>managed Browser</strong> is optional and has its own security and deployment boundaries.</li><li>A signed installer is available only where a deployment has actually published and configured the corresponding signed release feed.</li></ul><p>This distinction matters when people are trusting software to touch their computers.</p><p>For the most current evidence and limitations, read the <a href="https://github.com/bazobehram/commandcore/blob/main/docs/PLATFORM_SUPPORT.md">platform support matrix</a>, <a href="https://github.com/bazobehram/commandcore/blob/main/docs/VALIDATION_RESULTS.md">validation notes</a>, and <a href="https://github.com/bazobehram/commandcore/blob/main/docs/PUBLIC_RELEASE_CHECKLIST.md">release checklist</a>.</p><figure><img alt="Later AI-client interaction showing tools and results." src="https://cdn-images-1.medium.com/max/854/0*oVqDiXZJsxwlZtjm.jpg" /></figure><p><em>Figure 8. The later part of the real demonstration returns to the actual AI-client workflow, with tools and results visible. </em><a href="https://youtu.be/kRVtG7oW1aQ?t=1320"><em>Video moment</em></a><em>.</em></p><h3>Open source means you can inspect it, improve it, and run it yourself</h3><p>CommandCore is released under the <strong>GNU AGPL-3.0-or-later</strong> license.</p><p>The goal is not to build a black box that asks you to trust it with your machines. It is to build a control plane whose behavior, security boundaries, installation process, and limitations can be inspected.</p><p>If you want to contribute, start with the <a href="https://github.com/bazobehram/commandcore">repository</a>, <a href="https://github.com/bazobehram/commandcore/blob/main/CONTRIBUTING.md">contribution guidelines</a>, and <a href="https://github.com/bazobehram/commandcore/issues">open issues</a>.</p><p>Code contributions pass through pull requests and CI. Security issues should follow the <a href="https://github.com/bazobehram/commandcore/blob/main/SECURITY.md">private disclosure policy</a>, not a public issue.</p><p>If you are interested in MCP, self-hosting, device authorization, Linux Agents, Rust, frontend experience, browser isolation, or signed software updates, there are meaningful areas to explore.</p><h3>The full video: see the workflow, not just the diagrams</h3><p>The article is the explanation. The video is the demonstration.</p><p><a href="https://youtu.be/kRVtG7oW1aQ"><strong>Watch the complete CommandCore demonstration on YouTube</strong></a></p><p>The original recording is in Turkish. An English-dubbed version was produced as a separate audio workflow; check the video player’s available audio tracks before assuming YouTube offers an English track.</p><p>You can see the Workspace, enrolled machines, AI-client interactions, and real execution paths rather than only a concept design.</p><p>I built CommandCore because I wanted to carry my work with me without carrying all my computers with me. My phone should be enough to ask the right question. My own machines should do the work. And I should remain the person deciding what the AI is allowed to access.</p><p>That is the direction I want to keep building.</p><p><strong>Your AI. Your devices. Your control.</strong></p><p><strong>Links and references</strong></p><p><a href="https://commandcore.app/">Website</a> · <a href="https://github.com/bazobehram/commandcore">GitHub</a> · <a href="https://youtu.be/kRVtG7oW1aQ">Video</a> · <a href="https://github.com/bazobehram/commandcore/tree/main/docs">Documentation</a> · <a href="https://github.com/bazobehram/commandcore/blob/main/README.md">Getting started</a> · <a href="https://github.com/bazobehram/commandcore/blob/main/docs/INSTALLATION.md">Installation</a> · <a href="https://github.com/bazobehram/commandcore/blob/main/docs/AGENT_ASSISTED_INSTALL.md">Agent-assisted setup</a> · <a href="https://github.com/bazobehram/commandcore/blob/main/docs/SECURITY_MODEL.md">Security</a> · <a href="https://github.com/bazobehram/commandcore/blob/main/docs/PLATFORM_SUPPORT.md">Supported platforms</a> · <a href="https://github.com/bazobehram/commandcore/blob/main/CONTRIBUTING.md">Contributing</a> · <a href="https://github.com/bazobehram/commandcore/blob/main/LICENSE">License</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ade8118891e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[İnsan Gibi Düşünmüyor. Peki Zekâ Değil mi?]]></title>
            <link>https://medium.com/@bazobehram/i%CC%87nsan-gibi-d%C3%BC%C5%9F%C3%BCnm%C3%BCyor-peki-zek%C3%A2-de%C4%9Fil-mi-5b1cd7d2684e?source=rss-9b4c8c153c46------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b1cd7d2684e</guid>
            <category><![CDATA[yapay-zeka]]></category>
            <category><![CDATA[üretken-yapay-zeka]]></category>
            <category><![CDATA[dijital-zeka]]></category>
            <category><![CDATA[zeka-nedir]]></category>
            <dc:creator><![CDATA[Behram Bazo]]></dc:creator>
            <pubDate>Sun, 16 Aug 2026 18:15:28 GMT</pubDate>
            <atom:updated>2026-08-16T18:15:28.545Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pDFl-dgbGJ1QdIGqNcZF-w.png" /></figure><h3>Dijital Zekâ — 1/3</h3><p>Bu yazı, Dijital Zekâ üzerine hazırladığım üç bölümlük serinin ilk yazısı.</p><p><strong>1. İnsan Gibi Düşünmüyor. Peki Zekâ Değil mi?</strong><br>Dijital zekâ nedir, ne değildir? İnsan zekâsını neden tek ölçü olarak almamalıyız?</p><p><strong>2. Bir Yapay Zekâ Ne Zaman Kendi Başına Hareket Etmeye Başlar?</strong><br>Agentlar, özerklik, amaçlar ve dijital zekânın eyleme geçmesi.</p><p><strong>3. Makine Daha Çok Çalışıyorsa Biz Neden Daha Az Çalışmıyoruz?</strong><br>Dijital zekânın toplumsal üretimi, mülkiyet, emek, yabancılaşma ve çalışma süresi.</p><p>Bu yazıyı yazmaya başlamamda son dönemde izlediğim iki video da etkili oldu.</p><p>Bunlardan biri:</p><p>Yapay Zeka Nasıl Düşünüyor?</p><p><a href="https://www.youtube.com/watch?v=9PR9RJ7uWx0">https://www.youtube.com/watch?v=9PR9RJ7uWx0</a></p><p>Diğeri ise Prof. Dr. B. Taner Dinçer’in katıldığı:</p><p><strong>Büyük Dil Modelleri | Ben HALA işimi buna teslim etmem!</strong><br><a href="https://youtu.be/X8E1qZArsWs">https://youtu.be/X8E1qZArsWs</a></p><p>Bu iki video aynı şeyi söylemiyor. İlk video daha çok LLM’lerin nasıl çalıştığını anlatmaya çalışırken, ikinci videoda bundan daha güçlü felsefi sonuçlara ulaşılıyor. Ama ikisinde de benim itiraz ettiğim ortak bir damar var.</p><p>Birinci videoda LLM’lerin next-token prediction mekanizması anlatıldıktan sonra mesele neredeyse <strong>“Yapay zekâ dediğiniz şey tamamen bundan ibaret.”</strong> noktasına geliyor. Diğer videoda ise Transformer için <strong>“Çok gelişkin bir dictionary.”</strong>, <strong>“Ezber yapıyor yani.”</strong> deniliyor. Ardından çok daha ileri gidilerek <strong>“Karar yok, düşünme yok.”</strong> ve nihayet <strong>“Buradan AGI çıkmaz.”</strong> sonucuna ulaşılıyor.</p><p>Burada benim ilgimi çeken şey teknik tartışmanın kendisinden çok, bu teknik açıklamadan çıkarılan felsefi sonuç. Transformer’ın içinde matris çarpımı olduğunu gösterdik. Attention mekanizmasını açıkladık. Tokenların nasıl üretildiğini anlattık. O halde zekâ yok.</p><p>Bu bana çok hızlı yapılmış bir sıçrama gibi geliyor.</p><p>Ama tartışmanın karşı tarafında da başka bir aşırılık var. Bir tarafta yapay zekâyı “sadece istatistik, sadece hesaplama, sadece token tahmini” diyerek bütün kapasitesini sıfırlayan bir yaklaşım varken, diğer tarafta AI çevresinde giderek büyüyen AGI ve süperzekâ anlatıları var.</p><p>OpenAI çevresinde süperzekâya doğru ilerleyen bir gelecekten söz ediliyor. Sam Altman da önümüzdeki yıllarda süperzekânın inşa edilmesini güçlü bir olasılık olarak ele alıyor. Anthropic CEO’su Dario Amodei ise gelecekteki güçlü AI sistemlerini tarif ederken bir veri merkezindeki “dahiler ülkesi” benzetmesini kullanıyor.</p><p>Bunlar kendi başına “AI bilinçlidir” iddiası değil. Bilinç atfetme bunun daha ileri bir biçimi. 2022’de Google mühendisi Blake Lemoine, Google’ın LaMDA dil modelinin bilinçli olduğuna ve bir tür kişiliğe sahip olduğuna inandığını açıkladı. Google ise bu iddiayı reddetti.</p><p>Dolayısıyla bugün tartışmanın garip bir yerde sıkıştığını düşünüyorum. Bir tarafta <strong>“Sadece token tahmin ediyor. Zekâ yok.”</strong> deniliyor. Diğer tarafta <strong>“AGI geliyor, süperzekâ geliyor.”</strong> deniliyor. Daha ileri gidildiğinde ise <strong>“Belki de bilinçli.”</strong></p><p>Ben bunların hiçbirinden başlamak istemiyorum.</p><p>Bugünkü yapay zekâ sistemlerine insan bilinci atfetmek zorunda değiliz. Ama içlerinde insan gibi düşünen bir özne bulamadığımız için ortaya koydukları kapasiteyi zekâ kategorisinin tamamen dışına atmak zorunda da değiliz.</p><p>Belki de önce sormamız gereken soru daha basit:</p><p><strong>Zekâ dediğimiz şey neden mutlaka insan gibi olmak zorunda?</strong></p><p>90’ların çocuklarıysanız iyi bilirsiniz ki bu kuşak, kâğıt oyunlarıyla büyüyen bir kuşaktan el konsollarıyla Tetris, Pac-Man, araba yarışı vs. oynamaya başladı. Daha sonra atari salonları vardı. Atari salonlarından sonra atariler evlere taşındı, yüzlerce oyun kasetiyle oyunlar oynamaya başladık.</p><p>Bu oyunlarda karşılıklı oynayamadığımız durumlarda, hatırlayanınız varsa, birden fazla oyunculu oyunlarda botlarla oynanırdı. Botların zorluk seviyeleri vardı. Biz oyunu öğrendikçe, geliştikçe zorluk seviyesini artırırdık ve bu seviyeleri geçmek bazen aylar, bazen yıllar alır, bazense hiç mümkün olmazdı. Botlar bizim düşünemediğimiz ve bize zeki, çevik gelen hamleler yapabilirdi.</p><p>Ve bu yıllarda pek kimse bu makineler için “çok zeki” demezdi. Çünkü bu botların çoğu geliştiricilerin önceden yazdığı kurallar ve davranış sistemleri içerisinde hareket ederdi.</p><p>1997’de dünyanın en iyi satranç oyuncularından biri olan Garry Kasparov, Deep Blue isimli bir makine tarafından yenildi. Deep Blue saniyede yaklaşık 200 milyon satranç pozisyonunu değerlendirebiliyordu.</p><p>Deep Blue “Atı buraya koyarsam Kasparov psikolojik olarak baskı hisseder.” demedi. Hatta fiziksel bir satranç tahtasını bile görmüyordu. Ama yaptığı şey dünyanın en başarılı satranççılarından birini yenmek oldu.</p><p>Deep Blue Kasparov’u yenince şu itiraz çok güçlüydü:</p><p><strong>“Bu zekâ değil. Sadece inanılmaz hızlı hesap yapıyor.”</strong></p><p>Bu itirazın bir zemini vardı. Deep Blue satranç için özel tasarlanmıştı; insan gibi satranç öğrenmiyor, çok büyük miktarda olası hamleyi değerlendiriyor ve satranç uzmanlarının bilgisinden de yararlanıyordu.</p><p><strong>Peki davranışı tek tek programlamazsak ve sistem deneyerek öğrenirse?</strong></p><p>DeepMind araştırmacıları eski Atari 2600 oyunlarını bir yapay zekâ sınavına çevirdiler. Sisteme Breakout’un ne olduğu, topun ne işe yaradığı ya da hangi stratejinin izlenmesi gerektiği anlatılmadı. DQN denilen derin pekiştirmeli öğrenme sistemi oyun ekranındaki pikselleri aldı, hareketler yaptı ve bu hareketlerin getirdiği ödül sinyalinden öğrendi.</p><p>Aynı temel yöntem 49 farklı Atari oyununa uygulanmış ve bazı oyunlarda insan düzeyinde veya üzerinde performans göstermişti. Kimse makineye duvarın kenarından tünel açmasını söylememişti. Yine de bunu keşfetti.</p><p>Peki buna yalnızca “hesaplama” mı diyeceğiz, yoksa öğrenmenin kendisi zaten zekânın bir parçası mı?</p><p>Çünkü sistem oyunun kurallarını insan gibi okuyup anlamıyordu. Ekrandaki piksellerden hareket ediyor, yaptığı eylemlerden aldığı ödülle giderek daha iyi davranışlar öğreniyordu.</p><p>Burada önemli bir ayrım var:</p><p><strong>Bir davranışı tek tek programlamakla, o davranışı üretebilecek bir sistemi programlamak aynı şey değil.</strong></p><p>Peki <strong>hesaplamak zekâ değil diyorsak, öğrenmek ne olacak?</strong></p><p>AlphaGo tam da bunu görünür hale getirdi. Genelde insanlar yapay zekâ sanki ilk burada ortaya çıktı gibi düşündü. Çünkü insanlar uzunca yıllar makinelerin sadece hesaplayabileceğini kabul etti. Zor kabul edilen şey ise bu makinelerin bizim tek tek öğretmediğimiz iyi fikirler bulabileceğiydi. Yani ona verilenler ve öğrendikleri arasında yeni bir bağlantı kurabilmesi.</p><p>Burada “yoktan yeni bir bilgi yaratıyor” demiyorum elbette. İnsan da yoktan bir şey yaratmıyor. Yeni olan şey, sistemin kendisine tek tek verilmemiş bir ilişkiyi veya çözümü kurabilmesi.</p><p>AlphaGo’nun Lee Sedol karşısındaki meşhur 37. hamlesi bunun güzel bir sembolü. İnsan yorumcuların bir kısmı ilk anda hamleyi hata olarak değerlendirdi. Sonra hamlenin olağanüstü olduğu ortaya çıktı.</p><p>Burada önemli bir ayrıntı var: AlphaGo başlangıçta insan uzmanların oyunlarından öğrenmiş, daha sonra kendi kendisiyle oynayarak pekiştirmeli öğrenmeyle gelişmişti. Dolayısıyla AlphaGo için “insan oyunlarını hiç görmedi” diyemeyiz. Ama insan oyunlarını birebir taklit etmekle sınırlı kalmadığını söyleyebiliriz.</p><p>Sonra AlphaZero geldi. Bu defa insan oyuncuların geçmiş oyunlarını eğitim verisi olarak kullanmadan, oyunun temel kurallarıyla başlayıp kendisiyle oynayarak satranç, Shogi ve Go öğrenen bir sistem vardı.</p><p>Bu önemli, çünkü <strong>“İnsanın yaptığı hamleleri ezberliyor.”</strong> itirazını daha da zayıflatıyor.</p><p>Ama yine aynı şeyi söylüyorum: AlphaZero da yoktan bir şey yaratmıyor. Kurallar var, hedef var, öğrenme sistemi var, donanım var, insanlığın geliştirdiği bütün teknik altyapı var. Sadece stratejiler tek tek programcı tarafından yazılmıyor.</p><p>Yani tekrar aynı ayrım karşımıza çıkıyor:</p><p><strong>Davranışı programlamak ile davranışı üretebilecek sistemi programlamak aynı şey değil.</strong></p><p>Şimdi ise LLM’ler için benzer bir şey söyleniyor:</p><p><strong>“Sadece next-token prediction.”</strong></p><p>Yani bir sonraki tokenı tahmin eden, daha karmaşık haldeki örüntüleri istatistiksel olarak bir araya getiren bir sistem olduğu söyleniyor. Transformer mimarisinin içini açıp baktığınızda yüksek boyutlu matematiksel işlemler, olasılıklar, ağırlıklar görüyorsunuz ama baktığınızda herhangi bir “zekâ” göremiyorsunuz.</p><p>Satranç motorunda dışarı çıkan şey bir hamleyken, LLM’de bir sonraki token çıkıyor. Ama çıktının biçimi, onu üreten kapasitenin tamamını açıklıyor mu?</p><p>Üstelik <strong>next-token prediction modelin eğitim hedefini söylüyor.</strong> Modelin bu tahmini yapabilmek için içeride hangi temsilleri kurduğunu, hangi ilişkileri öğrendiğini ve bunları nasıl örgütlediğini tek başına açıklamıyor.</p><p>Bunun kontrollü örnekleri de var. Örneğin Othello hamle dizilerinde bir sonraki hamleyi tahmin etmek üzere eğitilmiş GPT benzeri modeller üzerinde yapılan çalışmalar, sistemin yalnızca hamle dizilerinin yüzeysel istatistiklerini tutmadığına; oyunun mevcut tahta durumuna ilişkin içsel temsiller geliştirdiğine dair deneysel kanıtlar buldu. Üstelik bu temsillerin modelin tahmin davranışıyla nedensel olarak ilişkili olduğuna dair sonuçlar da var.</p><p>Bu, <strong>“LLM dünyayı insan gibi anlıyor.”</strong> demek değil. Ama <strong>“Bir sonraki tokenı tahmin ediyor, dolayısıyla içeride yalnızca kelime istatistiği var.”</strong> demek için de yeterli değil.</p><p>Bu bana kitabı yalnızca mürekkep ve kâğıt olarak görmek gibi geliyor.</p><p>Çünkü zekâ denilen kavram doğal olarak toplumsal ve bilişsel yetenekleriyle insan üzerinden ele alındı. İnsan zekâsını zekânın kendisiyle özdeşleştirdik. Oysa zekâ dediğimiz şey dijital ağlarda ve makinelerde insan zekâsıyla aynı biçimde ortaya çıkmak zorunda değil.</p><p>Ben bunu <strong>Dijital Zekâ</strong> olarak tanımlıyorum.</p><p>Ve bu tanım insan zekâsını doğrudan referans almamalı.</p><p>Örneğin kuş uçar, uçak da uçar ama uçak kuş gibi uçmaz. Bir şeyin uçması için kuş gibi kanat çırpması gerekmiyor. Uçmanın tek biçimi kuşların uçuş biçimi değil.</p><p>Zekâ için neden farklı düşünelim?</p><p>Daha netleştirmek gerekirse:</p><p><strong>İnsan zekâsı, zekânın biyolojik bir gerçekleşme biçimidir; mümkün olan tek gerçekleşme biçimi olmak zorunda değildir.</strong></p><p>Ve:</p><p><strong>Makinenin insan gibi düşünmemesi, onun başka türden bir zekâ geliştiremeyeceğini göstermez.</strong></p><p>Dijital sistemlerin insan zihnine benzememesi aslında büyük bir avantajdır. Ancak bu sayede yüksek hesaplama gücü, paralellik, daha geniş bellek, farklı veri türleri ve araçlarla aynı anda bağlantı kurabilme gibi olanaklarla gelişebilir.</p><p>Zekâ insana özgü, doğanın tepesine yerleştirilmiş özel bir cevher değildir. İnsanın zekâsını da doğa ve toplum birlikte biçimlendirir.</p><p>Bu yüzden insan beynini açtığınızda, nöronları tek tek alıp incelediğinizde “zekâ” göremezsiniz. Elektriksel, kimyasal, biyolojik süreçler görürsünüz.</p><p>Bir nörona baktığımızda insan zekâsını göremiyorsak, neden bir attention katmanına baktığımızda dijital zekâyı görmeyi bekliyoruz?</p><p>Burada insan beyniyle Transformer’ın aynı şey olduğunu söylemiyorum. Tam tersine bunlar birbirinden çok farklı maddi örgütlenmeler.</p><p>Söylediğim şey şu:</p><p><strong>Parçaların nasıl çalıştığını açıklamak, sistem düzeyinde ortaya çıkan kapasiteyi ortadan kaldırmaz.</strong></p><p>İnsan sadece beyniyle de düşünmüyor. Doğayla ilişkisiyle, bedeniyle, nefes alarak, hareket ederek, diliyle ve içinde bulunduğu toplumsal ilişkilerle düşünüyor. Zekâ ve bilinç yalnızca beyin büyüklüğüne veya nöron sayısına indirgenemez.</p><p>Zekâ ile zekâyı taşıyan maddi yapıyı birbirinden ayırmak gerekir.</p><p>Burada dijital zekâ diyerek makinenin dünyayı insan gibi yaşadığını da söylemiyorum. Makine bir elmanın tadını bizim gibi bilmiyor, açlık yaşamıyor, acı çekmiyor, insanın bedensel ve toplumsal deneyimine sahip değil.</p><p>Ama insan tipi deneyimin bulunmamasından, sistemin ilişkileri işleyemediği veya başka bir zekâ biçimi geliştiremeyeceği sonucu da çıkmıyor.</p><p><strong>Dijital zekâyı, insanlığın tarihsel ve toplumsal olarak ürettiği zekânın dijital sistemlerde nesnelleşerek etkin bir kapasiteye dönüşmüş biçimi olarak tanımlıyorum.</strong></p><p>Bugünkü yapay zekâ tartışmasındaki iki yaklaşımı da bu nedenle yeterli bulmuyorum. Bir tarafta AI sistemlerini insanüstü bir zekâya, kaçınılmaz AGI’ye veya süperzekâya doğru ilerleyen tek bir çizgi olarak okuyan anlatılar var. Diğer tarafta ise buna tepki olarak <strong>“Bu sadece hesaplama, burada zekâ yok.”</strong> deniliyor.</p><p>Ben iki yaklaşımı da reddediyorum. Bunun ortasında bir uzlaşma aradığım için değil. Sorunun başka türlü kurulması gerektiğini düşündüğüm için.</p><h3>“Nesnelleşmiş zekâ”?</h3><p>İnsan düşüncesi, zekâsı ve bilgisi zaten hiçbir zaman sadece insanın kafasında değildi. Bütün bu tarihsel ve toplumsal bilgi ve beceri; araçta, makinede, üretim yönteminde, kurumda, belgede, kodda, algoritmada, modelde insanın dışında maddi ve nesnel bir biçim kazanıyor.</p><p>Dijital üretken zekâ da bunun özel bir aşaması.</p><p>Ama burada toplumsal zekânın basit bir kopyasından söz etmiyorum. İnsanlığın tarihsel birikimi dijital sisteme malzemesini, araçlarını, hedeflerini ve başlangıç koşullarını veriyor. Sistem ise bunları kendi hesaplamalı örgütlenmesi içinde yeniden işleyebiliyor, daha önce tek tek verilmemiş ilişkiler ve çözümler üretebiliyor.</p><p>Burada sistemin hedefinin insan tarafından verilmiş olması da tek başına onun zekâsını geçersiz kılmıyor. Deep Blue’ya satrançta kazanma hedefini insan verdi. DQN’nin ödül yapısını insan kurdu. AlphaGo’ya oyunun kazanılması gerektiğini insan söyledi.</p><p>Ama hedefin dışarıdan verilmesiyle, o hedefe ulaşmak için izlenecek bütün yolların tek tek dışarıdan verilmesi aynı şey değil.</p><p>Bir sistemin kendi amaçlarını yaratması başka bir problem. Bu artık yalnızca zekâ değil, <strong>özerklik ve özne</strong> meselesine doğru gidiyor. Ve bu serinin ikinci bölümünün konusu da tam olarak bu olacak.</p><p>Yakın tarihsel hattı kabaca şöyle düşünebiliriz:</p><p><strong>Eski oyun botları → Pac-Man hayaletleri gibi basit ajanlar → Counter-Strike botları → uzman sistemler → satranç motorları → optimizasyon sistemleri → makine öğrenmesi → DQN → AlphaGo ve AlphaZero → LLM’ler → agent sistemleri.</strong></p><p>Bunların hepsinin aynı şey olduğunu söylemiyorum. Tam tersine, aralarındaki farklar bize dijital zekânın nasıl geliştiği konusunda bir şeyler söylüyor.</p><h3>Bir hesaplama makinesinden Dijital Zekâ’nın ayrımı nasıl yapılabilir?</h3><p>Zekâyı bir input ve output başarısına indirgediğimizde her fonksiyon, her hesap makinesi, hatta bir termostat bile zeki bir sisteme dönüşür.</p><p>Nörobilim insanı Türker Kılıç’ın <strong>“Bilgi işleyen tüm sistemler er-geç zekâ üretirler.”</strong> yaklaşımında da bence benzer bir sorun var.</p><p>Zekâyı yalnızca bilgi işleme faaliyetinin doğal sonucu haline getirdiğimizde, atomu enformasyona indirgeyen metafizik bağlantısalcılığın düştüğü probleme benzer bir yere düşüyoruz.</p><p>Bir termostat da bilgi işler. Sıcaklığı ölçer, bir hedef değerle karşılaştırır ve buna göre faaliyette bulunur. Bir if/else programı da durumlar arasında ayrım yapabilir.</p><p>O zaman ayrımı nerede kuracağız?</p><p>Burada bir sistemin programlanmış olması da tek başına bir ölçüt değil. AlphaGo da programdır, LLM de, oyun botu da.</p><p>Tekrar aynı meseleye geliyoruz:</p><p><strong>Bir davranışı programlamakla, davranışı üretebilecek sistemi programlamak aynı şey değildir.</strong></p><p>Dijital zekâ dediğim şeyin önemli özelliklerinden biri burada ortaya çıkıyor.</p><p>Eğer bir sistem durumlar arasında ayrım yapabiliyor, insanın kurduğu “ilişkinin” kendisini aynı biçimde kuramasa bile etkileşimsel olarak ilişkisel örüntüleri işleyebiliyor, bağlama göre farklı sonuçlar üretebiliyor, seçenekler arasında seçim yapabiliyor, hedef doğrultusunda davranışını yönlendirebiliyor ve önceden tek tek tarif edilmemiş yeni durumlara uyarlanabilme kapasitesi geliştirebiliyorsa burada basit bir input-output fonksiyonundan daha farklı bir şey vardır.</p><p>Yani kısacası:</p><p><strong>Bir dijital sistemin, önceden tek tek belirlenmemiş durumların ilişkisel ve etkileşimsel boyutlarını işleyebilmesi, alternatifler arasında bağlama ve hedefe göre seçim yapabilmesi ve faaliyetini yeni durumlara göre değiştirebilmesi bir Dijital Zekâ göstergesidir.</strong></p><p>Burada zekâyı bir aç-kapa düğmesi gibi düşünmek de doğru değil. Pac-Man’deki bir botla AlphaGo, bir LLM veya gelişmiş bir agent aynı düzeyde dijital zekâya sahip değildir. Bunların kapsamları, uyarlanabilirlikleri, ilişki kurabildikleri alanlar ve üretebildikleri davranışların çeşitliliği birbirinden farklıdır.</p><p>Bu yüzden dijital zekâ da dereceli olarak düşünülebilir.</p><p>Bir başka ayrım da önemli:</p><p><strong>Bilgi, öğrenme ve zekâ aynı şey değildir.</strong></p><p>Bir sistem çok fazla bilgiye sahip olabilir ama bu bilgiyle ne yapacağını bilemeyebilir. Bir satranç motoru dünyanın geri kalanı hakkında neredeyse hiçbir şey bilmeden satrançta çok yüksek bir kapasite gösterebilir. Bir sistem çalışırken sürekli öğrenmeden de daha önce öğrendiği ilişkileri kullanarak yeni durumlarda sonuç üretebilir.</p><p>O yüzden <strong>“Bu bilgiyi insandan aldı.”</strong> demek tek başına zekâ meselesini çözmez.</p><p>İnsan dilin kendisini nasıl icat etmiyor, doğduğunda o dili ediniyorsa; matematiği her seferinde yeniden icat etmek zorunda değilsek; kavramlarımızı tek başımıza üretmiyorsak; bilimi, tarihi ve toplumu yeniden başlatmıyor, zaten içine doğduğumuz bu ilişkiler içinde bunları hazır buluyorsak ve bunların içerisinde zekâ ve bilinç taşıyıcıları haline geliyorsak, yapay zekâya neden <strong>“AI başkalarının ürettiği bilgilerden öğreniyor, dolayısıyla zekâ değildir.”</strong> gibi bir sonuca bu kadar kolay ulaşıyoruz?</p><p>Burada insanla makineyi aynı şey haline getirmek veya ikisinin aynı biçimde öğrendiğini söylemek için bu örneği vermiyorum elbette.</p><p>İnsan toplumsal yaşamın içerisinde bedeniyle, ihtiyaçlarıyla, doğayla ve diğer insanlarla gerçek ilişkiler kurarak öğreniyor. Dijital sistem ise bu tarihsel ve toplumsal yaşamın dijital olarak nesnelleşmiş izlerini başka bir maddi örgütlenme içerisinde işliyor.</p><p>Ortaya çıkan şeyi tam da bu nedenle insan zekâsının kötü veya eksik bir taklidi olarak değil, <strong>başka bir zekâ biçimi olarak kavramsallaştırıyorum.</strong></p><p>Burada bilinçten de henüz bahsetmiyorum.</p><p>Bir sistemin zeki bir kapasite göstermesiyle kendi varlığının farkında olması, öznel bir deneyim yaşaması veya kendi amaçlarını oluşturması aynı şey değil. Bunlar başka sorular.</p><p>Bu yazıda sorduğum soru daha temel:</p><h3>İnsan gibi düşünmeyen bir sistem, neden başka bir biçimde zeki olamasın?</h3><h3>Dijital Zekâ — 2/3</h3><h3>Bir Yapay Zekâ Ne Zaman Kendi Başına Hareket Etmeye Başlar?</h3><p>Bir sonraki bölümde mesele zekânın var olup olmamasından, bu zekânın <strong>eyleme geçmesine</strong> kayacak.</p><p>Bir AI sadece cevap üretmek yerine araç kullanmaya, plan yapmaya, alt hedefler oluşturmaya, çevrede eylemde bulunmaya ve yaptığı eylemin sonucuna göre davranışını değiştirmeye başladığında ne değişiyor?</p><p>Bir agent ne zaman yalnızca araç olmaktan çıkıp belirli bir operasyonel özerklik kazanmaya başlıyor?</p><p>Ve daha zor soru:</p><p><strong>Özerklik ile özne olmak aynı şey mi?</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b1cd7d2684e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Makinenin İçinde Bilinç Aramak]]></title>
            <link>https://medium.com/@bazobehram/makinenin-i%CC%87%C3%A7inde-bilin%C3%A7-aramak-ea83abb3687a?source=rss-9b4c8c153c46------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea83abb3687a</guid>
            <category><![CDATA[makine-öğrenmesi]]></category>
            <category><![CDATA[yapay-zekâ-etiği]]></category>
            <category><![CDATA[yapayzekâ]]></category>
            <category><![CDATA[makine-bilinci]]></category>
            <category><![CDATA[felsefe]]></category>
            <dc:creator><![CDATA[Behram Bazo]]></dc:creator>
            <pubDate>Sat, 08 Aug 2026 10:55:46 GMT</pubDate>
            <atom:updated>2026-08-08T11:50:11.710Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oqoW_aVqNJPnrSizD-STEA.png" /></figure><h3>İnsanlığın kolektif olarak ürettiği dil, bilim ve kültür birkaç büyük yapay zekâ şirketinin elinde model eğitim malzemesine dönüştürüldü. Şimdi aynı şirketler bu modellerin derinliklerinde bağımsız bir bilinç arıyor.</h3><p>Geçenlerde Anthropic’in Claude’un nasıl “düşündüğünü” anlattığı videosunu ve AI Mevzuları’nın Google’ın bir araştırmasını ele aldığı videoyu izledim. İkisi farklı konulara değiniyor gibi görünse de yapay zekâ konusunda bugün yaşanan iki önemli eğilimi yan yana gösteriyor.</p><p>Anthropic tarafında modelin iç yapısı, katmanları, aktivasyonları ve temsil uzayları inceleniyor. Bunları araştırmak elbette önemli. Bir neural network’ün bilgiyi nasıl taşıdığını, hangi yapıların oluştuğunu anlamadan daha iyi modeller geliştirmek de zor. Yalnız teknik araştırmanın üzerine kurulan anlatı zaman zaman başka bir yere gidiyor. Modelin derinliklerinde henüz ulaşılamamış bir iç dünya, bir düşünce alanı, hatta bilinç benzeri bir şey aranıyor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bAC3bEFdwDdhLAdaVdclEQ.png" /></figure><p>Eskiden bilinç yalnız insan beyninin içine kapatılıp orada aranıyordu. Şimdi benzer bir arayış latent space’in içine taşınıyor.</p><p>AI Mevzuları’nın anlattığı Google araştırması ise işin başka bir tarafını gösteriyor. Modelin belirli temsil yönlerine müdahale edildiğinde bilinç, inanç, umut veya hayvan zihni gibi konulardaki görüşleri de değişebiliyor. Burada modelin gerçekten ne düşündüğü sorusu iyice bulanıklaşıyor. İlk verdiği cevap mı onun görüşü, alignment sonrası verdiği mi, sistem promptu değiştirildiğinde söylediği mi, yoksa vektör müdahalesinden sonra ortaya çıkan mı?</p><p>YZ modellerinin farklı görüşleri öğrenip bunların ortalamasına yakın sonuçlar üretmesi de bağımsız bir dünya görüşüne ulaştıkları anlamına gelmez. Çünkü bu ortalamanın kendisi tarafsız değil. İnsanlığın çok uzun bir tarihi olmasına rağmen yazılı kültürün, bilimin, felsefenin ve bugünkü kurumsallaşmış düşüncenin önemli bölümü sınıflı toplumların içinden gelişti. Egemen sınıflar yalnız üretim araçlarını değil, bilginin üretildiği ve yayıldığı kurumları da tarih boyunca biçimlendirdi.</p><p>Bugünkü modeller de bu tarihsel malzemenin içinden öğreniyor. Bunun üzerine alignment, safety ve preference training geliyor. Hangi cevabın güvenli, tehlikeli, aşırı veya kabul edilebilir olduğuna dair yeni müdahaleler yapılıyor. Modelin sürekli belirli bir merkeze çekilmesi bu nedenle onun bağımsız bir sonuca ulaştığını göstermeyebilir. Eğitim verisinin ve daha sonra modeli hizalayan kurumların oluşturduğu merkez yeniden üretiliyor olabilir.</p><p>Bilim de bütün bunların dışında değil. Kapitalist toplumda bilim sınıflar üstü bir boşlukta gelişmiyor. Hangi araştırmaya kaynak ayrılacağı, hangi teknolojinin geliştirileceği, hangi problemin önemli kabul edileceği toplumsal ve ekonomik ilişkilerden bağımsız değil. Buna rağmen bilinç ve zekâ söz konusu olduğunda bütün mesele yeniden beynin veya yapay sinir ağının içine sıkıştırılıyor.</p><p>Oysa insan yalnız beyniyle düşünmüyor. Bedeniyle, diliyle ve içinde yaşadığı toplumsal ilişkilerle düşünüyor. Sermaye, mülkiyet, devlet veya emek gibi kavramları beynin içindeki tek bir nörondan çıkarmak mümkün değil. Bunlar insanların birbirleriyle kurduğu tarihsel ilişkiler içinde oluşuyor ve insan zihni de bu ilişkilerin içinde gelişiyor.</p><p>Yapay zekâ modellerinde ilginç olan bir başka nokta da burada ortaya çıkıyor. İnsanlığın yüzlerce yıldır kolektif olarak ürettiği kitaplar, bilimsel çalışmalar, tartışmalar, kodlar, sanat, haberler, fikirler ve gündelik konuşmalar dev veri kümelerine çevrilerek model eğitiminde kullanılıyor. Ardından bütün bu toplumsal üretimin sonucunda ortaya çıkan model, onu oluşturan insan ilişkilerinden kopuk bağımsız bir özne gibi ele alınmaya başlanıyor.</p><p>Bunun meta fetişizmine benzeyen bir yanı var. İlişkiler görünmezleşiyor, ürün kendi gücüne sahipmiş gibi görünmeye başlıyor.</p><h3>Kelime üretmek başka, kavram üretmek başka</h3><p>Beni Devim tarafına götüren konulardan biri de kavram meselesiydi. Bugünkü güçlü bir LLM’ye “yeni bir kavram oluştur” denildiğinde birkaç saniye içinde onlarca isim, tanım ve alt kategori üretebilir. Fakat yeni bir kelime üretmekle yeni bir kavram oluşturmak aynı şey değil.</p><p>Kimsenin kullanmadığı yeni bir kelime üretilebilir. Altına oldukça ikna edici bir tanım da yazılabilir. Ama bu kelime hiçbir gerçek ilişkiyi ayırt etmiyorsa, başka kavramlarla bir bağı yoksa veya herhangi bir olguyu açıklamıyorsa bunun hangi anlamda kavram olduğu tartışmalıdır.</p><p>Örneğin sermaye yalnız “üretimde kullanılan para veya varlık” şeklinde bir sözlük tanımından oluşmuyor. Emekle, metayla, mülkiyetle, artı değerle ve üretim ilişkileriyle birlikte anlam kazanıyor. Bu ilişkiler çıkarıldığında kelime duruyor ama kavramın içeriği kayboluyor.</p><p>İlyenkov’u okurken kavramların bu ilişkisel yönü Devim açısından daha fazla ilgimi çekmeye başladı. Somutluk bir şey hakkında olabildiğince fazla ayrıntı bilmek değil; o şeyin hangi ilişkiler içinde oluştuğunu yeniden kurabilmek. Bir kavramı yalnızca bir etiket veya embedding noktası olarak değil, başka kavramlarla ilişkileri ve değişme koşulları içinde ele almak gerekiyor.</p><p>Bunun neural bir modelde gerçekten nasıl yapılabileceğinin hazır bir cevabı yok. Zaten araştırmanın kendisi burada başlıyor.</p><h3>Devim’de neyi deniyorum?</h3><p>Bu sorular beni Devim’de farklı bir model mimarisi denemeye götürdü. Burada ilgilendiğim şey, modelin kavramları yalnızca kelimeler ve istatistiksel ilişkiler olarak değil, birbirleriyle ilişkileri ve yeni kanıt karşısında değişimleri içinde ele alıp alamayacağı.</p><p>Örneğin model iki farklı açıklamayla karşılaştığında bunlardan birini hemen silmeden ikisini de taşıyabiliyor mu? Yeni kanıt geldiğinde görüşünün yalnız gerekli kısmını değiştirip hâlâ geçerli olan kısmını koruyabiliyor mu? Bir çelişkiyle karşılaştığında eksik veri mi var, kapsam mı değişmiş, yoksa farklı iki süreç mi birbirine karışmış diye ayırabiliyor mu? Kanıt yetersiz olduğunda çekimser kalabiliyor mu?</p><p>Daha önemlisi, bunları dışarıdan eklenen uzun bir reasoning promptu sayesinde değil, modelin kendi öğrenilmiş neural yapısı içinde yapabilir mi?</p><p>Devim sıfırdan Türkçe öğretilen bir model denemesi. Transformer mimarisini tamamen atmıyorum, ama yalnızca mevcut modele dışarıdan bir düşünme katmanı eklemek de istemiyorum. Kavramsal revizyon, rakip açıklamaları koruma, kanıt, kapsam ve çekimserlik gibi davranışların gerçekten model ağırlıklarında öğrenilip öğrenemeyeceğini araştırıyorum.</p><p>Burada da aynı mistifikasyon tehlikesi var. Bir deterministic sistem doğru sonucu verdi diye Devim öğrenmiş olmuyor. Loss düşmesi düşünmenin öğrenildiğini göstermiyor. Modelin istenen cümleyi söylemesi de aranan mekanizmanın neural yapıda oluştuğunu kanıtlamıyor. Yapay zekâ şirketlerinin modellerinde görmek istedikleri bilinci görmesi ne kadar sorunluysa, Devim’de görmek istediğim sonucu görmem de aynı biçimde yanıltıcı olabilir.</p><p>Bu nedenle felsefe burada hazır bir cevap değil. Daha çok hangi soruların araştırmaya değer olduğunu gösteriyor. Sonucu ise deney, modelin ham çıktıları ve gerçekten öğrenip öğrenmediğini gösteren testler belirlemeli.</p><h3>Makinenin içine bakarken dışarıyı kaybetmemek</h3><p>LLM’lerin yaptığı şeyi küçümsemeye gerek yok. İnsanlığın ürettiği devasa miktarda dil ve bilgiyi matematiksel bir yapıda işleyip buradan yeni metinler, kodlar ve açıklamalar üretebilen sistemler zaten başlı başına önemli bir teknolojik gelişme.</p><p>Bunun ilginç olması için modellerin içinde gizli bir ruh veya bilinç olduğunu varsaymaya gerek yok.</p><p>Belki yapay zekâyı anlamak için yalnız hangi aktivasyonun nerede ortaya çıktığına değil, hangi ilişkilerin öğrenildiğine, hangilerinin kaybolduğuna, hangi dünya görüşlerinin eğitim sırasında baskın hale geldiğine ve modelin yeni bilgi karşısında kavramlarını gerçekten değiştirip değiştiremediğine de bakmak gerekiyor.</p><p>Yapay zekâ şirketleri makinenin içine giderek daha derin bakıyor. Oraya bakmak gerekli. Ama yalnız oraya bakıldığında, makineyi ortaya çıkaran insanlık tarihini, kolektif emeği ve toplumsal ilişkileri gözden kaybetmek çok kolay.</p><p>İzlediğim videolar ve okuduğum kaynaklar:</p><p><a href="https://www.anthropic.com/research/global-workspace"><strong>A global workspace in language models</strong></a></p><p><a href="https://www.anthropic.com/research/global-workspace">A global workspace in language models</a></p><iframe src="https://drive.google.com/viewerng/viewer?url=https%3A//arxiv.org/pdf/1706.03762&amp;embedded=true" width="600" height="780" frameborder="0" scrolling="no"><a href="https://medium.com/media/1ba43c5c2c61b190f5ecd1e5f9ec8ec4/href">https://medium.com/media/1ba43c5c2c61b190f5ecd1e5f9ec8ec4/href</a></iframe><p><strong>Evald Vasilyeviç İlyenkov — Diyalektik Mantık</strong></p><p><strong>Anthropic — <em>The Different Levels of How Claude</em></strong><em> Thinks</em><a href="https://www.youtube.com/watch?v=rKV5JcALQoQ">https://www.youtube.com/watch?v=rKV5JcALQoQ</a></p><p><strong>AI Mevzuları — <em>Konuştuğunuz Yapay Zekanın Bilinci Kapatılmış Olabilir!</em><br></strong><a href="https://youtu.be/Lm5dJXh0m0c?si=stC95EcduIMizfFT">https://youtu.be/Lm5dJXh0m0c?si=stC95EcduIMizfFT</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea83abb3687a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Stopped Trusting git clone Blindly. So I Built an AI Firewall for My Terminal]]></title>
            <link>https://medium.com/@bazobehram/i-stopped-trusting-git-clone-blindly-so-i-built-an-ai-firewall-for-my-terminal-53d9e41890ad?source=rss-9b4c8c153c46------2</link>
            <guid isPermaLink="false">https://medium.com/p/53d9e41890ad</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Behram Bazo]]></dc:creator>
            <pubDate>Mon, 26 Jan 2026 18:27:14 GMT</pubDate>
            <atom:updated>2026-01-26T18:27:37.957Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*rcvVo6IYzpOTRdefFibSTg.png" /></figure><p>I have a confession: For years, I treated git clone like a harmless command.</p><p>I’d find a library, run the clone command, and hit Enter. In that split second, I bypassed every firewall, every vulnerability scanner, and every safety check in my CI/CD pipeline. I basically invited unknown code directly onto my machine.</p><p>Supply chain attacks aren’t just about vulnerable dependencies anymore. They are about typosquatting, compromised maintainer accounts, and hidden postinstall scripts that harvest your .env files the moment they touch your disk.</p><p>I realized my local environment was the weakest link. I didn’t want a scanner that tells me I’m infected <em>after</em> the fact. I wanted a bouncer. I wanted a firewall that checks the ID of the code <strong>before</strong> letting it in.</p><p>So, I built <strong>Vanguard</strong>. And today, I’m releasing <strong>V3 (Enterprise Edition)</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*U_77jFnhVttPlemf-ckGMA.png" /></figure><h3>The Concept: “Pre-Clone” Defense</h3><p>Most security tools are “reactive.” You download the code, install dependencies, and <em>then</em> scan it. By then, it might be too late.</p><p>Vanguard acts as a middleware for your Git client. When you run vanguard clone &lt;url&gt;, it:</p><ol><li><strong>Intercepts</strong> the request.</li><li><strong>Isolates</strong> the repo in a temporary memory sandbox (nothing touches your actual disk yet).</li><li><strong>Audits</strong> the code using <strong>Hybrid Intelligence</strong>.</li><li><strong>Blocks</strong> the clone if it detects malware, backdoors, or obfuscated scripts.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RBKJjLweSiUulhDQ4MvHrw.png" /></figure><h3>What’s New in V3: Privacy First (Local Intelligence)</h3><p>In earlier versions, I relied on cloud AI. It worked, but I know many of you (myself included) get nervous sending code to a third-party API.</p><p>V3 changes the game with <strong>Local Intelligence</strong>.</p><h3>1. 100% Privacy with Ollama 🦙</h3><p>This was the #1 request. You can now connect Vanguard to a local <strong>Ollama</strong> instance. Whether you prefer qwen2.5-coder, llama3, or deepseek, Vanguard can now audit code <strong>completely offline</strong>.</p><p>Your data never leaves your machine. It’s faster, private, and free.</p><h3>2. Hybrid Power (Gemini 2.0) 🧠</h3><p>Need a second opinion? You can toggle on <strong>Google Gemini 2.0 Flash</strong>. It’s incredibly good at understanding <em>intent</em>. It doesn’t just look for “suspicious words”; it analyzes if a script is trying to decode a base64 string and send it to a random IP address.</p><h3>3. “Invisible” Protection (vanguard integrate)</h3><p>I know I won’t remember to type vanguard clone every single time. So, I added a shell integration:</p><pre>vanguard integrate</pre><p>This hooks into your shell (Bash, Zsh, PowerShell). Now, even if you type standard git clone, Vanguard is watching in the background, ready to step in if things look sketchy.</p><h3>Putting it to the Test (The Demo)</h3><p>Does it actually work? To prove it, I created a dedicated <strong>“Malware Lab”</strong> repository (vanguard-malware-lab). It contains simulated threats like data exfiltration scripts and reverse shells.</p><p>Here is what happened when I tried to clone it:</p><pre>vanguard clone https://github.com/bazobehram/vanguard-malware-lab.git</pre><p><strong>Verdict:</strong> BLOCK 🛑</p><p><strong>Risk Score:</strong> 99/100</p><p>It instantly flagged the postinstall.js file for &quot;Spyware/Harvesting&quot; logic and blocked the download. My disk stayed clean.</p><h3>Open Source &amp; Ready</h3><p>I built Vanguard because developer security tools should be accessible, not locked behind enterprise sales calls.</p><p>Vanguard V3 is fully <strong>Open Source</strong> under the MIT License. I’m actively looking for contributors to help expand the <strong>Threat DB</strong> and improve our <strong>Ollama</strong> prompts.</p><h3>Try it out</h3><p>You can install it directly from NPM:</p><pre>npm install -g vanguard-cli</pre><p>👉 <strong>GitHub Repo:</strong> <a href="https://github.com/bazobehram/vanguard">github.com/bazobehram/vanguard</a></p><p>📦 <strong>NPM Package:</strong> <a href="https://www.npmjs.com/package/vanguard-cli">npmjs.com/package/vanguard-cli</a></p><p>🧪 <strong>Malware Lab (Test it yourself):</strong> <a href="https://github.com/bazobehram/vanguard-malware-lab">github.com/bazobehram/vanguard-malware-lab</a></p><p>Let me know what you think in the comments.</p><p>Happy (and safe) coding! 🛡️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=53d9e41890ad" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Transcendence DAO: A Web3 Decentralized Application Development Prototype on Solana Blockchain]]></title>
            <link>https://medium.com/@bazobehram/transcendence-dao-a-web3-decentralized-application-development-prototype-on-solana-blockchain-f30977c74c11?source=rss-9b4c8c153c46------2</link>
            <guid isPermaLink="false">https://medium.com/p/f30977c74c11</guid>
            <category><![CDATA[blockchain-development]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[anchor]]></category>
            <category><![CDATA[solanas]]></category>
            <category><![CDATA[rust-programming]]></category>
            <dc:creator><![CDATA[Behram Bazo]]></dc:creator>
            <pubDate>Tue, 15 Jul 2025 12:18:57 GMT</pubDate>
            <atom:updated>2025-07-15T13:05:01.567Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/768/0*qr-HYx3JIxPiKfdH.jpg" /></figure><p>To begin, let’s outline the purpose and plan of this article, and what experiences I’ll be sharing:</p><ol><li><strong>Developing a Web3 decentralized application on the Solana Blockchain network.</strong> Why do we need something like this? To create a censorship-resistant, free web environment. This could involve a new token economy, the sharing of real-life needs alongside digital ones, and a deeper exploration of these concepts.</li><li>What’s been changing in problem-solving, coding, and project development processes is that <strong>the rules of the game are being rewritten</strong>. Think vibe coding, AI agents, new languages, libraries, and renewed project development motivation.</li><li>I believe it’s crucial to <strong>move beyond the traditional programmer mindset</strong>. More than just a technical project engineer or architect, it’s important to consider data, artificial intelligence, and blockchain in the Web3 space where labor is redefined. This means aligning with productive social forces and striving to design creative projects based on these production and social relationships. For example, it requires structuring labor not merely as a means of livelihood, but as leverage for development and liberation. It’s about envisioning an applicable, testable prototype for a new economy that transitions to a new society and a new model of relationships. This could be a rehearsal for a new society. Society isn’t a mere model to be extracted from this prototype; we can attempt to simulate it. This won’t be limited to Blockchain socialism, anarchism, or traditional Marxist formulas, nor can it be confined to liberal capitalist utopianism. The project’s vision might sound utopian, but to escape our current dystopia, it’s vital to scientifically ground what seems utopian within society’s demands, needs, and inherent transformation. The inability to build a new world and the urgent need for it are critically important. As long as we base our dreams on a scientific and real foundation, these aspirations can transcend the ordinary and become a tool for unconventional and critical thinking.</li><li><strong>Token system:</strong> I’ve designed the project’s token system at this stage, and it’s open to contributions. Existing market tokens are typically used as products (commodities) and money, based on accumulation and exchange value. Many cryptocurrencies are plagued by severe inflation, boom-and-bust cycles, and speculation. This project’s token system focuses on <strong>anonymous user recognition, humans, animals, nature as a whole, and the relationships and meaning among them.</strong> This system establishes a dynamic resistance mechanism against the material and interest-based relationships of current capitalism and the exchange value derived from them. We’ll delve into this in more detail before diving into the project.</li></ol><p>So, let’s begin:</p><p>For me, this article is more than just an attempt to develop a systematic decentralized application on the Blockchain; it’s also <strong>a quest and purpose for a new world.</strong> We’re living in times where existing workflows are changing with vibe coding and AI agents. The fact that knowledge itself is becoming a productive force is why I’m sharing this prototype, which I’ve named <strong>Transcendence</strong>, as a concrete result and a new beginning. Forget the working methods of clouds, databases, and applications in the traditional web world. We don’t have to surrender our data to companies like OpenAI, Amazon Claude, Google Gemini, and other alternative open-source models just to use their applications.</p><p>Let’s list what we need when developing Web3 applications, as demonstrated in the prototype below:</p><ol><li>We need to <strong>learn the fundamentals of Blockchain</strong>. (I learned this from <a href="https://www.youtube.com/watch?v=_160oMzblY8">this video years ago</a>).</li><li>You need to <strong>decide from the beginning which network you’ll write the applications on</strong> — whether it’s Ethereum, Solana, Near Protocol, or something similar. I highly recommend trying to make this decision upfront. Simply knowing a programming language isn’t enough; if you’ll be using different Blockchain layers, I suggest learning the programming language suitable for that specific network, or even that particular framework.</li><li><strong>Learn programming languages specific to this field</strong> (Rust, Solidity, Move, Go, etc.) to develop on your chosen Blockchain network.</li></ol><p>I chose the <strong>Solana network</strong> to develop the Transcendence DAO prototype. My reasons for this choice are Solana’s remarkable speed compared to traditional networks like Ethereum, the very low transaction fees, its own playgrounds and libraries, and its excellent documentation, all of which make dApp development on this Blockchain platform highly practical. While it’s a good choice for this example, a much more advanced blockchain network could even be built from scratch in a general sense, provided there’s a strong community.</p><p>The Solana platform enables the development of <strong>memory-safe, high-performance, and secure smart contracts (programs) using the Rust programming language.</strong> The Anchor framework on Solana significantly simplifies the coding, building, and testing processes.</p><p>Solana has faced significant trust issues due to its association with the meme coin craze, where serious speculations and rug pulls have occurred. Applications on the network have also been used for fraudulent activities. Furthermore, while the network often handles high transaction volumes, the team sometimes has to perform a reset when the network jams. However, they’ve stated that they plan to transfer these interventions to the nodes over time, eliminating the need for such manual interventions.</p><h3>Our Project Structure</h3><p>Our project will follow this flow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*aSlkjfaHcLG8CiVWjZ4Z7g.png" /></figure><p><strong>User Action (Frontend) → Angular Component → Service → Blockchain → State Update → UI Refresh</strong></p><ol><li>User clicks “Create Activity”</li><li>Activities Component calls transcendenceDaoService.createActivity()</li><li>Service prepares blockchain transaction</li><li>Transaction sent to Solana via Phantom wallet</li><li>Blockchain processes transaction and updates state</li><li>Real-time subscriptions detect changes</li><li>Angular signals automatically update components</li><li>UI refreshes with new data</li></ol><h3>Installation of Technical Prerequisites</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QGc8vIKJ4iOlOX5lTeemvg.gif" /></figure><p>Since we’ll be building the prototype with a Solana program (smart contract) and Angular 20, the traditional backend and frontend relationship and behaviors won’t apply here. Instead, <strong>user verification (login) will be handled via users’ wallets.</strong> Individuals will anonymously verify their identity as users, and these wallets will serve as their authenticators.</p><p>In this example, we’ll be using the <strong>Phantom wallet</strong>. You can find the link here: <a href="https://chromewebstore.google.com/detail/phantom/bfnaelmomeimhlpmgjnjophhpkkoljpa">https://chromewebstore.google.com/detail/phantom/bfnaelmomeimhlpmgjnjophhpkkoljpa</a></p><p>Our system needs Node.js, followed by the installation of Angular CLI. For detailed information on Angular installation, those unfamiliar can refer to: <a href="https://angular.dev/installation">https://angular.dev/installation</a></p><p>If you want to quickly develop some applications on Solana and learn this ecosystem without dealing with extensive setup and losing motivation at the start, check out:</p><p><a href="https://beta.solpg.io/">https://beta.solpg.io/</a></p><p>This playground, and even some tutorials, will guide you through tasks and help you understand the logic of running, testing, building, and deploying applications.</p><p>For those who are just starting their learning journey, this is a great place to experiment. For those who prefer to set up on their local machine, I recommend the following:</p><p>If you’re using Windows, you should switch to <strong>WSL</strong> to run dependencies. You can download the <strong>Ubuntu app from the Microsoft Store</strong>. This will provide a comfortable environment for installing and using all the requirements of the Solana ecosystem.</p><pre>curl -proto &#39;=https&#39; -tlsv1.2 -sSfL https://solana-install.solana.workers.dev | bash</pre><p>After running this, ensure the following are correctly installed:</p><pre>Installed Versions:<br>Rust: rustc 1.86.0 (05f9846f8 2025-03-31)<br>Solana CLI: solana-cli 2.2.12 (src:0315eb6a; feat:1522022101, client:Agave)<br>Anchor CLI: anchor-cli 0.31.1<br>Node.js: v23.11.0<br>Yarn: 1.22.1</pre><p>Source: <a href="https://solana.com/docs/intro/installation">https://solana.com/docs/intro/installation</a></p><p>All necessary components, including Node.js, will be installed, preparing your environment for development. You can find answers to your questions and more detailed information in the Solana documentation.</p><p>If you prefer to set up your environment by watching a video, the link is here: <a href="https://youtu.be/4UfDM27nWkI?si=5a9n1XN4CUN1rHoD">https://youtu.be/4UfDM27nWkI?si=5a9n1XN4CUN1rHoD</a></p><p>If you’re unfamiliar with the <strong>Rust programming language</strong>, you can browse its documentation here: <a href="https://www.rust-lang.org/learn">https://www.rust-lang.org/learn</a>. You can also learn faster by using artificial intelligence help on this playground: <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2024">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2024</a></p><p>Now that our environment is ready for Web3 application development, the next step is to establish the project’s own token economy.</p><h3>Token System and Project Architecture</h3><p><strong>Transcendence DAO</strong> is a decentralized application that <strong>tokenizes social solidarity activities</strong>. These can include human aid, labor, nature and environmental protection, earthquake relief, the exercise of democratic rights, and more. Essentially, it tokenizes users’ social solidarity efforts not just in the digital realm, but also in the real world.</p><p><strong>Participation incentive:</strong> Participants receive <strong>solidarity tokens</strong> from the system for their solidarity activities. These tokens are <strong>not for material gain</strong> but serve to acknowledge contributions to the community’s philosophy of common good. The tokens are non-transferable and accumulated tokens do not grant special status. An individual’s voice is proportional to their contribution. A person stands out based on the quality and quantity of their labor and contribution to the community. Solidarity and assistance become visible as expressions of respect and trust within the collective memory of the helping community. What is created is <strong>meaning</strong>, not material power or assets. The algorithm prevents these tokenized contributions from being measured, compared to other contributions, or accumulated.</p><p>The value generated in return for a contribution can only be a <strong>symbolic, social, or even artistic representation</strong> that creates meaning exclusively within the Transcendence network.</p><ul><li>Tokens express <strong>existence, not ownership</strong>, and cannot be transformed into an object.</li><li>A token never carries value; it is <strong>only proof of a contribution</strong>. It’s a testament, not a reward.</li><li>Tokens are <strong>non-transferable</strong> and cannot be assigned to another person. They only provide visibility within the community and are uniquely tied to the individual.</li><li>Tokens are <strong>deleted from the system or archived after a certain period</strong>. There is a <strong>cycle, not accumulation</strong>.</li><li>The system absolutely <strong>does not include profit-generating mechanisms</strong> such as interest, farming, or staking. <strong>Contribution is paramount, not profit.</strong></li><li>The person helping <strong>never “expects” anything in return</strong>. Tokens offer a purpose. This purpose is valid for collective memory.</li></ul><p>Now, let’s create a prototype using a smart contract with Solana.</p><p>After discussing the theoretical framework and our ideals, we’ve now determined how our Token economy stands against accumulation and commodity fetishism, and how it focuses on creating meaning.</p><p>Let’s divide the system into two main parts:</p><ul><li><strong>Solana Smart Contract (Program):</strong> This is like the project’s immutable, decentralized, and transparent contract. We’ll design it as a digital brain that defines the new rules for social relationships and labor, which no one can unilaterally change. We’ll write it in <strong>Rust and the Anchor framework</strong>.</li><li><strong>Angular:</strong> This is the framework we’ll use to write the frontend, allowing users (the community) to interact with this decentralized brain. Here, Angular will function like a <strong>transparent window opening to the Blockchain</strong>, unlike Web2’s closed, data-collecting doors.</li></ul><h3>1. The Brain of the System: Solana Smart Contract (Rust &amp; Anchor)</h3><p>This code <em>is</em> Transcendence DAO itself. All economic and social rules are embedded onto the blockchain in an autonomous and censorship-resistant manner. This logic operates openly for everyone to see, not behind a company’s closed doors.</p><p>Thanks to <strong>vibe coding</strong>, it’s become possible to quickly learn the Rust programming language and write smart contracts rapidly on Solana. The programming in this article is, in fact, an example of this</p><pre>declare_id!(&quot;Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcKsg476zPFsLnS&quot;);</pre><pre>#[program]<br>pub mod smart_contracts {<br>    // Program logic here<br>}</pre><p>After writing our smart contract (program) with this immutable ID number, generated by typing solana-keygen new in the terminal, we must create a <strong>unique keypair</strong> for it before deploying it to the Solana network. Then, when we execute anchor deploy, the system will use this special key to sign our program and permanently record it on the blockchain at the exact address indicated by its public key.</p><p>To use this contract from the Angular side, you can install &quot;@solana/web3.js&quot; via npm install after building the program. You&#39;ll use the program ID provided during the build process to interact with the contract.</p><p>To utilize the contract, you’ll need the user to perform <strong>wallet verification</strong> and then allow them to participate in the program’s functionalities.</p><p>You can learn how to connect and disconnect a wallet, how to retrieve wallet-related information, and how to control the program on the <strong>Solana devnet</strong> (a network for developers to experiment). If you select developer mode in your Phantom Wallet settings via the terminal within the Solana ecosystem, it will provide you with a wallet token that operates on the devnet. With that wallet token, you can type solana airdrop followed by your token to receive test tokens in your wallet on the devnet. Alternatively, you can do this directly here: <a href="https://faucet.solana.com/">https://faucet.solana.com/</a></p><p>With the code below, we’re creating a <strong>state</strong>. Since we don’t have traditional backend database queries, the purpose of this state is to establish a structure where we can modify data within a state on a decentralized blockchain network. This isn’t like a standard CRUD operation; each record requires opening a transaction and wallet approval.</p><p>The InitializeDao struct below is the initial operation that brings your project&#39;s DAO to life.</p><pre>// Account structures<br>#[derive(Accounts)]<br>pub struct InitializeDao&lt;&#39;info&gt; {<br>    #[account(<br>        init,<br>        payer = authority,<br>        space = 8 + DaoState::INIT_SPACE,<br>        seeds = [b&quot;dao_state&quot;],<br>        bump<br>    )]<br>    pub dao_state: Account&lt;&#39;info, DaoState&gt;,<br>    #[account(mut)]<br>    pub authority: Signer&lt;&#39;info&gt;,<br>    pub system_program: Program&lt;&#39;info, System&gt;,<br>}</pre><p>This code snippet helps us define the necessary accounts for an instruction named InitializeDao in an Anchor program. Its primary goal is to <strong>securely initialize and activate the project&#39;s Decentralized Autonomous Organization (DAO)</strong>. The authorized user (authority) who invokes the transaction creates the dao_state, which serves as a central state account to store all the DAO&#39;s data. This account is created as a program-derived address (PDA), which guarantees that its ownership and control belong entirely to the smart contract, preventing external interference.</p><h3>Intermediate Summary:</h3><ul><li>The user communicates with the Solana blockchain through an interface built with <strong>Angular</strong>.</li><li>The user connects their wallet to the application via <strong>Phantom</strong> on the site.</li><li>When the user wishes to perform an action (e.g., vote on a proposal, request a need, or contribute to addressing a need), these actions are <strong>signed with their wallet</strong> and then sent to the Solana network.</li><li>The Solana network executes the relevant function in the transcendence-dao smart contract (as in the examples above), and these changes are <strong>permanently recorded on the blockchain</strong>.</li></ul><p>In the activity section, for instance, when you fill out a form to log a contribution related to an earthquake or environmental cleanup, your wallet automatically opens and prompts you to sign the transaction. If the community then verifies the accuracy of this activity, the system shares a solidarity token with you. This activity is then opened for community voting, as shown below.</p><h3>Step-by-Step Data Flow: How an Activity is Recorded</h3><p>To understand the program’s functionalities and operational logic, let’s delve into how the data flow works from the moment the user fills out the form and clicks the “<strong>Create Activity</strong>” button (as in the new activity creation example above) to initiate an activity in our project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZT09ai5HGHSc6pOAbyP5ZQ.png" /></figure><ul><li>The <strong>Target Address (</strong><strong>programId)</strong> specifies which smart contract this package will target. This is the address of our transcendence-dao program on the blockchain.</li><li><strong>Required Accounts (Accounts):</strong> This is a list specifying which “data containers” the instruction needs to access to run. Each line in your CreateProposal struct is added here:</li><li>dao_state: To read and update the general state of the DAO.</li><li>proposal: The address of the new account to be created.</li><li>proposer: Who signed the transaction (i.e., you).</li><li>system_program: Solana&#39;s native program required to create a new account.</li></ul><pre>#[derive(Accounts)]<br>pub struct CreateActivity&lt;&#39;info&gt; {<br>    #[account(<br>        init,<br>        payer = user,<br>        space = 8 + Activity::INIT_SPACE,<br>        seeds = [b&quot;activity&quot;, user.key().as_ref(), &amp;Clock::get()?.unix_timestamp.to_le_bytes()],<br>        bump<br>    )]<br>    pub activity: Account&lt;&#39;info, Activity&gt;,<br>    #[account(mut)]<br>    pub dao_state: Account&lt;&#39;info, DaoState&gt;,<br>    #[account(mut)]<br>    pub user: Signer&lt;&#39;info&gt;,<br>    pub system_program: Program&lt;&#39;info, System&gt;,<br>    pub clock: Sysvar&lt;&#39;info, Clock&gt;,<br>}</pre><ul><li><strong>Validation:</strong> The <strong>Validator</strong> checks the package’s signature. If the signature is valid, it proceeds.</li><li><strong>Execution of the Instruction (</strong><strong>create_proposal):</strong></li><li><strong>READ:</strong> The program first reads the data from the dao_state account. Why? Because it needs the current proposal_count value to determine the ID of the new proposal. Let&#39;s say the current value is 5. The new proposal&#39;s ID will be 5.</li><li><strong>NEW CREATION [account(init, …)]:</strong> This command comes into play here. The program, using Solana’s System Program, creates a brand new “proposal” account at the address calculated with seeds = [b”proposal”, 5]. The &quot;rent&quot; (the cost of occupying space on the blockchain) for this account is paid from your wallet, as specified by payer = proposer. This is analogous to creating a new file on a disk.</li><li><strong>WRITE:</strong> The data received from the package is then written into the newly created, empty proposal account:</li></ul><pre>pub fn create_proposal(<br>        ctx: Context&lt;CreateProposal&gt;,<br>        title: String,<br>        description: String,<br>        proposal_type: ProposalType,<br>    ) -&gt; Result&lt;()&gt; {<br>        let proposal = &amp;mut ctx.accounts.proposal;<br>        proposal.creator = ctx.accounts.user.key();<br>        proposal.title = title;<br>        proposal.description = description;<br>        proposal.proposal_type = proposal_type;<br>        proposal.votes_for = 0;<br>        proposal.votes_against = 0;<br>        proposal.status = ProposalStatus::Active;<br>        proposal.created_at = Clock::get()?.unix_timestamp;<br>        proposal.voting_deadline = Clock::get()?.unix_timestamp + (72 * 60 * 60); // 72 hours<br>        proposal.voters = vec![];<br>        proposal.bump = ctx.bumps.proposal;<br>        <br>        Ok(())<br>    }</pre><ul><li><strong>UPDATE:</strong> Finally, the program returns to the dao_state account and updates the proposal_count value from 5 to 6. This ensures the correct ID is used for the next proposal.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*w5-hadydfz5Mkb8wH9GwcA.png" /></figure><p>Once these steps are completed, our data becomes a permanent part of the Solana blockchain. Keep in mind that adapting to the decentralized network of the Web3 world isn’t always easy, especially if you’re accustomed to Web 2.0 habits. Remember that this domain is <strong>immutable, undeletable</strong> (can only be updated according to program rules), and <strong>verifiable by everyone</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/293/1*vRK-TPPAGOZVQuYqJMCQCA.png" /></figure><p>You can access the lib.rs file from the following GitHub repository.</p><h3>Voting and UBI System</h3><p>As you’ll see in lib.rs, the vote_on_proposal function isn&#39;t a simple &quot;one person, one vote&quot; system. We&#39;re enabling community members to vote using a much more sophisticated method called <strong>Quadratic Voting</strong>. We&#39;ve implemented this to prevent the concentration of voting power among large token holders (&quot;whales&quot;) and to achieve a more democratic outcome. Roughly speaking, for now, an individual&#39;s voting power is proportional to the square root of the amount of tokens they hold.</p><pre>pub fn vote_on_proposal(<br>        ctx: Context&lt;VoteOnProposal&gt;,<br>        vote: bool, // true for yes, false for no<br>        token_amount: u64,<br>    ) -&gt; Result&lt;()&gt; {<br>        let proposal = &amp;mut ctx.accounts.proposal;<br>        let voter = ctx.accounts.voter.key();<br>        <br>        require!(proposal.status == ProposalStatus::Active, ErrorCode::ProposalNotActive);<br>        require!(Clock::get()?.unix_timestamp &lt; proposal.voting_deadline, ErrorCode::VotingDeadlinePassed);<br>        require!(!proposal.voters.contains(&amp;voter), ErrorCode::AlreadyVoted);<br>        <br>        // Quadratic voting: vote weight = sqrt(token_amount)<br>        let vote_weight = (token_amount as f64).sqrt() as u64;<br>        <br>        if vote {<br>            proposal.votes_for = proposal.votes_for.checked_add(vote_weight).unwrap();<br>        } else {<br>            proposal.votes_against = proposal.votes_against.checked_add(vote_weight).unwrap();<br>        }<br>        <br>        proposal.voters.push(voter);<br>        <br>        Ok(())<br>    }</pre><p>With the distribute_ubi function, we&#39;ve fundamentally established a prototype for fair governance and an incentive mechanism through our <strong>Universal Basic Income (UBI)</strong> model.</p><pre>pub fn distribute_ubi(ctx: Context&lt;DistributeUbi&gt;) -&gt; Result&lt;()&gt; {<br>        let user_profile = &amp;mut ctx.accounts.user_profile;<br>        <br>        // Check if user is eligible (active in last week)<br>        let current_time = Clock::get()?.unix_timestamp;<br>        let week_ago = current_time - (7 * 24 * 60 * 60);<br>        <br>        require!(user_profile.last_activity &gt; week_ago, ErrorCode::UserNotActive);<br>        <br>        // Distribute UBI<br>        user_profile.tokens_earned = user_profile.tokens_earned.checked_add(UBI_DAILY_AMOUNT).unwrap();<br>        <br>        Ok(())<br>    }</pre><p>With the apply_token_decay function, when a user&#39;s token holdings exceed the average (median) level in the community, we begin to <strong>reduce a small portion of these excess tokens</strong>. Our goal, as previously stated, is to <strong>prevent token hoarding</strong>, keep the economy vibrant, and encourage a <strong>fairer distribution of tokens</strong>.</p><p>You can access the demo of the Web3 application via GitHub Pages here:<a href="https://bazobehram.github.io/solana-transcendence-dao-prototype/">https://bazobehram.github.io/solana-transcendence-dao-prototype/</a></p><p>And the GitHub repository:<a href="https://github.com/bazobehram/solana-transcendence-dao-prototype">https://github.com/bazobehram/solana-transcendence-dao-prototype</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f30977c74c11" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Breaking Free from Zone.js: Exploring Angular’s New Zoneless Era]]></title>
            <link>https://medium.com/@bazobehram/breaking-free-from-zone-js-exploring-angulars-new-zoneless-era-7446242e9f93?source=rss-9b4c8c153c46------2</link>
            <guid isPermaLink="false">https://medium.com/p/7446242e9f93</guid>
            <category><![CDATA[j-zone]]></category>
            <category><![CDATA[zoneless]]></category>
            <category><![CDATA[angular-zoneless]]></category>
            <category><![CDATA[angular-18-features]]></category>
            <category><![CDATA[breaking-free-zonejs]]></category>
            <dc:creator><![CDATA[Behram Bazo]]></dc:creator>
            <pubDate>Fri, 02 Aug 2024 09:42:49 GMT</pubDate>
            <atom:updated>2024-08-02T09:46:31.442Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Recently, </em><strong><em>Angular</em></strong><em> released an independent “ </em><strong><em>experiential” development feature called Zone.js.</em></strong><em> Although this feature is still in the experimental phase, the </em><strong><em>Angular</em></strong><em> team has been working on this important innovation for a long time. Reactive primitives are becoming more important for developers and it indicates that </em><strong><em>Angular</em></strong><em> is entering another new era. </em><strong><em>Angular</em></strong><em>’s ​​dependencies make the advantages of </em><strong><em>Signals</em></strong><em> and </em><strong><em>Rxjs more apparent, freeing it from the need to constantly listen to Zone.js-</em></strong><em>dependent changes and ending the situation of being an intermediary in the development process.</em></p><p><strong><em>Angular will continue to be a bold and powerful framework in the future as it begins a new transformation.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*bMtnV82jsXIaytei.png" /></figure><blockquote>First of all, none of my articles aim to teach anyone anything. I hope my readers do not find themselves worthy of such passivity. I try to share my experiences and learnings as much as I can and open them up for discussion. It is important to discuss together, exchange views with each other, and make evaluations based on critical thinking. It should not be forgotten that especially while the technologies that are the subject of this article are still being experienced by everyone, there is still some confusion about how exactly they work and I would like to state that even the change detection mechanism still creates some confusion within Angular’s core team.</blockquote><h3>What is Zone.js and what does it do?</h3><p><strong>Zone.js</strong> is known to have emerged as a small library for managing asynchronous work in <strong>JavaScript</strong> in 2010 by <strong>Brian Ford under the name of “ Zones</strong> ”. Inspired by languages ​​such as <strong>Erlang</strong> and <strong>Dart, it aims to bring structured concurrency to JavaScript’s</strong> single-threaded environment. It gains momentum when the <strong>Angular</strong> team adopts <strong>Zones</strong> for its change detection mechanism in <strong>Angular 2</strong>, and it begins to be contributed by <strong>the Angular</strong> team as <strong>Zone.js</strong>, providing wider community participation and further development. Today, although it is still tightly connected to <strong>Angular, Zone.js</strong> can be said to be considered a powerful tool for monitoring and intervening in asynchronous tasks, enabling performance profiling, error handling functions, as well as many problematic ones.</p><h3>So why is Angular giving up on Zone.js?</h3><p>By taking advantage of artificial intelligence’s ability to easily transform the images in our imagination into pictures, a visual was created using the “sponge under the bed” metaphor for easier understanding.</p><p>Imagine a bed like the one in the picture above, instead of being on the floor, it is resting on a large sponge. <strong>Zone.js</strong> acts like a sponge in <strong>Angular</strong> applications. This sponge ensures that the bed is on a comfortable, supportive base, while providing relative comfort for the sleeper. The sponge absorbs every movement of the bed, preventing the movements in the bed from being reflected outside.</p><p><strong>Monkey patches</strong> in <strong>Zone.js</strong> listen for all asynchronous APIs in the browser, such as: <strong>events, promises, observables, setTimeout, setInterval</strong>, etc.</p><p>By listening to these, all changes are detected in <strong>Angular</strong> applications and as a result, the user interface is updated, in fact, just like the sponge supports the bed, <strong>Zone.js</strong> also manages to make <strong>the Angular</strong> application work smoothly. In this case, performance problems that become apparent in very large projects that we do not feel may occur.</p><p>On the other hand, over time, this complex structure seems to prevent us from perceiving certain specific changes. Each previous feature and development, together with its own internal development and changing needs, suddenly becomes an obstacle to the next one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*za51PkSe91CoekUo" /></figure><p>When we pull the sponge out from under us, we see that natural freedom of movement begins to emerge, as the bed is in direct contact with the ground. The moment the restrictive effect that the sponge brings with its comfort begins to disappear, this means that the movement on the bed will now be directly reflected on the ground.</p><p>Such a metaphor may imply that the sponge offers a comfort zone and provides a relatively more comfortable sleep. <strong>Zone.js</strong> is like such a sponge; it offers a serious comfort zone and allows us to feel every change on the entire surface. However, over time, this complex structure may prevent us from perceiving some specific changes. When we pull the sponge out from under us, back pain may occur; these pains and aches indicate that we have descended from the artificial ground to a natural ground, and although the transition experience may be a little painful, in the end, as the waist straightens, a more comfortable sleep and better blood circulation can be achieved, as well as a healthier body and mental acuity. When we switch to the zoneless area, that is, the back and joint pains that occur as a result of sleeping on a bed without a sponge, are good signs that we have switched from the artificial ground to a natural ground. Although this transition experience is a little painful, as our waist starts to reshape towards its former natural state, the transition pains also disappear and provide better blood circulation; the transition example here corresponds to <strong>the experimental Zoneless</strong> we heard with <strong>Angular v18.</strong></p><p><strong>Zone.js</strong> is seen to add additional load because it follows asektron operations and transmits them to <strong>Angular detection mechanisms such as call</strong>, <strong>event</strong>, <strong>errors,</strong> etc. Today, we cannot see or even feel the additional load here in terms of <strong>Angular‘s performance. Zone.js</strong> can be developed further and some debugging problems can be solved, but the basic here is <strong>Angular</strong>‘s roadmap. We see that <strong>Angular’s</strong> own internally developed <strong>Signals reactive primitive Zone.js</strong> is now turning into a hindrance in Angular’s future plans. While there is a <strong>Signals</strong> structure that is quite useful in terms of detection mechanism and good in terms of performance, easy to use and powerful<strong>, Zone.js</strong> ceases to be necessary, but not as a library that can be dispensed with overnight.</p><p><strong>We understand that Angular</strong> does not want to limit its dreams, and wants to build a more flexible and reliable application with a more self-sufficient framework by eliminating intermediate processes as much as possible. We see <strong>Angular constantly moving towards a more practical state and trying to catch the chance to enter an upward trend again in the future. Unfortunately, we cannot say that it is in such a trend from the </strong><a href="https://stateofjs.com/en-US"><strong>StateofJS</strong></a> surveys at the moment, but we also see that <strong>Angular</strong> is open to all possible innovations.</p><h3>How do we switch to Zoneless mode in Angular 18?</h3><p><strong>Angular 18</strong> came with a step that will allow us to switch to <strong>zoneless</strong> mode and get rid of the sponge. As you can see below, we can now provide this experience with the zoneless change detection mechanism in the bootstrapping phase.</p><pre>bootstrapApplication(App, {<br>  providers: [<br>    provideExperimentalZonelessChangeDetection()<br>  ]<br>});</pre><p><strong>After the above function is added to providers, we can now remove the zone.js</strong> defined in <strong><em>the polyfills</em></strong> array below from angular.json with the npm uninstall zone.js command.</p><pre>&quot;polyfills&quot;: [&quot;zone.js] // &lt;- remove it</pre><p>Now we can use Angular Zoneless!</p><h3>What are the advantages of Zoneless?</h3><p>Zoneless provides us with a more streamlined ecosystem for our applications by eliminating unnecessary listening operations. This means faster rendering, increased performance, page loading speeds, lower bundle sizes, and easier debugging.</p><p>As a classic test method, for example, you added a counter by clicking a button and you want to increase this number as the button is clicked. In this case, we can see that the changing value is rendered when each function is triggered and this value changes in the HTML. Because it is already a function and we triggered it directly, here it is rendered. However, what happens if this value changes due to an external effect and we want to see that any value has changed without us triggering it manually? If Zone.js was there, it would constantly listen for all changes and notify Angular’s “change detection” mechanism on our behalf. However, since there is no such mechanism now, we either need to trigger the change detection mechanism after certain asynchronous operations or we need to use Signals or RxJS directly so that the changes are directly detected thanks to this reactivity.</p><p>The disappearance of Sponge shows us that it is not only <strong>Zone.js</strong> that is gone but also the “comfort zone”.</p><p>If we were to use <strong>Zone.js</strong> as a module with vanilla JavaScript, it would look like this.</p><pre>import &#39;zone.js&#39;;<br><br>// A new custom zone<br>const customZone = Zone.current.fork({<br>  name: &#39;customZone&#39;,<br>  onInvoke: function (<br>    parentZoneDelegate,<br>    currentZone,<br>    targetZone,<br>    delegate,<br>    applyThis,<br>    applyArgs,<br>    source<br>  ) {<br>    console.log(&#39;Entering custom zone: &#39; + targetZone.name);<br>    return parentZoneDelegate.invoke(<br>      targetZone,<br>      delegate,<br>      applyThis,<br>      applyArgs,<br>      source<br>    );<br>  },<br>  onHasTask: function (delegate, current, target, hasTaskState) {<br>    const allTasksComplete = !hasTaskState.microTask &amp;&amp; <br>                             !hasTaskState.macroTask &amp;&amp; <br>                             !hasTaskState.eventTask;<br>    <br>    if (allTasksComplete) {<br>      console.log(&#39;All tasks completed in zone: &#39; + target.name);<br>    }<br>  },<br>});<br><br>// Execute code within the custom zone<br>customZone.run(() =&gt; {<br>  console.log(&#39;Initiating task in customZone&#39;);<br>  setTimeout(() =&gt; {<br>    console.log(&#39;Delayed task executed in customZone&#39;);<br>  }, 1500);<br>});t</pre><p><strong>In Angular</strong>, we were not dealing with these situations; with <strong>ngZone</strong>, these operations were already working in conjunction with the detecting mechanism.</p><p>For example, in the cases of direct <strong>DOM, event listener</strong> , <strong>observables</strong> and <strong>promises</strong> , <strong>HTTP request</strong> and A <strong>synchronous Control Flow</strong>, we have to manually trigger the change detection mechanism for async operations.</p><pre>import { Component, OnInit, ChangeDetectorRef, inject } from &#39;@angular/core&#39;;<br>import { HttpClient } from &#39;@angular/common/http&#39;;<br><br>@Component({<br>  selector: &#39;app-async-operations&#39;,<br>  template: `<br>    &lt;div&gt;Data: {{ data }}&lt;/div&gt;<br>    &lt;div&gt;Count: {{ count }}&lt;/div&gt;<br>    &lt;div&gt;Result: {{ result }}&lt;/div&gt;<br>    &lt;button (click)=&quot;increment()&quot;&gt;Increment&lt;/button&gt;<br>  `<br>})<br>export class ExampleComponent implements OnInit {<br>  data: any;<br>  count = 0;<br>  result: string;<br>  cdr = inject(ChangeDetectorRef);<br>  cdr = inject(HttpClient);<br><br>  ngOnInit() {<br>    // Example for HTTP request<br>    this.http.get(&#39;https://example-api.com/data&#39;).subscribe(response =&gt; {<br>      this.data = response;<br>      this.cdr.markForCheck();<br>    });<br><br>    // Example for setInterval<br>    setInterval(() =&gt; {<br>      this.count += 1;<br>      this.cdr.markForCheck();<br>    }, 1000);<br><br>    // Example for Promise<br>    this.someAsyncOperation().then(response =&gt; {<br>      this.result = response;<br>      this.cdr.markForCheck();<br>    });<br>  }<br><br>  increment() {<br>    this.count += 1;<br>    this.cdr.markForCheck();<br>  }<br><br>  someAsyncOperation(): Promise&lt;string&gt; {<br>    return new Promise(resolve =&gt; {<br>      setTimeout(() =&gt; resolve(&#39;Completed&#39;), 2000);<br>    });<br>  }<br>}</pre><p><strong>Since Signals</strong> or R<strong>xjs</strong> automatically detect changes reactively, there is no need to trigger the change detection mechanism.</p><p><strong>Signals</strong> example:</p><pre>import { Component, OnInit, Signal, signal } from &#39;@angular/core&#39;;<br>import { HttpClient } from &#39;@angular/common/http&#39;;<br><br>@Component({<br>  selector: &#39;app-async-operations&#39;,<br>  template: `<br>    &lt;div&gt;Data: {{ data() }}&lt;/div&gt;<br>    &lt;div&gt;Count: {{ count() }}&lt;/div&gt;<br>    &lt;div&gt;Result: {{ result() }}&lt;/div&gt;<br>    &lt;button (click)=&quot;increment()&quot;&gt;Increment&lt;/button&gt;<br>  `<br>})<br>export class ExampleComponent implements OnInit {<br>  data: Signal&lt;any&gt; = signal(null);<br>  count: Signal&lt;number&gt; = signal(0);<br>  result: Signal&lt;string&gt; = signal(&#39;&#39;);<br>  private http: HttpClient;<br><br>  constructor(http: HttpClient) {<br>    this.http = http;<br>  }<br><br>  ngOnInit() {<br>    // Example for HTTP request<br>    this.http.get(&#39;https://example-api.com/data&#39;).subscribe(response =&gt; {<br>      this.data.set(response);<br>    });<br><br>    // Example for setInterval<br>    setInterval(() =&gt; {<br>      this.count.set(this.count() + 1);<br>    }, 1000);<br><br>    // Example for Promise<br>    this.someAsyncOperation().then(response =&gt; {<br>      this.result.set(response);<br>    });<br>  }<br><br>  increment() {<br>    this.count.set(this.count() + 1);<br>  }<br><br>  someAsyncOperation(): Promise&lt;string&gt; {<br>    return new Promise(resolve =&gt; {<br>      setTimeout(() =&gt; resolve(&#39;Completed&#39;), 2000);<br>    });<br>  }<br>}</pre><p>Now let’s write an application to test Zoneless and <strong>Angular‘s change detection mechanism and see how it works.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*wvPpw3flSdmoC67T.gif" /></figure><p>After starting the interval defined as standard above, we see that it starts working but <strong>the DOM</strong> is not refreshed and the changes are not reflected. When we start the <strong>Interval</strong> with <strong>Signals</strong>, we see that it works without the need to trigger <strong>Angular</strong>‘s change detection mechanism. It is seen that with the start of the click events and signals’ interval, <strong>Angular</strong> notices the change, instantly catches the change in our standard interval and then releases it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*-raBdc9PXG-Ath0E.gif" /></figure><p>When we send the value in a variable to the parent components, it is seen that it is perceived differently in both <strong>on-push</strong> and <strong>default cases.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*HNmo9YjC0VTkeqYJ.gif" /></figure><p>When we make a binding on the Input on the left, the changes are reflected when it is zoneless, and in the same way, it is seen that the change is reflected after a click as a result of a promise.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/0*aQ5WoKxD28z9TZFg.gif" /></figure><p>Here we see that after an HTTP call without using detect changes<strong>,</strong> the change is not reflected and it comes when we trigger it manually. Naturally, <strong>Signals</strong> easily reflects the newcomer to the desired screen. Some of the codes are as follows:</p><p><strong><em>app.component.ts</em></strong></p><pre> onInput(event: Event) {<br>    this.inputValue = (event.target as HTMLInputElement).value;<br>  }<br><br>  getPosts(): Observable&lt;Post[]&gt; {<br>    return this.http.get&lt;Post[]&gt;(this.apiUrl);<br>  }<br><br>  updateParentValue() {<br>    this.displayNumber++;<br>  }<br>  parentData = { value: 0 };<br><br>  updateParent() {<br>    this.parentData.value++;<br>  }<br><br>  updateChild() {<br>    // This will not trigger change detection in OnPush component<br>    this.parentData.value++;<br>  }<br><br>  startStandartInterval() {<br>    if (!this.standartIntervalId) {<br>      // Only start if not already running<br>      this.standartIntervalId = setInterval(() =&gt; {<br>        this.standartCount++;<br>      }, 1000);<br>    }<br>  }<br><br>  // Method to stop the interval<br>  stopStandartInterval() {<br>    if (this.standartIntervalId) {<br>      clearInterval(this.standartIntervalId);<br>      this.standartIntervalId = null; // Reset the intervalId after clearing it<br>    }<br>  }<br><br>  startSignalInterval() {<br>    if (!this.signalIntervalId) {<br>      // Only start if not already running<br>      this.signalIntervalId = setInterval(() =&gt; {<br>        this.signalCount.update((count) =&gt; count + 1);<br>      }, 1000);<br>    }<br>  }<br><br>  // Method to stop the interval<br>  stopSignalInterval() {<br>    if (this.signalIntervalId) {<br>      clearInterval(this.signalIntervalId);<br>      this.signalIntervalId = null; // Reset the intervalId after clearing it<br>    }<br>  }<br><br>  callWithoutChangeDetection(): void {<br>    this.getPosts().subscribe({<br>      next: (posts) =&gt; {<br>        console.log(posts), (this.posts = posts);<br>      },<br>      error: (error) =&gt; console.error(&#39;Error fetching posts:&#39;, error),<br>    });<br>  }<br><br>  callWithSignals(): void {<br>    this.getPosts().subscribe({<br>      next: (posts) =&gt; {<br>        console.log(posts), this.signalPosts.set(posts);<br>      },<br>      error: (error) =&gt; console.error(&#39;Error fetching posts:&#39;, error),<br>    });<br>  }<br><br>  changeDetectorRef(): void {<br>    this.detectChanges.update((value) =&gt; !value);<br>    this.cdr.detectChanges();<br>    setTimeout(() =&gt; {<br>      this.detectChanges.update((value) =&gt; !value);<br>    }, 2000);<br>  }<br><br>  runPromise() {<br>    Promise.resolve().then(() =&gt; {<br>      this.promiseResult = new Date().toISOString();<br>    });<br>  }</pre><p><strong><em>change-detection-demo.component.ts</em></strong></p><pre>ngOnInit() {<br>    this.updateSubject.subscribe((value) =&gt; {<br>      console.log(&#39;Observable updated:&#39;, value);<br>      this.observableValue = value;<br>      // No automatic change detection in zoneless mode<br>    });<br>  }<br><br>  runMicroVsMacro() {<br>    console.time(&#39;MicroVsMacro&#39;);<br><br>    Promise.resolve().then(() =&gt; {<br>      this.microtaskValue = &#39;Updated by microtask&#39;;<br>      console.log(&#39;Microtask executed&#39;);<br>      // Microtasks might trigger change detection automatically<br>    });<br><br>    setTimeout(() =&gt; {<br>      this.macrotaskValue = &#39;Updated by macrotask&#39;;<br>      console.log(&#39;Macrotask executed&#39;);<br>      this.cdr.detectChanges(); // Manual detection needed for macrotasks<br>      console.timeEnd(&#39;MicroVsMacro&#39;);<br>    }, 0);<br>  }<br><br>  updateManually() {<br>    this.manualValue = &#39;Updated manually: &#39; + new Date().toISOString();<br>    console.log(&#39;Manual update without detection&#39;);<br>    // No change detection, view won&#39;t update<br>  }<br><br>  updateManuallyWithDetection() {<br>    this.manualValue = &#39;Updated with detection: &#39; + new Date().toISOString();<br>    console.log(&#39;Manual update with detection&#39;);<br>    this.cdr.detectChanges(); // Manual detection<br>  }<br><br>  runAsyncOperations() {<br>    console.time(&#39;AsyncOperations&#39;);<br><br>    // Promise<br>    Promise.resolve().then(() =&gt; {<br>      this.promiseValue = &#39;Promise resolved&#39;;<br>      console.log(&#39;Promise resolved&#39;);<br>      // Promises might trigger change detection automatically<br>    });<br><br>    // Observable<br>    of(&#39;Observable emitted&#39;)<br>      .pipe(<br>        delay(100),<br>        tap(() =&gt; console.log(&#39;Observable emitted&#39;)),<br>      )<br>      .subscribe((value) =&gt; {<br>        this.updateSubject.next(value);<br>        this.cdr.detectChanges(); // Manual detection needed for observables<br>        console.timeEnd(&#39;AsyncOperations&#39;);<br>      });<br>  }<br><br>  updateChild() {<br>    this.parentValue = &#39;Updated Parent: &#39; + new Date().toISOString();<br>    console.log(&#39;Parent updated, child should reflect changes&#39;);<br>    this.cdr.detectChanges(); // Updates both parent and child<br>  }<br><br>  measurePerformance() {<br>    const start = performance.now();<br>    for (let i = 0; i &lt; 1000; i++) {<br>      this.cdr.detectChanges();<br>    }<br>    const end = performance.now();<br>    this.lastUpdateTime = `${end - start} ms for 1000 detections`;<br>    console.log(`Performance: ${this.lastUpdateTime}`);<br>    this.cdr.detectChanges(); // Update the view with the measurement<br>  }<br><br>  compareNgZone() {<br>    this.ngZone.run(() =&gt; {<br>      this.insideNgZoneValue = &#39;Inside NgZone: &#39; + new Date().toISOString();<br>      console.log(&#39;Inside NgZone update&#39;);<br>      // This might trigger change detection automatically<br>    });<br><br>    this.ngZone.runOutsideAngular(() =&gt; {<br>      this.outsideNgZoneValue = &#39;Outside NgZone: &#39; + new Date().toISOString();<br>      console.log(&#39;Outside NgZone update&#39;);<br>      this.cdr.detectChanges(); // Manual detection needed outside NgZone<br>    });<br>  }</pre><p>This application is published on <strong>Stacklibitz</strong>, you can take a look at the rest of the tests. You can also follow the results in the UI via the code.</p><p><strong>S</strong><a href="https://stackblitz.com/~/github.com/bazobehram/angular-zoneless-change-detection"><strong>tackblitz</strong></a><strong>: </strong><a href="https://stackblitz.com/~/github.com/bazobehram/angular-zoneless-change-detection">https://stackblitz.com/~/github.com/bazobehram/angular-zoneless-change-detection</a></p><p><strong>GitHub:</strong> <a href="https://github.com/bazobehram/angular-zoneless-change-detection">https://github.com/bazobehram/angular-zoneless-change-detection</a></p><p>There is also a sample application below showing how <strong>Angular</strong>‘s change detection mechanism works, you can also try it out from there.</p><p><a href="https://jeanmeche.github.io/angular-change-detection/">https://jeanmeche.github.io/angular-change-detection/?source=post_page-----9344079c3b9d</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*wki9pRJJkRRhSWLv.png" /><figcaption>Implementation for understanding Angular Change Detection — Mathieu Riegler</figcaption></figure><h3>Things to consider when switching to zoneless mode</h3><p><strong>It should be noted that ExperimentalZonelessChangeDetection</strong> is still in the experimental phase, as its name suggests.</p><p>While doing some tests, we noticed some oddities in the change detection mechanism. For example, when some changes are not triggered manually, we see that there is no change in the DOM and the state is not refreshed. However, when another signal or reactive variable works outside the change detection mechanism and causes the DOM to refresh, we can observe that the previous state that was not refreshed is also refreshed.</p><p>If you want to implement this feature in an existing project, all operations and application behaviors should be tested carefully. Especially third-party libraries may depend on Zone.js, which may cause some errors and rendering issues.</p><p><strong>Resources:</strong></p><p><strong><em>Articles:</em></strong></p><p>1:<a href="https://angular.dev/guide/experimental/zoneless">https://angular.dev/guide/experimental/zoneless</a><br>2: [<a href="https://medium.com/ngconf/deep-dive-into-zone-js-part-1-execution-context-92166bbb957">https://medium.com/ngconf/deep-dive-into-zone-js-part-1-execution-context-92166bbb957</a>]</p><p><a href="https://www.codingrequired.com/angular-zone-js-is-bad-d3ae48df98a7">3: https://www.codingrequired.com/angular-zone-js-is-bad-d3ae48df98a7</a></p><p>4: <a href="https://justangular.com/blog/a-new-era-for-angular-zoneless-change-detection">https://justangular.com/blog/a-new-era-for-angular-zoneless-change-detection</a></p><p>5:<a href="https://itnext.io/angular-18-zoneless-change-detection-381bfdcdd13e">https://itnext.io/angular-18-zoneless-change-detection-381bfdcdd13e</a></p><p><strong><em>Videos:</em></strong></p><p>1:<a href="https://www.youtube.com/watch?v=MZ6s5EL7hKk&amp;t=540s">https://www.youtube.com/watch?v=MZ6s5EL7hKk&amp;t=540s</a></p><p>2: <a href="https://www.youtube.com/watch?v=vHNeAqgNM4o&amp;t=">https://www.youtube.com/watch?v=vHNeAqgNM4o&amp;t</a></p><p>4: <a href="https://www.youtube.com/watch?v=Z9e6MPv4_PI&amp;t=">https://www.youtube.com/watch?v=Z9e6MPv4_PI&amp;t</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7446242e9f93" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Zone.js’den Kurtulmak: Angular’ın Zoneless Dönemine Bir Geçiş İncelemesi]]></title>
            <link>https://medium.com/@bazobehram/zone-jsden-kurtulmak-angular-%C4%B1n-zoneless-d%C3%B6nemine-bir-ge%C3%A7i%C5%9F-i%CC%87ncelemesi-6209bfad3ef3?source=rss-9b4c8c153c46------2</link>
            <guid isPermaLink="false">https://medium.com/p/6209bfad3ef3</guid>
            <category><![CDATA[zoneless]]></category>
            <category><![CDATA[change-detecting]]></category>
            <category><![CDATA[angular-18]]></category>
            <category><![CDATA[angular-zoneless]]></category>
            <category><![CDATA[zonejsden-kurtulmak]]></category>
            <dc:creator><![CDATA[Behram Bazo]]></dc:creator>
            <pubDate>Fri, 02 Aug 2024 09:24:30 GMT</pubDate>
            <atom:updated>2024-08-02T09:26:37.363Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Kısa bir süre önce </em><strong><em>Angular</em></strong><em>, </em><strong><em>Zone.js </em></strong><em>bağımsız bir “</em><strong><em>experiential</em></strong><em>” geliştirme özelliği yayınladı. Bu özellik henüz deneme aşamasında olsa da, </em><strong><em>Angular</em></strong><em> ekibi uzun zamandır bu önemli yenilikler üzerinde çalışıyor. Geliştiriciler için reaktif primitive’ler daha da önem kazanıyor ve </em><strong><em>Angular</em></strong><em> için başka bir yeni döneme girildiğini gösteriyor. </em><strong><em>Angular</em></strong><em>’ın bağımlılıkları, </em><strong><em>Signals</em></strong><em> ve </em><strong><em>Rxjs</em></strong><em>’in avantajlarını daha belirgin hale getirerek </em><strong><em>Zone.js</em></strong><em> bağımlı sürekli değişiklikleri dinleme zorunluluğundan kurtuluyor ve geliştirme sürecinde bir dolayım olma durumunu sonlandırıyor.</em></p><p><strong><em>Angular, yeni bir dönüşüm başlatırken gelecekte de cesur ve güçlü bir framework olmaya devam edecek.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aNC6Dukju10SDmkeelldXg.png" /></figure><blockquote>Öncelikli olarak, makalelerimin hiçbirinin amacı bir şeyleri birilerine öğretmek değil. Umuyorum ki okuyucularım da kendilerini böylesine bir edilgenliğe layık görmüyorlardır. Elimden geldiğince edindiğim deneyimlerimi ve öğrendiklerimi paylaşmaya ve bunları tartışmaya açıyorum. Birlikte tartışmak ve birbirimizle görüş alışverişi yapmak, eleştirel düşünme zemininde değerlendirmelerde bulunmak önemlidir. Unutulmamalıdır ki, özellikle bu makalenin konusu olan teknolojiler henüz herkes tarafından yeni deneyimlenirken, bunların tam olarak nasıl çalıştığı ile ilgili bazı kafa karışıklıklarının devam ettiği ve edeceğini, change detection mekanizmasında bile hala Angular’ın core ekibinin içinde daha bazı kafa karışıklıkları yarattığını gözlemlediğimi belirtmek istiyorum.</blockquote><h3><strong>Zone.js nedir, ne yapar?</strong></h3><p><strong>Zone.js</strong>, 2010 yıllarında <strong>Brian Ford</strong> tarafından “<strong>Zones</strong>” adıyla, <strong>JavaScript</strong>’te asenkron çalışmayı yönetmek amacıyla küçük bir kütüphane olarak ortaya çıktığı bilinir. <strong>Erlang</strong>, <strong>Dart</strong> gibi dillerden ilham alarak, <strong>JavaScript’</strong>in tek iş parçacıklı ortamına yapılandırılmış eşzamanlılık getirmeyi hedefliyor. <strong>Angular</strong> ekibi, <strong>Angular 2</strong>&#39;deki değişim algılama mekanizması için <strong>Zones</strong>’u benimsediğinde büyük bir ivme kazanıyor ve daha geniş bir topluluk katılımı ve daha fazla geliştirme sağlayarak <strong>Angular</strong> ekibi tarafından <strong>Zone.js</strong> olarak contrubute edilmeye başlıyor. Günümüzde, hala <strong>Angular</strong> ile sıkı bir şekilde bağlantılı olsa da <strong>Zone.js</strong>, bir çok sorunlu yanı sıra, performans profili çıkarma, hata işleme işlevlerini mümkün kılarak, asenkron görevleri izlemek ve bunlara müdahale etmek için güçlü bir araç olarak kabul edildiği söylenebilir.</p><h3>O halde, Angular’ın neden Zone.js’den vazgeçiyor?</h3><p>Yapay zekanın hayal gücümüzdeki imgeleri kolayca resimlere dönüştürme kabiliyetinden yararlanarak daha kolay anlaşılması açısından, kurduğumuz “yatak altı sünger” metaforu üzerinden bir görsellik oluşturuldu.</p><p>Hayal edin ki yukarıdaki resimde olduğu bir yatak, zeminde yer almak yerine, büyük bir sünger üzerinde duruyor olsun. İşte <strong>Angular</strong> uygulamalarında da <strong>Zone.js</strong> bir sünger gibi davranır. Bu sünger, yatağın konforlu, destekleyici bir zeminde durmasını sağlarken, üzerinde uyuyan için göreli bir rahatlık sağlar. Sünger, yatağın her hareketini emerek, yataktaki hareketlerin dışarı yansımasını önler.</p><p><strong>Zone.js</strong>’de ki <strong>monkey patches </strong>browser’daki tüm asynchronous API’leri dinler örneğin: <strong>events, promises, observables, setTimeout, setInterval</strong> vb.</p><p>Bunların dinlenmesi ile <strong>Angular</strong> uygulamalarında tüm değişiklikler algılanıp sonuç olarak kullanıcı arayüzünün güncellenmesi sağlanıyor, aslında tıpkı süngerin yatağı desteklediği gibi, <strong>Zone.js</strong>’de <strong>Angular</strong> uygulamasının sorunsuz çalışmasını bu sayede beceriyor. Bu durumda bizim hissetmediğimiz çok büyük projelerde belirginleşen bir performans problemleri oluşabiliyor.</p><p>Diğer yandan ise zamanla bu kompleks yapı, spesifik olan bazı değişiklikleri algılamamıza engel olmaya başladığı görülüyor. Her bir önceki özellikle ve gelişim, kendi iç gelişimi ve değişen ihtiyaçlarla birlikte biranda kendinden sonrakinin engeli haline geliveriyor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oc4emqz1JNBAezh4" /></figure><p>Süngeri altımızdan çekip çıkartığımızda, yatak doğrudan zeminle temas ettiği için doğal hareket özgürlüğünün ortaya çıkmaya başladığını görürüz. Süngerin konforla geldiği sınırlayıcı etki ortadan kalkmaya başladığı an, bu yatak üzerindeki hareketin doğrudan zemine artık yansıyayacağı anlamına gelir.</p><p>Böyle bir metafor bize, sünger’in konfor alanı sunduğunu ve göreli olarak daha rahat bir uyku sağladığını ima edebilir. <strong>Zone.js</strong> de böyle bir sünger gibidir; ciddi bir konfor alanı sunar ve tüm yüzeydeki her değişimi hissetmemizi sağlar. Ancak zamanla, bu kompleks yapı spesifik bazı değişiklikleri algılamamıza engel olabilir. Süngeri altımızdan çekip çıkarttığımızda, sırtta ağrılar oluşabilir; bu ağrı ve sancılar, suni zeminden doğal bir zemine inildiğini ifade eder ve geçiş deneyimi biraz sancılı olsa da, sonunda bel düzleştikçe daha rahat bir uyku ve daha iyi bir kan dolaşımı ile daha sağlıklı bir vücut ve zihinsel keskinlik elde edilebilir. Zoneless alana geçildiğinde, yani süngersiz bir yatakta uyumanın sonucu olarak ortaya çıkan bel ve eklem ağrıları, suni zeminden doğal bir zemine geçtiğimizin habercisi olan iyi belirtilerdir. Bu geçiş deneyimi biraz sancılı geçse de, sonuçta belimiz eski doğal durumuna doğru yeniden şekil almaya başladıkça, geçiş ağrıları da ortadan kalkar ve daha iyi bir kan dolaşımı sağlar; buradaki geçiş örneği, <strong>Angular v18</strong> ile duyduğumuz <strong>experimental Zoneless</strong>’a denk düşer.</p><p><strong>Zone.js</strong> asektron işlemleri takip edip <strong>call</strong>, <strong>event</strong>, <strong>errors</strong> vb. bunu <strong>Angular</strong> detection mekanimasına ilettiği için arada ek bir yük getirdiği görülüyor. Bugün <strong>Angular</strong>’ın performansı açısından biz buradaki ek yükü göremiyor hatta hissetmiyoruz. <strong>Zone.js</strong> daha da geliştirilebilir ve bazı hata ayıklama sorunları çözülebilir de, yalnız buradaki temel mesela <strong>Angular</strong>’ın yol haritası. <strong>Angular</strong> kendi bünyesinde geliştirdiği <strong>Signals</strong> reactive primitive’i Angular’ın çizdiği gelecek planlarında <strong>Zone.js</strong> artık ayak bağına dönüşmeye başladığını görüyoruz. Detect mekanizması açısından oldukça kullanışlı ve performans açısından iyi, kullanım açısından kolay ve güçlü bir <strong>Signals</strong> yapısı varken <strong>Zone.js</strong> gerekli olmaktan çıkıveriyor, yalnız bir gecede vazgeçilebilecek bir kütüphane olarak değil.</p><p><strong>Angular</strong>, hayallerine sınır koymak istemediği gibi, ara işlemleri olabildiğince ortadan kaldırarak, kendi kendine daha çok yeten bir framework ile daha esnek ve güven verici bir uygulama inşa etmek istediğini anlıyoruz. Sürekli daha pratik hale doğru geçen bir <strong>Angular</strong> görüyoruz ve ileriki dönemlerde yeniden yükseliş trendine girme şansını da yakalamaya çalışıyor. Şu an için <a href="https://stateofjs.com/en-US"><strong>StateofJS</strong></a> anketlerinden böyle bir eğilimde olduğunu maalesef söyleyemiyoruz, ancak buna karşın <strong>Angular</strong>’ın olabilecek tüm yeniliklere kendini açtığını da görüyoruz.</p><h3><strong>Angular 18&#39;de Zoneless moda nasıl geçeriz?</strong></h3><p><strong>Angular 18</strong> bizim <strong>zoneless</strong> moda geçmemizi süngerden kurtulmamızı sağlayacak bir adım ile geldi. Bu deneyimi yaşamamız için aşağıda gördüğünüz gibi bootstrapping aşamasında zoneless change detection mekanizması ile artık bunu sağlayabiliyoruz.</p><pre>bootstrapApplication(App, {<br>  providers: [<br>    provideExperimentalZonelessChangeDetection()<br>  ]<br>});</pre><p>Yukarıdaki fonksiyon artık providers’e eklendikten sonra artık npm unistall zone.js komutundan sonra da angular.json’dan aşağıdaki <strong><em>polyfills</em></strong> array içindeki tanımlı <strong>zone.js</strong>’i kaldırabiliriz.</p><pre>&quot;polyfills&quot;: [&quot;zone.js] // remove it</pre><p>Artık zoneless olarak Angular’ı kullanabiliriz!</p><h3><strong>Zoneless’ın avantajları nedir?</strong></h3><p>Zoneless gereksiz olan dinleme işlemlerinden kurtarak bize uygulamamız için daha düzgün bir ekosistem sunar. Bu hızlı bir render ile performans yükselmesi, sayfa yükleme hız artışları ve daha az bundle size ve kolay bir debug etme olanağı sağlaması anlamına geliyor.</p><p>Klasik bir deneme yöntemi olarak, örneğin bir düğmeye tıklayarak bir sayaç eklediniz ve bu sayıyı düğmeye tıkladıkça arttırmak istiyorsunuz. Bu durumda, her bir fonksiyon tetiklendiğinde değişen değerin render olduğunu ve HTML içerisinde de bu değerin değiştiğini görebiliriz. Çünkü zaten bir fonksiyon olduğu ve bunu biz doğrudan tetiklediğimiz için burada render oldu. Ancak bu değer dışarıdan bir etki ile değişirse ve herhangi bir değerin biz doğrudan manuel olarak tetiklemeden değiştiğini görmek istersek nasıl olacak? Eğer Zone.js olsaydı, bütün değişiklikleri sürekli dinliyor ve bunu bizim yerimize Angular’ın “change detection” mekanizmasına haber veriyordu. Ancak şimdi böyle bir mekanizma olmadığı için ya bizim belirli asenkron işlemlerden sonra change detection mekanizmasını tetiklememiz gerekiyor ya da doğrudan Signals veya RxJS kullanmamız gerekiyor ki değişiklikler bu reaktivite sayesinde doğrudan algılansın.</p><p>Sünger’in ortadan kalkması bize, artık ortadan kalkanın sadece <strong>Zone.js</strong>’in değil “confort zone” olduğunu da gösteriyor.</p><p>Eğer<strong> Zone.js</strong>’i vanilla javascript ile module olarak kullansaydık, şu şekilde olurdu.</p><pre>import &#39;zone.js&#39;;<br><br>// A new custom zone<br>const customZone = Zone.current.fork({<br>  name: &#39;customZone&#39;,<br>  onInvoke: function (<br>    parentZoneDelegate,<br>    currentZone,<br>    targetZone,<br>    delegate,<br>    applyThis,<br>    applyArgs,<br>    source<br>  ) {<br>    console.log(&#39;Entering custom zone: &#39; + targetZone.name);<br>    return parentZoneDelegate.invoke(<br>      targetZone,<br>      delegate,<br>      applyThis,<br>      applyArgs,<br>      source<br>    );<br>  },<br>  onHasTask: function (delegate, current, target, hasTaskState) {<br>    const allTasksComplete = !hasTaskState.microTask &amp;&amp; <br>                             !hasTaskState.macroTask &amp;&amp; <br>                             !hasTaskState.eventTask;<br>    <br>    if (allTasksComplete) {<br>      console.log(&#39;All tasks completed in zone: &#39; + target.name);<br>    }<br>  },<br>});<br><br>// Execute code within the custom zone<br>customZone.run(() =&gt; {<br>  console.log(&#39;Initiating task in customZone&#39;);<br>  setTimeout(() =&gt; {<br>    console.log(&#39;Delayed task executed in customZone&#39;);<br>  }, 1500);<br>});</pre><p><strong>Angular’</strong>da ise bu durumlarla uğraşmıyorduk, <strong>ngZone</strong> ile bu işlemler zaten detecting mekanizması ile bağlantılı çalışıyordu.</p><p>Örneğin direct <strong>DOM,</strong> <strong>event listener</strong>, <strong>observables</strong> and <strong>promises</strong>, <strong>http request</strong> ve A<strong>synchronous Control Flow</strong> durumlarında, async operations’lar için change detection mekanizmasını el ile manuel tetiklemek durumundayız.</p><pre>import { Component, OnInit, ChangeDetectorRef, inject } from &#39;@angular/core&#39;;<br>import { HttpClient } from &#39;@angular/common/http&#39;;<br><br>@Component({<br>  selector: &#39;app-async-operations&#39;,<br>  template: `<br>    &lt;div&gt;Data: {{ data }}&lt;/div&gt;<br>    &lt;div&gt;Count: {{ count }}&lt;/div&gt;<br>    &lt;div&gt;Result: {{ result }}&lt;/div&gt;<br>    &lt;button (click)=&quot;increment()&quot;&gt;Increment&lt;/button&gt;<br>  `<br>})<br>export class ExampleComponent implements OnInit {<br>  data: any;<br>  count = 0;<br>  result: string;<br>  cdr = inject(ChangeDetectorRef);<br>  cdr = inject(HttpClient);<br><br>  ngOnInit() {<br>    // Example for HTTP request<br>    this.http.get(&#39;https://example-api.com/data&#39;).subscribe(response =&gt; {<br>      this.data = response;<br>      this.cdr.markForCheck();<br>    });<br><br>    // Example for setInterval<br>    setInterval(() =&gt; {<br>      this.count += 1;<br>      this.cdr.markForCheck();<br>    }, 1000);<br><br>    // Example for Promise<br>    this.someAsyncOperation().then(response =&gt; {<br>      this.result = response;<br>      this.cdr.markForCheck();<br>    });<br>  }<br><br>  increment() {<br>    this.count += 1;<br>    this.cdr.markForCheck();<br>  }<br><br>  someAsyncOperation(): Promise&lt;string&gt; {<br>    return new Promise(resolve =&gt; {<br>      setTimeout(() =&gt; resolve(&#39;Completed&#39;), 2000);<br>    });<br>  }<br>}</pre><p><strong>Signals</strong> veya R<strong>xjs</strong> reactive olarak değişiklikleri otomatik algıladığı için, change detecting mekanızmasının tetiklenmesine ihtiyaç kalmaz.</p><p><strong>Signals</strong> örneği:</p><pre>import { Component, OnInit, Signal, signal } from &#39;@angular/core&#39;;<br>import { HttpClient } from &#39;@angular/common/http&#39;;<br><br>@Component({<br>  selector: &#39;app-async-operations&#39;,<br>  template: `<br>    &lt;div&gt;Data: {{ data() }}&lt;/div&gt;<br>    &lt;div&gt;Count: {{ count() }}&lt;/div&gt;<br>    &lt;div&gt;Result: {{ result() }}&lt;/div&gt;<br>    &lt;button (click)=&quot;increment()&quot;&gt;Increment&lt;/button&gt;<br>  `<br>})<br>export class ExampleComponent implements OnInit {<br>  data: Signal&lt;any&gt; = signal(null);<br>  count: Signal&lt;number&gt; = signal(0);<br>  result: Signal&lt;string&gt; = signal(&#39;&#39;);<br>  private http: HttpClient;<br><br>  constructor(http: HttpClient) {<br>    this.http = http;<br>  }<br><br>  ngOnInit() {<br>    // Example for HTTP request<br>    this.http.get(&#39;https://example-api.com/data&#39;).subscribe(response =&gt; {<br>      this.data.set(response);<br>    });<br><br>    // Example for setInterval<br>    setInterval(() =&gt; {<br>      this.count.set(this.count() + 1);<br>    }, 1000);<br><br>    // Example for Promise<br>    this.someAsyncOperation().then(response =&gt; {<br>      this.result.set(response);<br>    });<br>  }<br><br>  increment() {<br>    this.count.set(this.count() + 1);<br>  }<br><br>  someAsyncOperation(): Promise&lt;string&gt; {<br>    return new Promise(resolve =&gt; {<br>      setTimeout(() =&gt; resolve(&#39;Completed&#39;), 2000);<br>    });<br>  }<br>}</pre><p>Şimdi zoneless’ı ve <strong>Angular</strong>’ın change detection mekanizmasını test etmek için bir uygulama yazalım ve nasıl çalıştığına bir bakalım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*3idtKiWNWPxvBEb4g_a4DQ.gif" /></figure><p>Yukarıda standart olarak tanımlanmış interval’i başlattıktan sonra çalışmaya başladığını ama <strong>DOM</strong>’un yenilenmediğini ve değişikliklerin yansımadığını görüyoruz. <strong>Signals</strong> ile <strong>Interval</strong>’i başlattığımızda, <strong>Angular</strong>’ın change detection mekanizmasını tetiklemeye gerek kalmaksızın çalıştığını görüyoruz. Click event’tlarının ve signals’s interval’in başlaması ile <strong>Angular</strong>’ın değişikliği fark edip, standart olan intervalimizdeki değişikliği anlık olarak yakaladığını ve sonra geri bıraktığını görülüyor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*eC0pe9JjqXZsiEAYEw2HUw.gif" /></figure><p>Bir değişkendeki değeri, parent componentlara gönderdiğimizde, <strong>onpush</strong> ve <strong>default</strong> durumlarının ikisinde de değişik algılandığı görülüyor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*bv-V81XQuF9aInZ0gV35_w.gif" /></figure><p>Sol başta Input üzerinde binding yaptığımızda zoneless iken değişiklikler yansıyor aynı şekilde bir promises sonucu da click’den sonra değişikliğin yansıdığı görülüyor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*aqV3qqu98xqmoCcroIzpbQ.gif" /></figure><p>Burada <strong>detectChanges</strong> kullanılmadan yapılan bir http call işleminden sonra değişikliğin yansımadığını ve biz el ile trigger edince geldiğini görüyoruz. <strong>Signals</strong> doğallığında yeni gelen istediği ekrana kolayca yansıtıyor. Kodların bir kısmı aşağıdaki gibidir:</p><p><strong><em>app.component.ts</em></strong></p><pre> onInput(event: Event) {<br>    this.inputValue = (event.target as HTMLInputElement).value;<br>  }<br><br>  getPosts(): Observable&lt;Post[]&gt; {<br>    return this.http.get&lt;Post[]&gt;(this.apiUrl);<br>  }<br><br>  updateParentValue() {<br>    this.displayNumber++;<br>  }<br>  parentData = { value: 0 };<br><br>  updateParent() {<br>    this.parentData.value++;<br>  }<br><br>  updateChild() {<br>    // This will not trigger change detection in OnPush component<br>    this.parentData.value++;<br>  }<br><br>  startStandartInterval() {<br>    if (!this.standartIntervalId) {<br>      // Only start if not already running<br>      this.standartIntervalId = setInterval(() =&gt; {<br>        this.standartCount++;<br>      }, 1000);<br>    }<br>  }<br><br>  // Method to stop the interval<br>  stopStandartInterval() {<br>    if (this.standartIntervalId) {<br>      clearInterval(this.standartIntervalId);<br>      this.standartIntervalId = null; // Reset the intervalId after clearing it<br>    }<br>  }<br><br>  startSignalInterval() {<br>    if (!this.signalIntervalId) {<br>      // Only start if not already running<br>      this.signalIntervalId = setInterval(() =&gt; {<br>        this.signalCount.update((count) =&gt; count + 1);<br>      }, 1000);<br>    }<br>  }<br><br>  // Method to stop the interval<br>  stopSignalInterval() {<br>    if (this.signalIntervalId) {<br>      clearInterval(this.signalIntervalId);<br>      this.signalIntervalId = null; // Reset the intervalId after clearing it<br>    }<br>  }<br><br>  callWithoutChangeDetection(): void {<br>    this.getPosts().subscribe({<br>      next: (posts) =&gt; {<br>        console.log(posts), (this.posts = posts);<br>      },<br>      error: (error) =&gt; console.error(&#39;Error fetching posts:&#39;, error),<br>    });<br>  }<br><br>  callWithSignals(): void {<br>    this.getPosts().subscribe({<br>      next: (posts) =&gt; {<br>        console.log(posts), this.signalPosts.set(posts);<br>      },<br>      error: (error) =&gt; console.error(&#39;Error fetching posts:&#39;, error),<br>    });<br>  }<br><br>  changeDetectorRef(): void {<br>    this.detectChanges.update((value) =&gt; !value);<br>    this.cdr.detectChanges();<br>    setTimeout(() =&gt; {<br>      this.detectChanges.update((value) =&gt; !value);<br>    }, 2000);<br>  }<br><br>  runPromise() {<br>    Promise.resolve().then(() =&gt; {<br>      this.promiseResult = new Date().toISOString();<br>    });<br>  }<br><br><br><br></pre><p><strong><em>change-detection-demo.component.ts</em></strong></p><pre>ngOnInit() {<br>    this.updateSubject.subscribe((value) =&gt; {<br>      console.log(&#39;Observable updated:&#39;, value);<br>      this.observableValue = value;<br>      // No automatic change detection in zoneless mode<br>    });<br>  }<br><br>  runMicroVsMacro() {<br>    console.time(&#39;MicroVsMacro&#39;);<br><br>    Promise.resolve().then(() =&gt; {<br>      this.microtaskValue = &#39;Updated by microtask&#39;;<br>      console.log(&#39;Microtask executed&#39;);<br>      // Microtasks might trigger change detection automatically<br>    });<br><br>    setTimeout(() =&gt; {<br>      this.macrotaskValue = &#39;Updated by macrotask&#39;;<br>      console.log(&#39;Macrotask executed&#39;);<br>      this.cdr.detectChanges(); // Manual detection needed for macrotasks<br>      console.timeEnd(&#39;MicroVsMacro&#39;);<br>    }, 0);<br>  }<br><br>  updateManually() {<br>    this.manualValue = &#39;Updated manually: &#39; + new Date().toISOString();<br>    console.log(&#39;Manual update without detection&#39;);<br>    // No change detection, view won&#39;t update<br>  }<br><br>  updateManuallyWithDetection() {<br>    this.manualValue = &#39;Updated with detection: &#39; + new Date().toISOString();<br>    console.log(&#39;Manual update with detection&#39;);<br>    this.cdr.detectChanges(); // Manual detection<br>  }<br><br>  runAsyncOperations() {<br>    console.time(&#39;AsyncOperations&#39;);<br><br>    // Promise<br>    Promise.resolve().then(() =&gt; {<br>      this.promiseValue = &#39;Promise resolved&#39;;<br>      console.log(&#39;Promise resolved&#39;);<br>      // Promises might trigger change detection automatically<br>    });<br><br>    // Observable<br>    of(&#39;Observable emitted&#39;)<br>      .pipe(<br>        delay(100),<br>        tap(() =&gt; console.log(&#39;Observable emitted&#39;)),<br>      )<br>      .subscribe((value) =&gt; {<br>        this.updateSubject.next(value);<br>        this.cdr.detectChanges(); // Manual detection needed for observables<br>        console.timeEnd(&#39;AsyncOperations&#39;);<br>      });<br>  }<br><br>  updateChild() {<br>    this.parentValue = &#39;Updated Parent: &#39; + new Date().toISOString();<br>    console.log(&#39;Parent updated, child should reflect changes&#39;);<br>    this.cdr.detectChanges(); // Updates both parent and child<br>  }<br><br>  measurePerformance() {<br>    const start = performance.now();<br>    for (let i = 0; i &lt; 1000; i++) {<br>      this.cdr.detectChanges();<br>    }<br>    const end = performance.now();<br>    this.lastUpdateTime = `${end - start} ms for 1000 detections`;<br>    console.log(`Performance: ${this.lastUpdateTime}`);<br>    this.cdr.detectChanges(); // Update the view with the measurement<br>  }<br><br>  compareNgZone() {<br>    this.ngZone.run(() =&gt; {<br>      this.insideNgZoneValue = &#39;Inside NgZone: &#39; + new Date().toISOString();<br>      console.log(&#39;Inside NgZone update&#39;);<br>      // This might trigger change detection automatically<br>    });<br><br>    this.ngZone.runOutsideAngular(() =&gt; {<br>      this.outsideNgZoneValue = &#39;Outside NgZone: &#39; + new Date().toISOString();<br>      console.log(&#39;Outside NgZone update&#39;);<br>      this.cdr.detectChanges(); // Manual detection needed outside NgZone<br>    });<br>  }</pre><p>Bu uygulama <strong>stacklibitz</strong>’de yayınlandı, geri kalan testlere sizde bir göz atabilirsiniz. Ayrıca kullanıcı arayüzündeki sonuçları kod üzerinden de takip edebilirsiniz.</p><p><a href="https://stackblitz.com/~/github.com/bazobehram/angular-zoneless-change-detection"><strong>stackblitz</strong></a><strong>: </strong><a href="https://stackblitz.com/~/github.com/bazobehram/angular-zoneless-change-detection">https://stackblitz.com/~/github.com/bazobehram/angular-zoneless-change-detection</a></p><p><strong>github:</strong> <a href="https://github.com/bazobehram/angular-zoneless-change-detection">https://github.com/bazobehram/angular-zoneless-change-detection</a></p><p>Ayrıca <strong>Angular</strong>’ın change detection mekanimasının nasıl çalıştığına ilişkin altta bir örnek uygulama var, buradan da ayrıca denemeler yapabilirsiniz.</p><p><a href="https://jeanmeche.github.io/angular-change-detection/?source=post_page-----9344079c3b9d">https://jeanmeche.github.io/angular-change-detection/?source=post_page-----9344079c3b9d</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fo3PYSetSjHunctmd6HHdA.png" /><figcaption>Angular Change Detection Anlaşılması için uygulama — Mathieu Riegler</figcaption></figure><h4><strong>Zoneless moda geçildiğinde dikkat edilmesi gerekenler</strong></h4><p><strong>ExperimentalZonelessChangeDetection </strong>adı üstünde hala deneysel aşamada olduğu için dikkat edilmelidir.</p><p>Bazı testler yaparken, change detection mekanizmasında bazı gariplikler fark ediliyor. Örneğin, bazı değişiklikler manuel olarak change detection tetiklenmediğinde DOM üzerinde bir değişiklik olmadığını ve state’in yenilenmediğini görüyoruz. Ancak, başka bir signal veya reaktif değişken, change detection mekanizması dışında çalıştığında ve DOM’un yenilenmesini sağladığında, bir önceki yenilenmeyen state’in de yenilendiğini gözlemleyebiliyoruz.</p><p>Eğer bu özelliği mevcut projede devreye almak isterseniz, tüm operasyonlar ve uygulama davranışları dikkatle test edilmelidir. Özellikle üçüncü parti kütüphaneler Zone.js’e bağımlı olabilir ve bu durumda bazı hatalara ve render sorunlarına neden olabilir.</p><p><strong>Kaynaklar:</strong></p><p><strong><em>Makaleler:</em></strong></p><p>1:<a href="https://angular.dev/guide/experimental/zoneless">https://angular.dev/guide/experimental/zoneless</a><br>2: [<a href="https://medium.com/ngconf/deep-dive-into-zone-js-part-1-execution-context-92166bbb957">https://medium.com/ngconf/deep-dive-into-zone-js-part-1-execution-context-92166bbb957</a>]</p><p><a href="https://www.codingrequired.com/angular-zone-js-is-bad-d3ae48df98a7">3: https://www.codingrequired.com/angular-zone-js-is-bad-d3ae48df98a7</a></p><p>4: <a href="https://justangular.com/blog/a-new-era-for-angular-zoneless-change-detection">https://justangular.com/blog/a-new-era-for-angular-zoneless-change-detection</a></p><p>5:<a href="https://itnext.io/angular-18-zoneless-change-detection-381bfdcdd13e">https://itnext.io/angular-18-zoneless-change-detection-381bfdcdd13e</a></p><p><strong><em>Videolar:</em></strong></p><p>1:<a href="https://www.youtube.com/watch?v=MZ6s5EL7hKk&amp;t=540s">https://www.youtube.com/watch?v=MZ6s5EL7hKk&amp;t=540s</a></p><p>2: <a href="https://www.youtube.com/watch?v=vHNeAqgNM4o&amp;t">https://www.youtube.com/watch?v=vHNeAqgNM4o&amp;t</a></p><p>4: <a href="https://www.youtube.com/watch?v=Z9e6MPv4_PI&amp;t">https://www.youtube.com/watch?v=Z9e6MPv4_PI&amp;t</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6209bfad3ef3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular Güncellemesine Derin Dalış: Eski Projelerinizi En Son Sürüme Dönüştürmek İçin Bir Kaç…]]></title>
            <link>https://medium.com/@bazobehram/angular-g%C3%BCncellemesine-derin-dal%C4%B1%C5%9F-eski-projelerinizi-en-son-s%C3%BCr%C3%BCme-d%C3%B6n%C3%BC%C5%9Ft%C3%BCrmek-i%CC%87%C3%A7in-bir-ka%C3%A7-9ae17f6f3798?source=rss-9b4c8c153c46------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ae17f6f3798</guid>
            <category><![CDATA[kütüphane-güncelleme]]></category>
            <category><![CDATA[angular-update]]></category>
            <category><![CDATA[eski-projeleri-dönüştürme]]></category>
            <category><![CDATA[angular-güncelleme]]></category>
            <dc:creator><![CDATA[Behram Bazo]]></dc:creator>
            <pubDate>Sat, 06 Jul 2024 13:05:47 GMT</pubDate>
            <atom:updated>2024-07-06T13:05:47.302Z</atom:updated>
            <content:encoded><![CDATA[<h3>Angular Güncellemesine Derin Dalış: Eski Projelerinizi En Son Sürüme Dönüştürmek İçin Bir Kaç Taktik</h3><p><em>Angular projelerinizi en son sürüme güncellerken yaşanabilecek zorlukları ve bu süreci daha az stresli hale getirecek taktikleri bu makalede bulacaksınız. Eski projelerinizi modernleştirirken karşılaşabileceğiniz problemlere karşı hazırlıklı olmanızı ve adım adım nasıl ilerleyeceğinizi anlattım. Güncellemelerin avantajlarını ve risklerini değerlendirirken, projelerinizdeki bağımlılıkları nasıl yönetmeniz gerektiğini öğrenmelisiniz. Bu rehberle, Angular’ın en yeni özelliklerini projelerinize dahil ederken, dönüşüm süreci kolaylaşabilir.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jXFYzsXa3PrNxUCjAwt6zg.jpeg" /></figure><p>Karşınıza uzun bir süredir güncellenmeyen, ertelenmiş veya artık güncellenmesi korkutucu hale gelmiş <strong>Angular</strong> sürümleri çıkabilir. Halı altına süpürülmüş ve artık geliştirme yapmanın engeli haline gelen bu projelere genelde yazılımcılar girmek istemez. Çünkü bu tür projelerin dönüşümü genelde sancılı geçer. Hali hazırda bir takım belirsizlikler de taşıyorsa, kimse elini taşın altına koymak istemez. Projenin asıl geliştiricileri bundan sakınırken, böyle bir projede istemeseniz de rol almak zorunda kalabilirsiniz. Bu çok can sıkıcıdır ve bazı riskler barındırır. Bu sorunlardan dolayı projelerinden Angular yerine başka kütüphanelere geçmeyi düşünen hatta geçen bile olmuştur. Build problemlerinin çözülemez ve hataların nereden kaynaklandığı kestirilemez hala gelirse, bu durum artık bit için yorganı yakmaya kadar götürebilir.</p><p>Bu anlar da risk almaktan korkmamak gerekir; karşımızda kaybetmek zorunda olacağınız işiniz dahi olsa. Çünkü eski projeleri dönüştürme becerisi kazanmak mevcut işinizde kalmaktan daha değerli olabilir.</p><p>Güncellemeler genellikle iyidir, yeni özelliklere kavuşmanızı sağlar veya elinizdekini de götürebilir ama bu genellikle düşük bir ihtimaldir. Bir güncelleme bağımlısı olarak söylüyorum, kullandığım <strong>Ubuntu Linux</strong>’dan telefondaki uygulamalara kadar her şeyin güncelliğini otomatik güncelleme asistanından daha fazla takip ederim.</p><p>Gelişimin en son aşaması ve olanaklarından faydalanmak daima yeni kapılar açar ve bazı güvenlik risklerini kapatabilir. Tam tersine başımıza başka dertler açma ihtimali de yok değildir ama risksiz bir dünya yoktur. Bu sadece geliştirilmiş bir yazılımla ilgili bir şey değil.</p><h4>Kolları sıvayalım</h4><p>Angular&#39;da yenilikleri ve yeni versiyonları takip ediyorsanız ve projelerinizi <strong>Angular.dev</strong>&#39;deki <a href="https://angular.dev/update-guide/"><strong>Update Guide</strong></a> kısmından takip ederek yapıyorsanız, sizin için bir önceki sürümden yeni sürüme geçişler sorun yaşatmıyor olabilir; hatta risk de taşımıyor olabilir. Fakat üzerinde çalıştığınız projeler eskiyse ve dönüşüme girmesi gerekiyorsa, <strong>Angular</strong>&#39;ın son versiyonundaki birçok özelliği kullanamamakla birlikte, projeniz hangi sürümde kalmışsa, sadece programlama dili açısından bile hangi <strong>Typescript</strong>, <strong>Ecmascript</strong> sürümleri kullanılıyorsa onun modern yetenekleri ulaşmak gerekir. Diğer third-party kütüphaneleriniz için düştüğünüz durumu anlatmaya bile gerek yok. Debug yaparken veya development aşamasında uygun versiyona göre çözümler bakmak zorunda kalacak, daha zor ve daha az destekle bu işi yürütmek zorunda kalacağınız için birçok tatsız, motivasyon emici bir geliştirme sürecinin içinde kendinizi bulabilirsiniz.</p><p>Eski teknolojiler ile çalışmanın diğer problemli yanları ise performans, güvenlik ve uyumsuzluk problemleri ile boğuşmaktır. Düşünün ki <strong>Angular</strong> <strong>18 </strong>sürümü yayınlanmış ve build sisteminden tutun birçok breaking changes ile bir framework ortaya çıkmış; ama sizin çalıştığınız proje hala <strong>Angular</strong>’ın 7. versiyonunu kullanıyor. Bu noktadan sonra artık <strong>Angular</strong>’ı projenizde upgrade etmek istediğinizde, özellikle projeniz orta ve üst büyüklükte ise birçok zorlukla karşılaşmaya hazır olun.</p><p>İşte bu yüzden bu makale size, böyle bir dönüşüm görevinde, daha az stres ile <strong>Angular</strong> upgrade’nizi yapmanız için yardımcı olmak amacıyla yazıldı. Eski projelerin dönüşümünde yaşadığım zorluklarla tecrübe ettiğim bazı ince noktaları bu makalede ele alacağım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6UI11UydKv-KKifcODha-g.jpeg" /></figure><h3>Güncellemeye Başlamadan Önceki İlk Hazırlıklar</h3><h4>Bağımlılıkları İnceleyin</h4><p>Kullandığınız projedeki tüm bağımlılıkları inceleyin. Projeye özel kütüphaneler ve üçüncü taraf bağımlılıkları belirleyin. Public kütüphaneler dışındaki bağımlılıkları da gözden geçirmeniz gerekebilir. Örneğin, özel bir kütüphaneyi güncellemek için şu komutu kullanabilirsiniz:</p><pre>$ npm install --registry https://custom-registry.example.com/</pre><p>Eğer public kütüphaneler dışında da bağımlılıklarınız varsa, mevcut kütüphanelerinizi proje olarak indirip, güncellemesini yapacağınız projenize göre onu da güncellemeniz gerekir. Kütüphanenizle npm link &lt;library name&gt; sayesinde eşzamanlı local bir bağlantı kurarak, <strong>Angular</strong> güncellemeleri sırasında uyumsuzlukları takip edebilir ve aynı anda onu da güncelleyebilirsiniz.</p><p>npm config get registry komutu ile <strong>NPM</strong> yapılandırma dosyasında ayarlanmış olan mevcut kayıt (registry) <strong>URL&#39;</strong>sini görüntüleyebilirsiniz.</p><p>Örnek bir proje üzerinden <strong>Angular</strong> update’i nasıl yapacağımızı kurgulayalım:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular-9-material-mattable-crud-yzudn2%3Fembed%3D1%26file%3Dpackage.json%26view%3Deditor&amp;display_name=StackBlitz&amp;url=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular-9-material-mattable-crud-yzudn2%3Fembed%3D1%26file%3Dpackage.json%26view%3Deditor&amp;image=https%3A%2F%2Fsocial-img.staticblitz.com%2Fprojects%2Fangular-9-material-mattable-crud-yzudn2%2F613b42d84890b2f797a79c57924f9ee5&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=stackblitz" width="745" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/075c10b2a3380a47928cd77fa5e80791/href">https://medium.com/media/075c10b2a3380a47928cd77fa5e80791/href</a></iframe><p>İlk sorumuzun böyle bir projeyi hangi sürüme yükseltmeyi amaçlıyoruz ile başlaması önemli. Çünkü amaçladığımız sürüme güncelleyemeyebiliriz. Bu Angular’dan dolayı değil, projenin kullandığı dependencies’lerle ilgili olabilir. Siz projenizi <strong>Angular</strong>’ın en son sürümüne güncelleyebilirsiniz.</p><h4>İlk Sorununuz: Hangi Sürüme Yükseltmeyi Amaçlıyoruz?</h4><p>u soruya verdiğiniz cevap önemli çünkü projenizin güncellemesini etkileyen birçok faktör var. Hedeflediğiniz sürüme ulaşamamanız, kullandığınız kütüphanelere olan bağımlılığınızın derecesine bağlı olabilir. Bu durum, Angular’ın kendisinden ziyade projenizin bağımlı olduğu kütüphanelerden kaynaklanabilir. Elinizdeki kütüphanelerle uyumlu olduğunda, projenizi Angular’ın en son sürümüne güncelleyebilirsiniz.</p><h3>Adım Adım Güncelleme</h3><p>Adım adım güncelleme yapmak genellikle daha güvenlidir. Örneğin:</p><ul><li><strong>Angular</strong> 9&#39;dan <strong>Angular</strong> 10&#39;a geçiş</li><li><strong>Angular</strong> 10&#39;dan <strong>Angular</strong> 11&#39;e geçiş</li></ul><p>Bu şekilde devam ederek en son sürüme ulaşmak. Bu sırada kullandığınız ortam, ihtiyaçlar, breaking changes’lar bunları gözeterek hareket etmelisiniz. Çok tecrübeliyseniz ve aradaki geçişlerin ne olduğunu biliyorsanız ve elle kendiniz kaldırmayı göze alıyorsanız doğrudan <strong>Angular</strong> 9&#39;dan <strong>Angular 18&#39;</strong>e de geçirebilirsiniz ama burada aşağı yukarı nelerle karşılaşacağınızı bilmeniz ve hazırlıklı olmanız gerekir. Bu yüzden bu yöntem pek önerilmez. Ya da bazı araçlar kullanabilirsiniz, örneğin <strong>NX</strong>’in otomatik migrate aracını ve benzeri araçları kullanabilirsiniz. Link burada: <a href="https://nx.dev/features/automate-updating-dependencies">NX Otomatik Migrate Aracı</a></p><p>Siz <strong>Angular</strong> 18&#39;e geçiş yaptığınız zaman eğer ki third-party library’ler bunu desteklemiyorsa, çok ciddi sıkıntılar yaşarsınız. Kütüphanelerin alternatiflerini bulabilirseniz ve çok masraflı olmayacaksa bu değişimle en son sürüme geçebilirsiniz ama öyle bir şansınız yoksa ilgili paketin Angular’ın yeni sürümüne uygun güncelleme yapmasını beklemek zorunda kalabilirsiniz. Bu durumda ilgili kütüphanenin <strong>GitHub’</strong>da changelog’larına, açılan issue’lara bakabilirsiniz, community’de bunlar konuşuluyor olabilir. Geliştiricilerine destek mesajı atabilirsiniz ve birçok yol ve yöntem…</p><p>İlk adımda hangi sürüme geçeceğimizi belirledikten sonra artık sürüm geçişlerini yapmaya başlayabiliriz.</p><p>Angular’da böyle bir update guide öncesi ve sonrası nelerle karşılaşacağınızı, hangi <strong>Node</strong> sürümüne ihtiyacınız olduğundan tutun, hangi Typescript sürümüne ihtiyacınız var, kaldırılan bir şey var mı, breaking changes var mı ve birçok şeye her bir versiyon adımında dikkatlice takip etmelisiniz. Ama burada sadece bunu takip etmek yetmeyebilir, çünkü kullandığınız projenin genişliği ve kütüphaneler doğallığında işleri karıştırabilir. Bu durumda yapmanız gerekenler şunlar:</p><ul><li>İlk önce <a href="https://github.com/nvm-sh/nvm"><strong>bu linkten</strong></a> <strong>NVM</strong>’i yüklemeniz işinizi rahatlatır. Sürekli <strong>Nodejs</strong> sürümleri arasında değişiklik yapacaksınız, bu araç sizin versiyonlar arasında kolayca geçiş yapmanıza olanak tanır.</li><li><strong>NPM</strong> update ile güncelleme yapmadan önce, update yaptıktan sonra yüklenecek olan Angular versiyonu ile bağımlılıklar arasında çatışmanın sonuçlarını düşünün. Örneğin, @angular/cli@wantedversion @angular/core@wantedversion şeklinde yapmadan önce bu sürüme kafanızda geçmeye çalışın ve bu sürümden geriye doğru hayal edin. Yani geçtiğiniz sürümün nasıl bir ortam ve değişiklikleri olduğunu hayal eder ve daha ona geçmeden uygun ortamı sağlarsanız, geçişte sorun yaşamazsınız — forceda kullanmanıza gerek kalmaz.</li><li><strong>Angular</strong>’ın hangi <strong>Node</strong> versiyonları ile uyumlu olup olmadığını buradan takip edebilirsiniz: <a href="https://angular.dev/reference/versions">Angular Sürüm Uyum Tablosu</a></li></ul><p><strong>Angular</strong> otomatik olarak geçiş sırasında birçok değişikliği yapacaktır ama her şeyi değil. Bu sırada guide dokümantasyonunu iyi okumanız, hangi değişikliklerin olduğunu görmeniz size bir sonraki sürüme geçişte kolaylık sağlar.</p><pre>$ node -v // Bu komut ile sık sık node sürümünüzü kontrol etmeniz gerecek.<br>$ npm outdated // Bu komut, projedeki bağımlılıkların güncel olup olmadığını kontrol edecek.<br>  // Current: Yüklü sürüm, Wanted: İstenen sürüm, Latest: En son sürüm, Location: Bulunduğu konum.</pre><p>Yukarıdaki komutlar en temelinde bilmeniz gerekenler. Daha sonra geçiş sırasında en çok kontrol için kullanacağınız komutlar şunlar olabilir:</p><pre>$ npm view &lt;your-package-name&gt; versions  // Komutu, yazdığınız paketin NPM kayıtlarındaki mevcut tüm sürümlerini listeler.<br>$ npm info &lt;package-name&gt;  // Komutunu NPM&#39;deki bir paket hakkında detaylı bilgi almak için kullanılır.</pre><p>Yukarıdaki projedeki senaryoda olası karşılaşacağımız problemler şunlardır ve hesaplamalarımızı şu şekilde yapabiliriz:</p><p>Bu makalenin yazıldığı tarih itibari ile devextreme-angular yanılmıyorsam 24 sürümü <strong>Angular 18</strong>&#39;i desteklemiyor. Birçok geliştirici support&#39;a yazarak yeni bir sürümün çıkmasını bekliyor. Bundan dolayı projemizde bu kütüphane temel bir konumda ve vazgeçilemez halde ise biz bu projede en fazla Angular 17 sürümüne kadar geliştirme yapabiliriz. Bu durumda kademeli olarak örneğimizdeki @nebular/theme kütüphanesini Angular 17 sürümüne kadar kademeli olarak 5.1.0&#39;den 13.0.0&#39;a çekebiliriz.</p><p>Yine örnek projemizde bulunan: node-uuid, popper.js, request, har-validator kütüphaneleri update sırasında bize console&#39;da deprecated yani kullanımdan kaldırılmış olarak görünecek ve biz bu durumda bu kütüphanelerden kurtulmamız, alternatiflerini araştırmamız gerekiyor.</p><p>Eğer bir paketi doğrudan komut girerek kontrol etmek isterseniz:</p><pre>$ npm info har-validator</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qQ_-FDjmb93Tg3SY.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*QQyDEoEj_si22yleJX9GMQ.png" /></figure><p>Bu güncelleme geçişleri sırasında import &#39;zone.js/dist/zone&#39;; artık -&gt; import &#39;zone.js&#39; şeklinde olması gerekecek polyfills.ts içinde.</p><p>Güncelleme sırasında gözünüz terminalde ve build sırasında, hiçbir şeyi okumadan atlamayın, o o sonra sizin başınıza bela açabilir. Terminalde bu işlemleri yaparken birçok defa uyarılar alacaksınız, Angular’ı ayağa kaldırma sırasında (ng serve, npm start) veya build alma sırasında (ng build) Angular sizi yönlendirecek.</p><p>Yine terminal’de birçok defa sürümlerle ilgili, hata ve uyarılar konusunda terminal sizi uyaracak. Sorunları çözmeden başka sürümlere geçmenizi önerilmez eğer ki o sorun ancak diğer bir eşikte diğer paketlerin uyumluluğu ile çözülmeyecekse. Aşama aşama örneğin 9 ve 10 sürümlere yaklaşınca Ivy: true ya da false yapmanızı isteyecek, sonra bir süre sonra diğer sürümlerde artık bu stable haline gelince kaldırın artık gereksiz diyecek gibi bazı değişiklikleri manuel olarak da yapıyor olacaksınız. Güncelleme aldıkça Typescript&#39;e bakmanız, önemli olur. Arada compiler&#39;da bir şeyler patlayacak -&gt; skipLibCheck tsconfig&#39;e hayat kurtaracak, kimi yerde ecmascript sürümlerini değiştirmeniz gerekecek module ve lib&#39;den. sourceMapin true olması yararınıza olur, hata ayıklama süreçlerinde çok faydalı olur.</p><p>Her geçtiğiniz Nodejs sürümünde ilgili @Angular/Cli&#39;i Nodejs Genel&#39;den -G güncellemeyi unutmayın.</p><p>Arada trick dediğimiz garip şeyler olacak, her şeyden mantıksal sonuç beklemeyin bu programlama dahi olsa; çünkü bunlar hatalar üreten dinamik yapılar.</p><p>Örneğin Angular 15 CLI yüklü Nodejs Genel’de NodeJs 16 sürümünü kullanıyorsunuz. Terminal’de Nodejs sürümü 12. sürümü detect edildi diyebilir. Siz node -v yapsanız da anlam veremezsiniz. Bazen servisleri kapatmak, bazen birçok şey birbirine girdiğinde bilgisayarı bile kapatıp açmak sizi büyük zahmetlerden kurtarabilir. Çekinmeyin, aptalca problemlere basit çözümler gerekebilir.</p><p>Şunlar daima elinizin altında bir yerlerde olsun, bu tip durumlardan kurtulmak için:</p><pre>$ npm cache verify<br>$ npm cache clean --force<br>$ rm -rf node_modules<br>$ rm package-lock.json</pre><p>Garip durumları kontrol etmek için ayrıca:</p><pre>$ npm doctor  // Komutu NPM ortamınızın doğru şekilde çalışıp çalışmadığını kontrol eder ve potansiyel sorunlarını tespit edebilir.</pre><p>NPM install durumlarında --forcedan önce bununla çözmenizde fayda var:</p><pre>$ npm install — legacy-peer-deps</pre><p>Breaking changes ve uygulamanızdan kaldırmak zorunda olduğunuz deprecated paketler için çözüm bulmanız gerekiyor. Breaking changes’ler ve yeni gelen birçok özellik için terminalde build’i ve compile durumlarını takip ederken, asıl olarak yeniliklerin ne olduğunu ilgili <strong>Angular</strong> sürümlerini inceleyerek anlamak veya araştırma yaparak, yapay zeka kullanarak birçok yöntemle keşfedip düzenleyebilirsiniz.</p><p>Çıkan hataların gözünüzü korkutmasına izin vermeyin, Angular’ın güçlü bir hata yakalayıcı sistemi var, bazen hataları yakalamak zor olsa da genellikle yönlendirmeleri doğru oluyor.</p><p><strong>Angular’ın 17</strong>. versiyonuna geldiğinizde uygulamanızda application-builder kullanmayı unutmayın. Vite ile build süresi <strong>%70</strong>&#39;e kadar azalabilir. Bunun için:</p><pre>$ ng update @angular/cli --name use-application-builder</pre><p>Daha fazlası için -&gt; <a href="https://v17.angular.io/guide/esbuild">Vite ile Build Süresi</a></p><p>Angular 18&#39;de ise artık isterseniz zonelessChangeDetection kullanabilirsiniz:</p><pre>bootstrapApplication(App, {<br>  providers: [<br>    provideExperimentalZonelessChangeDetection()<br>  ]<br>});</pre><h3>Sonuç ve Gelecek Adımlar</h3><p><strong>Angular</strong> güncellemelerini başarıyla tamamladıktan sonra artık, projenizi daha ileriye taşıyacak diğer iyileştirmeleri düşünebilirsiniz. Örneğin, performans optimizasyonları yapabilir, kod kalitesini artırmak için linting ve testing araçlarını kullanabilirsiniz, artık bu kısımlar sizin ihtiyaçlarınıza göre… Ayrıca, projenizin sürekli entegrasyon ve dağıtım süreçlerini otomatikleştirerek geliştirme sürecinizi daha verimli hale getirmek mümkün. Bunlarla birlikte <strong>Angular</strong> Major versiyon geçişleri takip edildiğinde, Angular güncellemeleri kabus olmaktan çıkacaktır.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ae17f6f3798" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular İle Kelime Tahmin Modeli Kullanarak Kütüphane Geliştirme]]></title>
            <link>https://medium.com/@bazobehram/angular-i%CC%87le-kelime-tahmin-modeli-kullanarak-k%C3%BCt%C3%BCphane-geli%C5%9Ftirme-532bd05a6ea2?source=rss-9b4c8c153c46------2</link>
            <guid isPermaLink="false">https://medium.com/p/532bd05a6ea2</guid>
            <category><![CDATA[kütüphane-geliştirme]]></category>
            <category><![CDATA[sonraki-kelimeyi-tahmin]]></category>
            <category><![CDATA[makine-öğrenmesi]]></category>
            <category><![CDATA[tahmin-modeli]]></category>
            <category><![CDATA[yapay-zeka]]></category>
            <dc:creator><![CDATA[Behram Bazo]]></dc:creator>
            <pubDate>Sat, 06 Jul 2024 13:01:51 GMT</pubDate>
            <atom:updated>2024-07-09T07:56:34.804Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Bu makalenin iki temel amacı var. Birincisi, </em><strong><em>Angular</em></strong><em>’da kütüphane geliştirirken karşılaşılacak zorlukları ve kolaylıkları, sıfırdan </em><strong><em>NPM’</em></strong><em>de yayınlanmasına kadar olan süreci basit bir kütüphane örneği yaparak göstermektir. İkincisi ise, yapay zeka döneminde frontend geliştiricilerinin yapay zeka modellerini bu alanda nasıl uygulayabileceklerine dair bazı tartışmalar açmaktır. Bu bağlamda, aynı zamanda </em><strong><em>AI</em></strong><em> özellikli bir kütüphane yaparak küçük bir örnek üzerinden Frontend ve AI bileşimli geliştirme üzerine düşünmeyi ve tartışmayı amaçlamaktadır.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gTZFe7WPIHwGjUbvHcSoJg.jpeg" /></figure><h4>Neden Package Geliştirmek Gerekir?</h4><p><strong>Angular</strong>, büyük ölçekli uygulamaların geliştirilmesi için güçlü bir framework’tür. Ancak bazen kendi bileşenlerimizi, hizmetlerimizi veya diğer kod parçalarını yeniden kullanılabilir bir şekilde paketlemek isteyebiliriz. Bu, projelerimizin benzer standart ve <strong>UI’</strong>a sahip olmasını, tek bir paketle birçok projeyi güncel ve aynı özelliklerde tutmamızı sağlar. Ayrıca, aralarındaki ortak kütüphanelerin paylaşılmasını da mümkün kılar. Bu paket, kendi özel sunucumuzdan indirilebilen veya <strong>NPM registry</strong>’ye eklenmiş bir özel paket olabilir; tam tersi, herkesin kullanımına açık bir paket de olabilir.</p><p>Open source olarak sunulan bu paket, başka geliştiricilerin ihtiyaçlarını karşılamaya başladığı andan itibaren, onların geri bildirimleriyle daha da gelişir. Bu, paketin çok daha fazla yorum, eleştiri ve öneri ile buluşmasını sağlar. Bu süreç, kişinin başlangıçta hesaplamadığı birçok heyecan verici, yaratıcı ve kompleks işin ortaya çıkmasına sebep olabilir. Ancak, bu tamamen insan ihtiyaçları ve paketin ne kadar yararlılık içerdiği ile ilgilidir.</p><p>Açık kaynak dünyası paylaşımı önceler; yardım ettiğinden fazlasını yardım olarak alırsın. İşte tam bu noktada, Angular kütüphanesi bu süreci daha da kolaylaştırmak için devreye girer. Bu makalede, <strong>Angular</strong>’da bir kütüphane nasıl geliştirileceğini adım adım inceleyeceğiz.</p><p>Eğer hiç Angular package geliştirmediyseniz ve bunun zor olabileceğini düşünüp hiç denemediyseniz, ön yargılarınızın kurbanı olmuşsunuz denilebilir. <strong>Angular</strong>, kütüphane geliştirme süreçlerinde ciddi kolaylıklar sunan esnek bir frameworktür. Hadi başlayalım!</p><h4>Yeni bir <strong>Angular</strong> Projesi Oluşturulması</h4><pre>ng new next-word-prediction-app <br>cd my-library-project<br>ng library ng-next-word-prediction</pre><p>Eğer uygulama olmadan sadece kütüphaneyi yaratmak isterseniz -&gt;</p><p>--create-application=false komutun sonuna ekleyebilirsiniz.</p><pre>ng new next-word-prediction-app --create-application=false</pre><p>Benim tarafta proje yapısı aşağıdaki gibi görünüyor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*iC3uRZDenLiJCnkgTXqM8Q.png" /></figure><p>Projects klasörü altında ng-next-word-prediction adında bir klasörüm oluştu. src/lib altında ise component&#39;im yaratıldı. Aşağıdaki screenshot&#39;taki diğer directive ve services klasörlerini, yapacağımız kütüphane örneğinde gerekli diyerek el ile yarattım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*siJGxxeCIdGa_2SsnEly4Q.png" /></figure><p>Bu projemizin workspace’inde bulunan kütüphanemiz artık başka uygulamalar içinde kullanılabilir hale geldi. Bu package, eğer başka bir uygulamaya yüklenirse, ng-next-word-prediction.component.html ve ts dosyalarında ne varsa onlar gösterilir. Doğal olarak, şu an sadece &quot;<strong><em>word-prediction works!</em></strong>&quot; yazdığı için, bu paketi yükleyen kişiler sadece bunu görürler. Şimdi, senaryomuzda başka bir projeye bunu implement etmek ve burada bu kütüphaneyi geliştirirken görmek istediğimiz değişiklikleri doğrudan başka bir uygulama üzerinden takip etmek istediğimizi farz edelim.</p><pre>ng new an-another-project <br>cd an-another-project</pre><p>“<strong>an-another-project</strong>” isimli projemize “<strong>ng-next-word-prediction</strong>” paketimizi yükleyelim. Buna geçmeden önce, <strong>Angular</strong>’ın npm installolmadan doğrudan bu uygulamadaki başka bir klasörümüzdeki package’yi yüklemesi için ufak bir ayar yapmamız gerekiyor. “an-another-project” isimli uygulamamızın ana dizinindeki angular.json dosyasını açıyoruz ve aşağıdaki kısıma preserveSymlink: true olarak tanımlıyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*Otb9D13_9pyqGQzaZP4Arg.png" /></figure><p>Artık uygulamamız, npm link üzerinden tanımlanmış olan linkleri kullanarak package.json&#39;a bir paket ekleyebilecektir. Bunun için geri dönüp, &quot;next-word-prediction-app&quot; isimli uygulamamızı açıp, ana dizindeyken aşağıdaki komutu verirsek:</p><pre>ng build ng-next-word-prediction — watch</pre><p>Angular kütüphanemizin build’ini alıp, ayrıca her değişiklik durumunu takip ederek yeni bir build almak için hazırda bekliyor olacak. Her defasında paketi kullanıma hazır hale getirip, projemizin ana dizininde /dist yaratacak ve içerisine package&#39;yi ekleyecek.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/214/1*uetBXhCZ3IFfcElHPBDnDg.png" /></figure><p>/dist klasörünün içine, &quot;<em>ng-next-word-prediction</em>&quot; klasörünün içine girip terminale:</p><pre>npm link</pre><p>diye eklerseniz, bu link sizin <strong>Node.js</strong> genel sistemine paket olarak eklenmiş olacak.</p><pre>npm list -g </pre><p>komutu ile, bu paketi lokal olarak göründüğü şekilde görebilmelisiniz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*6jUHvzz2VjAdBqDaixHeSA.png" /></figure><p>Daha sonra geri &quot;an-another-project&quot; uygulamamızı açıp, ana dizininden:</p><pre>“npm link ng-next-word-prediction”</pre><p>dediğimizde, uygulamamız bu kütüphaneyi artık doğrudan projeye eklemiş olacak. Eğer package.json dosyanızda görmek isterseniz:</p><pre>npm link ng-next-word-prediction - save</pre><p>şeklinde ekleyebilirsiniz. Bu, diğer npm paket yüklemelerinden tek farkı, “install” yerine “link” kullanmış olmanızdır. package.json dosyasında aşağıdaki gibi görünecektir:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*QVGerqojMQ3y8Hx7K3gZWg.png" /></figure><p>Bu dakikadan sonra projemizde bu <strong>package’</strong>yi:</p><pre>import { NgNextWordPredictionComponent } from ‘ng-next-word-prediction’;</pre><p>bu şekilde import ederek istediğimiz yerde kullanabiliriz.</p><p>Yukarıda anlatılan işlemler sırasında, yükleme sonrasında “ng serve” yaptıysanız birçok defa hata almış olabilirsiniz. Böyle durumlarda portları öldürüp tekrar “ng serve” yapmak daha az yanıltıcı olur.</p><p>Şimdi herhangi bir açık kaynak yapay zeka modelini bilgisayarımıza indirip, bunu kütüphanemize nasıl entegre edebileceğimiz üzerine çalışmaya başlayalım. <a href="https://huggingface.co/allenai/t5-small-next-word-generator-qoogle">Hugging Face</a>’de bulduğumuz bir açık kaynak modeli, bilgisayarımıza indirip nasıl çalıştığını inceleyip kütüphanemize ekleyelim:</p><pre>git clone https://huggingface.co/allenai/t5-small-next-word-generator-qoogle</pre><p>Local’imde dosyalar şu şekilde görünüyor. “Readme” dosyasında nasıl çalıştığı gösteriliyor ama çok fazla detay yok. Bu projeyi çalıştırabilmek için bilgisayarınızda Python yüklü olması lazım. Aşağıdaki adımları izleyerek projenin çalışıp çalışmadığını görebilirsiniz:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*HkRjXySpvLQMJiqA_rvbgg.png" /></figure><ul><li><strong>Python Yüklenmesi:</strong> Bilgisayarınızda Python yüklü değilse, <a href="https://www.python.org/downloads/">Python’un resmi web sitesinden</a> Python’u indirip kurabilirsiniz.</li><li><strong>Gerekli Kütüphanelerin Kurulması:</strong> Projeyi çalıştırmak için gerekli Python kütüphanelerini kurmanız gerekebilir. Bunun için terminal veya komut istemcisinde proje dizinine giderek aşağıdaki komutu çalıştırın:</li></ul><pre>pip install -r requirements.txt</pre><ul><li><strong>Projenin Çalıştırılması:</strong> Projeyi çalıştırarak çalışıp çalışmadığını görmek için aşağıdaki komutu terminalde veya komut istemcisinde çalıştırın:</li></ul><pre>python main.py</pre><p>Aşağıdaki adımları izleyerek modelin çalışıp çalışmadığını test edebilirsiniz. Bu adımları “<strong>main.py</strong>” dosyası olarak kaydedin ve çalıştırın. Gerekli bağımlılıklar yüklendikten sonra model çalışacak ve sonraki kelime tahminini terminalde göreceksiniz.</p><ol><li><strong>Gerekli Kütüphanelerin Yüklenmesi:</strong></li></ol><p>Terminalde veya <strong><em>Jupyter Notebook</em></strong>’ta aşağıdaki komutu çalıştırarak gerekli kütüphaneleri yükleyin:</p><pre>!pip install transformers torch</pre><ul><li><strong>Modelin ve Tokenizer’ın İndirilmesi ve Kaydedilmesi:</strong></li></ul><ol><li>Aşağıdaki <strong>Python </strong>kodunu kullanarak modeli ve tokenizer’ı indirin ve yerel olarak kaydedin:</li></ol><pre>from transformers import T5ForConditionalGeneration, T5Tokenizer<br><br>model_name = &quot;allenai/t5-small-next-word-generator-qoogle&quot;<br>model = T5ForConditionalGeneration.from_pretrained(model_name)<br>tokenizer = T5Tokenizer.from_pretrained(model_name)<br><br>model.save_pretrained(&quot;t5-small-next-word-generator-qoogle&quot;)<br>tokenizer.save_pretrained(&quot;t5-small-next-word-generator-qoogle&quot;)<br><br>print(&quot;Model and tokenizer downloaded and saved locally.&quot;)</pre><p><strong>Model ve Tokenizer’ın Yüklenmesi:</strong></p><p>Yerel olarak kaydedilen model ve tokenizer’ı yüklemek için aşağıdaki kodu kullanın:</p><pre>model = T5ForConditionalGeneration.from_pretrained(&quot;./t5-small-next-word-generator-qoogle&quot;)<br>tokenizer = T5Tokenizer.from_pretrained(&quot;./t5-small-next-word-generator-qoogle&quot;)Kelime Tahmini Fonksiyonunun Oluşturulması:</pre><p>Kelime tahmini yapmak için bir fonksiyon oluşturun:</p><pre>def generate_next_word(prompt):     inputs = tokenizer(prompt, return_tensors=&quot;pt&quot;)     outputs = model.generate(inputs[&quot;input_ids&quot;], max_length=20)     next_word = tokenizer.decode(outputs[0], skip_special_tokens=True)     return next_word</pre><p><strong>Modelin Test Edilmesi:</strong></p><p>Modeli test etmek için aşağıdaki kodu çalıştırın:</p><pre>prompt = &quot;what is the&quot;<br>next_word = generate_next_word(prompt)<br>print(&quot;Generated text:&quot;, next_word)</pre><p><strong>Sonuçların Görüntülenmesi:</strong></p><p>Modeli bu şekilde “main.py” dosyası olarak çalıştırdığınızda, gerekli bağımlılıklar yüklenecek ve model çalışarak tahmin edilen kelimeyi terminalde gösterecektir. Muhtemelen “difference” gibi bir tahmin terminalde print() ile basılmış olarak görünecektir.</p><p>Aşağıdaki kodu “main.py” dosyasına ekleyin ve çalıştırın:</p><pre>from transformers import T5ForConditionalGeneration, T5Tokenizer</pre><pre>model_name = &quot;allenai/t5-small-next-word-generator-qoogle&quot;<br>model = T5ForConditionalGeneration.from_pretrained(model_name)<br>tokenizer = T5Tokenizer.from_pretrained(model_name)</pre><pre>model.save_pretrained(&quot;t5-small-next-word-generator-qoogle&quot;)<br>tokenizer.save_pretrained(&quot;t5-small-next-word-generator-qoogle&quot;)</pre><pre>print(&quot;Model and tokenizer downloaded and saved locally.&quot;)</pre><pre>model = T5ForConditionalGeneration.from_pretrained(&quot;./t5-small-next-word-generator-qoogle&quot;)<br>tokenizer = T5Tokenizer.from_pretrained(&quot;./t5-small-next-word-generator-qoogle&quot;)</pre><pre>def generate_next_word(prompt):<br>    inputs = tokenizer(prompt, return_tensors=&quot;pt&quot;)<br>    outputs = model.generate(inputs[&quot;input_ids&quot;], max_length=20)<br>    next_word = tokenizer.decode(outputs[0], skip_special_tokens=True)<br>    return next_word</pre><pre>prompt = &quot;what is the&quot;<br>next_word = generate_next_word(prompt)<br>print(&quot;Generated text:&quot;, next_word)</pre><p>Bu adımları izleyerek modelinizi başarıyla çalıştırabilir ve test edebilirsiniz.</p><h3>Python ile Hızlıca FastAPI Kullanarak Bir Servis Oluşturma ve Kütüphaneye Bağlama</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*khlU_Ht5LBnEAamGO-hVhw.png" /></figure><p>Python’da bunu hızlıca pip install fastapikullanarak bir servise dönüştürüp daha sonra ise kütüphanemize bağlayalım.</p><pre>pip install fastapi uvicorn transformers torch pydantic</pre><pre>from fastapi import FastAPI, HTTPException<br>from pydantic import BaseModel<br>from transformers import T5ForConditionalGeneration, T5Tokenizer<br><br>app = FastAPI()py<br><br># Load the model and tokenizer<br>model_path = &quot;./t5-small-next-word-generator-qoogle&quot;<br>model = T5ForConditionalGeneration.from_pretrained(model_path)<br>tokenizer = T5Tokenizer.from_pretrained(model_path)<br><br>class TextGenerationRequest(BaseModel):<br>    prompt: str<br><br>class TextGenerationResponse(BaseModel):<br>    generated_text: str<br><br>def generate_next_word(prompt: str) -&gt; str:<br>    inputs = tokenizer(prompt, return_tensors=&quot;pt&quot;)<br>    outputs = model.generate(inputs[&quot;input_ids&quot;], max_length=20)<br>    next_word = tokenizer.decode(outputs[0], skip_special_tokens=True)<br>    return next_word<br><br>@app.post(&quot;/generate&quot;, response_model=TextGenerationResponse)<br>async def generate(request: TextGenerationRequest):<br>    try:<br>        generated_text = generate_next_word(request.prompt)<br>        return TextGenerationResponse(generated_text=generated_text)<br>    except Exception as e:<br>        raise HTTPException(status_code=500, detail=str(e))<br><br>@app.get(&quot;/&quot;)<br>async def root():<br>    return {&quot;message&quot;: &quot;Welcome to the Next Word Prediction API}</pre><p>Daha sonra servisi başlatmak için:</p><pre>uvicorn main:app — host 0.0.0.0 — port 8000</pre><p>Tarayıcınızda http://localhost:8000 adresine giderek servisin çalıştığını doğrulayabiliriz. Ayrıca, Postman veya benzeri bir araç kullanarak http://localhost:8000/generate endpoint&#39;ine POST isteği göndererek kelime tahminini test edebiliriz.</p><p>Şimdi, oluşturduğumuz API servisini Angular projenize bağlayarak kullanabiliriz. Bunun için Angular’da bir servis oluşturulan bu servisi kullanarak API’den tahmin edilen kelimeleri alalım.</p><pre>{<br>  &quot;prompt&quot;: &quot;what is the&quot;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*jVryMqp-GBN4LRS9ySxS7Q.png" /></figure><p>Artık ilgili servisi yaratarak, service klasörümüzün içerisine ekleyip kullanmaya başlayabiliriz. Eğer bu modeli package ile aynı sunucuya koymak istiyor ve sunucunuzda<em> </em><strong><em>3GB</em></strong>’ye kadar yer varsa, bu model orada çalışabilir. <strong>Heroku </strong>gibi cloud servislerine atmak isterseniz, paket sınırınızı genişletmeniz gerekir. Aksi takdirde aşağıdaki gibi bir hata alırsınız:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*ZTDHPAHUspEdtmd_wEeOYQ.png" /></figure><p>HuggingFace üzerinden kendi API’larını ile bu modeli kullanma şansınız var.</p><h4>Hugging Face API Kullanarak Modeli Entegre Etme</h4><pre>https://api-inference.huggingface.co/models/allenai/t5-small-next-word-generator-qoogle</pre><p>Hugging Face üzerinden kendi API’larını kullanarak bu modeli entegre etme şansınız var. Aşağıdaki URL’yi kullanarak bir istek yapabilirsiniz: <a href="https://api-inference.huggingface.co/models/allenai/t5-small-next-word-generator-qoogle">Hugging Face Model API</a></p><p><strong>Github:</strong> <a href="https://github.com/bazobehram/ng-next-word-prediction.git">https://github.com/bazobehram/ng-next-word-prediction.git</a></p><p>Bir sonraki kelimeyi tahminleme aracımız text area üzerinde çalışmaya başladı.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*uVz1DidCguURUJm9PSdBFA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*2W7GUXQkNEF7WM_4BOjl8A.gif" /></figure><h4>TensorFlow.js ile Basit Tahminleme Modelleri Kurma</h4><p>Eğer büyük modellere ihtiyacınız yoksa ve basit tahminleme modelleri kurmak istiyorsanız, TensorFlow’un JavaScript sürümünü doğrudan projeye paket olarak ekleyebilirsiniz. Aşağıdaki linkten @tensorflow/tfjs paketini install edebilirsiniz: <a href="https://www.npmjs.com/package/@tensorflow/tfjs">TensorFlow.js on npm</a></p><p>TensorFlow.js, JavaScript dilinde makine öğrenimi ve derin öğrenme modellerini tanımlamak, eğitmek ve çalıştırmak için kullanılan güçlü bir kütüphanedir. Bu kütüphane, tarayıcı ve <strong>Node.js</strong> ortamlarında çalışabilen modeller oluşturmanıza ve dağıtmanıza olanak tanır. Ayrıca, hesaplamalarımızı hızlandırmak için <strong>WebGL </strong>ve <strong>WebAssembly </strong>gibi teknolojileri kullanabilir ve burada yaptığımız örnekteki gibi Pre-trained modeller kurmamıza ve kullanmamıza olanak sağlar.</p><pre>npm install @tensorflow/tfjs</pre><pre>import * as tf from &#39;@tensorflow/tfjs&#39;;<br><br>export class WordPredictionService {<br>    async loadModel() {<br>        const model = await tf.loadLayersModel(&#39;path/to/model.json&#39;);<br>        return model;<br>    }<br><br>    predictNextWord(prompt: string, model: tf.LayersModel): string {<br>        const inputTensor = tf.tensor(prompt.split(&#39; &#39;).map(word =&gt; word.length)); <br>        const prediction = model.predict(inputTensor) as tf.Tensor;<br>        return prediction.dataSync().toString(); <br>    }<br>}</pre><p>model.json ile vereceğiniz şekilde uğraşmak ciddi caba ve training’e ihtiyacını ortaya çıkardığını unutmamak ve deep learning konseptine aşina olmak gerekli.</p><pre>import wikipediaapi<br>import tensorflow as tf<br>from tensorflow.keras.preprocessing.text import Tokenizer<br>from tensorflow.keras.models import Sequential<br>from tensorflow.keras.layers import Embedding, LSTM, Dense<br>import numpy as np<br>import json<br><br>wiki_wiki = wikipediaapi.Wikipedia(<br>    language=&#39;en&#39;,<br>    user_agent=&#39;userAgent/1.0 (example.com; email@example.com)&#39;<br>)<br>page = wiki_wiki.page(&#39;Machine_learning&#39;)<br>text = page.text<br><br>text = text.replace(&#39;\n&#39;, &#39; &#39;).replace(&#39;\r&#39;, &#39; &#39;).replace(&#39;\ufeff&#39;, &#39;&#39;).replace(&#39;“&#39;, &#39;&#39;).replace(&#39;”&#39;, &#39;&#39;)<br><br>tokenizer = Tokenizer()<br>tokenizer.fit_on_texts([text])<br>word_index = tokenizer.word_index<br><br>with open(&#39;word_index.json&#39;, &#39;w&#39;) as f:<br>    json.dump({&#39;wordIndex&#39;: word_index}, f)<br><br>total_words = len(word_index) + 1<br>input_sequences = []<br><br>token_list = tokenizer.texts_to_sequences([text])[0]<br>for i in range(1, len(token_list)):<br>    n_gram_sequence = token_list[:i+1]<br>    input_sequences.append(n_gram_sequence)<br><br># Padding<br>max_sequence_len = max([len(x) for x in input_sequences])<br>input_sequences = np.array(tf.keras.preprocessing.sequence.pad_sequences(input_sequences, maxlen=max_sequence_len, padding=&#39;pre&#39;))<br><br># Features and labels<br>X, y = input_sequences[:,:-1], input_sequences[:,-1]<br>y = tf.keras.utils.to_categorical(y, num_classes=total_words)<br><br>model = Sequential()<br>model.add(Embedding(total_words, 10, input_length=max_sequence_len-1))<br>model.add(LSTM(100))<br>model.add(Dense(total_words, activation=&#39;softmax&#39;))<br>model.compile(loss=&#39;categorical_crossentropy&#39;, optimizer=&#39;adam&#39;, metrics=[&#39;accuracy&#39;])<br><br>model.fit(X, y, epochs=100, verbose=1)<br><br>model.save(&#39;word_prediction_model.h5&#39;)</pre><p><strong>Github</strong>: <a href="https://github.com/bazobehram/building-a-word-prediction-model">https://github.com/bazobehram/building-a-word-prediction-model</a></p><p>Yukarıdaki örnek, bir model inşa etme sürecini göstermektedir. Burada, ‘<strong><em>Machine_learning</em></strong>’ başlıklı Wikipedia sayfasının metin içeriği çekilmekte ve daha sonra yeni satır karakterleri, satır başları ve özel Unicode karakterleri gibi istenmeyen karakterler kaldırılarak metin temizlenmektedir. Bu süreçte, metin bir dil modeli olarak eğitilmekte ve girdiğimiz kelimelerden bir sonraki kelimeyi tahmin etmemizi sağlamaktadır. Sonuç olarak, <strong>epochs=100</strong>&#39;e kadar geri yayılım (backpropagation) yoluyla model kendi hatalarından öğrenmekte ve düzeltilmekte, kayıp (loss) değerlerinin giderek azalması ve doğruluk (accuracy) oranlarının artması gözlemlenebilmektedir.</p><p>Uygun <strong>CUDA </strong>destekli bir ekran kartınız varsa, daha hızlı sonuçlar alabilirsiniz. Eğer donanımınız yeterince iyi değilse, bu eğitim birkaç günden fazla sürebilir.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=532bd05a6ea2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deep Dive into Angular Update: A Few Tricks to Convert Your Old Projects to The Latest Version]]></title>
            <link>https://medium.com/@bazobehram/deep-dive-into-angular-update-a-few-tricks-to-convert-your-old-projects-to-the-latest-version-3893c0d0ef8b?source=rss-9b4c8c153c46------2</link>
            <guid isPermaLink="false">https://medium.com/p/3893c0d0ef8b</guid>
            <category><![CDATA[performance-optimization]]></category>
            <category><![CDATA[angular-version-migration]]></category>
            <category><![CDATA[project-transformation]]></category>
            <category><![CDATA[dependency-management]]></category>
            <category><![CDATA[step-by-step-update-guide]]></category>
            <dc:creator><![CDATA[Behram Bazo]]></dc:creator>
            <pubDate>Sat, 29 Jun 2024 18:50:58 GMT</pubDate>
            <atom:updated>2024-06-29T19:23:10.775Z</atom:updated>
            <content:encoded><![CDATA[<p><em>In this article, you will find the difficulties that can be experienced when updating your Angular projects to the latest version and the tactics that will make this process less stressful. I explained how to be prepared for the problems you may encounter while modernizing your old projects and how to proceed step by step. While evaluating the advantages and risks of updates, you should learn how to manage dependencies in your projects. With this guide, you can ease the transformation process while incorporating the latest features of Angular into your projects.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jXFYzsXa3PrNxUCjAwt6zg.jpeg" /></figure><p><strong>You may come across Angular</strong> versions that have not been updated for a long time, have been postponed or have become scary to update. Software developers generally do not want to get involved in these projects that have been swept under the rug and have become an obstacle to development. Because the transformation of such projects is usually painful. If there are already some uncertainties, no one wants to take on the responsibility. While the main developers of the project avoid this, you may have to take a role in such a project even if you do not want to. This is very annoying and carries some risks. Due to these problems, some people have even considered switching from Angular to other libraries in their projects. If build problems cannot be solved and it is not possible to predict where the errors originate from, this situation can lead to burning the blanket for bits.</p><p>In these moments, you should not be afraid to take risks; even if it is a job that you will have to lose. Because gaining the ability to transform old projects can be more valuable than staying in your current job.</p><p>Updates are usually good, they can give you new features or take away what you have, but this is usually unlikely. I say this as an update addict, I keep track of the updates of everything, from <strong>the Ubuntu Linux</strong> I use to the applications on the phone, more than the automatic update assistant.</p><p>Taking advantage of the latest stage and possibilities of development always opens new doors and can close some security risks. On the contrary, it is not impossible that it can cause us other troubles, but there is no world without risk. This is not just about developed software.</p><h4>Let’s roll up our sleeves</h4><p>If you are following the updates and new versions in Angular, and you are updating your projects by following the <a href="https://angular.dev/update-guide">Update Guide </a>on Angular.dev, transitioning from the previous version to the new one may not cause any issues for you; it might not even carry any risks. However, if the projects you are working on are outdated and need to be transformed, even though you cannot use many features in the latest version of <a href="https://angular.dev/update-guide">Angular</a>, you need to access the modern capabilities of whichever <strong>Typescript</strong>, <strong>Ecmascript</strong> versions are being used in your project, just from the programming language perspective. Not to mention the situation you face for your other third-party libraries. You may find yourself in a very unpleasant, motivation-draining development process as you will need to look for solutions according to the appropriate version while debugging or in the development phase, and you may have to carry out this task with more difficulty and less support.</p><p>Working with outdated technologies also brings other problematic aspects such as performance, security, and compatibility issues. Imagine that Angular 18 has been released and a framework has emerged with many breaking changes from the build system onwards, but the project you are working on still uses <strong>Angular</strong> 7. From this point on, when you want to upgrade Angular in your project, especially if your project is medium to large in size, be prepared to face many difficulties.</p><p>That’s why this article was written to help you upgrade your Angular with less stress in such a transformation task. I will address some key points that I have experienced in the difficulties of transforming old projects in this article.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6UI11UydKv-KKifcODha-g.jpeg" /></figure><h3>First Preparations Before Starting the Update</h3><h3>Check out the Addictions</h3><p>Check all the dependencies in the project you are using. Identify the project-specific libraries and third-party dependencies. You may need to review dependencies other than public libraries as well. For example, you can use the following command to update a specific library:</p><p>If you have dependencies other than public libraries, you need to download your existing libraries as a project and update them according to the project you will update. npm link &lt;library name&gt;By establishing a simultaneous local connection with your library, you can track incompatibilities during <strong>Angular updates and update it at the same time.</strong></p><p>npm config get registryYou can view the current registry <strong>URL set in the NPM</strong> configuration file with the command.</p><p><strong>Let&#39;s imagine how to do Angular</strong> update through an example project :</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular-9-material-mattable-crud-yzudn2%3Fembed%3D1%26file%3Dpackage.json%26view%3Deditor&amp;display_name=StackBlitz&amp;url=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular-9-material-mattable-crud-yzudn2%3Fembed%3D1%26file%3Dpackage.json%26view%3Deditor&amp;image=https%3A%2F%2Fsocial-img.staticblitz.com%2Fprojects%2Fangular-9-material-mattable-crud-yzudn2%2F613b42d84890b2f797a79c57924f9ee5&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=stackblitz" width="745" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/075c10b2a3380a47928cd77fa5e80791/href">https://medium.com/media/075c10b2a3380a47928cd77fa5e80791/href</a></iframe><p>It is important that our first question starts with which version we aim to upgrade such a project. Because we may not be able to update to the version we aim. This may not be due to Angular, but to the dependencies the project uses. You can update your project to the latest version of <strong>Angular.</strong></p><h4>Your First Question: Which Version Do We Intend to Upgrade to?</h4><p>Your answer to this question is important because there are many factors that affect the update of your project. Not being able to reach your target version may depend on the degree of your dependency on the libraries you use. This may be due to the libraries your project depends on rather than Angular itself. Once it is compatible with the libraries you have, you can update your project to the latest version of Angular.</p><h3>Step by Step Update</h3><p>It is usually safer to update step by step. For example:</p><ul><li>Migrating from <strong>Angular</strong> 9 to <strong>Angular 10</strong></li><li>Migrating from <strong>Angular</strong> 10 to <strong>Angular 11</strong></li></ul><p>By continuing in this way, you will reach the latest version. In the meantime, you should act by taking into account the environment you use, your needs, and breaking changes. If you are very experienced and know what the transitions are and are willing to manually remove them yourself, you can also migrate directly from <strong>Angular</strong> 9 to <strong>Angular 18</strong>, but here you need to know more or less what you will encounter and be prepared. That&#39;s why this method is not recommended. Or you can use some tools, for example, <strong>NX</strong> &#39;s automigrate tool and similar tools. Link here: <a href="https://nx.dev/features/automate-updating-dependencies">NX Auto Migrate Tool</a></p><p>If third-party libraries do not support this when you switch to <strong>Angular</strong> <strong>18, you will experience serious problems. If you can find alternatives to the libraries and it is not too costly, you can switch to the latest version with this change, but if you do not have such a chance, you may have to wait for the relevant package to update to the new version of Angular. In this case, you can look at the changelogs and issues opened for the relevant library on GitHub</strong>, these may be discussed in the community. You can send a support message to the developers and many ways and methods…</p><p>After determining which version we will switch to in the first step, we can now start making version transitions.</p><p>You should follow carefully what you will encounter before and after such an update guide in Angular, from which <strong>Node</strong> version you need, which Typescript version you need, whether is there anything removed, are there any breaking changes and many other things in each version step. But here, following only this may not be enough, because the width of the project you use and the libraries can naturally complicate things. In this case, here&#39;s what you need to do:</p><ul><li>First, install <strong>NVM </strong><a href="https://github.com/nvm-sh/nvm"><strong>from this link</strong></a> to make your work easier. You will be constantly changing between <strong>Nodejs</strong> versions, this tool allows you to easily switch between versions.</li><li>Before updating with <strong>NPM</strong>@angular/cli@wantedversion @angular/core@wantedversion update, consider the consequences of conflicts between the Angular version that will be installed after updating and the dependencies. For example, before doing this, try to switch to this version in your mind and imagine backwards from this version. In other words, if you imagine what kind of environment and changes the version you are switching to has and provide the appropriate environment before switching to it, you will not have any problems during the transition — forceand you will not need to use it.</li><li>You can follow which <strong>Node versions Angular</strong> is compatible with here: <a href="https://angular.dev/reference/versions">Angular Version Compatibility Table</a></li></ul><p><strong>Angular</strong> will automatically make many changes during the migration, but not everything. In the meantime, reading the guide documentation carefully and seeing what changes are will make it easier for you to move to the next version.</p><pre>$ node -v // You will need to check your node version frequently with this command. <br>$ npm outdated // This command will check if the dependencies in the project are up to date. <br>  // Current: Installed version, Wanted: Desired version, Latest: Latest version, Location: Current location.</pre><p>The above commands are the most basic ones you need to know. Later, the commands you will use for most control during the transition can be:</p><pre>$ npm view &lt;your- package -name&gt; versions   // The command lists all available versions of the package you type in the NPM registry.<br> $ npm info &lt; package -name&gt;   // The command is used to get detailed information about a package in NPM.</pre><p>The possible problems we will encounter in the scenario in the project above are as follows and we can make our calculations as follows:</p><p>As of the date of writing this article, devextreme-angularif I&#39;m not mistaken, version 24 does not support <strong>Angular 18</strong>. Many developers write to support and wait for a new version to be released. Therefore, if this library is in a fundamental position and indispensable in our project, we can develop this project up to Angular 17 version at most. In this case, we can gradually @nebular/thememove the library in our example from 5.1.0 to 13.0.0 until the Angular 17 version.</p><p>Again, the libraries: node-uuid, popper.js, request, in our sample project har-validatorwill appear as deprecated in the console during the update, and in this case, we need to get rid of these libraries and research alternatives.</p><p>If you want to check a package directly by entering the command:</p><pre>$ npm info har-validator</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qQ_-FDjmb93Tg3SY.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*QQyDEoEj_si22yleJX9GMQ.png" /></figure><p>During these update transitions, it will now have to be in the form import &#39;zone.js/dist/zone&#39;;-&gt; .import &#39;zone.js&#39;polyfills.ts</p><p>Keep an eye on the terminal during the update and during the build, do not skip anything without reading it, it may cause you trouble later. You will receive warnings many times while performing these operations in the terminal, Angular will guide you during the launch ( ng serve, npm start) or during the build ( ng build).</p><p>Again, the terminal will warn you many times about errors and warnings related to versions. It is not recommended to switch to other versions without solving the problems unless that problem can only be solved with the compatibility of other packages at another threshold. You will be making some changes manually, step by step, for example, when you get closer to the 9th and 10th versions, Ivy: trueor falseit will ask you to make it, and then after a while, when it becomes stable in other versions, it will tell you to remove it and it is no longer necessary. It&#39;s important to keep an eye on Typescript as it gets updates. Sometimes something will explode in the compiler -&gt; skipLibChecktsconfig will save your life, sometimes you will need to change the ECMAScript versions of the module and lib. sourceMapIt will be beneficial for you to have in true, it will be very useful in debugging processes.</p><p>@Angular/CliDon&#39;t forget to update the relevant &#39;i -G&#39; from Nodejs General for each Nodejs version you switch to.</p><p>Sometimes there will be strange things that we call tricks, do not expect logical results from everything, even if it is programming; because these are dynamic structures that produce errors.</p><p>For example, you are using NodeJs 16 version in Nodejs General with Angular 15 CLI installed. In Terminal, it may say Nodejs version 12 has been detected. Even if you node -vdo it, you cannot understand it. Sometimes turning off services or even turning off and on the computer when many things get mixed up can save you a lot of trouble. Don&#39;t be shy, stupid problems may need simple solutions.</p><p>Always keep these items handy to avoid such situations:</p><pre>$ npm cache verify<br>$ npm cache clean --force<br>$ rm -rf node_modules<br>$ rm package-lock.json</pre><p>To check for strange situations also:</p><pre>$ npm doctor // The command checks whether your NPM environment is working properly and can detect potential problems .</pre><p>In case of NPM install, --forceit is useful to solve it with this:</p><pre>$ npm install — legacy-peer-deps</pre><p>You need to find solutions for breaking changes and deprecated packages that you have to remove from your application. While you can follow the build and compile statuses in the terminal for breaking changes and many new features, you can understand what the actual innovations are by examining the relevant <strong>Angular</strong> versions, or you can discover and edit them in many ways by doing research and using artificial intelligence.</p><p>Don’t let the errors that appear intimidate you, Angular has a powerful error catcher system, sometimes it is difficult to catch errors but usually, the guidance is correct.</p><p><strong>Angular’s 17th</strong>. When you come to the version, do not forget to use application-builder in your application. With gear, build time can be reduced by up to <strong>70%</strong>. For this:</p><pre>$ ng update @angular/cli --name use-application-builder</pre><p>For more -&gt; <a href="https://v17.angular.io/guide/esbuild">Build Time with Gear</a></p><p>In Angular 18, you can now use zonelessChangeDetection if you want:</p><pre>bootstrapApplication ( App , { <br>  providers : [ <br>    provideExperimentalZonelessChangeDetection () <br>  ] <br>});</pre><h3>Conclusion and Next Steps</h3><p><strong>After successfully completing Angular</strong> updates, you can now think about other improvements that will take your project further. For example, you can make performance optimizations, and use linting and testing tools to increase code quality, these parts are now according to your needs… In addition, it is possible to make your development process more efficient by automating the continuous integration and deployment processes of your project. With these, when <strong>Angular</strong> Major version transitions are followed, Angular updates will no longer be a nightmare.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3893c0d0ef8b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>