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

标签:#programming

找到 1341 篇相关文章

AI 资讯

Modern C# Features: A Deep Dive into Records, Pattern Matching, Async, and Performance

Modern C# Features: A Deep Dive into Records, Pattern Matching, Async, and Performance A practical guide to the C# language features that have reshaped how we write .NET code — records, pattern matching, async/await improvements, nullable reference types, LINQ enhancements, Span<T> , and performance optimizations. Table of Contents Introduction Records Pattern Matching Async/Await Improvements Nullable Reference Types LINQ Enhancements Span<T> and Memory<T> Performance Optimizations Quick Reference Table Conclusion Introduction C# has evolved significantly since C# 8. Each release (9, 10, 11, 12, 13) has focused on three consistent themes: Conciseness — write less boilerplate to express the same intent. Safety — catch bugs at compile time instead of runtime (especially around null ). Performance — give developers low-level control without leaving the managed, safe world of .NET. This guide walks through the features that matter most in day-to-day development, with working code examples you can drop into a dotnet run project. 1. Records Introduced in C# 9 , record types give you immutable, value-based data models with almost no ceremony. Why records exist Before records, representing an immutable data object meant hand-writing a constructor, Equals , GetHashCode , ToString , and often a With -style copy method. Records generate all of this for you. // Before: a "plain" immutable class public class PersonClass { public string FirstName { get ; } public string LastName { get ; } public PersonClass ( string firstName , string lastName ) { FirstName = firstName ; LastName = lastName ; } public override bool Equals ( object ? obj ) => obj is PersonClass p && p . FirstName == FirstName && p . LastName == LastName ; public override int GetHashCode () => HashCode . Combine ( FirstName , LastName ); public override string ToString () => $"PersonClass {{ FirstName = { FirstName }, LastName = { LastName } }} " ; } // After: the same thing as a record public record Person ( stri

2026-07-05 原文 →
AI 资讯

AI Won't Replace Developers—But Developers Who Use AI Will Build Faster

Artificial Intelligence has changed the way we write software, but one thing has become clear: AI is a collaborator, not a replacement. After using coding assistants for months, I've realized they're best at handling repetitive tasks: Generating boilerplate code Explaining unfamiliar APIs Refactoring existing functions Writing documentation Creating unit tests Finding bugs faster Where AI still struggles is understanding the bigger picture. It doesn't know your product vision, business requirements, or why one architectural decision is better than another. Those are still human problems. The most productive workflow isn't asking AI to build an entire application from scratch. It's treating AI like an experienced teammate that can help with implementation while you stay responsible for the design and direction. The developers who will thrive over the next few years won't necessarily be the ones writing the most code—they'll be the ones asking better questions, validating AI-generated solutions, and combining technical knowledge with critical thinking. AI is changing software development, but it's also raising the value of good engineering judgment. How has AI changed your development workflow? What's one task you now almost always delegate to an AI assistant?

2026-07-05 原文 →
AI 资讯

Why v7 UUIDs beat v4 for database keys (and how to hand-roll both)

I build one small browser tool a day and write down what I learned. Day 25 was a UUID generator. What started as "make some random IDs" turned into a proper look at how the bits are laid out, and why the newer v7 format is quietly the better default for a primary key. Live tool: https://dev48v.infy.uk/solve/day25-uuid.html A UUID is just 16 bytes with a few fixed bits A UUID is a 128-bit number, written as 32 hex digits grouped 8-4-4-4-12 . That is about 3.4x10^38 possible values, which is the whole point: any machine can pick one and trust it will not clash with any other UUID minted anywhere, ever. It carries no meaning — it is an identifier, not data. The reason UUIDs exist at all is coordination. The classic database ID is 1, 2, 3... from a central counter, and that works great until you have more than one writer. Two servers, an offline mobile app, or a sharded database cannot all ask one counter for the next number without a round-trip and a lock. UUIDs sidestep that entirely: each node generates its own IDs locally, with zero coordination, and they still do not collide. A client can even create the ID before the row ever reaches the server. Version 4: 122 random bits v4 is the one most people mean by "UUID". Fill all 16 bytes with cryptographic randomness, then overwrite two small fields so tools can recognise the format: const b = new Uint8Array ( 16 ); crypto . getRandomValues ( b ); // never Math.random() b [ 6 ] = ( b [ 6 ] & 0x0f ) | 0x40 ; // version 4 b [ 8 ] = ( b [ 8 ] & 0x3f ) | 0x80 ; // variant 10xx Two things get pinned. The high nibble of byte 6 becomes 4 — that is the digit right after the second hyphen, and it is how any parser knows the scheme. The top two bits of byte 8 become 10 , which is why the 17th hex digit of almost every UUID you see is 8 , 9 , a or b . Everything else stays random: 122 bits of it. Is "random and never collides" a contradiction? The birthday paradox says collisions become likely around the square root of the space, w

2026-07-05 原文 →
AI 资讯

Java & AI: What Developers Need to Know

Stop the ReAct Chaos: Building Deterministic Multi-Agent Cycles with Spring AI Graph If you are still letting LLMs freely decide their next execution step in an unconstrained ReAct loop, you are burning cloud budget on infinite loops and non-deterministic failures. In 2026, enterprise-grade AI requires the strict guardrails of stateful, cyclic graphs where transitions are governed by code, not LLM vibes. Why Most Developers Get This Wrong Naive ReAct Loops: Relying entirely on prompt-based tool calling to determine flow, which inevitably derails after 3-4 turns. Stateless Agents: Passing massive, unmanaged chat histories back and forth instead of maintaining a single, thread-safe state object. Lack of Edge Controls: Failing to hardcode conditional transitions, letting the LLM hallucinate its way into non-existent API endpoints. The Right Way The solution is to model your multi-agent system as a deterministic, cyclic graph where the LLM only executes node-level tasks, while Java code controls the state transitions. Define an Immutable State: Use Java record types to represent the thread-safe state passed between nodes. Explicit Nodes and Edges: Map agents (e.g., Writer, Critic) to discrete nodes and use conditional routers to decide the next transition. Spring AI Graph API: Leverage Spring AI 1.2.0's StatefulGraph to manage state persistence and concurrent transitions out-of-the-box. Model Specialization: Use fast, cheap models (like Llama 3.3) for routing decisions, and reasoning models (like Claude 3.5 Sonnet) only for complex node tasks. Show Me The Code (or Example) // Define stateful graph with immutable State record var workflow = new StatefulGraph < AgentState >() . addNode ( "writer" , state -> writerAgent . call ( state )) . addNode ( "critic" , state -> criticAgent . call ( state )) . addEdge ( START , "writer" ) . addEdge ( "writer" , "critic" ) . addConditionalEdge ( "critic" , state -> { return state . isApproved () ? END : "writer" ; // Deterministic cy

2026-07-05 原文 →
AI 资讯

The Push Notification Bug That Took Three Layers to Find

1:00 AM to 2:27 AM. One bug, three root causes, zero clean error messages. It started with a simple complaint: an admin sends a push notification, and the user never receives it. No crash, no red error in the console, nothing obviously broken. Just silence on the other end. That kind of bug is the most frustrating kind. Everything looks like it's working. The permission prompt shows up fine. The admin panel says "sent." And yet nothing arrives. By 1 AM, after a long day already spent on a fairly large project, this was the last thing left to fix before calling it a night. It turned into an hour and a half of tracing one silent failure into another. Layer One: The CSP Was Blocking the Fix Before It Could Even Start The first clue showed up in the browser console: a Content Security Policy violation, quietly blocking a script that OneSignal's SDK needed to complete its own initialization. The permission popup looked completely normal, so it was easy to assume the subscription step was working. It wasn't. The script that OneSignal used internally to finish setting up the subscription was being blocked by the site's own security headers. The fix was small: add the missing domain to the script-src directive. But finding it meant not trusting what the UI looked like it was doing, and instead reading the actual network requests line by line. Layer Two: "Sent" and "Delivered" Are Not the Same Thing Once the CSP was fixed, notifications appeared to send successfully. The API returned a success response, an ID was created, and the admin panel showed a "sent" confirmation. Except the user still got nothing. This turned out to be a subtler problem. OneSignal's newer API doesn't return a recipient count in that initial response, so a message could be "created" successfully by OneSignal's servers while still reaching zero actual devices. The code was treating message creation as proof of delivery, which is not the same thing at all. The fix involved polling OneSignal's delivery-s

2026-07-05 原文 →
AI 资讯

From MVP to Enterprise: Architecting AI APIs That Don't Fail at 3AM

From MVP to Enterprise: Architecting AI APIs That Don't Fail at 3AM I've been on-call for enough production incidents to know that the difference between a startup's AI integration and an enterprise one isn't just budget. It's everything downstream — your p99 latency, your failover story, the size of your blast radius when a provider has a bad Tuesday. Most guides lump these two worlds together and that's exactly why teams end up rearchitecting at the worst possible moment. Let me walk you through how I think about it now, after spending years shipping LLM-backed services for both early-stage teams and Fortune 500 procurement departments. The short version: I almost always route through Global API, and the tier I pick depends entirely on what keeps me up at night. The Question Nobody Asks First: What Breaks When? When I sit down with a founder, the conversation usually starts with "which model should we use?" That's the wrong first question. The right first question is: what's your tolerance for a 3 a.m. page? If you're a seed-stage startup with a handful of users, your answer is probably "none, but I'll deal with it." If you're a publicly traded company processing loan applications, your answer is "I need a 99.9% SLA in writing, multi-region failover, and a support escalation path that doesn't start with a Discord server." Those two answers produce two completely different architectures. Let me show you what I mean. The Startup Reality: Speed and Optionality Here's the dirty secret about direct provider integration for startups: it feels free, and then it isn't. I watched a team burn six weeks trying to wire up DeepSeek's API directly. They needed a Chinese phone number for verification, an Alipay or WeChat account for payment, and they were stuck the moment they wanted to A/B test against Qwen or another model. Their CTO told me afterward, "We spent a sprint on payment infrastructure before we shipped a single feature." That pain compounds. Every new model is a ne

2026-07-05 原文 →
AI 资讯

Any tips?

I’ve started working on my own Selfhosting Cloud Service, 2 Weeks work to get the basics done. Programming in Golang, understanding Docker, Caddy and how to use a terminal to do commands 😅 I’ve included AES-256 decryption for datas, a license key to check if a license is valid. Its own right-wing administration. All in one to install all dependencies at install. Any idea what could add more safety, or features I didn’t planned myself actually? submitted by /u/CaptainPM-Ger [link] [留言]

2026-07-05 原文 →
AI 资讯

The Beginner App Idea Checklist Before You Ask AI To Code In 2026

The most dangerous moment in an AI-built app project is not when the code breaks. It is earlier. It is the moment where your idea is still blurry, the AI coding tool is sitting there politely, and you type: Build me an app that... That sentence feels productive. It also gives the tool permission to make a pile of decisions you have not made yet. Who is the app for? What is version one? Which workflow matters first? What data has to exist? What should not be built yet? What would make the first version successful? If those answers are missing, AI has to guess. And AI guessing at product shape is how beginners end up with a login system, dashboard, profile editor, notifications panel, admin area, billing flow, and settings page before one real user problem has been solved. That is not momentum. That is software confetti. I like AI coding tools. I use them heavily in real app work. But the tool gets much better when the project has boundaries before code starts changing. So before you ask AI to code your first app, run the idea through a checklist. Not a giant business plan. Not a pitch deck. Not a 47-tab spreadsheet that makes you feel like you joined a corporate strategy retreat by accident. A practical beginner checklist. The goal is simple: turn a rough app idea into something AI can help you build without inventing the whole product for you. 1. Can You Name The Person? Do not start with "users." Start with one person you can picture. Bad: This app is for people who want to be more productive. Better: This app is for freelance designers who need one place to track client feedback, revision status, and final file delivery. Bad: This app is for musicians. Better: This app is for guitarists who want to capture riff ideas quickly on their phone without opening a full mobile studio app. Bad: This app is for students. Better: This app is for college students who want to scan textbook chapters and turn them into study notes before an exam. When you name the person, the ap

2026-07-05 原文 →
AI 资讯

Structuring a Senior Data Scientist Resume After a Chinese SOE Tenure

Why Your SOE Resume Needs a Structural Overhaul Chinese state-owned enterprises (SOEs) often have deep hierarchical structures and a culture of collective achievement. But Western tech companies want to see individual impact, autonomy, and data-driven results. Continuing to lead with your former employer's prestige or your rank (e.g., "Senior Engineer Grade 7") wastes valuable space. The solution: reshape every section to answer the question "What did you personally accomplish with data?" The Core Shift: From Hierarchy to Impact In a Chinese SOE resume, it's tempting to list departments you led or teams you oversaw. In a Western senior data scientist resume, focus on the problems you defined, the algorithms you deployed, and the revenue, cost savings, or user metrics that improved. For example, instead of "Led the data analytics team of 10 people," write "Designed and deployed a demand-forecasting model that reduced inventory costs by 15% (¥12M annually)." Three Resume Sections That Require Full Rewriting Professional Summary: From 'Accomplished Engineer' to 'Data Science Leader' Start with your total years of experience, your technical stack, and the types of business problems you solve. Example: "Senior Data Scientist with 10+ years applying machine learning to supply chain and logistics. Expertise in Python, TensorFlow, and Spark. Reduced operational costs by 15-30% through predictive models deployed at [SOE name]." Work Experience: From Role Descriptions to Metric-Driven Bullets For each role, list 3-5 bullets. Every bullet should have a verb, a task, a technology (if relevant), and a quantified result. Avoid vague phrases like "responsible for." Use specific numbers: "Improved forecast accuracy from 70% to 85% by building an ensemble of ARIMA and XGBoost models." Education & Certifications: Emphasize Transferable Skills Your Chinese degree is fine, but add relevant certifications (AWS, TensorFlow, Coursera) to show adaptability. Consider a "Technical Skills" se

2026-07-04 原文 →
AI 资讯

Why Good Developers Write Less Code, Not More

A few years into my career, I went back to a project I'd built solo about eighteen months earlier. I was proud of it at the time. It had a custom state management solution, several layers of abstraction, a utility library I'd assembled myself, and what I distinctly remember thinking of as "a robust architecture." Reading through it again, I spent twenty minutes just trying to understand why I'd built a particular module the way I had. The logic was split across four files. There were abstractions on top of abstractions. Two functions did nearly the same thing with slightly different names. A third was never called anywhere. The worst part wasn't the code itself. It was realizing that a simpler version, one I could have written in a day instead of a week, would have done exactly the same thing with a fraction of the complexity. That experience changed how I think about software development more than any course, book, or conference ever did. Writing less code, genuinely less, often requires more thinking than writing more. And the developers who figure that out early tend to produce work that holds up significantly better over time. Why More Code Doesn't Mean Better Code There's a belief that's easy to absorb early in a development career, that skill shows up in volume. More features, more files, more clever solutions. A complex system feels like proof that something serious was built here. That feeling is almost entirely wrong. More code means more surface area for bugs. Every line is a line that can break, a line that needs to be read, a line that needs to be tested, a line that a new team member has to understand before they can confidently change anything. None of those costs are trivial, and they compound. Complexity hides bugs. A simple function with one responsibility is easy to test and easy to debug. A function that does five things, or calls three other functions that each do three things, creates a web of possible failure points that's genuinely difficult t

2026-07-04 原文 →
AI 资讯

Data structures your CS degree kind of glossed over

Hello, I'm Maneshwar. I'm building git-lrc, a Micro AI code reviewer that runs on every commit. It is free and source-available on Github. Star git-lrc to help devs discover the project. Do give it a try and share your feedback. Every CS program hammers the same seven into you. Arrays, linked lists, hash tables, stacks, queues, graphs, trees. You could probably recite their Big O complexities in your sleep at this point, and honestly, for 90% of the code you'll ever write, that's plenty. But every now and then a system hits a wall that none of the seven basics can handle gracefully, and someone had to invent a weirder tool to patch the gap. I went down a rabbit hole recently looking at a handful of these, and I liked them enough that I wanted to write them up properly instead of just leaving forty open tabs to rot. Fair warning, there is some depth here. Get a drink. When your hash table can't promise you a fast answer: Bloom filters Normal hash tables are great until you need to ask "have I possibly seen this before" across a dataset way too big to store in memory. Think a crawler checking billions of URLs, or a database deciding whether it's even worth going to disk to look for a row. A Bloom filter solves this by giving up on certainty in one direction. It's a fixed array of bits, plus a small handful of independent hash functions. Adding an item flips a handful of bits on. Checking for an item hashes it the same way and checks whether those same bits are on. If any single bit is off, that item was never added, full stop, no ambiguity. If they're all on, the item was probably added, but two unrelated items can accidentally light up the same bits, so you might get a false alarm. The asymmetry is the entire design. Zero false negatives, occasional false positives. It's the data structure equivalent of a metal detector at a stadium gate. It'll never wave through someone with a knife, but it might beep at your belt buckle and make you empty your pockets for nothing.

2026-07-04 原文 →