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
Related
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
Is there a ready-made implementation of an interpreter for ObjC. Basically, I need my program to be extendable via a scripting language.
I'm not sure if this is already provided by some kind of framework, or perhaps I can implement AppleScript internally - not sure how I would do that tho. It seems to only apply to automating the program itself, not for extending its own functionality.
Something similar to mIRC's means of interfacing with a scripting language.
You bet there is. It's called FScript; it's open-source and includes a console with a REPL in which you can interact with Cocoa objects. The syntax is Smalltalk-like, which is very similar to Objective-C -- the main difference is no square brackets. Here's some snippets from their tutorial. Notice that variables don't have to be explicitly typed!
> imageLocation := NSURL fileURLWithPath:'/Library/Desktop Pictures/Nature/Clown Fish.jpg'.
> image := CIImage imageWithContentsOfURL:imageLocation.
> image drawInRect:(200<>80 extent:600<>400) fromRect:image extent operation:NSCompositeSourceOver fraction:1.
You will be interested in their Embedding FScript Into Cocoa Applications Guide.
Do you just want your program to be scriptable? If so, then you should probably add AppleScript support. See Introduction to Cocoa Scripting Guide for information on how to do this.
Python and Ruby can interact with the Objective C calls so you can use them to extend the program's functionality.
Objective C is not a scripting language, so it has no interpreter. It can only be compiled to machine codes.
If you want to use scripting language is suggest Lua. It is really easy and lightweight but still very powerful. You can use it with you native C/C++ programs and there are also ObjC bindings.
Anyway any scripting language (Python, Lua, AppleScript etc.) is built on top of some native programming language (usually C or C++) and if you want to extend your program with new features you still need to implement them first using native language.
Fot you to start: how to bind Lua. It is for C++, but it is the same for C and ObjC (as it is a superset of 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.
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.
Is there any other scripting language that can be used to embed scripts inside applications, which can access Mac OS X, or application classes with the same features, or most of the features seen in F-script?
The scripting language with the best support on the Mac is still AppleScript. But unlike F-Script, it cannot directly access the Objective-C level, it can only use what the target application chooses to expose for scripting.
There are Objective-C bridges for Perl, Python, and Ruby. I suppose those can embedded to provide scripting to your application.
Nu is an interesting option, although it isn't very popular yet.
A lot of people seem to like JSTalk.
But probably Applescript is your best bet: integrated into the system and all that.
I would say F-Script for many reasons. It has many unique features and is extremely tightly integrated with Cocoa and the Objective-C runtime. You can for example inspect various Finder classes (windows, icons, coverflow view...) and it's very easy (one or two lines of code) to start or control other processes. I don't think there is any good reason to prefer AppleScript. It's good for very short scripts, but will probably drive you crazy if you want to do something more complex.
Also, MacRuby is going to rock when it's a bit more stable, and some serious stuff has been accomplished using PyObjC as well, although I don't think it's very actively maintained anymore.
If you don't need F-Script graphical introspection tools, which are quite unique, there are some decent scripting languages that you can embed in applications. See in Particular RubyCocoa (for Ruby), PyObjC (for Python), JSTalk (for JavaScript) and CamelBones (for Perl). They are based on bridges between Cocoa and a foreign object model, which leads to some complexities. This is different from F-Script, which is directly built for the Cocoa object model. When ready, MacRuby might be an option too, but the syntax for manipulating Objective-C objects is not very nice (it improves on RubyCocoa, though). Nu is also an option: directly built for Cocoa like F-Script, but with a strong Lisp flavor.
MacRuby is an implementation of Ruby 1.9 that uses the Objective-C runtime and garbage collector. It can be embedded in a Objective-C application.
Even if the last available version is only 0.6, it is reported to be stable enough to be used in applications.