PyObjc vs RubyCocoa for Mac development: Which is more mature? - python

I've been wanting to have a play with either Ruby or Python while at the same time I've been wanting to do a bit of Cocoa programming.
So I thought the best way to achieve both these goals is to develop something using either a Ruby or Python to Objective-C bridge (PyObjc or RubyCocoa).
I know that ideally to get the best learning experience I would learn each techonology independently but I don't have the time. :)
So my question is which is a more mature platform, PyObc or RubyCocoa, main things I am looking for:
Documentation of API
Tutorials
Tools
Supportive Community
Completness of Cocoa API avaialble through the bridge
Regarding point 5 I don't expect that the entire Cocoa API will be availble through either bridge but I need to have enough Cocoa APIs available to develop a functioning application.

While you say you "don't have time" to learn technologies independently the fastest route to learning Cocoa will still be to learn it in its native language: Objective-C. Once you understand Objective-C and have gotten over the initial learning curve of the Cocoa frameworks you'll have a much easier time picking up either PyObjC or RubyCocoa.

I would echo Chris' assesment and will expand a bit on why you should learn Objective-C to learn Cocoa. As Chris says, Objective-C is the foundation and native language of Cocoa and many of its paradigms are inextricably linked with that lineage. In particular, selectors and dynamic message resolution and ability to modify classes at run time are required to implement Cocoa technologies such as Distributed Objects and bindings. Although these features are available in other dynamic languages such as Ruby and Python, there is enough of a mismatch in the language models that you will have to at least understand Objective-C to understand Cocoa. I suggest you take a look at this previous question for further discussion: Do I have to learn Objective-C for professional Mac Development?
Fortunately, Objective-C is very easy to learn. I often tell people it will take them a day to learn Objective-C coming from C/C++/Java or LISP, Scheme, or any of the 'newer' dynamic languages such as Ruby and Python. In addition to expanding your mind a bit, you'll learn to at least read the code that is used in virtually all of the Cocoa documentation and examples.
As for Ruby vs. Python, the bridge capabilities are very similar. In fact, they both use Apple's BridgeSupport (shipped with Leopard) to provide the bridge description. Both are supported by Apple and ship with Leopard. It's a matter of personal taste which language you prefer. If you choose Ruby, I suggest you give MacRuby a look. It's definitely the future of Ruby on OS X, as it reimplements the Ruby runtime on top of the Objective-C run time. This provides some nice performance and conceptual advantages (including integration with the Objective-C garbage collection system, a feature currently lacking in PyObjC which uses the native python gc). MacRuby also includes a custom parser that makes the syntax of bridged objective-c methods a little nicer. The downside of MacRuby is that it's not quite ready for production-level use at the time of this writing (June 2009). Since it sounds like this is a learning project for you, that's probably not an issue.

Both are roughly equal, I'd say. Better in some places, worse in others. But I wouldn't recommend learning Cocoa with either. Like Chris said, Cocoa requires some understanding of Objective-C. I like Ruby better than Objective-C, but I still don't recommend using it to learn Cocoa. Once you have a solid foundation (no pun intended) in Cocoa/Objective-C, then the bridges can be useful to you.

Apple seems to be getting behind Ruby scripting for Cocoa but not RubyCocoa. They are hosting and I believe supporting MacRuby. I often wonder if MacRuby is Apple's answer to a higher level language for OSX prototyping and full on application development.

ObjectiveC is nowhere near as much fun or as productive as either Python or Ruby. That is why people want to pick a python or ruby with good Objective C access. Advising them to learn Objective C first misses the point imo. I have really good things to say about pyobjc. Its ability to interoperate painlessly with Objective C frameworks is superb. I have less experience with Ruby Cocoa and that was partly because when I last looked it didn't seem to have as clean and relatively painless interoperability. I feel hesitant about MacRuby because it seems to go too far. In pyobjc you can write plain python and only subclass/use Foundation and Cocoa objects when you really want/mean to. From what I understand of MacRuby it is a Ruby on top of Cocoa. So a string is always an NSString. I am less happy with that. YMMV.

Related

Jython - Using Spring, Programming in Python?

Ok, I'm a total newbie in this stuff.
So, I know Spring is really good as a framework, and I've been programming in Python for a while, so I was wondering if somehow I can use the Spring Framework but use code from Python.
I heard that maybe Jython was a good possibility for doing this, since it's (I think) Python running on the JVM, right?
So, is this possible? For me to use Spring while coding in Python?
First, you're right that Jython is Python running in the JVM. And it's not just running in the JVM, it can interact with it in pretty much all the ways you want—use Java classes as Python classes, implement Java interfaces in a Python class and pass it to Java code, etc.
However, unlike some of the other JVM languages, Jython doesn't make any attempt to be semantically equivalent to Java (or to a superset of it). And of course Python and Java have very different idiomatic styles.
So, in short, just about anything is possible, but not everything is pleasant, as Marcin says.
For specifics about how Spring works with Jython, a quick Google search turned up See how Spring Python works with Jython. And in fact, it's part of a blog called "Spring Python", which is part of a site also called "Spring Python". It seems like this may be a port of Spring to Python rather than about using Jython with Spring. ("This project takes the concepts of Spring and applies it to the language and environment of Python. This includes pragmatic libraries and useful abstractions that quickly gets you back to working on the code that makes you money.") So, that might be another alternative for you.
The next search result was Jython Spring MVC Controllers.
And there were half a dozen other promising results. So, I think you'll have no problem finding information and examples.

Is Ruby or Python not suitable for iPhone or Mac app development because of speed, and any compiler that can help boost the speed? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I am reading a little bit on Objective-C, and since it comes from Smalltalk, like Ruby does, so I wonder, is it true that if using Ruby, (if Apple change XCode to support it), to develop iPhone or Mac app, it is not suitable really because of the speed? For example, Angry Birds probably isn't as smooth as it is now if using Ruby, vs if Objective-C, it is compiled and running as machine code.
But currently, is there any way of compiling Ruby or Python code into machine code so that it is running in the similar speed zone as Objective-C programs can?
On desktop those are fine languages to use, and for Python you could use py2app to deploy your app. You wouldn't want to write low-level graphics routines in an interpreted language, but that's what libraries like PyGame are for.
(Not that this is a particular advantage, but note that one of the most popular 2D game frameworks on iOS is a port of a 2D game framework for Python: http://cocos2d.org/ )
Until recently the iOS developer terms specifically disallowed running an interpreter, so nobody used Ruby or Python on iPhone. Apps programmed in those languages will probably start showing up, but you won't find much about that just yet.
Ruby/Python can be fast enough for Mac and even iOS development. It depends on performance requirements for your applications. It should be acceptable for most use cases.
Apple is developing Ruby implementation specifically targeted for Mac application development - MacRuby. Another option would be to use RhoMobile, a mobile development framework using Ruby.
Also OS X is bundled with Python and PyObjC library by default, which enables developing cocoa applications with python.
Possible ways to speed up your Python applications:
Use Cython. A python-like language, that compiles to c, to ease interoperability with c code.
Use Pyrex or Shedskin. The former compiles a subset of python to C, the latter to C++.
Use PyPy or Psyco. Both compile Python code to machine code on the fly.
For Ruby you might want to look at Rubinius - Ruby implementation that compiles to native code on the fly.
Python and Ruby themselves are not too fast, but many programs today are written to basically do none of the heavy lifting alone. For instance, if you want to save a PNG file as a JPG, you are certainly going to use the built in system calls to do it. In that case it does not really matter if it takes 0.00001 seconds in Obj-C, or 0.001 seconds in Python to process the mouse click, when the optimized system code to convert the image is the exact same code in both programs, and takes, say 1/2 a second to run. On the other hand if you are making a low level data munger of your own design, then you might want some C. Basically all languages that you would use on a Mac allow you to write something in C, and call it from that language, so even that does not slow you down.
Pick the language for the task based usually on what everyone else is doing for that problem, intersected with your abilities.

Game engine with python scripting?

Looking to put together a 3D side-scrolling action platformer. Since this is my first time trying to put together a non-simple adventure game, I'm at a loss for which engine to consider.
I would prefer one that supports scripting in python, since that's my primary language. Without tight controls, the game will suck... so speed is a priority. Cross-platform is also important to me.
Any suggestions?
Active game engines with Python scripting
Panda3D is a framework and requires low-level programming
pyglet is a multimedia library and requires low-level programming
Inactive game engines with Python scripting
ratcave (based on pyglet, inactive since 2018)
Engendro 3D (inactive since 2018)
PySoy3D (inactive since 2016)
Delta3D (inactive since 2016)
sylphis3d (inactive since 2015)
Eden (based on Panda3D, inactive since 2014)
Python-Ogre (inactive)
Blender Game Engine (discontinued)
The OGRE engine used to have 3rd party Python bindings, as of 1.10 official Python bindings. As of 2.2 there is no official or 3rd party Python support.
Panda3D:
http://www.panda3d.org/
It's a 3D game engine written in C++ but specifically designed for use in Python. Disney has used it for some of its games in the past, including 2 MMOs. There is support for shaders, etc., and is BSD licensed. Windows, Mac, and Linux are all supported, and there appears to be a browser plugin. I haven't used it personally, though.
Try PyGame and PyOpenGL together, here are some examples.
You also may use the Blender Game Engine.
Pyglet is another one.
http://www.pyglet.org/
See Differences between Python game libraries Pygame and Pyglet?
PyOgre is the Python bindings of the C++ graphics engine Ogre.
Unfortunately there are no game engines in the modern sense of the word (includes editors, tools, physics, not just an audio and graphics programming library), that support Python scripting.
However there are modern game engines, which have benefits like level editors and built-in physics that might make up for the lack of Python:
Godot (GDScript which has syntax similar to Python, open source)
Unity (C#, proprietary)
Unreal (C++, proprietary)
This is what I would use: Unity. It has a learning curve, but once you get the hang of it, it's very powerful. It uses your choice of Java, Boo(which I hear is very similar to Python), and C#.
Regardless of what you pick, I would advise you learn Java. It's a widespread language, so it should open up lots of options for you in various ventures. Learning another language is always very good for you.
Both Unity and Unreal have excellent third party Python Bindings. Its been a while since I've used the Unity one, but at the time it was perfectly competent. It does use Iron Python, so its not the C Python implementation, but at least its not Boo which I believe has been dropped from Unity anyway.
https://forum.unity.com/threads/python-interpreter-in-unity.86461/
And heres the Unreal one. I've used this a lot, and it works great. Its a bit of a headache to install initially, and I'd advise against it if your planning to deploy mobile as you'd have to get your hands dirty with some messy C++ and a very tight runtime. But if your writing a desktop game, its perfectly competent.
https://github.com/20tab/UnrealEnginePython

What's the state-of-the-art in Python programming in Windows? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm looking to set up my development environment at home for writing Windows applications in Python.
For my first piece, I'm writing a simple, forms-based application that stores data input as XML (and can read that information back.) I do want to set up the tools I'd use professionally, though, having already done a round of didactic programming.
What tools are professional python developers using these days? In order to have a working python environment, what version of the compiler should I be using? What editor is common for professionals? What libraries are considered a must-have for every serious python developer?
Specifically, which Windowing and XML libraries are de rigeur for working in Windows?
I like Eclipse + PyDev (with extensions).
It is available on Windows, and it works very well well. However, there are many other IDEs, with strengths and weakness.
As for the interpreter (Python is interpreted, not compiled!), you have three main choices: CPython, IronPython and Jython.
When people say "Python" they usually refer to "CPython" that is the reference implementation, but the other two (based, respectively, on .Net and Java) are full pythons as well :-)
In your case, I would maybe go on IronPython, because it will allow you to leverage your knowledge of .Net to build the GUI and treating the XML, while leaving the implementation of business logic to Python.
Finally, should you decide to use CPython, finally, there are several choices for working with xml:
minidom; included in the standard library
lxml, faster and with a better API; it means an additional installation on top of Python.
Lots of questions, most hard to answer correctly. First of all, most of python development happens on unix-like platforms. You will hit many walls during development on Windows box.
Python is not a compiled lanugage, current preferred version for production is 2.5. For environement setup you should take a look at virtualenv. Editor is a personal choice, many Python developers use Vim, you can customize it pretty well to suite your needs.
About libraries, Python is very strong around this area and it's really hard to say what is a must to know. If you want to handle XML, I would preffer lxml.
If you go for CPython, make sure you get the win32 extensions by Mark Hammond, either as a separate download which you install on top of the vanilla Python installation, or as part of ActiveState's ActivePython. It includes an integrated editor and debugger.
Jython has recently reached 2.5 compliancy, but we quickly ran into recursion limit issues.
The standard distribution includes IDLE, a graphical editor and debugger.
I like shells, so I'm using IPython for interactive work, and pydb as debugger (unfortunately, I had problems getting pydb to work under Windows).
"What tools are professional python developers using these days?"
Lots
"In order to have a working python environment, what version of the compiler should I be using?"
["compiler" is meaningless. I'll assume you mean "Python"]
We use 2.5.4. We'll be upgrading to 2.6 as soon as we've done the testing.
"What editor is common for professionals?"
We use Komodo Edit.
"What libraries are considered a must-have for every serious python developer?"
We use Django, XLRD, PIL, and a few others. We don't plan this kind of thing in advance. As our requirements arrive, we start looking for libraries. We don't "pre-load" a bunch of "must-have" libraries. The very idea is silly. We load what we need to solve the problems we have.
There are no set standards in these matters, and for good reasons:
there is a fair amount of good choice
different people are productive with different tools
different tools and libraries are suited for solving different problems
That said, I think it's a valid question exactly because there is a fair amount of good choice. When there is too much choice people often do not chose at all and move on. You still need to do your own research to decide what is best for you but you may find here some good starting points.
Here is what I use professionally on windows:
python 2.5.4
latest wxPython
XRC Resource Editor from the wxPython docs & demos for the grunt of the tedious GUI design
lxml or gnosis utils for xml
WingIDE Professional
Taking the headline question literally, the answer has to be IronPython. The 2.0 releases are equivalent to CPython 2.5, and the 2.6 release (currently at beta2) is intended to match CPython 2.6 (full 2.6 release some time in the next couple of months). With either you can use the state of the art in Windows GUI frameworks, i.e. WPF; and you get the whole .net XML support libraries (excepting Linq to XML, which relies on clever bits of C# that IronPython cannot yet emulate).
I've used NetBeans Python plug-in happily as an IDE for IronPython using WPF.
The answer would depend on what you want to do with Python. If you want to do web programming, Python is blessed with many web frameworks. The most popular ones are: Django, Pylons, and Turbogears. There's also Google App Engine, where you can deploy your Python webapp (based on GAE framework) to Google's infrastructure. If you want to do Desktop programming then there is PyQT and TkInter, or you can even try using Java Swing with Jython. And if you want to do Mobile app programming then there is Python for S60 which is backed by Nokia.
Python is interpreted language, so there is no compiler (although the interpreter also compiles your python module into bytecode). I would recommend using Python 2.6 as it has some syntax and libraries that is different compared to 2.5. You can also start learning Python 3.0 too.
There is several IDE that is good for Python. You don't have to get yourself attached into one editor/IDE because most of them are good ones. For the commercial ones there is WingIDE which is really focus on making IDE for Python and I would really recommend IntelliJ IDEA with Python plugin which is really nice if you often look at the libraries in your Python environment. For the free ones (as others have said) there is Komodo Edit or you can also try Netbeans with Python plugin.
As for the must-have libraries, this is depending on what you want to do. What kind of application you want to develop with Python. But I think every Python developer should consider PIL for imaging library. I also use simplejson quite often, because I prefer using JSON rather than XML. If you are using XML though, you can use lxml as it is really fast in parsing XML.

Study Objective-C , Ruby OR Python? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I am working on C++ since last 4-5 years . Recently I have bought iphone and macbook and want do do some programming for iphone.
So I have started reading one book about Objective-C. I have also learn that we can program with Ruby and Python on MAC.
So my question is which one to study? Which language you guys see the FUTURE???
Can we program with these languages on other platforms? Or are these only limited on MAC?
I am just a beginner in objective-C.Need some expert thoughts which way to go.
AC
If you want to program for iphone then you should use objective-C. The entire iphone API is based on objective-C, and you have the benefits of using interface builder and IDE support from Xcode.
I use all the languages C++, Ruby, Python and Objective-C. I like each one in different ways. If you want to get into Mac and iPhone development as others I recommend Objective-C.
One of the benefits not mentioned is that Objective-C is a proper superset of C (C++ is almost a superset), that means you can bring over all your C programming knowledge from doing C++ to Objective-C programming. In fact you can also mix in C++ code in Objective-C code.
You can't do that in a seamless way in Python and Ruby. The reason why you can do this is that Objective-C is actually a very simple language.
Originally it was just C with a custom made preprocessor which took statements like this:
[rectangle setX: 10 y: 10 width: 20 height: 20];
and converted it to this before compiling:
objc_msgSend(rectangle, "setX:y:width:height:", 10, 10, 20, 20);
Apart from that Ruby, Python and Objective-C are very similar in their object model at least compared to C++. In C++ classes are created at compile time. In Objective-C, Ruby and Python classes are things created at runtime.
I wrote some stuff on why Obj-C is cool here
Objective-C is the only way to program an iPhone if you want to produce native programs that can be sold in the App Store.
Some of the more advanced concepts in Objective-C are now being added to languages like C# (eg: extension methods in C# v3.0). Learning to think in Objective-C will be useful, the OO model you learn will be applicable to most other languages and environments as an addition to your C++ experience.
Ruby's object model is closer to that of Objective-C than is Python so I suggest also learning Ruby but not until you have your Objective-C skills down solidly.
Note that you can use Objective-C++ and use C++ for all but your GUI code by having .mm suffixes on your files - this works on both iPhone and Mac. Given your C++ experience, that help you be productive.
If you want to program iPhone, don't bother learning the new Objective-C 2.0 memory management but you can still use the Properties model (iPhone effectively has a subset of the Objective-C 2.0 runtime).
Which language you guys see the FUTURE???
Future of what? iPhone development? Objective-C.
Web Services? Python/Ruby in parallel for a while. At least until people start trying to do maintenance on large Ruby applications and get frustrated with it's opacity.
Real-time game engine development? Embedded applications? Future of what?
"Can we program with these languages on other platforms? Or are these only limited on MAC?"
Ruby and Python: Yes. These are designed to run on any platform that supports C.
Objective-C: Yes. It's open source, it's in the GCC, it should work almost anywhere.
Learning a new language is not a zero-sum game. You can learn more than one language; learning Objective-C now does not prevent you from learning Python or Ruby in the future.
As a Perlite, I'm just going to point out that OS X has Perl as well as Python or Ruby.
As far as Perl/Python/Ruby goes, programs are almost completely cross-platform. It is fairly easy to run a Perl/Python/Ruby program on any platform and it works more or less the same. There may be some minor differences, but they're not major.
Objective-C, while not strictly confined to OS X, is only really used in OpenStep-based environments, which generally means OS X and the iPhone. The only Objective-C compiler I know of is gcc, and I imagine you can write Objective-C on Linux, but I don't know if Windows support is very good (if it exists).
As for which is the language of the "future", all 3 (or 4) languages will be used very widely in the future. No one can really predict this kind of thing, and none of the languages are really going to die off (unless Apple switches to a new language as a "standard" for making Mac programs), so you'll be pretty safe with any of them.
My advice: try them all out and see which one you think most suits your style, and learn that one.
As has been noted by others, if you want to program the iPhone, Objective-C is the way to go.
Objective-C is pretty Mac-specific; of course, the Gnu Objective-C compiler is avaialble for other platforms as well, and there is also GnuStep, but I think the main applicability of Objective-C today is for programming Macs and iPhones.
Python and Ruby on the other hand are available on a large number of platforms (including both Windows and many Unix-dialects). Personally, I prefer Python, but I would say both languages are very usable and pretty easy to approach.
Note also that both Python and Ruby have Objective-C bridges available, which allows you to write quite fancy Cococa applications in any of those languages.
If you program with Objective-C, your main goal should be writing Cocoa applications on the Mac. Beyond that, it has little use. Ruby and Python are useful scripting languages, and there are also bridges to write Cocoa applications.
If you want to write apps on the Mac, I would start with Objective-C. There is more support available.
In terms of the future, it seems like a lot of people are jumping on the Ruby bandwagon at the moment. Good luck.
To program on Mac OS X, you really do need a good foundation in Objective-C. The vast majority of documentation will assume Objective-C. Even if you choose to program some applications in some other language, you will be better off having a good understanding of it.
Ruby. With Ruby you will be able to do both web development (Rails/Sinatra/etc.) and very soon program on the MAC/Iphone platform with the Macruby project. Why not get the best of both worlds?
Tommy
Just my two cents...As I'm sure you're aware, Apple and others in the respective communities are doing a lot of work with Ruby and Python, for both Mac and iPhone development. Objective-C will pretty much get you into Apple arenas only these days (though maybe that's not a bad thing;) However, if you are only going to learn one language in the foreseeable future, think about where you will be using it, and what for. Ruby and Python will get you a lot further if you are looking beyond solely Mac desktop and iPhone.
I have written small games, interpreters, and tons of awessome stuff in Ruby. I Wouldn't recommend It to write intensive AI programs for instance, but It's fun to learn and powerful for most applications. Even when I do most of my work in C++ Ruby is my favorite language for subjective reasons.
Objective C as most people said Is a must in iPhone development, and fun if You're enthusiastic about learning languages.
I haven't tried Python, but I hear nothing but good things about It, and PyGames Is quite popular.
I would learn the three ( well...I would skip objective C unless You're curious about getting into iPhone development), the most languages you know, the best professional You will be. As a good professor of mine always said..It's not about being the master in just one language, It's about knowing the pros and cons of each one to choose the right one according to the particular problem You want to solve.
Cheers !
Objective-C is only Mac/iPhone, and I recommend you to learn if you want to develop applications for Mac/iPhone.
Python is everything and it's future, but python more preferable for web development. Python is Google :) Python is web, games, science, graphics, desktop, etc. Also it's very good choice if you are C/C++ developer.
Not sure if i can recommend you to learn Ruby...

Categories