8 ms·
Ivy: iOS app written in Go
- suyash 11y agoanyone care to explain the technical how-to that made this possible.
- kejaed 11y agoCould be related to this https://news.ycombinator.com/item?id=9815464 https://news.ycombinator.com/item?id=9815464
- crawshaw 11y agoThe gomobile tool is part of the broader project, but that particular CL is about `gomobile build`, a sub-command designed to build all-Go apps. From inside Go, we have only built out access to portable APIs like OpenGL. This app uses a different mode of the same tool, `gomobile bind`. This lets you use a Go package from inside an Android app, or from ObjC in an iOS app. It is related but parallel work.
- fleitz 11y agoI can estimate it as follows. Cocoa/UIKit works in ObjC. ObjC is a super set of C that translates the objc parts to calls to objc_msgsend. Go supports ARM/OSX. Go makes it pretty easy to call into C Therefore it should be pretty easy to port to iOS, all you need to do is to write a bit of go to interface with objc_msgsend.
- crawshaw 11y agoThis work is the extension of the Go on mobile experiment for Android, which was originally proposed here: http://golang.org/s/go14android http://golang.org/s/go14android. Over the past several months, several open source contributors (most notably minux) and I have been working on darwin/arm and darwin/arm64 support for Go 1.5. We can build binaries, and we can build Go packages as C archives that can be compiled into an ObjC program. At the same time Hana has been extending gobind (http://golang.org/s/gobind http://golang.org/s/gobind) with ObjC support, and came up with the idea of turning Rob's Ivy into an app. Hana built the Android app, I did the iOS app. This is a few hundred lines of ObjC/UIKit for the UI, calling into a Go function: func Exec(line string) (string, error) With the bulk of the app being the actual Ivy implementation in Go. It will be open source when I find the hours in the next week.
- fit2rule 11y agoJust wanted to thank you and acknowledge your work - Go on iOS represents a significant opportunity. Thanks!
- barsonme 11y agoFun little app to mess with and I'm glad Go's branching out. That said, I was very disappointed when the app didn't include the ability to clear the screen.
- crawshaw 11y agoThanks. Screen clearing and state saving are on my todo list. It's just a big list. I'd like to get the source code published first, and that means landing some toolchain cleanups first. (The android app is a bit ahead, it has a clear button.)
- deleted 11y ago[deleted]
- andrewchambers 11y agoThe point is that is a working app in go.
- ejcx 11y agoThis is awesome. Ignoring the fact that it is written in Go, the iOS calculator only goes up to 100,000,000 and it is super annoying. Free ones have obnoxious advertisements. Now, I want to learn to write iOS apps in Go as well.. Super neat and a great app to start with
- markelliot 11y agoFun trick: turn your phone to landscape mode while in Calculator and you get 26 digits instead of 9.
- bottled_poe 11y ago26? I get 15 digits before it switches to exponent representation. This is on iPhone 5s running iOS 8.4.
- eridius 11y ago15 decimal digits around is the approximate limit for a 64-bit IEEE floating-point number, which is what the built-in Calculator uses (most non-integral math done on computers uses either 32-bit of 64-bit IEEE floating-point numbers). The exponential notation is because floating-point numbers can represent absurdly large values, it just is limited on precision. So you can represent 10^31, you just can't represent 10^31 + 1.
- sneak 11y agoWhy should the user of a calculator care how the numbers are represented internally? More importantly, why should they be forced to? It's a bug.
- 0xdeadbeefbabe 11y agoWell, what if these users you speak of are trying to accomplish more than just homework?
- 11y ago
- molecule 11y agoprevious discussion: https://news.ycombinator.com/item?id=9866152 https://news.ycombinator.com/item?id=9866152
- ZoF 11y agoCool stuff! I'm curious why they chose to have expressions evaluated in right-associative order.... Basically why is operator precedence equivalent? Was it done because it was easier to code? Don't understand why this would be of significant difficulty. Won't this complete diversion from accepted notation hinder adoption?(not intending to imply they are aiming for widespread adoption) Could anyone who would use the app for an actual purpose chime in here? Totally understand this is a pet-project/example btw. Just wondering. Cool shit googlers :)
- coke12 11y agoOperators in APL had the same associativity and precedence semantics. On his github page, Rob Pike describes Ivy as "an interpreter for an APL-like language", so it makes sense.
- aric 11y agoRob Pike's Ivy: https://github.com/robpike/ivy https://github.com/robpike/ivy Video about it (Nov 2014): "Implementing a bignum calculator" https://www.youtube.com/watch?v=PXoG0WX0r_E https://www.youtube.com/watch?v=PXoG0WX0r_E
- hammerha 11y agoDoesn't this break the policy of Apple? As I know, Apple allows apps only made of some restricted languages from when Adobe tried to make iOS apps with Flash.
- glibgil 11y agoNo, Apple does not allow JIT. It does not dictate language use.
- fit2rule 11y agoI'm using LuaJIT on iOS just fine, and experienced no restrictions from Apple about using it.
- rsynnott 11y agoLuaJIT for iOS, confusingly, does not do JITing. Normal apps on iOS are unable to mark pages as executable, so it's impossible to JIT; it's not just an app store review-enforces restriction.
- fit2rule 11y agoAlas, you are right and I have learned something new today. It seems that Safari is the only JIT'able process we developers can gain access to ..
- deleted 11y ago[deleted]
- GeneralTspoon 11y agoThere are plenty of apps on the App Store with using Flash (Adobe AiR). As well as other languages like JS (React Native, Titanium). I think you're thinking of when iOS decided not to support Flash in the browser.
- david-given 11y agoI did actually think that Apple required the use of Apple's developer tools for iThing apps --- so unless you can compile your target language into C, C++, ObjC (or Swift, I suppose) and then use XCode to compile the final binary, your app would be rejected. Has this changed?
- dmitshur 11y agoRob Pike tweeted about it (the Android version) recently [1]. I ported [2] the app to the web within a few hours. The port involves ~70 lines of Go, 22 lines of HTML, and 24 lines of CSS [3]. [1]: https://twitter.com/rob_pike/status/619995629566058496 https://twitter.com/rob_pike/status/619995629566058496 [2]: https://twitter.com/shurcooL/status/620084337401171968 https://twitter.com/shurcooL/status/620084337401171968 [3]: https://twitter.com/shurcooL/status/620343011671609344 https://twitter.com/shurcooL/status/620343011671609344
- ericfrederich 11y agoPython seems faster than this gopherjs solution. I thought they'd be about equal or the JS being faster since JS is supposed to be really fast at math. I ran 2123456 in both and Python was quite fast, Ivy on gohperjs quite slow
- gjm11 11y agoUnfortunately, if you write 2[star][star]123456 in a HN comment, the HN software will decide that this means a 2, then an emphasized empty string, then 123456, and the results will be indistinguishable to readers from the much smaller number 2123456.
- deleted 11y ago[deleted]
- shurcooL 11y agoDo you have a link to the Python version? What was used to generate it? Also, what browser did you use, I'm curious.
- boomlinde 11y agoI believe he means plain python, which automatically promotes big integers to the bigint type
- estefan 11y agoA friend of mine was recently at gophercon and sent me this link: https://sourcegraph.com/blog/live/gophercon2015/123653512740 https://sourcegraph.com/blog/live/gophercon2015/123653512740 Writing a single shared library for different platforms makes sense. I think Google do this currently with java & then convert the java to objc, but if go provides an alternative it might finally be time for me to learn it...
- jheriko 11y ago> Writing a single shared library for different platforms makes sense i've always taken this approach... like since the 90s, although not necessarily a library, but shared code. there has always been a way to do this thanks to the ubiquity of C - its just been that Google has been reluctant to allow 3rd parties to do on android what they do internally for reasons I really don't know...
- GeneralTspoon 11y agoHuh? You can use C libraries on Android with JNI & the NDK. In fact it's how most games do it.
- jheriko 11y agoi never said you can't. i just said you could...
- JustSomeNobody 11y agoReluctant how?
- jheriko 11y agothey held back a toolchain for android native development for ages, but yet quite obviously used one to build the OS itself. its still a 3rd class citizen, despite being the backbone of the platform.
- jheriko 11y agovery good of apple to not reject it for the terrible ui... well done though its good to see new tech making its way into the walled garden of the app store.
- xiaoma 11y agoWhat's the point? Swift is a much nicer language to work in, it's more performent and iOS supports it...
- vhakulinen 11y agoThe same Go code works on Android and desktop too.
- sangnoir 11y agoand web.
- vhakulinen 11y agoWorth to mention, only the logic part is shared[1], for UI, both on Android and iOS native tools are used. [1]: https://www.reddit.com/r/golang/comments/3d0stz/ivy_first_android_app_in_100_golang_on_google/ct0rcdj https://www.reddit.com/r/golang/comments/3d0stz/ivy_first_an...
- fit2rule 11y agoI recently ported IPFS (http://ipfs.io http://ipfs.io) to iOS and have been running it on my iPhone for the last few months .. I was very pleasantly surprised how little fuss was required to get Go compiling for the iOS platform, and reminded once again that underneath all the garden trimmings, iOS is really just a little Unix workstation. (BTW, IPFS on iOS: not ready for primetime, but .. what a world it will be when it is!)
- maximveksler 11y agoI strongly feel that once Swift makes it to be open sourced the path from iOS native to Android (cross) will become much simpler then (go:logic, java:android UI, objc:iOS UI).
- wstrange 11y agoI think Google is more interested in Dart as a cross platform language. See the Sky project https://github.com/domokit/sky_sdk/ https://github.com/domokit/sky_sdk/ which uses Dart as the UI framework. Currently runs on Android- but I believe the intent is to have it run on iOS as well. From my perspective, Dart makes a lot more sense as an application language when compared to Go.
- TheMagicHorsey 11y agoI wish Go had a proper way to do graphics and GUI. It would be great to make Go desktop and mobile apps without all the messy interop or launching a web browser locally.
- tree_of_item 11y agoYou'll probably be interested in https://github.com/google/gxui https://github.com/google/gxui, targets desktop, mobile and web.
- not_with_retard 11y agoIt's _extremely_ early for that framework unfortunately, and development is quite slow.
- rhodysurf 11y agoHere's some really basic Qt bindings I've been helping with recently https://github.com/salviati/go-qt5 https://github.com/salviati/go-qt5