What is the best scripting language to embed in Mac OS X 10.6 applications? - 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.

Related

How to develop many-language / multi-platform lib?

Background: I want to develop a component therefore building a class library.
This component should be usable with many higher-order languages such as C, C#, C++, VB, Java, Haskell, Ruby, Erlang, ...
I do not want to exclude any users which are not using my development language.
Are there principles or tools which supports my project?
I searched a little bit and found Haxle for compiling into different languages, but it supports very few of them.
I would even develop parallel in all n languages to be supported, but if I want to change or fix something I have to maintain all other n-1 and the code is possibly distributed...
This is not what I know about clean code design and maintainability. So how to manage edits on code for the different languages?
What is the proper way to solve this? I am surely not the first one which want to build a library for multiple languages.
I want to develop this library (in this case for complexity reduction) in one target language but this time for multiple platforms (Unix, Win, Mac ...).
How to manage this? In fact there will be appreciated about 90% of code which is platform independent and 10% which differs for every OS.
What is the best way to control the changes in the platform dependent code? (The independent is easy ...)
What if I change so things in the part which uses Unix dependent code, then I have to trail all other platform and the code is possibly distributed.
I think #IFDEF is no option ...
Are there any experiences or hints?
I would be delighted if there are existing solutions to these problems, which are quite similar.
What you want is only possible if you provide interfaces for every language you want to support. Some kind of wrapper which transforms between the client language and ypu library.
This is possible but not practical in most cases for standalone libraries.
Take a look at webservices or or message orientad middleware. In this case your application will be provided within a special container which itself provides interface mechanism e.g.
SOAP, XML-RPC to call your application.
For 1), I would use an interface that all these languages can use. A common approach is something based on networking/TCP, like protobuffer, REST, SOAP. Many languages support these in their standard libraries, and interfaces designed with that are normally language agnostic.
There are basically two options - you could develop a network server or you could develop a JVM-based library which could be shared between some of the JVM languages like JRuby or Jython.
Update from #millimoose: you could also develop your library in C and create bindings for all other languages.
For multi-language:
I thought about TCP/middleware/webservices/REST/ which seems to be the recommended proceeding.
But I think it's all to much at runtime for only using a library.
Also the functionality is a little bit time-critical and so direct procedure calls are more fitting (instead of networking even on localhost). And the library user hasn't to construct an access component only to use the library functions.
So I think the way to go seems to be developing the library in a core language which is widely supported (C/C++, ...) and provide wrapper interfaces for the different target languages.
For multi-platform (mono-language):
No real answer has been provided also not in my mind.
Of course I could simply use Java (what I am familiar with) but what about other languages?
I am surely not the first one having this/these problem(s) ...

FoundationKit on gcc/Linux

I am trying to test Objective-C on Linux (Ubuntu 10.04), mainly to decide if it's worth it to get a Mac and XCode. I have to like a language before I seriously consider programming in it (even more so when I have to pay a lot for it)
I am using gcc (with gobjc++). But this of course does not include the Foundation Kit and the rest of the Cocoa API (not overly concerned about this one).
Short of GNUStep, what is the best way for me to get into Obj-C programming in Linux or Windows? I want to get at least class in the FoundationKit.
You have two options:
GNUstep, which is focused on Linux
Cocotron, which is focused on Windows
Those are the only freely available implementations of Foundation that I'm aware of.
Honestly, the language is hardly ever used outside of the Apple ecosystem, so you're not going to get a first-class experience here. Not knocking those groups' efforts, but if you're looking for something comparable to what you get on OS X, it just isn't there.

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.

Is Objective-C used without Cocoa?

It seems that Cocoa seems to be the main platform for Objective-C. GCC (which Xcode uses) supports Objective-C so it must be available on a wide range of platforms.
Are there any notable cross-platform projects that use Objective-C but not Cocoa (or its open source cousin GNUStep)? Is it really used outside the Apple ecosystem?
Objective-C has also been popular in the scientific and financial services communities. There are still many Objective-C based applications deployed in banking, mostly on the trading analysis front. A friend works on a nearly million line of code Objective-C based analysis and trading engine for which they have written their own class hierarchy from scratch.
At one point, one of the more popular Linux window managers was written in Objective-C. That was a few years ago and may no longer be the case.
The LLVM compiler also compiles Objective-C, including having full support for Blocks. It is quite portable, too.
There is also David Stes's Portable Object Compiler. It compiles Objective-C to C and uses a class hierarchy that is based quite directly upon the original ICPak class hierarchy from StepStone.
It seems what you're asking is if Objective-C is ever used without Cocoa, or GNUstep, or Cocotron, or any API like them.
The answer is basically no. Without an API like Cocoa (or GNUstep, etc.), Objective-C isn't very useful. For example, without NSObject, retain and release wouldn't even exist. A ton of very important features are built into these APIs, so it's somewhat pointless to use Obj-C without one of them.
Yep, there sure are. The one I can think of from the top of my head is Cocotron. An effort to port AppKit to Windows.
http://www.cocotron.org/
Aside from that, Objective-C can be used on any platform that gcc will run on. You won't have the wealth of frameworks that are available in Cocoa on OS X or the iPhone, although as you mentioned, GNUStep does a pretty good effort.

Has Lua a future as a general-purpose scripting language?

As already discussed in "Lua as a general-purpose scripting language?" Lua currently probably isn't the best scripting language for the desktop environment.
But what do you think about the future? Will Lua get so popular that there will soon be enough libraries to be able to use it like Python, Ruby or something similar?
Or will it simply stay in it's WoW niche and that's it?
I think it has a great future, a lot of projects are starting to adopt it for it's simplicity and usefulness.
Example: Awesome WM (Window Manager)
The project recently released version 3, incorporating a new configuration system completely written in Lua. Allowing you to literally write your configuration file as a program, loops, booleans, data structures.
Personally I love the syntax and the flexibility of such a system, I think it has great potential.
I wouldn't be surprised if it became more popular in the future.
Brian G
I suppose the answer starts with 'It depends how you want to use it...'.
If you're writing the common business app (fetch the data from the database, display the data in a web page or window, save the data to the database), Lua already has what you need.
The Kepler Project contains goodies for web development. Check out their modules to see some of the available libraries - there's network, MVC, DBMS access, XML, zip, WSAPI, docs...
As an example web app, check out Sputnik.
For desktop UI, there's wxLua - Lua hooks for wxWidgets.
ORM is conspicuously missing but that didn't stop people from developing in other languages before ORM was available.
If you're looking for specialized libraries - scientific, multimedia , security - don't count Lua out before you check LuaForge.
When it comes down to it, there's nothing in Lua's design that prevents general purpose use. It just happens to be small, fast, and easy to embed... so people do.
Uh? I would say instead WoW is a niche in the Lua ecosystem... The world of Lua doesn't revolve around WoW, there are lot of applications, some big like Adobe Lightroom (to take a non game), using Lua.
Lua is initially a scripting language, in the initial sense, ie. made to be embedded in an application to script it. But it is also designed as an extensible language, so we will see progressively more and more bindings of various libraries for various purposes.
But you will never get an official big distribution with batteries included, like Python or Perl, because it is just not the philosophy of the authors.
Which doesn't prevent other people to make distributions including lot of features out of the box (for Windows, particularly, where it is difficult to build the softwares).
Lot of people already use it for general system-level scripting, desktop applications, and such anyway.
There are more and more libraries for Lua.
If you are a Windows user, have look at Lua for Windows. It comes with "batteries included" (wxLua, LuaCURL, LuaUnit, getopt, LuaXML, LPeg...).
Very usefull!
It's 2017, 9 years after this question was first asked, and lua is now being heavily used in the field of machine learning due to the Torch library.
I really like it as an embedded language. It's small, very easy to use and embed and mostly does what I need right out of the box. It's also similar enough to most languages that it has never really been an issue for me. I also like how easy it is to redefine and add base functions and keywords to the language to suit whatever needs my application has.
I have used it in the WoW area but I've also found it useful as a generic scripting language for a number of different applications I've worked on, including as a type of database trigger. I like Ruby and Python and other more full-featured scripting languages but they're not nearly as convenient for embedding in small applications to give users more options for customizing their environments.
being comfortable as a shell language has nothing to do with being a great general purpose language.
i, for one, don't use it embedded in other applications; i write my applications in Lua, and anything 'extra' is a special-purpose library, either in Lua or in C.
Also, being 'popular' isn't so important. in the Lua-users list periodically someone appears that says "Lua won't be popular unless it does X!", and the usual answer is either: "great!, write it!", or "already discussed and rejected".
I think the great feature of Lua is, that it is very easily extensible. It is very easy to add the Lua interpreter to a program of your own (e.g. one written in C, C++ or Obj-C) and with just a few lines of code, you can give Lua access to any system resource you can think of. E.g. Lua offers no function to do xxx. Write one and make it available to Lua. But it's also possible the other way round. Write your own Lua extension in a language of your choice (one that is compilable), compile it into a native library, load the library within Lua and you can use the function.
That said, Lua might not be the best choice as a standalone crossplatform language. But Lua is a great language to add scripting support to your application in a crossplatform manner (if your app is crossplatform, the better!). I think Lua will have a future and I think you can expect that this language will constantly gain popularity in the long run.
Warhammer Online, and World of Warcraft use it for their addon language I believe.
I think it's hot! I'm just no good at it!
Well, greetings from 2022.
It is already a general purpose language. Today you can even serve pages using OpenResty, extend games, read databases or create scripts as shellscript replacements.
There are a plenty of libraries "modules" for Lua, many ways to achieve what you are wanting and Lua 5.4 is even faster.
The "extendable and extensive" nature of Lua, accostumed people to think it should only be used as plugin or extension. In Linux, by example, you can shebang a file with lua-any, make it executable and run like any system script. Or you can make a folder app like Python or virtualenv using Lupe. Lua 5.3 also gained impressive performance improvements.
Also there are many good tools like IUP to create native windows in Lua for Mac, BSD, Linux and Windows and side environments like Terra that lets you use Lua with its counterpart Terra and write compiled programs. Lua now, is more than a extension language, it has its own universe.