TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

A Tale of Two Libcs

84 pointsby stargraveover 4 years ago

7 comments

joostersover 4 years ago
I absolutely loathe and despise the arrogant &#x27;your code must be bullshit&#x27; attitude that runs throughout this article.<p>When you encounter other peoples&#x27; code and it looks a bit complicated, and not the &#x27;obvious and simple&#x27; thing, your first thought should never be &#x27;they wrote bullshit code&#x27;, but instead &#x27;what have I missed? What did I forget to consider for this function?&#x27;<p>I don&#x27;t know anything about the glibc authors, or their code style, but if you go through your life assuming incompetence if someone wrote a function differently to your initial thoughts, then you are an arrogant prick.
评论 #24598096 未加载
评论 #24598199 未加载
评论 #24598212 未加载
评论 #24598151 未加载
minus7over 4 years ago
I was wondering whether there was a significant performance improvement of the table lookup glibc does over the naive implementation musl has.<p>The answer is a pretty big yes. Glibc&#x27;s isalnum is about 6-7 times faster than musl&#x27;s.<p>Benchmark code: <a href="https:&#x2F;&#x2F;paste.sr.ht&#x2F;~minus&#x2F;18b44cfe58789bc1fb69494130e859a1189d1772" rel="nofollow">https:&#x2F;&#x2F;paste.sr.ht&#x2F;~minus&#x2F;18b44cfe58789bc1fb69494130e859a11...</a>
评论 #24598552 未加载
评论 #24597865 未加载
pitterpatterover 4 years ago
Man, the condescension pouring off from the post.<p>&gt;So the fix is obvious at this point. Okay, fine, my bad. My code is wrong. I apparently cannot just hand a UCS-32 codepoint to isalnum and expect it to tell me if it’s between 0x30-0x39, 0x41-0x5A, or 0x61-0x7A.<p>If that&#x27;s what you want, just go ahead and write that.
评论 #24597981 未加载
rightbyteover 4 years ago
I guess the glibc complexity with a LUT is to support non-ascii character sets? It seems quite silly to compare a general solution to a hard coded special case.
评论 #24597612 未加载
评论 #24597661 未加载
busterover 4 years ago
I am wondering what would happen, if someone swapped out the glibc implementation? Would this uncover the deeper technical reason for the implementation? Would suddenly bugs occur elsewhere?<p>It probably just shows how old the glibc is and like most software entropy is increasing over time.
评论 #24597590 未加载
fancyfredbotover 4 years ago
TLDR; glibc is complicated, musl is not. libc supports thread specific locales, musl does not.
评论 #24597697 未加载
pojntfxover 4 years ago
Switched to Alpine Linux (a distro built with musl libc) a while back for my dev and k3s cluster machines and never looked back since.