Swarm FAQ:Language
From SwarmWiki
Objective-C or Java?
You need to decide whether you will write your Swarm programs using Objective-C or Java. Aside from obvious points (such as the fact that you might already be more familiar with one of the languages), here are the pros and cons of the two languages:
- In the world of software development, at least one hundred times as much programming is done in Java as in Objective-C — see http://www.cs.berkeley.edu/~flab/languages.html. So you'll find more people and books that can help you with Java than with Objective-C. You'll also find more third-party libraries so, for example, if your model is three-dimensional, you might choose to abandon Swarm's visual interface (which uses TCL) in favor of Java's Java3D technology.
- Java was created over ten years later than Objective-C, and presumably takes advantage of the advances in language design that occurred after Objective-C was created.
- Probably more Swarm programs have been written in Objective-C than in Java, so there are more Swarm-specific programming models in Objective-C than in Java. On the other hand, given the size of the universe of all individual-based models that anyone might like to program in Swarm, unless you know of a relevant existing model right now, you're not likely to find anything more useful than the standard Swarm demos available in both languages. (But see: Swarm:_contributed_code)
- Although expertise in Swarm is rare, and expertise in Objective-C is rare, the latter tends to go with the former. So for the Swarm side of programming, you may find it easier to obtain help in Objective-C, while for the pure model building (programming the behavior of your agents), Java will, as mentioned above, provide more helpful resources.
- If one language is faster at run time, it's likely to be Objective-C. However, the difference is likely to be slight. You should not accept claims about speed without seeing a relevant benchmark. Try googling benchmark java objective-c.
- Java's treatment of floating-point arithmetic is not a full implementation of the IEEE 754 standard, in that you cannot check whether floating-point errors have occurred or change the rounding direction. In Objective-C this is not a limitation so long as your platform supplies C libraries to access the floating point unit (e.g. fpgetsticky() and fpgsetround()). This is a key advantage of Swarm over other pure-Java libraries. For more on this issue, there's a general paper on how floating-point arithmetic issues are relevant to agent-based models, and another showing how these issues affected two specific published models. You may also wish to vote for some requests for enhancements to Java logged with the Sun website (in particular bug IDs 5095286 and 5095600).
- Since the Java interface to the Swarm engine is generated automatically, identical functionality is available in both languages. Thus functionality would never be a reason for choosing one language over the other.
- There is additional discussion of Java vs. Objective-C versions of Swarm and some speed comparisons in the paper: Railsback, S. F., S. L. Lytinen, and S. K. Jackson. 2006. Agent-based simulation platforms: review and development recommendations. Simulation 82:609-623. See: Software_Reviews
![[Main Page]](/stylesheets/images/wiki.png)