HNHacker News
TopNewBestAskShowJobs

mayoff

2,016 karma · joined June 2, 2010

Random bits of iOS programming
submissionscomments
mayoff··on Problems with C++ exceptions
Swift doesn't capture a stack trace in the `Error` object, but Xcode can break when an error is thrown if you set a “Swift Error Breakpoint”, and the debugger will show you the stack trace. Under the hood it just sets breakpoints on the runtime functions `swift_willThrow` and `swift_willThrowTypedImpl`.
mayoff··on Problems with C++ exceptions
Another really nice thing about Swift is that you have to put the `try` keyword in front of any expression that can throw. This means there's no hidden control flow: if some function call can throw, you're informed at the call site and don't have to look at the function declaration.
mayoff··on Problems with C++ exceptions
Swift gained limited support for “typed throws” in Swift 6.0 (2024).

https://github.com/swiftlang/swift-evolution/blob/main/propo...

I say limited because the compiler doesn't (yet, as of 6.2) perform typed throw inference for closures (a closure that throws is inferred to throw `any Error`). I have personally found this sufficiently limiting that I've given up using typed throws in the few places I want to, for now.

mayoff··on Revisiting Interface Segregation in Go
See also https://news.ycombinator.com/item?id=36908369 (“The bigger the interface, the weaker the abstraction")
mayoff··on Precompiled headers and why Squid won't be using them (2023)
I hate cmake but this is something cmake does well in my experience. I had to write a Godot 4 plugin and Godot has many many header files. I made a project header that #included all the Godot headers, and a single target_precompile_headers directive in CMakeLists was enough to get it working on Mac and Linux (and I think on Windows but I didn’t need to run it on Windows).
mayoff··on Minecraft removing obfuscation in Java Edition
Probably the Sun Ray computer.

https://en.wikipedia.org/wiki/Sun_Ray

mayoff··on Typst 0.14
Unicode superscript characters.

https://en.wikipedia.org/wiki/Unicode_subscripts_and_supersc...

mayoff··on Xcode Is the Worst Piece of Professional Software I Have Ever Used
My problem with AppCode was that the syntax of Swift was still undergoing rapid development, and AppCode lagged too far behind. So AppCode wouldn't understand parts of my code unless I avoided the latest (often very valuable) additions to the language.

When it did understand my code, it was much better than Xcode for navigating and refactoring.

Also, AppCode couldn't edit or even display XIBs so I often had to keep Xcode running alongside it anyway to edit XIBs and make connections between XIB and code, and that was a hassle.

mayoff··on Ask HN: What's a good 3D Printer for sub $1000?
> Cura (Ultimaker's slicer) isn't open source

Isn't it? https://github.com/Ultimaker/Cura

mayoff··on Public static void main(String[] args) is dead
But in Java, a program doesn't have a single static entry point. You can have as many different classes as you want, each with its own static void main, and choose which to use as the entry point when you start up your JVM.
mayoff··on Show HN: I was curious about spherical helix, ended up making this visualization
You can play with the equations on 3D Desmos here: https://www.desmos.com/3d/t66etxi1y8

Interesting to note that the parametric equations of the spiral are linear in spherical coordinates. https://en.wikipedia.org/wiki/List_of_common_coordinate_tran...

mayoff··on Window Activation
Supposedly this was improved in macOS 14 (Sonoma, late 2023) with "cooperative app activation". It's discussed in this WWDC 2023 video:

https://developer.apple.com/videos/play/wwdc2023/10054/?time...

mayoff··on Replicube: 3D shader puzzle game, online demo
I golfed mine down to 15.623 cycles / voxel.

    d2 = x^2+y^2
    -- 6 / pi = 1.909859317102744
    angle = 6 + 1.909859317102744 * atan(x, y)
    
    if z ~= 0 or d2 > 20 then return EMPTY end
    if d2 < 11 then return GREEN end
    if angle > t then return PURPLE end
    -- ugly special case because reference isn't smooth at 13
    if t == 13 or angle + 12 > t then return RED end
    return PURPLE
mayoff··on College baseball, venture capital, and the long maybe
Have you heard of CTE?

https://www.bu.edu/articles/2017/cte-former-nfl-players/

mayoff··on I Convinced HP's Board to Buy Palm for $1.2B. I Watched Them Kill It in 49 Days
When I think about HP as a software & services company, I think about the times I booked Disney vacations in the 2010s. The Disney web site for managing your reservations, looking at park attraction wait times, etc., was usually painfully slow, and the bottom of every page proudly featured the HP logo.

It's probably still slow (I haven't been to Disney in a while) but no longer mentions HP.

mayoff··on I convinced HP's board to buy Palm and watched them kill it
The state preservation API wasn't added until iOS 6.0 in 2012.

https://developer.apple.com/documentation/uikit/uiviewcontro...

mayoff··on OxCaml - a set of extensions to the OCaml programming language.
ha ha oops I got confused
mayoff··on OxCaml - a set of extensions to the OCaml programming language.
(this comment was off topic, sorry)
mayoff··on RSyncUI – A SwiftUI based macOS GUI for rsync
This is a copy of an infamous comment about the then-new Dropbox: https://news.ycombinator.com/item?id=9224
mayoff··on Why the original Macintosh had a screen resolution of 512×324
The data and address registers of the 68000 were 32 bits wide.
mayoff··on I Tried Windows Gaming on a Mac and It's Amazing
Lots of older Mac Steam games support 64-bit but show the incompatibility warning in the store anyway. It’s annoying but with Steam’s return policy it’s not a real risk to test such games.
mayoff··on I tried Windows gaming on a Mac
I use CrossOver to play lighter-spec games on my Mac, like Animal Well, Loco Motive, Ori, UFO 50, and The Outer Wilds. I also have a gaming PC but I pretty much only use it for more demanding or super latency-sensitive games like Overwatch and Elden Ring. I’m not into most of the really high-spec AAA titles so I have not idea how well those would run.
mayoff··on Show HN: Pledge – A Lightweight Reactive Framework for Swift (No Rx Overhead)
You could check out OpenCombine or CombineX.

https://github.com/OpenCombine/OpenCombine

https://github.com/cx-org/CombineX

mayoff··on API design note: Beware of adding an "Other" enum value
Swift allows an enum to be marked `@frozen`, which is an API (and ABI) stability guarantee that the enum will never gain more cases. Apple uses this quite sparingly in their APIs.

Swift also has two versions of a `default` case in switch statements, like you described. It has regular `default` and it has `@unknown default`. The `@unknown default` case is specifically for use with non-frozen enums, and gives a warning if you haven't handled all known cases.

So with `@unknown default`, the compiler tells you if you haven't been exhaustive (vs. the current API), but doesn't complain that your `@unknown default` case is unreachable.

mayoff··on In Zig, what's a writer?
Swift does that. https://github.com/swiftlang/swift-evolution/blob/main/propo...
mayoff··on Show HN: A free alternative to Typora –– IF
I'm puzzled why this is headlined as an alternative to Typora.

I'm a happy, paying Typora (on macOS) customer. Looking at the linked page, I would never have guessed that IF is at all a Typora competitor.

I love Typora because it is a great, flexible WYSIWYG-ish Markdown editor (at least for me), and that is how it bills itself: “A minimal Markdown editor and reader.”

The linked page about IF doesn't mention Markdown at all… but it does mention things like “todo” and “pomo” and “schedule”. What do those have to do with editing Markdown?

mayoff··on Strange Design Decision: An Oven with French Doors
I have this in-wall oven with French doors: https://www.bluestarcooking.com/cooking/ovens/30-electric-wa... The French doors do make it easier to get stuff in and out.

But for something that's essentially a countertop toaster oven, I don't think French doors make a whole lot of sense. My Breville countertop toaster oven has a normal fold-down door and I have never felt like it's getting in the way.

mayoff··on Ask HN: Does anyone use sound effects in their dev environment?
I have Xcode set up to play a sound effect when a build or a test run finishes successfully, and a different sound effect (the Metal Gear alert) when it fails.
mayoff··on Go is my hammer, and everything is a nail
Related:

Java for Everything

https://www.teamten.com/lawrence/writings/java-for-everythin...

Previously HN discussion of "Java for Everything":

https://news.ycombinator.com/item?id=26934297

mayoff··on My philosophy of exceptions: they're always ambiguous (2021)
> If you’re using Python, you’re stuck with the endless debates. For instance, you’ll never know why there’s a dict.get() to avoid KeyError but no list.get() to avoid IndexError.

Probably for the same reason that, in Swift, dictionary lookup returns an Optional but Array traps on out-of-bounds: dictionary keys tend to come from outside the dictionary, but array indices tend to be derived from the array bounds. This means a dictionary lookup failure tends to be expected, and an out-of-bounds array index tends to be a logic error. More details here: https://stackoverflow.com/a/75780575/77567

← PreviousPage 2 of 12Next →