S
Saagar Jha
saagarjha.com · Personal blog · on HN since 2018
Saagar Jha writes about macOS and iOS internals, debugging, Swift, and low-level programming topics.
What HN saysCommenters value his detailed macOS walkthroughs, like the one on private logging, and cite his iOS JIT and ptrace post and his package manager opinions.
40HN people shared it
18linked it in comments
27stories submitted
2.0Kstory points
4 months agolast shared
2018people per year2026
Most-shared posts
- 1Thoughts on macOS Package Managers13 people · 132 points · first shared 2019 · 91 comments on HN
- 2Designing a better strcpy8 people · 145 points · first shared 2020 · 120 comments on HN
- 3We at $Famous_company switched to $Hyped_technology6 people · 1.5K points · first shared 2020 · 200 comments on HN
- 4Jailed Just-in-Time Compilation on iOS4 people · 165 points · first shared 2020 · 14 comments on HN
- 5Bypassing Objc_msgSend4 people · 9 points · first shared 2019 · discussion on HN
- 6Swift Concurrency Waits for No One4 people · 7 points · first shared 2023 · discussion on HN
- 7Debugging Python Operator Precedence with MacsBug2 people · 2 points · first shared 2020 · discussion on HN
- 8Fixing section 2 5 22 people · first shared 2020
- 9Wiring Your House for Networking1 people · 49 points · first shared 2024 · 30 comments on HN
- 10Making Friends with AttributeGraph1 people · 43 points · first shared 2024 · discussion on HN
- 11Mac App Store Sandbox Escape1 people · 4 points · first shared 2020 · discussion on HN
- 12Scheduling Dark Mode1 people · 1 points · first shared 2018 · discussion on HN
- 13Dual booting chrome os and elementary os1 people · first shared 2019
- 14Making os log public on macos catalina1 people · first shared 2020
- 15Mocking capabilities in the ios simulator1 people · first shared 2020
What HN people wrote when they linked it
wffurr · 2021-05-24
There is an opt-in developer mode on iOS. You can compile and install any software you want on your own iPad; no paid Apple developer account needed.
There’s even a way to get W^X memory regions on iOS by abusing ptrace: https://saagarjha.com/blog/2020/02/23/jailed-just-in-time-compilation-…
It can’t be submitted to the App Store or deployed with TestFlight, but you can build and install an app using that hack just fine on your own device.
Open source browser vendors, like Firefox and Chromium, could provide builds that enable a full browser engine experience on iOS devices, were they to think it worth the effort.
saagarjha · 2020-11-22
From a bit of experimenting, I don't even know what it's counting. I thought it was total transmitted bytes, since the numbers seemed pretty low…but then I checked and danluu's site is like 20 KB on my computer because of Google Analytics but it's listed as 3 (TIL it's five times heavier than my site, though I write much less: https://saagarjha.com/). Anyone know what is going on here? Is it "transferred bytes with JavaScript off", which is a rather strange metric?
snazz · 2020-08-22
I'm somewhat surprised that this guide recommends Homebrew. I agree that using a package manager is a good way to keep software updated from a central, trusted repository--always a good thing--but Homebrew makes a number of trade-offs for convenience instead of security. MacPorts has most of the same common packages and doesn't mess up filesystem permissions like Homebrew does. If I remember correctly, the all-inside-the-home-directory technique used in this guide is unsupported by the Homebrew developers as well.
See https://saagarjha.com/blog/2019/04/26/thoughts-on-macos-package-manage… for a more nuanced take on this.
varenc · 2020-05-23
wait a sec...I recognize that name. I only know how to enable private logging thanks to your detailed and informative blog post! Seriously, it's one of the favorite macOS things I've read in a while. I loved the step by step walk through using gdb you showed.
Though just today I saw that apparently an enterprise policy config can enable private logging in 10.15.3+ without having to disable SIP. https://georgegarside.com/blog/macos/sierra-console-private/
For reference for others: this is the blog post by OP on enabling private logging in Catalina. check it out! https://saagarjha.com/blog/2019/09/29/making-os-log-public-on-macos-ca…
ChrisMarshallNY · 2024-12-22
Come on, you know me better than that.
In this case, the comment fit the conversation. The original comment was a short, pithy, and rather sarcastic one that was, nonetheless, correct. They pointed out that we need to write higher-Quality software, in order to give folks like the NSO people fewer “hooks.” The NSO folks are smart, dedicated people, that, in other circumstances, we would admire for their creativity and intelligence. They often take advantage of mistakes (or deliberate decisions) made by folks that we may find less admirable.
I like this community and medium, and sincerely want to be a “good citizen.” The opportunity to interact with people like you, is a privilege that I respect and value. We may not always agree on everything, but I find many of your contributions to be inspiring, educational, and relevant, so I appreciate you. You have taught me lessons, and have changed my mind, and, I’m sure, will continue to do so. You have great insight, knowledge, and experience, which I value, and appreciate you sharing it (for example: https://saagarjha.com/blog/2023/12/22/swift-concurrency-waits-for-no-o… People like you, are why I like this place. We have no social interaction, so I have no idea if we’d get along, IRL. I would like to think we would, but I’m often wrong, and not afraid to promptly admit it.
For myself, I try to participate by making very specific suggestions, and “keeping it focused on me.” I don’t attack others, even if I find what they say…
azalemeth · 2021-09-13
Honestly, they're both very good, and any discussion of this is going to be almost bordering on opinion and little else.
Here are a few potential downsides:
- The 'kool kids' tend to use brew -- so sometimes you end up with packages that are not in the ports ecosystem. That said, the total number of ports is, I believe, about 4x larger than brew's formulae. But take that number with a pinch of salt.
- Every time you upgrade the OS (e.g. 10.14 to 10.15) you need to effectively reinstall ports. This sounds hard, but it isn't -- it's also well documented [1]. It's because they link against various OS-specific foundations.
- Very rarely you run into apt-style "dependency hell". This has only happened to me once or twice in ~15 years of using it, and is easily fixed.
The upsides:
- All that being said, it's rock stable
- The documentation is excellent
- It doesn't come with google analytics by default (unlike brew -- which is opt-out, I should say)
- Macports retains the entire dependency tree of a package and offers both source and binary builds
A more detailed comparison could be found e.g. here: https://saagarjha.com/blog/2019/04/26/thoughts-on-macos-package-manage…
[1] https://trac.macports.org/wiki/Migration
AnonC · 2026-02-09
I use MacPorts because of older versions of Homebrew having a weird and insecure design. [1] I think some of those design issues may have been fixed, but I’m wary of Homebrew.
[1]: https://saagarjha.com/blog/2019/04/26/thoughts-on-macos-package-manage…
haykuro · 2024-02-13
I switched to MacPorts after becoming tired of Brew tainting my filesystem.
MacPorts keeps things clean in /opt/.
https://www.macports.org/
https://saagarjha.com/blog/2019/04/26/thoughts-on-macos-package-manage…
jabl · 2023-04-25
As mentioned in the article linked above https://saagarjha.com/blog/2020/04/12/designing-a-better-strcpy/ , memccpy() comes relatively close and is slated to be part of C23.
Apocryphon · 2022-04-26
One of the reasons for why Apple disallowed third-party browser engines is because Mobile Safari alone is allowed to use a JavaScript JIT, ostensibly for security reasons. This is why Firefox on Safari uses WebKit, and why Chrome must rely on iOS's stock webviews rather than Blink's own JIT. Mobile Safari has this via the dynamic-codesigning entitlement.
Further reading:
https://saagarjha.com/blog/2020/02/23/jailed-just-in-time-compilation-…
Discussion: https://news.ycombinator.com/item?id=22401146
heavyset_go · 2021-07-13
Another HN user did a write up on Homebrew[1] that I agree with.
My main gripe is that Homebrew would regularly break my Python virtualenvs with linking errors. Meanwhile on Linux, I have virtualenvs that I created 9 years ago that still just work.
These days you might be able to sidestep that issue by not using Python from Homebrew at all, but installing and managing it with Pyenv instead.
[1] https://saagarjha.com/blog/2019/04/26/thoughts-on-macos-package-manage…
deergomoo · 2021-03-19
This is the article that prompted me to give it a try, and summarises my feelings better than I could:
https://saagarjha.com/blog/2019/04/26/thoughts-on-macos-package-manage…
newscracker · 2021-02-05
Here’s a blog post from April 2019 on package managers on macOS. [1] The author, saagarjha (who also comments here regularly), switched from homebrew to MacPorts. A more current update to this post would probably be more helpful.
In my limited experience, I’ve tried homebrew a few times, but found it a bit cumbersome with the “no sudo” requirement.
[1]: https://saagarjha.com/blog/2019/04/26/thoughts-on-macos-package-manage…
robocat · 2020-11-08
To me it appears they admit that iSH allows scripting (ummm, obviously), and that scripting is against Apple’s policy (as we all know). From one of their articles: “Soon after we released iSH without apk, we found users who had figured out a way to get apk back using wget and were posting about this throughout the internet”.
They argue that Apple’s policy should be changed to allow scripting: https://saagarjha.com/blog/2020/11/08/fixing-section-2-5-2/
It looks to me that Apple’s main reason for not allowing scripting is to prevent an app from deploying other apps within itself (preventing any competition with the app store), with a secondary reason being security for users (harder to argue against).
I can’t see Apple ever allowing a shell app into the store, as that would turn your iDevice into a general purpose computer.
rich_sasha · 2020-07-17
I’m sure there is good stuff there but superficially it is oh soo close to this: https://saagarjha.com/blog/2020/05/10/why-we-at-famous-company-switche…
SigmundA · 2021-03-24
Beyond any TOS issues there has always been a technical issue where an app store app cannot write to memory that is marked executable for security purposes.
This prevents JIT's but does not prevent an interpreter from functioning since an interpreter does not directly generate machine code and execute it, it simply reads the code to interpret as data and executes through its own engine.
Most modern JS engines JIT which is why you don't see say electron / node / chromium based stuff on iOS, a lot of it has to do with V8 requiring the ability to JIT.
Hermes does not JIT so it sidesteps the technical limitations on iOS then its just a matter of passing review.
There where some ways around this that have been patched and Apple has recent introduced an official entitlement but does not allow it in the app store yet:
https://saagarjha.com/blog/2020/02/23/jailed-just-in-time-compilation-…
https://9to5mac.com/2020/11/06/ios-14-2-brings-jit-compilation-support…