今日已更新 396 条资讯 | 累计 20866 条内容
关于我们

标签:#programming

找到 1376 篇相关文章

AI 资讯

TypeScript Patterns for Environment Variables

Yesterday, as I was working on a CORS configuration, AI generated a block of code for me: const allowedOrigins = [ process . env . FRONTEND_URL || " http://localhost:3000 " , process . env . ADMIN_URL || " http://localhost:3001 " , ]. filter ( Boolean ); I was wondering... why use .filter(Boolean) here? 🤔 The fallbacks already guarantee strings. So I hovered on the variable. The type definition read: const allowedOrigins : string [] Fine. Made sense. But then I got curious. What if I removed the hardcoded fallbacks? const allowedOrigins = [ process . env . FRONTEND_URL , process . env . ADMIN_URL , ]. filter ( Boolean ); My type definition changed to: const allowedOrigins : ( string | undefined )[] I was shocked. I just filtered the array. How can TypeScript still think there's an undefined in there? First: What Does .filter(Boolean) Even Do? Boolean used as a filter function removes any falsy value from an array: false null undefined 0 "" NaN So: [ " https://app.com " , "" , undefined ]. filter ( Boolean ) // Result: ["https://app.com"] At runtime, this works exactly as you'd expect. No undefined survives. So why does TypeScript disagree? 🤷‍♀️ The Real Answer: TypeScript Doesn't Run Your Code TypeScript is a transpiler. It doesn't execute .filter(Boolean) — it only looks at types. When it sees this: array . filter ( Boolean ) It knows the callback returns a boolean . But it doesn't know what that means for the type of the elements that survive. It can't infer "if Boolean(x) is true, then x must be a string." So the undefined stays in the type — even though it'll never actually be there at runtime. That's the gap: your runtime behavior is correct, but your types are lying. The Fix: Type Predicates TypeScript lets you close that gap with a type predicate — a way of explicitly telling the compiler what a filter function guarantees: const allowedOrigins = [ process . env . FRONTEND_URL , process . env . ADMIN_URL , ]. filter (( origin ): origin is string => Boolean ( o

2026-06-16 原文 →
开发者

Introducing Zentax A New Programming Language

Hi everyone, I’m working on a new programming language called Zentax. It is still in early development, but the goal is to build a modern language focused on: Performance and low-level control Simple and clean syntax Native desktop application support A modular compiler and runtime design Zentax is not trying to replace existing languages — it is an experiment in building a unified approach for systems programming and UI development. Current Status Compiler: in development Runtime: early design stage Renderer: experimental Standard library: planning phase Looking for Contributors I’m open to collaboration from anyone interested in: Programming language design Compiler development Runtime systems Graphics / rendering engines Open-source tooling Even feedback and ideas are welcome at this stage. Links Git Hub Repo Discord Thanks for reading. Dr. Zoha Tariq Anoneurx

2026-06-16 原文 →
AI 资讯

Agentic Design Patterns: The Shapes Every Coding Agent Reuses

This is an adapted excerpt from a guide in my AI Knowledge Hub. The full interactive version is linked at the end. Agentic design patterns are named control structures for arranging LLM calls and tools. This post gives you the decision rule for picking one, the exact shape of each pattern, and the cost each adds — so you can match a task to the minimum structure that solves it. Everything here is model-agnostic and grounded in Anthropic's Building Effective Agents and the Claude Agent SDK. Workflow vs. agent: the split that decides everything Anthropic divides all agentic systems into two categories, and the split decides every downstream tradeoff: Category Definition Control lives in Use when Workflow LLMs and tools orchestrated through predefined code paths Your code You can pre-map the decision tree; want accuracy, control, lower cost Agent LLMs dynamically direct their own processes and tool usage , maintaining control over how they accomplish tasks The model Open-ended task where you can't predict the number of steps Every pattern composes one unit: the augmented LLM — an LLM enhanced with retrieval, tools, and memory. It generates its own search queries, selects tools, and decides what to retain. If a single augmented LLM call solves the task, stop — no pattern required. The escalation rule is the whole game: find "the simplest solution possible, and only increasing complexity when needed" — which "might mean not building agentic systems at all." Agentic systems trade latency and cost for better task performance, so only escalate when a specific failure mode forces it. The agent loop: gather → act → verify → repeat For open-ended tasks, every agent runs the same four-beat loop: Gather context — read files, run agentic search ( grep / find / tail to pull relevant slices instead of whole files), or delegate to subagents with isolated context windows. Take action — execute via tools: bash, code generation, file edits, MCP servers. Verify work — check the result b

2026-06-16 原文 →
AI 资讯

Java Interface

today we discuss about Interface in Java. first we understand the concept with simple Analogy, Imagine you go to a shop and buy items. in a bill counter, the shop keeper care about only one thing. The customer paid the Money or not. The shopkeeper does NOT care about how you pay the money, UPI Debit Card Cash They only thing is payment paid in successfully. Here a interface acts like a Rule in billing counter. It only defines what must be done, not how it should be done. Different payment methods follow the same rule, but each one works in its own way. The shopkeeper does not need to change anything in the billing counter. No matter how the customer pays, the system works the same. so, i follow this analogy and using a example for this blog. What is Interface? (in GeeksforGeeks) An interface in Java is a blueprint that defines a set of methods a class must implement without providing full implementation details. It helps achieve abstraction by focusing on what a class should do rather than how it does it. Interfaces also support multiple inheritance in Java. A class must implement all abstract methods of an interface. All variables in an interface are public, static, and final by default. Interfaces can have default, static, and private methods first create a interface file Payment.java public interface Payment { void pay ( int amount ); } here we create a method but not defined that method This is the shop rule. “Anyone wants to pay must follow one rule → pay the amount.” The shop does not explain how you pay, only thing is you must pay. next we create another file for Different Customers, class CardPayment implements Payment { public void pay ( int amount ) { System . out . println ( "Paid ₹" + amount + " using Card" ); } } class UpiPayment implements Payment { public void pay ( int amount ) { System . out . println ( "Paid ₹" + amount + " using UPI" ); } } class CashPayment implements Payment { public void pay ( int amount ) { System . out . println ( "Paid ₹" +

2026-06-16 原文 →
开发者

Cross-Language Data Types

Have you ever thought about sharing data across language boundaries without serialization? This blog post highlights the challenges behind this endeavor and how they can be overcome. Note: I'm not the original author of the blog post, but since the author does not have a Reddit account, I post it on his behalf. submitted by /u/elBoberido [link] [留言]

2026-06-16 原文 →
AI 资讯

AI won’t replace you, but bad AI habits will

A blunt playbook for devs who don’t want to turn into autocomplete zombies. The first time an AI wrote code for me, I felt like I had unlocked cheat codes for real life. I typed a half-baked function name, hit enter, and suddenly I had a block of code that looked legit. It was magical. The second time, though? It suggested something so catastrophic basically the programming equivalent of pulling the fire alarm that I realized: this thing is less “mentor” and more “overconfident intern who thinks they know pointers but actually just broke prod.” That’s where most of us are right now. AI is everywhere: in our IDEs, our docs, even sneaking into PR reviews. Some days it feels like rocket fuel; other days it feels like an autocomplete with a drinking problem. The tricky part isn’t whether AI is “good” or “bad.” The tricky part is how we, as developers, use it without becoming lazy, dependent, or worse complacent. Because here’s the uncomfortable truth: AI won’t replace you, but bad AI habits absolutely will. TLDR : This article is a survival guide for developers in the AI era. We’ll break down why AI feels both magical and mid, the five switches that make AI actually useful, when to trust and when to verify, how to use AI as a research assistant (not a code monkey), the dangers of autocomplete brain, and a playbook for building a healthy workflow. Why AI feels both magical and mid Every dev I know has had that moment with AI. The first time it autocompleted a function and nailed it, you probably thought: “Wow… this thing just saved me half an hour.” It’s the same dopamine hit as discovering ctrl+r in bash or realizing you can pipe grep into less . Pure wizardry. But the honeymoon ends quickly. The same tool that wrote a clean utility function also happily hallucinates imports that don’t exist, invents APIs, and will confidently explain things that are flat-out wrong. It’s like pair programming with someone who sounds senior but has never actually shipped code. The magic-

2026-06-15 原文 →
AI 资讯

Your AI agent doesn't have a memory. It has a transcript.

Notes from building a memory layer that forgets on purpose. Most "memory-enabled" agents don't remember anything. They re-read. Every turn, the whole conversation gets pasted back into the prompt, and we call that memory because the model can answer questions about earlier turns. It's a good trick. I used it for months. It also falls apart the moment real people start using the thing, and it falls apart in three separate ways. The first is the one everyone notices: it's expensive and noisy. You re-send every prior turn on every request. The single line you actually care about - "I'm allergic to peanuts" - is buried under a thousand lines of small talk, and you pay for all of it, every time. The second is quieter and worse. Transcript-stuffing has no idea what stale means. If someone told your agent "I'm vegetarian" in March and "I eat fish now" in May, you've just handed the model both facts with equal weight. Now it has to guess which one is current. Sometimes it guesses wrong, and there's nothing in the system that even thinks that's a problem. The third one is the reason I stopped treating this as a side quest. When you finally add summarization to control the cost from problem one, the summarizer is free to drop whatever it wants to save tokens. Including the allergy. I spent years around fintech, where the wrong record surviving (or the right one quietly vanishing) is how people get hurt, so this landed hard: forgetting an allergy to save 40 tokens isn't a cost bug. It's a safety bug wearing a cost bug's clothes. So the question I actually wanted to answer wasn't "how do I make my agent remember more." It was: how do I build something where acting on a fact the user already retracted and silently dropping a fact that must survive are impossible by construction, not just unlikely if the prompt is good that day. Everyone has already solved one third of this The encouraging part is that you don't have to invent much. The discouraging part is that every existing sy

2026-06-15 原文 →
AI 资讯

Bootcamp Grad Dives Into Google vs OpenAI API Pricing

Honestly, bootcamp Grad Dives Into Google vs OpenAI API Pricing When I finished my coding bootcamp three months ago, I thought I understood what an API did. I mean, you send a request, you get a response back, right? What I did not understand was how dramatically the cost could vary depending on which model you picked. I had no idea that a single line of code change could mean the difference between paying pennies and paying hundreds of dollars at scale. That is the rabbit hole I fell down last week, and I want to walk you through everything I learned. This is the post I wish I had read before I burned through my first $50 in API credits. Why I Started Looking At Pricing In The First Place I was building a small app that takes user reviews and summarizes them. Pretty straightforward. I figured I would just plug in the most popular model and call it a day. That model, if you have been paying attention to the news, is GPT-4o. So I wired it up, ran a few tests, and everything looked great. Then I did the math. GPT-4o charges $2.50 per million tokens on input and $10.00 per million tokens on output. I did not even know what a "million tokens" really meant in practice. So I tested my app with maybe 50 reviews and watched my credit balance drop. It was not catastrophic, but it was enough that I started wondering if there was a cheaper way. I was shocked when I found out how big the gap actually is. The Pricing Table That Changed My Whole Plan I stumbled onto a platform called Global API, and honestly, the pricing chart there blew my mind. They give you access to 184 different AI models, with prices ranging all the way from $0.01 to $3.50 per million tokens. Compare that to the GPT-4o output price of $10.00 per million tokens, and you start to understand why I panicked a little when I saw my early numbers. Here are the five models I ended up comparing side by side: Model Input Cost Output Cost Context Window DeepSeek V4 Flash $0.27 $1.10 128K DeepSeek V4 Pro $0.55 $2.20 20

2026-06-15 原文 →
AI 资讯

How to Check If an Online JSON Formatter Uploads Your Data

Most developers have done this at least once. You get a messy API response. You need to inspect a JWT. You have a webhook payload, a log object, or a config file that is hard to read. So you open a JSON formatter, paste the content, and move on. That habit is convenient. But it also deserves a second look. Not every JSON tool behaves the same way. Some tools process your input entirely in the browser. Some send content to a server. Some store snippets for sharing. Some extensions have permissions that are broader than you expect. The problem is not that every online formatter is unsafe. The problem is that you often do not know what happens after you paste. What you should avoid pasting blindly Before using any random online tool, be careful with: production JWTs API responses containing user data logs from real systems config files webhook payloads database URLs cloud keys internal endpoints tenant IDs error traces from production systems A JSON payload does not need to contain an obvious password to be sensitive. Sometimes the risky part is context: user IDs, internal URLs, tokens, customer data, or system structure. A quick DevTools check You can do a basic check with your browser’s DevTools. Open the JSON tool. Open DevTools. Go to the Network tab. Clear existing requests. Paste a harmless test JSON first. Run format, validate, diff, decode, or whatever action the tool provides. Watch the Network tab. Look for POST, PUT, fetch, XHR, or beacon requests after your input. Inspect request payloads if they exist. Check whether your pasted JSON appears in any request. Do this with harmless test data first. If the tool uploads the test JSON, do not paste production content into it. What to look for A few signs deserve attention: POST requests after you paste or click format request bodies containing your JSON share-link features that save snippets server-side validation APIs analytics events that include pasted content extension background requests that are not clearly

2026-06-15 原文 →
AI 资讯

Introducing Truthmark 2.2.0: Product and Engineering Truth Lanes for AI Coding Agents

AI coding agents are becoming better at changing software. That is no longer the hardest problem. The harder problem is keeping the repository understandable after those changes land. Code changes quickly. Documentation often does not. Product intent lives in chat history. Architecture notes fall behind. Reviewers can inspect the implementation diff, but they often cannot see whether the product promise, engineering contract, and repository workflow are still aligned. Truthmark is built for that gap. It is a Git-native workflow layer for AI-assisted software development. It installs repository-local truth workflows so AI agents can keep canonical truth docs aligned with functional code changes, while humans still review normal Git diffs. Truthmark 2.2.0 takes a significant step forward: it separates product truth from engineering truth. That may sound like a documentation detail. It is not. It is a workflow boundary for AI coding agents. Why truth needs lanes Most documentation systems treat “docs” as one surface. That works until AI agents start using those docs as operational context. A product promise and an implementation detail are not the same kind of truth. A product doc should say what must be true, why it matters, who benefits, what boundary is being protected, and what success means. An engineering doc should say how the repository currently realizes that promise: the behavior, contract, architecture, workflow, operations, tests, and source-backed implementation facts. When those two kinds of truth collapse into one file, the result is usually weak in both directions. Product truth becomes a summary of implementation mechanics. Engineering truth becomes a detailed version of product rationale. Neither is ideal for humans. Neither is ideal for agents. Truthmark 2.2.0 introduces explicit product and engineering lanes so agents can reason about these surfaces separately. The core rule is simple: Product truth says what must be true and why. Engineering truth

2026-06-15 原文 →