As I read mî code books I keep seeing how Obj-C is really smart, and progressive in reuseing code banks. And how everything on the screen is an object that sends and recives messages …
Not of OSX and cocoa , but just plain ol Obj-C and the smarts that come with it’s method. One would think that a smart coder could under stand it better than say C++ … Reading NeHe examples, and lots of them are Cocoa enabled or Xtools enabled…
Soooo is absolute ostriazation the most likely future if I use such a tool for blender?? Cause I can’t get used to python, not no waya not no how but still have to read it when looking at stuff in the source
Obj-C adds objects to C. People have been doing object-oriented programming for decades with C++, Java, Python, C#, Smalltalk and even C. Obj-C is hardly progressive or any better at making code reusable than other object oriented languages. Look at any modern UI toolkit (Qt, GTK, Winforms, …), and you will see everything on the screen is represented as an object. There is nothing new in Obj-C. I’m not saying it’s a bad language, but please try to get some perspective on things.
Combining C with Obj-C code is not so hard, but there are some subtle problems that can make things quite a pain. And only few coders know Obj-C.
But the main reason Obj-C would be problematic is that it is not supported by all compilers and platforms that Blender uses (e.g. visual studio). So unless you have a very compelling reason, I don’t see Obj-C code getting accepted anytime soon.
From what I can tell Python and Objective C people seem to be very similar mindsets to each other, so if you can’t get on with Python it probably isn’t going to come easy.
I’d love to learn Obj-C properly (simply for real Cocoa access), but it’s bracketing just drives me mad!
Well it all depends on what you actually want to do…what kind of application/library, what kind of environment etc.
Dynamic typing, message forwarding etc. are all nice - if you need them.
When writing rendering code, i just don’t. I much more benefit from C++ features like operator overloading, templates and the STL, so i’m quite glad i learned C++ instead. Of course you can do many awkward things with that too, but you don’t have to…that may apply to most language in some way.
And if i want to write a GUI? I use Qt…it features a quite powerfull signal/slot mechanism to pass information, and features just about everything else i could possibly need, and works quite well on Windows, Linux and OS X. But, of course there are downsides. Qt is huge, compiling requires an extra preprocessing step by the “MOC” and therefore compiles even slower than pure C++ code. With Java it would often be easier…
Also pretty much every C++ compiler still has its own ABI, which makes providing dynamic libraries a pain, e.g. OpenEXR, or the YafRay plugin for Blender…so doing stuff with Blender’s Python-API can be simpler unless it needs to process massive amounts of data.
So syntax and language features are just part of the decision IMHO…the environment in which it can be executed is just as important. But knowing more than one language is always good
I only know C and C++, a little Java and even less Python.
I liked that the OS X implementation of Objective-C is like Java and there are loads of predefined classes. This made GUI designing very easy. Drag and drop a constrained OpenGL context into a window beside tabs, text fields, sliders, you name it and it all works.
I also did a project combining C, Obj-C and C++. It’s not too difficult but I hate the syntax and I think it is slower than C or C++.
I personally wouldn’t use objective-c for a serious project. It actually took me ages to figure out how to write a pretty basic program. It just wasn’t intuitive to me.
What we really need is for all the boffins to get together and make a new language. The readability and flexibility of Python with the performance and low-level access of C and the compile times of obj-pascal. Then just scrap the rest.
I just wish Apple had used a more C-like syntax for their code. There is a C-style obj-c implementation.
osxrules, you seem to be a candidate for D
It tries pretty much that, add things like strings, resizeable arrays etc. as native data types, do away with header insanity, have garbage collection, and be designed towards compiler development, and produce native, highly optimized machine code and allow low-level access including inline assembly.
But i haven’t seen a reason yet to give up my C++ i just learned
Also D is not really ready i think, although there exist compilers, they don’t actually support all D features yet.
And as usual i’m sceptical about its power just like i was about C++…
You may well be right, I’m going to check it out. Thanks ;).
I imagine that D wouldn’t be vastly different. You should be able to take most of the same principles but they will be easier to implemement. As they say:
“If a language can capture 90% of the power of C++ with 10% of its complexity, I argue that is a worthwhile tradeoff.”
Sadly these things tend to take years to get off the ground and even then it’s a very slow struggle to gain popularity.
Anyone ever fuss with Eiffel? I watched a bunch of their introduction videos on the main site (what a good way to promote a cause) and it seemed pretty cool…
Eiffel is very cool. but unfortunately very minor.
My langage of choice is Objective-C and contrary to Osxrules fears it is not slower than C, as it is just C + object messaging. For comparison with C++ you have some precautions to make, but properly coded it is fast. The key is good protocols (looking at cocoa libs is an education).
Now, when you mix C++ and obj-C, you are a bit in trouble because the 2 langages are vastly different in their philosophy. and trying to mimic C++ behaviours in obj-C a sure recipe for disaster.
I’ve never spoken to anyone who used Objective-C. How do you find the syntax compared to C? Do you wish they’d used more of a C-style implementation? What kind of programs have you written in obj-C?
I know obj-c isn’t all that slow but some people think it is stil slower than C/C++:
You’re right though, it depends on how you use it. I would probably agree that mixing C++ and obj-c code is not a good idea but so much code is done in C++ that it makes it almost inevitable you would have to incorporate it at some point. Or would you just convert it?
my biggest app was an unfinished full featured usenet newsreader. although we never finished it as other contributors dropped out of project, it was fairly advanced and i was able to feel the real power of obj-C. I wrote the whole database thing and that was fairly big.
Obj-C is C + objects, and should coded that way. you really profit to have say, .m for all your GUI and where objects fit well, but you can fall back to good old C in the inner loops, that is even the beauty of it, you are never encumbered with unneeded baggages like in C++.
So coding in obj-C is really coding in same style as C.
you need a good text editor though as method and messages names are traditionally quite long.
with a program like blender, that would be perfect fit.
of course, runtime method lookups & type checking is (a small bit) slower than C++ vtables, but you regain a lot in the fact you need less messages to do more and your object hierarchy is much leaner.
A clever use of protocols and dynamicity is a key point too.
in critical parts you can even take adress of the methods you need and you are at full speed, but you then need to insure you are in a static like configuration. Memory management can be a bit of problem if you have short lived objects (malloc is slow) and in the newsreader i had to create custom pool allocators, but with this system it was really fast.
there is a number of good library for obj-C so C++ is not really needed. and as said they dont fit really well imho. So if you must use a C++ part in your code it should really an independant sub-module with limited communication.
Now Obj-C really make sense only if you have a good base library. the 2 most availables (Cocoa and Gnustep) are of same origin (NeXt) and are not really made for cross deployement. the POC one, which is portable, has some very different views on memory management and is far from being as complete.
the original Stepstone one (from which POC derives) was good too but is not anymore available
For what? For Obj-C or C/C++? Before aiming for a garbage collector you should be aware of why you would do so. If your primary reason is laziness I would recommend not to use one. It might probably be wise to stay away. Lazy code, one way or another, just ends up being bad code. Make sure you know why you want it and what drawbacks it brings. There are plenty of alternatives to garbage collectors if you are aiming for safety.
With that, How I read blenders code ??? It;'s soooo messy …
The parts I’ve looked at weren’t too messy, but it is a big application so for the untrained eye it can be overwhelming. It also highly depends on how confident you are in C.
As to choosing a proper language. Every programmer worth the title knows that good software is written by good programmers not good languages. When it comes to collaborating with many people on a large scale project it’s a good thing to talk the same language. Conformity in this case is a good thing. Therefore I would strongly recommend sticking to c/c++, even if you don’t think it is the best language.
there is some parts in codebase that are so untidy they start to stink.
Moreover, even in the numerous cleans parts, blender is C, and a struct based C with no friendly API but direct structs modification. So yes, the entry in the source is quite hard.
Best method is to find a small area of interest and start from there.
As to choosing a proper language. Every programmer worth the title knows that good software is written by good programmers not good languages. When it comes to collaborating with many people on a large scale project it’s a good thing to talk the same language. Conformity in this case is a good thing. Therefore I would strongly recommend sticking to c/c++, even if you don’t think it is the best language.
With our multi-platform requirements, i dont think anything else than C/C++,python can be accepted.
More, blender is divised in modules, and the C ones (which are all the core) and C++ (GE, several modules) must be kept separate.
GCC comes with the Objective-C libraries (libobjc), so you can create pure Obj-C programs without needing Cocoa or OpenStep. The Objective-C Pocket Reference covers both vanilla and Mac OSX versions of the language.
youngbatcat and osxrules: I’m with you guys in wondering what it would take to code an Obj-C version of Blender. An object-oriented base of some kind would probably make it easier to create a much-needed SDK for plug-ins and external rendering. I imagine that conversion would be quite an undertaking though, whether it was in Obj-C or C++, especially since I hear Ton is pretty much a C guy.