Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to a more modern language - lol #2

Closed
wants to merge 4 commits into from

Conversation

philipturner
Copy link

I challenge you to find whether translating to Swift brings a performance cost.

Seriously, I appreciate your work on optimizing Apple stuff, but I thought I'd do this just for kicks. It's a (hopefully) zero-cost literal translation from Objective-C to Swift, which I have a ton of experience with. I didn't mess with the compiled executable or podspec file.

Please tell me what you think about it!

@michaeleisel
Copy link
Contributor

I imagine this is indeed the same performance. The reason I did it in ObjC is because of all the bit-munging that's going on here, that I can more easily and explicitly do in C. I'm ambivalent about merging this, but we can see what other people think.

@michaeleisel
Copy link
Contributor

To be clear, I do appreciate your enthusiasm for writing modern code, and the code looks generally solid :)

@philipturner
Copy link
Author

philipturner commented Oct 22, 2021

For reference, I have avoided Objective-C since I started working with iOS. I created a lot of low-level code in Swift, learning how to do pointer arithmetic, forced inlining, bit casting, etc. without going to C or Objective-C. It took me around 30 minutes to translate your code to Swift.

Since you are maintaining the code, you would have to learn all the stuff I just listed above, which does take time. I know that it may be more productive for you to stay with Objective-C, but I was just curious what you would say. However, the moment when you actually get it to work in Swift feels super amazing.

@philipturner
Copy link
Author

Have you looked at the utility functions in ARHeadsetKit?

@philipturner
Copy link
Author

philipturner commented Oct 23, 2021

If the Objective-C -> Swift translation is actually implemented, the best option would be that you use my fork as a reference, but translate it to Swift yourself. I didn't really study what your code does, or if the translated code even works. I wouldn't be comfortable replacing my own code with something another person made, without at least thoroughly examining and testing it.

@philipturner
Copy link
Author

I would be honored to assist you in transferring to/maintaining this repository in Swift. I’m open 24/7 and eager to help with anything that gets rid of Objective-C!

@michaeleisel
Copy link
Contributor

I'm going to close for now. I've done bit-munging in Swift before, and that's not really the issue. The issue is how well-suited C is to it. Also, ObjC dependencies can be easier to integrate. For example, despite its claims of module stability (with the right flags), in practice I've seen bugs with Swift module stability, preventing one from vendoring it as a standalone library.

@philipturner
Copy link
Author

philipturner commented Jan 25, 2022

Sorry about my past rudeness. Your work here was great.

@michaeleisel
Copy link
Contributor

No worries

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants