Most active commenters
  • pjmlp(5)
  • fingerlocks(3)

←back to thread

168 points pabs3 | 23 comments | | HN request time: 0.678s | source | bottom
1. sanskarix ◴[] No.45756787[source]
This kind of thing is how you actually learn what's under the hood. Everyone's building with React Native and Flutter, which is fine until something breaks. Then you're stuck Googling black magic. Starting from assembly teaches you the real cost of abstraction.
replies(8): >>45757063 #>>45757628 #>>45758058 #>>45758840 #>>45758893 #>>45759007 #>>45760502 #>>45761692 #
2. internetter ◴[] No.45757063[source]
Is this really low level though? Because its hooking UIKit which is very high level relative to ASM. I'd be really curious to see an app draw on iOS without UIKit. I don't know if thats possible.
replies(4): >>45757231 #>>45757464 #>>45757623 #>>45758326 #
3. pjmlp ◴[] No.45757231[source]
As low level as it gets.

For lower level one needs something like ESP32, Arduino, retro-coding platforms.

4. shreddit ◴[] No.45757464[source]
Of course it is. You just have to reimplement UIKit in ASM, no big deal…
replies(1): >>45757829 #
5. saagarjha ◴[] No.45757623[source]
No, you’ll have to check in with backboard etc before it will let you do anything useful
6. saagarjha ◴[] No.45757628[source]
This is an excellent argument for not using assembly, actually
replies(2): >>45757931 #>>45758144 #
7. pjmlp ◴[] No.45757829{3}[source]
And even that won't do it, because within the constraints of iOS, eventually that framebuffer with software rendering has to be displayed on the screen via an OS API, which is UI Kit.
replies(1): >>45758436 #
8. bilekas ◴[] No.45757931[source]
The argument is that learning assembly is useful, it gives some insights into what happens under the hood. That seems like a no brainer to me.

Would I use it for production iOS app, no, I don't hate myself that much.

9. nurettin ◴[] No.45758058[source]
All this teaches is how to put parameters on stack, pass them to functions and use the results. It is pretty much a transliteration of what you would do in C.
10. flohofwoe ◴[] No.45758144[source]
It's still very educational. It shows how ObjC method calls work under the hood, because even calling objc_msgSend() from plain C involves a certain amount of non-obvious magic (because of the variable argument list and return types).

And tbh I'm kinda surprised how little assembly code it is, less than most UI framework hello-worlds in high level languages ;)

11. fingerlocks ◴[] No.45758326[source]
You can write directly to the frame buffer, like a video game. You still need the UIKit import to publish, because it has to be bundled into a .ipa which requires an AppDelegate, a UIBundle, among other things.

If you want to “technically” avoid UIKit, you can drop one step lower. UIKit is implemented on CoreAnimation. A bare UIView is nearly a pass through wrapper around CALayer. It wouldn’t be hard to build your own custom UI on CALayers. The old CA tutorials for implementing a ScrollView from the ground up are still floating around out there.

12. fingerlocks ◴[] No.45758436{4}[source]
It should be possible.

If you enable the JIT entitlement for personal development, then bundle a mach-o into an entitled app. Or compile it directly on the app and mprotect-x to execute it. Is there something else you can’t do that I’m not considering? I might give this a try.

replies(1): >>45758615 #
13. pjmlp ◴[] No.45758615{5}[source]
The point is what is possible within the constrains of public APIs.
replies(2): >>45758714 #>>45759556 #
14. fingerlocks ◴[] No.45758714{6}[source]
Everything I described is in a public header right inside your iOS SDK folder
replies(1): >>45759186 #
15. JojoFatsani ◴[] No.45758840[source]
Assembly is fine until it breaks too
replies(1): >>45758902 #
16. SoKamil ◴[] No.45758893[source]
You still have whole Objective-C runtime and CoreAnimation, UIKit abstraction under the hood.
17. bloomca ◴[] No.45759007[source]
You have a very long way between assembly and RN/Flutter. I do agree that it helps to know these things, but you need to learn a lot more before it becomes more generally applicable.
18. pjmlp ◴[] No.45759186{7}[source]
I doubt you can render an UI in pure Assembly and show it on the screen without going through UI Kit in a non-rooted device, given that even the device drivers extension points is quite limited.

Which was the whole discussion point that started the thread, how to make a iOS app with zero references to UI Kit.

This isn't an 8 and 16 bit home computers, or games console, with an address for the framebuffer.

19. Someone ◴[] No.45759556{6}[source]
Is syscall a public API on iOS? In the end, you have to call that to get anything on the screen?

Looking at unistd.h, it seems marked as

  __OS_AVAILABILITY_MSG(ios,deprecated=10.0,"syscall(2) is unsupported; "
    "please switch to a supported interface. For SYS_kdebug_trace use kdebug_signpost().")
and syscall numbers seem wrapped by

  #ifdef __APPLE_API_PRIVATE
in *<sys/syscall.h>
replies(1): >>45760251 #
20. pjmlp ◴[] No.45760251{7}[source]
Not at all, it is a Linux thing to keep applications doing syscalls, like back in MS-DOS interrupt days.

All other modern OSes give zero guarantees about syscalls.

Indeed, you have to call UI Kit, that is the public API for userspace applications.

Even if via OpenGL ES or Metal, you need a drawing context and a Window to render it.

21. wiseowise ◴[] No.45760502[source]
Complete bogus. This is programmers machismo that's completely detached from reality.
replies(1): >>45760889 #
22. scrumper ◴[] No.45760889[source]
I'm not sure this is entirely fair though I think you're mostly right. The comment you're replying to is right in terms of the value of understanding one or more levels of abstraction below the one you're working in. Conversely you're right in that learning assembler isn't going to do much to help you debug a failing Flutter app. It's just attacking the abstraction stack in detail from the opposite end - equally myopic.

But none the less valuable because of the additional perspective it brings. That's the real point of it, another lens through which to view and understand the mechanics of the application.

23. shay_ker ◴[] No.45761692[source]
This is the most HN comment I’ve seen in a while. The real abstraction here is coding with LLMs btw!!!