CoffeScript'esque language for Objective-C? - objective-c

Seeing what has been done for Java with Xtend and Mirah I can't help but think someone must be playing around with something similar for Objective-C or even C and C++ for that matter.
After some searching I've come up with nil. Is anyone aware of a CoffeeScript like Objective-C implementation?
Update:
Good input so far from the two that have submitted answers, however wouldn't it be superior (realizing that that's a little subjective) to have an intermediate language that compiled directly to Obj-C precisely as per how CoffeScript works? Now, I'm not asking for CoffeeScript mind you, but rather some language that doesn't compile directly, but rather gives you a more readable top layer syntactically a la Xtend.

Yes: Eero, which provides a somewhat Python-like syntax for Objective-C, implemented using a modified version of clang. (I haven't tried using it, though, so I can't comment on how useful it is!)

MacRuby and RubyMotion let you code Mac and iOS applications (respectively) in pure Ruby. CoffeeScript is very Ruby-inspired, so if you enjoy that language, i think you'll feel at home with Ruby :)
Also, it is my understanding that both MacRuby and RubyMotion integrate nicely with the native environment; they don't run on a separate Ruby VM on top of Mac/iOS, so there is no big performance penalty and the native things are not that far away. So in that sense i think they are more similar in sipirt to Mirah for the JVM than to JRuby or Jython for example.

This project actually compiles Ruby -> native code in the end, thus making it possible to write iOS apps via Ruby. It's called UnderOS (uOS - because it's all about "u" according to the author ;)) and is about the best solution I've found if you want to do iOS development with Ruby:
https://github.com/under-os/under-os
Example of building a calculate app:
http://vimeo.com/81919125

Related

Generate Objective-C code from any other language

Are there frameworks/generators for producing iOS code from any other language?
A dynamic language like JavaScript, ruby or Python are preferred. Googling for iOS code generators was largely fruitless.
The problem with systems like PhoneGap is that their output is a full-fledged application. What I need to produce is a library (.a & .h file eventually) that other Objective-C developers can reuse in their projects.
RubyMotion may or may not do what you want. I haven't seen much about the practicalities of it yet, but I'm thinking since it's statically compiled chances are good that it can produce libraries that can be simply linked into Objective-C projects. One might need another tool to produce the header files.
Of course, this is all speculation.
I think the best solution for what you're looking for is Titanium. It has its own sdk (in JavaScript), a complete IDE and allows you to have one codebase for all major platforms (iOS, Android included). What it's really awesome is the fact that it actually generates native code (a valid XCode project or a Java one for Android). It's also free and open source. Definetely worth a look.
I've never seen code generators, but there are a variety of "spoofs" as it were.
http://xamarin.com/monotouch - iOS on C#
http://phonegap.com/ - iOS on HTML, CSS , Javascript
http://ipodtoucher55.blogspot.com/2010/06/how-to-create-iphone-apps-in-flash-cs5.html - one of several tutorials for flash on iOS
I've seen links to python libraries and I think java too.
When it comes down to it though, they're all work arounds, not direct development.

REPL for Objective-C

Is there a REPL for Objective-C?
I am learning Objective-C and am sorely missing a REPL, coming from a Python background.
F-Script provides a Smalltalk-inspired REPL for Cocoa development, and Nu provides a Lisp-based one. F-Script seems a bit more polished and offers an object browser.
They both seem to be targeting OS X, rather than iOS development. There are scattered forum and blog posts with people describing using Nu for developing iOS apps, but they all seem to be from about two years ago. There's also a YouTube video, "Using a Scheme REPL to debug iPhone apps real-time" with a screencast of a fellow using Scheme to debug an iPhone app.
I haven't experimented with any of these technologies, but I would love to hear from anyone who has.
I just realized there's a simpler answer to all this. If you're coming from Python, and want to experiment with Cocoa in a REPL, you should just use the Python REPL. OS X ships with a Python to Objective-C bridge. Just run Python, do import objc, and you're off. There are also bridges for Ruby and Common Lisp, among others.
Of course, all these REPLs only let you write dynamic code to interact with Cocoa, but they don't let you write actual Objective-C code, and interpret it or compile it on the fly to interact with it dynamically. So none truly meets your original requirement.
When a breakpoint is triggered the debugger should pop open. When in the debugger, you can type whatever you want into gdb. You can use p [someObj someMethod] to print things out that are in scope to your breakpoint. gdb is a powerful utility well documented all over the web.
That's going to be as close as you get to what I think you are after. This is just a much clunkier thing to do in compiled languages, as there isn't any eval in Objective-C.
As far as I know, the closest you can get to a REPL at the moment is indeed through debuggers (i.e. GDB or the LLVM debugger LLDB).
For pure C, there is CCons.
Most things in Apple's Objective-C APIs (particularly Foundation) also have direct C equivalents (e.g. CFRelease(obj); is the same as [obj release];), which you can use in CCons.
CCons is built on top of LLVM and Clang, which also support Objective-C. It is probably possible to extend CCons for to also support Objective-C.
The 'trial' of CoderPad gives a public facing self-only REPL for zillions of languages including objc!!! I just used it and it's really a good sales tool for them (I'm not affiliated; they make tools for people interviewing coders). https://coderpad.io/
In the Gambit Objective-C project there seems to be an attempt to create a Scheme based REPL.
The REPL in Ruby Motion is also supposed to be good for exploratory purposes (I haven't tried it myself, though).
Yes, the REPL is in the output window.
"print object"
po object
but also execute commands which are running as app code with
expression i = 5
Read this interesting full debugging article for more information.

How to use some ruby with objective-c

I don't want to go the full rubyobjc, how would I be able to use a few ruby-terms in my cocoa/objective-c code?
The reason I want to switch is because I really like ruby's syntax. It's awesome!
If it's not possible, then I'm wondering if rubyobjc is good...
Unfortunately I've heard that when using rubyobjc there isn't a nib/interface builder.
Check out MacRuby, I was just watching a screencast on it the other day and he was able to use Interface Builder and call objective-c methods and ruby methods together to build a simple osx desktop app.
And now that Apple has lifted restrictions on iOS software, it might be possible to use it for iPhone/iPad development.
You can't mix Ruby terms or syntax into Objective-C source files. You may be able to make some classes in Ruby (with MacRuby) and other classes in Objective-C, though.

What languages besides Objective-C will generate application code that works on an iPad?

I would like to write an app for the iPad but I can't stand Objective-C.
Is there a language generator that would spit out Objective-C but let me write my iPad application in another language?
I've heard a little about MacRuby and am curious whether it could be used this way. Any other similar projects in other languages?
C# with MonoTouch.
JavaScript with Appcelerator Titanium.
Flex with ELIPS Studio 3.
Python with PyObjC (for jailbroken iPhones though).
Apparently Lua is an option.
John McIntosh uses Smalltalk on the iPhone. For instance, his Mobile Wiki Server app.
No computer anywhere (well maybe some) cares what language you write your programs in. Heck, you could hand-write machine instructions if you were patient (and crazy) enough. As long as you can figure out how to interact properly with the system call interface and the ABI, you can do whatever you want.
You could use Corona, Torque, or Unity. These all have advantages and disadvantages compared to using the standard Objective-C SDK, but really, if it's about the language itself, it's hard to see how you would be better able to "stand" the languages supported by these three than Objective-C.

Alternative language to do Cocoa programming

I'm a C++, Java developer and I want to program for Mac in something "nicer" than Objective-C.
I know Java Swing can mimic the MacOS X UI, but a Java Swing program is not a Cocoa first citizen. Also I know that I can use Qt in C++ or Jambi in Java to use the Qt toolkit that performs Cocoa calls but, though that is not a bad idea, it adds an abstraction layer in all the thing.
So, is there something like "Vala" for GTK+ or some Java bindings or some stuff to do Cocoa programming with no need of all the Objective-C thing?
[DISCLAIMER: "nicer" is just my appreciation, no trolling there]
It is indeed an inflammatory question.
There are bindings for Ruby and Python, if those fit your bill.
http://developer.apple.com/leopard/overview/apptech.html
Objective-C isn't all that un-nice and not all that dissimilar to Java in several ways, really, if you take some time to learn it.
MacRuby + HotCocoa lets you do it all in Ruby, and in a Rubyesque way - it looks more natural than a foreign binding might suggest.
Give Monobjc a shot. It's been great to work with.
If you're interested in .NET programming, you can use the Mono framework to program in pretty much any environment, including iPhone:
http://www.mono-project.com/Main_Page