<?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 Harry, Hsiao on Medium]]></title>
        <description><![CDATA[Stories by Harry, Hsiao on Medium]]></description>
        <link>https://medium.com/@harryhsiao0214?source=rss-5c549ba49dd9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*99iHQDRQa-qi_BUg</url>
            <title>Stories by Harry, Hsiao on Medium</title>
            <link>https://medium.com/@harryhsiao0214?source=rss-5c549ba49dd9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 21:50:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@harryhsiao0214/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[Learning Rust #2 — My Code Works, So Why Is Rust Still Complaining?]]></title>
            <link>https://medium.com/@harryhsiao0214/learning-rust-2-my-code-works-so-why-is-rust-still-complaining-48af5aa0eb87?source=rss-5c549ba49dd9------2</link>
            <guid isPermaLink="false">https://medium.com/p/48af5aa0eb87</guid>
            <category><![CDATA[compilers]]></category>
            <category><![CDATA[rust-programming-language]]></category>
            <category><![CDATA[learning-rust]]></category>
            <category><![CDATA[lint]]></category>
            <category><![CDATA[rust]]></category>
            <dc:creator><![CDATA[Harry, Hsiao]]></dc:creator>
            <pubDate>Sun, 13 Sep 2026 16:00:09 GMT</pubDate>
            <atom:updated>2026-09-13T16:00:09.197Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How a small naming warning led me to Rust’s lint system, compiler diagnostics, and the strange fact that a warning can become an error.</em></p><p>While learning Rust, I wrote a perfectly ordinary function:</p><pre>fn interProduct(a: i32, b: i32) -&gt; i32 {<br>    a * b<br>}</pre><pre>fn main() {<br>    println!(&quot;{}&quot;, interProduct(3, 4));<br>}</pre><p>The program compiled. It ran. It printed the correct answer.</p><p>And Rust still complained:</p><pre>warning: function `interProduct` should have a snake case name<br> --&gt; src/main.rs:1:4<br>  |<br>1 | fn interProduct(a: i32, b: i32) -&gt; i32 {<br>  |    ^^^^^^^^^^^^ help: convert the identifier to snake case: `inter_product`</pre><p>My first reaction was simple:</p><p><strong>If my code is valid and works correctly, why does the compiler care what I call my function?</strong></p><p>That small warning turned out to be a good introduction to a much larger part of Rust: <strong>lints, compiler diagnostics, and the distinction between code that is invalid and code that is merely suspicious or unconventional.</strong></p><h3>Error vs. Warning</h3><p>Let’s start with the obvious distinction.</p><p>Consider:</p><pre>fn main() {<br>    let x: i32 = &quot;hello&quot;;<br>}</pre><p>This is not valid Rust.</p><p>We are trying to assign a string to a variable whose type is i32. The compiler cannot simply ignore this and produce a correct program.</p><p>So we get an <strong>error</strong>, and compilation fails.</p><p>But this:</p><pre>fn interProduct(a: i32, b: i32) -&gt; i32 {<br>    a * b<br>}</pre><p>is different.</p><p>There is nothing fundamentally ambiguous or unsafe about calling a function interProduct.</p><p>Rust understands the function perfectly well.</p><p>The problem is that Rust’s naming convention expects function names to use <strong>snake_case</strong>:</p><pre>fn inter_product(a: i32, b: i32) -&gt; i32 {<br>    a * b<br>}</pre><p>So instead of rejecting the program, the compiler gives us a warning.</p><p>A useful first approximation is:</p><pre>Error<br>→ The compiler cannot accept the program.<br>→ Compilation fails.</pre><pre>Warning<br>→ The program is still valid.<br>→ Compilation can continue.<br>→ But the compiler found something worth our attention.</pre><p>That last sentence is where things become interesting.</p><h3>Why snake_case?</h3><p>There are several common naming styles in programming:</p><pre>snake_case<br>inter_product</pre><pre>camelCase<br>interProduct</pre><pre>PascalCase<br>InterProduct</pre><pre>SCREAMING_SNAKE_CASE<br>MAX_BUFFER_SIZE</pre><p>Rust uses different conventions for different kinds of identifiers.</p><p>Functions and variables normally use snake_case:</p><pre>fn calculate_total() {}</pre><pre>let user_name = &quot;Harry&quot;;</pre><p>Types such as structs, enums, and traits normally use PascalCase:</p><pre>struct UserAccount {}</pre><pre>enum Direction {<br>    Up,<br>    Down,<br>}</pre><pre>trait Printable {}</pre><p>Constants normally use SCREAMING_SNAKE_CASE:</p><pre>const MAX_BUFFER_SIZE: usize = 1024;</pre><p>These conventions are not necessary for the compiler to understand our program.</p><p>Instead, they create consistency.</p><p>When most Rust programs follow the same conventions, <strong>names themselves carry a little information about what we are looking at</strong>, and code written by different developers feels more familiar.</p><p>This is also why Rust can recommend:</p><pre>interProduct<br>     ↓<br>inter_product</pre><p>without claiming that the original program is invalid.</p><h3>This Warning Has a Name</h3><p>The compiler is not just producing an arbitrary message.</p><p>The warning comes from Rust’s <strong>lint system</strong>.</p><p>If we look closely at the complete diagnostic, we can see:</p><pre>= note: `#[warn(non_snake_case)]` on by default</pre><p>non_snake_case is the name of a <strong>lint</strong>.</p><p>A lint checks for a coding pattern that may be undesirable even though the program itself can still be valid.</p><p>For example, consider:</p><pre>fn main() {<br>    let x = 10;<br>}</pre><p>x is never used.</p><p>Rust may warn:</p><pre>warning: unused variable: `x`</pre><p>Again, the program is valid.</p><p>The compiler knows exactly what x is.</p><p>But it asks us to look at it because an unused variable might indicate that we forgot something, made a mistake, or simply left unnecessary code behind.</p><h3>Let’s Make Rust Complain a Little More</h3><p>I modified the program:</p><pre>fn interProduct(a: i32, b: i32) -&gt; i32 {<br>    a * b<br>}</pre><pre>fn main() {<br>    let unusedValue = 10;</pre><pre>    println!(&quot;{}&quot;, interProduct(3, 4));<br>}</pre><p>Then I ran:</p><pre>cargo check</pre><p>Rust reported three warnings.</p><p>The first was about the unused variable:</p><pre>warning: unused variable: `unusedValue`</pre><pre>help: if this is intentional, prefix it with an underscore:<br>`_unusedValue`</pre><p>The second was our original naming warning:</p><pre>warning: function `interProduct` should have a snake case name</pre><pre>help: convert the identifier to snake case:<br>`inter_product`</pre><p>And the third:</p><pre>warning: variable `unusedValue` should have a snake case name</pre><pre>help: convert the identifier to snake case:<br>`unused_value`</pre><p>Rust does not merely say it is wrong.</p><p>It tells us what it noticed, points to the exact location, identifies the relevant lint, and often suggests what we can do instead.</p><p>For the unused variable, it even recognizes that the variable might be intentionally unused:</p><pre>help: if this is intentional, prefix it with an underscore</pre><p>In other words, the diagnostic is not only reporting a problem.</p><p>It is trying to communicate <strong>why the compiler is concerned and what our options are</strong>.</p><h3>Note: What Is cargo check?</h3><p>I used:</p><pre>cargo check</pre><p>instead of:</p><pre>cargo run</pre><p>because I did not actually need to execute the program.</p><p>cargo check checks whether the project can compile and reports diagnostics without going through all the work needed to produce the final executable.</p><p>That generally makes it useful during development when the question is simply:</p><blockquote><em>“Does my code still compile, and what is the compiler unhappy about?”</em></blockquote><p>For a small program, the difference may barely matter.</p><p>For a larger project, cargo check can become a very convenient part of the development loop.</p><h3>Warnings Are Configurable</h3><p>Here is where Rust’s lint system becomes more interesting.</p><p>Suppose I know that I intentionally want this function to be called interProduct.</p><p>I can write:</p><pre>#[allow(non_snake_case)]<br>fn interProduct(a: i32, b: i32) -&gt; i32 {<br>    a * b<br>}</pre><p>#[allow(...)] changes the level of a lint.</p><p>Here, I am essentially telling Rust:</p><blockquote><em>I know this violates the usual naming convention. Don’t warn me about it here.</em></blockquote><p>Rust has several lint levels, including:</p><pre>allow<br>warn<br>deny<br>forbid</pre><p>For now, the first three are the most useful to understand.</p><p>allow suppresses the diagnostic.</p><p>warn reports the problem as a warning but allows compilation to continue.</p><p>deny treats a violation of that lint as an error.</p><p>And that leads to an interesting experiment.</p><h3>Turning Warnings Into Errors</h3><p>I added one line to the top of the program:</p><pre>#![deny(warnings)]</pre><pre>fn interProduct(a: i32, b: i32) -&gt; i32 {<br>    a * b<br>}</pre><pre>fn main() {<br>    let unusedValue = 10;</pre><pre>    println!(&quot;{}&quot;, interProduct(3, 4));<br>}</pre><p>Then I ran:</p><pre>cargo check</pre><p>This time:</p><pre>error: unused variable: `unusedValue`</pre><p>and:</p><pre>error: function `interProduct` should have a snake case name</pre><p>and:</p><pre>error: variable `unusedValue` should have a snake case name</pre><p>Finally:</p><pre>error: could not compile `exercise`<br>due to 3 previous errors</pre><p>The code had not fundamentally changed.</p><p>The same three patterns that were warnings before were now errors.</p><p>Because of:</p><pre>#![deny(warnings)]</pre><p>The compiler even explains this:</p><pre>= note: `#[deny(unused_variables)]`<br>  implied by `#[deny(warnings)]`</pre><p>The underlying code pattern did not suddenly become syntactically invalid.</p><p>We changed the project’s policy about how seriously that lint should be treated.</p><h3>What Is #[...]?</h3><p>At this point, another piece of Rust syntax appears:</p><pre>#[allow(non_snake_case)]</pre><p>This is an <strong>attribute</strong>.</p><p>Attributes attach additional metadata or instructions to parts of a Rust program.</p><p>You will see them everywhere:</p><pre>#[test]</pre><pre>#[derive(Debug)]</pre><pre>#[allow(dead_code)]</pre><p>The form:</p><pre>#[...]</pre><p>usually applies to the item that follows it.</p><p>For example:</p><pre>#[allow(non_snake_case)]<br>fn interProduct() {}</pre><p>But our earlier example used:</p><pre>#![deny(warnings)]</pre><p>Notice the !. This is an <strong>inner attribute</strong>, which applies to the enclosing scope rather than simply the next item.</p><p>At the top of main.rs:</p><pre>#![deny(warnings)]</pre><p>effectively establishes that lint policy for the crate.</p><p>For now, the important point is not memorizing every kind of attribute.</p><p>It is recognizing this syntax when it appears:</p><pre>#[...]<br>#![...]</pre><p>Rust uses attributes extensively to express additional compiler-facing information.</p><h3>A Warning Does Not Mean the Compiler Is Always Right</h3><p>There is another side to this.</p><p>If Rust gives us a warning, that does not necessarily mean:</p><blockquote><em>“You must change this code.”</em></blockquote><p>Sometimes there is a legitimate reason to violate a convention.</p><p>We may be interacting with an external API, generated code, an FFI boundary, an existing naming scheme, or some other constraint outside our control.</p><p>That is why Rust gives us tools such as:</p><pre>#[allow(non_snake_case)]</pre><p>instead of making every convention part of the language grammar.</p><h3>The Compiler as More Than a Gatekeeper</h3><p>A compiler obviously has to reject programs that violate the language rules.</p><p>But Rust’s compiler diagnostics also do something else.</p><p>They frequently try to explain what happened and guide us toward a possible solution.</p><p>For example:</p><pre>warning: unused variable: `unusedValue`</pre><p>is followed by:</p><pre>help: if this is intentional,<br>prefix it with an underscore: `_unusedValue`</pre><p>And:</p><pre>warning: function `interProduct`<br>should have a snake case name</pre><p>is followed by:</p><pre>help: convert the identifier to snake case:<br>`inter_product`</pre><p>This is not an accident.</p><p><a href="https://rustc-dev-guide.rust-lang.org/diagnostics.html">Rust’s official documentation</a> repeatedly emphasizes working alongside the compiler and learning from its diagnostics. <a href="https://doc.rust-lang.org/book/ch00-00-introduction.html">The Rust Book</a> describes compiler errors as something that can guide developers toward working code, rather than merely obstacles that stop compilation.</p><p>That does not mean the Rust compiler can guarantee that our code is “good.” It cannot tell us whether our architecture makes sense, whether our algorithm is appropriate, or whether our variable names actually communicate the right ideas.</p><p>But through lints and diagnostics, it can identify many patterns that are suspicious, inconsistent, or non-idiomatic and ask us to take another look.</p><h3>And Then There Is Clippy</h3><p>Rust takes this idea even further with <strong>Clippy</strong>.</p><p>You can run:</p><pre>cargo clippy</pre><p>Clippy is Rust’s official collection of additional lints.</p><p>While rustc already catches many suspicious patterns, Clippy checks for a much wider range of code that may be unnecessarily complicated, inefficient, or less idiomatic than it could be.</p><p>For example, imagine writing:</p><pre>if x == true {<br>    println!(&quot;yes&quot;);<br>}</pre><p>A linter can point out that this could simply be:</p><pre>if x {<br>    println!(&quot;yes&quot;);<br>}</pre><p>Neither version is fundamentally invalid.</p><p>The point is to help us notice opportunities to write clearer Rust.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=48af5aa0eb87" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learning Rust #1 — Why Did --release Make My Program 50,000× Faster?]]></title>
            <link>https://medium.com/@harryhsiao0214/learning-rust-1-why-did-release-make-my-program-50-000-faster-32d9467af9da?source=rss-5c549ba49dd9------2</link>
            <guid isPermaLink="false">https://medium.com/p/32d9467af9da</guid>
            <category><![CDATA[compilers]]></category>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[compiler-optimization]]></category>
            <category><![CDATA[rust-programming-language]]></category>
            <category><![CDATA[learning-rust]]></category>
            <dc:creator><![CDATA[Harry, Hsiao]]></dc:creator>
            <pubDate>Sat, 12 Sep 2026 15:11:57 GMT</pubDate>
            <atom:updated>2026-09-12T15:11:57.377Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently learning Rust with <a href="https://google.github.io/comprehensive-rust/index.html">Google’s <em>Comprehensive Rust</em> course</a>.</p><p>While going through the basics, I noticed something that looked simple at first:</p><pre>cargo run</pre><p>and</p><pre>cargo run --release</pre><p>I knew that --release was supposed to make programs faster.</p><p>But what does “release” actually mean? What is Rust doing differently?</p><p>So I decided to run a small experiment.</p><p>It ended with a billion-iteration loop disappearing completely.</p><h3>Debug and Release Builds</h3><p>When we run a Rust project with:</p><pre>cargo run</pre><p>Cargo prints something similar to:</p><pre>Finished `dev` profile [unoptimized + debuginfo]<br>Running `target/debug/exercise`</pre><p>There are two interesting words here:</p><pre>unoptimized + debuginfo</pre><p>By default, cargo run uses Cargo&#39;s <strong>development (</strong><strong>dev) profile</strong>.</p><p>During development, we usually care about things such as fast compilation and useful debugging information. We are constantly repeating a cycle like:</p><pre>write code → compile → run → find a bug → modify code → compile again</pre><p>Spending extra time heavily optimizing every build would often slow down this workflow.</p><p>When we run:</p><pre>cargo run --release</pre><p>the output changes:</p><pre>Finished `release` profile [optimized]<br>Running `target/release/exercise`</pre><p>This time Cargo uses the <strong>release profile</strong>, where compiler optimization is enabled much more aggressively.</p><p>The basic idea is simple: when we run cargo run, Cargo uses the <strong>development (</strong><strong>dev) profile</strong> and places the compiled program under target/debug/. This profile uses little optimization, which usually means faster compilation but slower runtime performance. In contrast, cargo run --release uses the <strong>release profile</strong> and places the executable under target/release/. The compiler performs much more aggressive optimization in this mode, so compilation may take longer, but the resulting program will usually run faster.</p><p>So far, nothing too surprising.</p><p>Then I tried measuring the difference.</p><h3>A Billion Additions</h3><p>I wrote a simple program that adds the integers from 0 to 999,999,999:</p><pre>use std::time::Instant;<br>fn main() {<br>    let start = Instant::now();<br>    let mut sum: u64 = 0;<br>    for i in 0..1_000_000_000 {<br>        sum = sum.wrapping_add(i);<br>    }<br>    println!(&quot;sum = {sum}&quot;);<br>    println!(&quot;time = {:?}&quot;, start.elapsed());<br>}</pre><p>Here, wrapping_add performs integer addition with wrapping behavior if an overflow occurs. Overflow is not actually reached in this example, so normal addition would work as well.</p><p>I first ran:</p><pre>cargo run</pre><p>and got:</p><pre>sum = 499999999500000000<br>time = 4.3996875s</pre><p>About <strong>4.4 seconds</strong>.</p><p>Then I tried:</p><pre>cargo run --release</pre><p>and got:</p><pre>sum = 499999999500000000<br>time = 84.875µs</pre><p>Wait. <strong>4.4 seconds versus 85 microseconds?</strong></p><p>That is roughly a <strong>50,000× difference</strong>.</p><p>Rust is fast, but surely enabling compiler optimization does not magically make one billion additions 50,000 times faster.</p><p>Something else had happened.</p><h3>The Compiler Doesn’t Have to Execute the Code You Wrote</h3><p>When we see this:</p><pre>for i in 0..1_000_000_000 {<br>    sum = sum.wrapping_add(i);<br>}</pre><p>we naturally imagine the computer doing something like:</p><pre>sum += 0<br>sum += 1<br>sum += 2<br>sum += 3<br>...<br>sum += 999999999</pre><p>In other words, one billion loop iterations.</p><p>But there is an important distinction: <strong>The source code we write is not the code the CPU eventually executes.</strong></p><p>Our Rust source code goes through a compiler:</p><pre>Rust source code<br>        ↓<br>     Compiler<br>        ↓<br>Optimized machine code<br>        ↓<br>       CPU</pre><p>As long as the observable behavior of the program remains correct, the optimizer is free to transform the implementation.</p><p>For example:</p><pre>let x = 10 * 20;</pre><p>does not necessarily mean the CPU needs to perform a multiplication at runtime.</p><p>The compiler can simply generate code equivalent to:</p><pre>let x = 200;</pre><p>Our billion-iteration loop turned out to be a much more dramatic example of the same idea.</p><h3>Let’s Look at the Assembly</h3><p>Instead of guessing what happened, we can ask Rust to generate assembly:</p><pre>cargo rustc --release -- --emit asm</pre><p>On my Apple Silicon Mac, this produces ARM64 assembly under:</p><pre>target/release/deps/</pre><p>Looking at the assembly generated for my Rust main, I found this:</p><pre>mov     x8, #39680<br>movk    x8, #46564, lsl #16<br>movk    x8, #23385, lsl #32<br>movk    x8, #1776, lsl #48<br>str     x8, [sp, #8]</pre><p>Something is missing. There is no obvious loop.</p><p>We do not see the usual pattern of:</p><pre>add<br>compare<br>branch back</pre><p>that we would expect from repeatedly executing a loop.</p><p>Instead, the compiler is constructing a 64-bit constant inside the x8 register.</p><p>The four pieces correspond to:</p><pre>39680<br>+ (46564 &lt;&lt; 16)<br>+ (23385 &lt;&lt; 32)<br>+ (1776 &lt;&lt; 48)</pre><p>And the result?</p><pre>499999999500000000</pre><p>Exactly the value printed by the program.</p><p>The compiler had effectively transformed:</p><pre>let mut sum: u64 = 0;</pre><pre>for i in 0..1_000_000_000 {<br>    sum = sum.wrapping_add(i);<br>}</pre><p>into something conceptually similar to:</p><pre>let sum: u64 = 499_999_999_500_000_000;</pre><p><strong>The billion-iteration loop was gone.</strong></p><p>The release version was not executing the same billion additions much faster.</p><p>It simply did not need to execute them at all.</p><h3>Making the Compiler Actually Do the Work</h3><p>This also reveals a common problem when writing small performance experiments.</p><p>Compilers are smart.</p><p>If a benchmark contains a computation whose result can be determined or simplified ahead of time, the optimizer may remove the work we thought we were measuring.</p><p>Rust provides std::hint::black_box for situations like this.</p><p>I modified the experiment:</p><pre>use std::hint::black_box;<br>use std::time::Instant;</pre><pre>fn main() {<br>    let start = Instant::now();</pre><pre>    let n = black_box(1_000_000_000_u64);</pre><pre>    let mut sum = 0_u64;</pre><pre>    for i in 0..n {<br>        sum = black_box(sum.wrapping_add(i));<br>    }</pre><pre>    println!(&quot;sum = {sum}&quot;);<br>    println!(&quot;time = {:?}&quot;, start.elapsed());<br>}</pre><p>You can roughly think of black_box as telling the optimizer:</p><blockquote><em>Don’t assume too much about this value. The computation really matters.</em></blockquote><p>This is not a magical “disable optimization” function, but it can prevent certain optimizations that would otherwise make a small benchmark meaningless.</p><p>I ran the experiment again.</p><p>Development build:</p><pre>sum = 499999999500000000<br>time = 4.642401292s</pre><p>Release build:</p><pre>sum = 499999999500000000<br>time = 1.788744209s</pre><p>Now we get:</p><pre>dev       ≈ 4.64 s<br>release   ≈ 1.79 s</pre><p>The release build is still about <strong>2.6× faster</strong>, but this is very different from the original 50,000× result.</p><p>This time, we are much closer to measuring the performance difference between optimized and unoptimized code rather than accidentally measuring the optimizer’s ability to eliminate our benchmark.</p><h3>So What Exactly Is a Build Profile?</h3><p>At this point, “debug versus release” becomes easier to understand.</p><p>They are not two different versions of Rust.</p><p>Cargo uses <strong>build profiles</strong>, which are collections of compiler settings for different situations.</p><p>The two profiles beginners encounter most often are:</p><pre>dev profile<br>    │<br>    ├── cargo build<br>    ├── cargo run<br>    └── target/debug/</pre><pre>release profile<br>    │<br>    ├── cargo build --release<br>    ├── cargo run --release<br>    └── target/release/</pre><p>These profiles can be configured in Cargo.toml.</p><p>For example:</p><pre>[profile.dev]<br>opt-level = 0</pre><pre>[profile.release]<br>opt-level = 3</pre><p>opt-level controls the optimization level used by the compiler.</p><p>The development profile prioritizes a convenient development cycle, while the release profile spends more effort optimizing the generated program for execution.</p><p>This also means that “debug” does <strong>not</strong> mean:</p><pre>a version of the program that contains bugs</pre><p>and “release” does not mean:</p><pre>the version after all bugs have been fixed</pre><p>They are simply different sets of build settings designed for different purposes.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32d9467af9da" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[從優式發掘優勢]]></title>
            <link>https://medium.com/@harryhsiao0214/%E5%BE%9E%E5%84%AA%E5%BC%8F%E7%99%BC%E6%8E%98%E5%84%AA%E5%8B%A2-6532e06a1c83?source=rss-5c549ba49dd9------2</link>
            <guid isPermaLink="false">https://medium.com/p/6532e06a1c83</guid>
            <category><![CDATA[實習生]]></category>
            <category><![CDATA[優式資本]]></category>
            <category><![CDATA[實習心得]]></category>
            <category><![CDATA[uc-capital]]></category>
            <dc:creator><![CDATA[Harry, Hsiao]]></dc:creator>
            <pubDate>Sat, 16 Aug 2025 08:37:06 GMT</pubDate>
            <atom:updated>2025-08-16T08:37:06.058Z</atom:updated>
            <content:encoded><![CDATA[<p>在優式資本實習的一個月 - 優式AI量化新星計畫 2025</p><p>筆者過去在上學時就對於量化交易產業略有耳聞，而當時有名的大多是國外的公司（例如 Jane Street , Optiver 等），而台灣公司則有 Kronos , 優式資本等。在六月中旬時看到優式在招 AI 實習生，且開出了蠻具有競爭力的薪水，加上本身蠻想多了解這個產業的生態，於是就來應徵看看。後來也有幸參與了實際計畫。</p><p>在優式資本的時間過得飛快，轉眼間已到尾聲。在此想紀錄這一個月的點點滴滴，以下就針對實習內容、實習生活及 <strong><em>隱藏轉職 </em></strong>三個面相分享。</p><h3>新手村-始於 AI 實習生</h3><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — -</p><p>在計劃一開始， mentors 先是介紹了貫穿這次實習的題目，我們基本上就是試著利用統計、機器學習、深度學習等方法試著解題（可想像成 kaggle 競賽）。同時公司也找讓我們每週上兩小時的機器學習過程，讓我們能補足對機器學習知識的不足。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dzyNXfXlVlBI_4VY_zL0bQ.png" /><figcaption>類似 kaggle 的計分介面</figcaption></figure><p>由於我們有各自的分組，基本上我們大多與組員討論並且撰寫特定程式碼，提交後討論結果，隨後改進策略等等。（循環 * n）</p><p>在實習的中後段，隨著 mentor 的指示我們開始有更多的跨組討論，筆者組成了 8 人團隊，由於團隊人手變多我們開始針對題目有更細緻的討論及分工，同時讓團隊成果更加多元（筆者在此十分感謝我的組員們）。但隨著我們深入探討題目本身，我們發現題目本身出題有些許瑕疵。在 mentor 的「暗示」下，我們開始自己創造題目，接著自己解題。</p><p>想要在此強調的是，我們所做之事正符合優式對我們的期待：發揮創造力。</p><h3>打怪升等-在 101 的實習生活</h3><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — -</p><p>在優式的實習期間，我們的主要行程有上課、實作、夥伴分享等內容。每天早上九點進公司後，通常會有半天有活動（例如上課），剩餘半天則是小組團隊的實作時間，中午則有 1 ~ 1.5 小時的休息時間。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j4VX-uzaclWtTjP7g_ghKg.png" /><figcaption>辦公室窗外風景</figcaption></figure><p>每天的下班時間為 17:00 ~ 18:00，通常在每週二、四會到 18:00 下班，這是由於每週三、五是各組的發表時間，這時候 mentor 就會適時的給我們未來建議。</p><p>筆者認為實習期間 mentor 在發表時間的建議讓我收穫良多，mentor 能夠精準的分析我們目前的處境，同時肯定我們的努力及提點我們未來的方向。讓我們在實習期間少走了許多彎路，也對未來的職涯有更清楚的規劃。</p><p>在優式上班的節奏並不慢，反而是充實且有趣。在專案期間需要耗費大量的心力，但與組員間的良性互動往往是專案開發的精髓，我想這就是「一個人走得快，一群人走的遠」的道理。過程中很幸運的是每一位正職員工都願意分享他們的建議、經驗（正職員工的親切程度令筆者感到不適應 xdd），讓我們能夠快速成長。</p><h3>隱藏轉職-從 AI 到系統開發</h3><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — -</p><p>在優式實習的時間， mentor 會主動與每個人單獨談話，談話內容並不侷限，可以聊聊公司文化、職涯發展、甚至是職場心得等話題。而我趁機提出想要參與公司的系統開發（同時被 mentor 識破我對 AI 並沒有高度興趣xd）。</p><p>所以最後一個禮拜就觸發轉職機制，我就與公司的同仁一起研究較為前研的資料探索，同時寫了幾支看起來有點用的程式。在這期間參與了一次員工訓練，學習業界對於 coding 的規範與要求，也同時明白我還有什麼可以精進的地方。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dhutb-UaHYyUHASHbxMzPA.png" /><figcaption>附上最後一個禮拜在 饗 A Joy 聚餐的風景</figcaption></figure><h3>探索未來- 從學生邁向工程師</h3><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — -</p><p>我想在優式這段時間學到最多的並不是豐富的 AI 知識，也不是深度的金融知識。而是對於了解職場文化，同時培養我們從一介學生成為一個好員工的過程。</p><p>透過近距離觀察每位正職員工、 mentor 的提醒，都能讓我對於「工作態度」上有更清晰的認知。我想這是在優式最寶貴的價值，也是給初入社會的我們一盞明燈。</p><p>最後，感謝優式給我這個機會參與實習計畫，期待未來延續這段緣分！</p><h3>歡迎各位冒險者-致未來有興趣的人們</h3><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — -</p><p>末尾驚喜！筆者想要感謝每一個讀到最後的讀者，也想給每一個對於量化交易產業有興趣的人們一些小建議。</p><p>量化產業並不是一個輕鬆的行業，行業裡工時長、壓力大是常態，唯有抱持著高度的熱忱才能勝任行業裡的工作。同時，這個產業也是高度成長的產業，工作機會俯拾皆是。我想讀者們若是對於金融、科技等相關領域有所涉略且有興趣，或許嘗試一番未嘗不可。</p><p>對於想要應徵優式資本職位的讀者們，我想公司最在意的是「態度」，對於每一位實習生、新人，公司看中的是「未來潛力」，拿出 120% 的幹勁是最有力的加分項。同時誠如 Steve Jobs 所言：「Stay hungry. Stay foolish.」，不斷學習、不斷進步才是優式在行業浪尖站穩腳步的關鍵。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6532e06a1c83" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[《 不當行為》讀後心得]]></title>
            <link>https://medium.com/@harryhsiao0214/%E4%B8%8D%E7%95%B6%E8%A1%8C%E7%82%BA-%E8%AE%80%E5%BE%8C%E5%BF%83%E5%BE%97-fcd8f7d91ab2?source=rss-5c549ba49dd9------2</link>
            <guid isPermaLink="false">https://medium.com/p/fcd8f7d91ab2</guid>
            <category><![CDATA[經濟學]]></category>
            <category><![CDATA[行為經濟學]]></category>
            <category><![CDATA[閱讀心得]]></category>
            <category><![CDATA[展望與回顧]]></category>
            <category><![CDATA[不當行為]]></category>
            <dc:creator><![CDATA[Harry, Hsiao]]></dc:creator>
            <pubDate>Tue, 08 Jul 2025 14:22:17 GMT</pubDate>
            <atom:updated>2025-07-08T14:22:17.774Z</atom:updated>
            <content:encoded><![CDATA[<p>筆者在六月時曾有幸獲得《 不當行為》一書，在六月下旬至七月上旬時把該書讀完。私認為整體內容豐富有趣，但故事章節的連貫性沒有那麼強烈，這其實也無可厚非，因為該書作者(理查．塞勒 , Richard H. Thaler)就是行為經濟學之父，所經歷的人生故事就是行為經濟學的發展。但筆者認為閱讀時章節之間稍顯雜亂，理查．塞勒應是以「自傳」方式著作，但筆者認為本書可分為兩個部分來討論：一為行為經濟學的理論發展（包含稟賦理論、展望理論等），二為行為經濟學這門學科的發展（筆者認為精髓是以孔恩之角度觀察），故本文章也會從這兩個角度切入</p><h3>一、行為經濟學理論發展</h3><p>本書在許多章節內都有理論介紹與舉例，但較為零散；故筆者將各個理論集中介紹，希望讓讀者們能夠快速查閱</p><ol><li>稟賦效應：人類更看重已擁有物品的價值，常人對於自身已經擁有的東西，會比「可能」擁有的東西（也就是有機會但尚未擁有的東西），要來得更加看重</li></ol><p>ex. 信用卡剛發行時，發卡機構與零售商會有不同的手續費。一般來說信用卡若是支付 1.03 美元，現金支付為 1 美元。中間相差的 3 美分可以被稱為「折扣」或是「額外費用」，理性經濟人對於這兩種稱呼其實並不會有任何的影響，但現實中的人們更傾向於接受「折扣」這個概念。這樣的效應是因為人們會認為支付額外費用是從口袋繼續掏錢，但沒能得到折扣只是損失概念飄渺的機會成本。</p><p>ex. 已經擁有馬克杯的人們會賦予馬克杯更高的價值，相較於未擁有馬克杯的人們約多一倍價值（符合價值函數圖表的預測）。</p><p>人們對於「擁有」物品的心態表現得相當快速，在幾分鐘內可能就會達成，而這樣快速達成的稟賦效應也被稱為「即刻稟賦效應」。</p><p>2. 展望理論：結合「稟賦效應」與「財富敏感度遞減」而成，可用下圖表示：</p><figure><img alt="展望理論" src="https://cdn-images-1.medium.com/max/433/0*Q2IpO9XLzI3Ju9VM.jpg" /><figcaption>價值函數圖表</figcaption></figure><p>我們可以看出常人的行為有幾項特點：</p><p>(1) 對於財富的變化呈現「敏感度遞減」。</p><p>(2) 對於額外的收入有著「風險規避」的傾向。</p><p>(3) 對於可能的支出且<strong>擁有機會翻平時，</strong>會有著「風險尋求」的傾向。（也可稱為翻本效應）</p><p>(4) 人們對於財富損失的厭惡比起相同程度收入的喜歡還要更加劇烈（約莫增加一倍），也被稱之為常人的「損失規避」效應</p><p>ex. 我們對於獲得第一次 1000 美元的喜悅程度與獲得第二次 1000 美元的喜悅程度並不相同，這是因為財富的變化在我們的心裡有著「敏感度遞減」的效應。</p><p>3. 韋伯-費希納定律：在心理學中描述「敏感度遞減」的定律。定義為「任何變項中的<strong>恰變差</strong>，會與該變項的量呈正比」，<strong>恰變差</strong>是指引發差別感受的最小改變量。通俗的說就是當某個變量越大時，常人對於這樣的變化會呈現敏感度遞減的效應。</p><p>ex. 我們比較會為了定價 45 元的商品開十分鐘的車去買折價 10 元的相同商品；但不會為了定價 450 元的商品這樣做。因為後者省下的錢還算不上<strong>恰變差。</strong></p><p>4. 獲得效用與交易效用：</p><p>(1) 獲得效用（消費者剩餘）：評估所獲得物品的效用 - 放棄的機會成本</p><p>(2) 交易效用：物品實際支付的價格 - 物品預期支付的價格 （消費者對這筆交易的感受）</p><p>ex. 我們可能在棉被特價時買了比所需尺寸更大的棉被，這是因為大棉被的交易效用較高</p><p>5. 沈沒成本謬誤：人們難以理解「沈沒成本」的觀念，常人會因為在意已經支付過的事物而做出不理性的舉動。</p><p>ex. 人們會因為已經支付室內網球場會員費，而選擇在手痛時仍舊去打球；因為他認為不該浪費自己已經繳的會員費。</p><p>6. 支付貶值：沈沒成本效應會隨著時間逐漸消失</p><p>ex. 某間俱樂部一年收兩次會員費，會員會在帳單出現後的一個月出席率陡然攀升，但會隨時間逐漸下降。</p><p>7. 心裡帳戶：每個人都有多個心理帳戶，常人會通過該心理帳戶進行各種各樣的經濟決策，通常會因爲金額的來源不同而歸類在不同的帳戶上。</p><p>ex. 人們會把工作換許的薪水放到「薪水」帳戶內，但卻會把年終獎放到「意外之財」帳戶內，並且更加願意使用「意外之財」帳戶內的金額進行消費。</p><p>ex. 賭客在賭博時常有「兩個口袋」的觀念，一個口袋代表成本，另一個則是多出來的金額；假設賭客只付了 300 元獲得了 500 元的酬勞，會將 200 元放入另一個口袋，並且認為這不是「自己真正的錢」。（也被稱為「賭場贏利效應」）</p><p>8. 行為生命週期假說：常人的自我控制能力不如理性經濟人，取而代之的是熱烈情感，有缺陷的望遠能力，對來源不同的財富區別看待（不同心裡帳戶），並且表現出「現時偏向」的喜好。</p><p>9. 自我控制理論：我們可以把內心的衝突想像成擁有兩個自我，分別是計畫者與行動者：</p><p>(1) 立意良好，關心未來的「計畫者」</p><p>(2) 不顧後果，專注當下的「行動者」</p><p>可以用「委託-代理人模型」解釋：委託人（計畫者）發號施令，而代理人（行動者）被授權執行；代理人會試圖以最少勞力賺取最多的錢，委託人則是會推出種種規定與流程限制代理人。</p><p>換句話說，計畫者會試圖用獎懲、規定、罪惡感等手段來影響行動者。</p><p>ex. 假設在 10 天內只有 10 根能量棒能夠果腹，計畫者會希望平均分配 1 根給每一天；但行動者則想吃更多。</p><p>10. 公平規則：常人願意犧牲一些自我利益去懲罰其他人不公平的行為，因爲人們討厭不公平的情形。</p><p>11. 有條件的合作者：一般人對於合作的態度常常表現的從眾，當足夠多的其他人採取合作策略時，那麼他們也願意合作；反之這些人則不會合作（搭便車的人）。</p><p>12. 科學革命模型：由孔恩首先提出，對於任何一個科學革命，都會先累積足夠多的異常案例，且研究社群因此對舊典範的質疑有了共識時，才會發生「典範轉移」。</p><p>13. 狹窄框架：常人看待事物往往不夠宏觀，落入一個較小尺度的觀察並得出結論，使其未達到全局化最佳行動。</p><p>ex. 若一個公司擁有多項投資案，每項成功率為 50% 獲得 100 萬美元，50 % 失去 50 萬美元，在公司的角度會選擇全部投資；但若是每項投資由一個專們的主管負責，該主管可能面臨到「成功沒有獎勵、失敗則被辭退」的困境，因而選擇不投資。（這樣的困境在委託-代理人模型中被稱為「傻瓜委託人」問題）</p><p>ex. 若有一個賭局為硬幣正面可獲得 200 元，反面失去 100 元，常人可能會選擇拒絕 1 次賭注，但接受 100 次賭注；這樣的表現實際上是因為當我們關注在單一賭注上時落入了狹窄框架，因此選擇拒絕。（短視的「損失規避」，更常檢視投資結果的人往往也變得更為小心謹慎）</p><p>14. 過度反應：常人受到「短暫且無關緊要的訊息」影響決策，但實際上與決策事物並無任何關係</p><p>ex. 在實驗中，受測對象預測幽默感與成績呈正比，因為他們只接受到被預測者的幽默感指數，因此過度反應將幽默感與成績相關聯。</p><p>ex. 股價的劇烈波動也可能是因為投資人受到一些無關因素影響而過度反應，使得漲跌大於預期。</p><p>15. 股市的價格經常是錯的：塞勒藉由觀察封閉型基金、小公司效應等現象，推翻了原先經濟學界普遍認同的「單一價格法則」。並指出股市價格會受到投資人情緒影響（動物本能影響）。</p><p>ex. 股市泡沫化可能是因為投資人原本的「過度狂熱」逐漸平息，使得股價從高點回到正常值。</p><p>16. 寇斯定理：在不存在交易成本的情況下，也就是當與人之間的交易順暢無礙時，資源會流向設定價值最高之處。換句話說，法官的決定（法官通常被認為有權決定誰擁有特定權利的人）並不會影響經濟活動本身</p><p>ex. A 與 B 同住一室， A討厭音樂而 B 喜歡放音樂，那麼最後會不會放音樂並不受舍監（法官）決定，而是取決於「A討厭音樂的程度是否大於 B 喜歡音樂的程度」。因為不論舍監如何決定，設定價值較高者皆可經由支付價值給另一方以獲取資源（就算舍監不讓 B 放音樂，B也可以藉由給錢收買 A 並繼續放音樂）。</p><p>塞勒發現，常人可能會拒絕接受「不公平」的提議，甚至寧願付出代價也要懲罰對方。這樣的行為違反寇斯定理。</p><p>17. 路徑依賴理論：常人會在兩種情況下主動尋求風險，其一是已提到的「落居下風確有機會扳回一城」，第二是「手風正順（在賭局中可用心理帳戶解釋，因為賭客們認為玩的是莊家的錢）」。</p><p>這項理論說明了常人對於現況的決策不同於理性經濟人般只注重當下情況，同時也會參考過去歷史並受之影響。</p><p>18. 大花生米假說：一筆金額的大小，要看他們被放在什麼樣的背景中。</p><p>ex. 500 美元在獎金競賽節目中被視為微不足道，但在實驗室裡卻是一筆不小的數目。</p><p>19. 推力理論：推力是吸引人們注意力和影響行為環境的某些小功能，對常人有效（理性經濟人應不受影響）。</p><p>ex. 在小便斗上畫上蒼蠅能夠使尿液飛濺的機率下降。</p><p>ex. 利用人們的「惰性」，讓我們期許發生的事設定為預設動作，這樣多數人就會因為懶得修正而符合預期行為。</p><p>筆者想要在此強調，本部分僅是羅列出書中大部分關注的理論，而非書中之重點。舉例而言，筆者認為行為經濟學的運用精髓可見書中對於規劃儲蓄金所提出的方案「明天存更多」，作者塞勒聰明地運用行為經濟學中各種觀念的組合使得該方案一經推出就廣受好評。</p><h3>二、行為經濟學的發展</h3><p>在書中末尾，作者塞勒對於行為經濟學提出了展望與回顧；作為行為經濟學的領軍人物（或可說行為經濟學之父），在書中提出的觀點自然具有份量。筆者無意反駁塞勒的任何觀點。僅僅是作為旁觀者試著以短期、中期、長期的角度回看行為經濟學的發展。筆者試著以經濟學的發展歷史，或是科學發展的歷史以三種不同跨度去回顧這場行為經濟學革命。</p><p>就短期視角而言，相信讀者們可在書中不斷地看到行為經濟學的短期展望，以及與傳統經濟學之間的較量。行為經濟學，作為一個新興學科，試圖融合經濟學與心理學，讓各類模型更能夠貼近真實的人類行為。與傳統經濟學不同，行為經濟學講究以實驗帶動理論，傳統經濟學則以數學理論為優先。因此讀者們可以在書中不斷地看到兩派學者們的對抗及合作。作為第三方的我們，藉由塞勒的人生故事可以看到行為經濟學正快速興起、發展，並且逐漸成為主流的經濟學分支。</p><p>上述所言是筆者以近百年來的經濟學發展所做之總結，接著讓我們將時間跨度拉長到數百年，從啟蒙時代至今。科學哲學家孔恩著作「科學革命的結構」時早已講述，任一科學革命都會先有足夠多的異例，進而產生質疑、共識直至產生新的理論模型。行為經濟學的革命並不是首例，早在地心說推翻日心說、道爾頓的原子論中就早已展現。當代科學家對於舊有模型找出異例，並逐漸發展新的模型；而這樣的革命過程會持續數十年乃至百餘年之久。因此，筆者以一場科學革命來看待行為經濟學的興起，可看出這是一場典型之革命，縱然不敢斷言未來之經濟學局勢，也可參照過去發生的革命結構來預測行爲經濟學的未來走向。（畢竟筆者過去對孔恩甚感興趣，因此看到書中有這樣的觀點時筆者十分高興）</p><p>最終，讓我們的時間跨度拉長到數千年，從經濟學的起源至現代。早在古文明（包含美索不達米亞文明、中國文明等）皆有人曾經探討過，亞里斯多德、阿奎那等人也有著不俗的發現。直至亞當·斯密著作的《國富論》與《道德情操論》，不難看出經濟學始終伴隨著文明的發展。而經濟學所要追求的目標，就是試著描述人類的行為。在《道德情操論》中可看出人性對於行為的影響，近代科學家凱恩斯也曾以「動物本能」之角度試著描述。但由於電腦科學、數學的高度發展，經濟理論在近代轉而以較為簡單的假設（理性經濟人模型）為基底，試圖忽略複雜的人性因素。而行為經濟學則是將人性重新納入考量的因素內。如同塞勒所言，當所有經濟學分支都考慮人性的因素時，行為經濟學將不復存在。「因為經濟學本來就要考慮人性的因素」。</p><h3>三、短語</h3><p>筆者認為《 不當行為》是一本難得的自傳，讓讀者們能夠有機會以本書作者塞勒的第一視角去體驗行為經濟學的發展。並且本書用了許多篇幅描述科學研究的「第一現場」，包含頂尖會議、頂尖期刊的互動，讓筆者深有感觸。同時，我們也可以藉由閱讀《 不當行為》一書，了解到許多在前沿的行為經濟學理論，以及行為經濟學在生活中的靈活運用（筆者一直認為書中的生活運用是本書精髓所在，十分推薦讀者重新回味）。我們可以帶入當下的問題場景，試著以自身角度出發，看看有沒有想到與塞勒博士相同的奇思妙想。《 不當行為》當然不是一本能讓行為經濟學精通的書籍，卻是能讓我們以行為經濟學的角度出發，重新探索世界、解決難題的寶典。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fcd8f7d91ab2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>