tags:

views:

582

answers:

8

I am trying to have some fun in summer. Writing a piece of code that enables presenting Arabic language in systems that support Unicode but no support for eastern languages it. I am writing only the logic hopefully with no integration code initially.

Should I use C++ or C?

Which is the easier language to write portable code and easier to integrate with Python possibly?


Edit:

I am fairly good with C/C++ though I consider myself closer to C++. But It seems it is easier to write C and plug it every where or I am wrong ? I would write some functions to process Arabic Unicode String. presenting Arabic language need some processing because ALMOST ALL characters have different shapes in different contexts.


Edit:

It seems I will go with C++, just to make it more fun.

+4  A: 

I would use C++, mostly because it provides a lot more "stuff" to use and as far as my experience goes is as portable as C. However, I have not used straight C/C compiler for 10 years or more.


EDIT

A commenter questioned my experience with portability. Mine is limited to Linux and Win32 primarily. I assumed this would be sufficient OSes for this exercise.

Tim
I'm curious, how many different operating systems did your software support regarding C++ begin more portable than C?
Todd Stout
I like C++ and C more basically. I believe it is harder to integrate with other languages ? Window and Linux.
AraK
@Todd - Your point is well-taken - I am currently only talking about linux, unix and Win32/win64. I have no experience with others, so my reading of portable and cross platform is effectively for those. I have found no problem with c++ portability on those platforms. I am sure there are lots of examples of other platforms, but given the context of MOST problems those are the platforms of interest. (aside from mac as well)
Tim
From what I've seen on the iPhone, it's a bit saner to use C libraries from Objective-C than it is to use C++ libraries with objective-C. The support _is_ there for C++, but C libraries seem the norm, and iPhone programmers are used to C libraries. I'll stick with C as being more portable.
Nosredna
I didn't really comment on apple products. They are in their own special world...
Tim
If you write a C library, just about everyone is in the same world.
Nosredna
How are apple products in their own special world? OS X and iPhone OS both run on BSD...
slypete
cocoa and objective C.
Tim
+3  A: 

If it's for fun, go for the language you want to learn better.

I'd bet that there are more recent libraries to support various language packs in C++, but maybe that's part of the fun, is to write your own version in C.

mmr
+1  A: 

Either one of C or C++ should enable you to write portable code if you're careful. For Unicode handling, you will likely also want a Unicode-aware string facility; for C, Glib can be quite useful.

Of course, you could just write it in Python from the beginning. That is reasonably portable, and probably easiest.

Michael E
+1  A: 

Try to see next sites:

"boost.org/" (see the integration with python)

or

"pocoproject.org/"

Both sites seems to have the sympathy of Stroustrup, the creator of C++

Anybody have experience with the pocoproject.org library? It looks very interesting. I want to get into iPhone development (seems a lot of people do), but I don't want to go back to the "C" part of Objective-C. I have been leaning towards Objective-C++, but not sure what c++ library to use.
chrish
+2  A: 

You need robust library support. For that, C++ has more rich options. If you use a framework like QT it will be almost trivial. It's also very portable over all systems. Integrating with Python is also straightforward (though for that I like boost::python).

SPWorley
+1  A: 

I think it is better to write in C.Because C will provide you more ways of producing optimized and portable code than C++.If you do it in C then it will be easier to integrate with python.

Enjoy coding
I never tried to write something to integrate with python. Is it easier to write C library for python or use Boost::python ? I never tried to do either!
AraK
boost::python has two big issues: it is very slow to compile, and boost is not portable. If you only care about recent platforms (win32 + VS 2005 and above, linux and gcc 4.x), then it is less a problem. But if you need to support tens of platforms, boost is a no-no IMHO.
David Cournapeau
To wrap a C API, my recommended tool is cython. It is not as automatic as boost, but I found it easier to use. If you have a big API to wrap, then you may want to look into something else.
David Cournapeau
+3  A: 

I would write it in C++ and provide a C interface to get the widest possible integration footprint. Also, you can use SWIG to generate wrappers to many common languages.

chrish
+5  A: 

I strongly disagree with the assertion that C and C++ are comparable when portability is a concern. True, if you limit yourself to recent Visual Studio and g++, C++ is "portable". But things like boost are a maintenance nightmare if you care about more platforms than that (older gcc/visual studio, many other old compilers on proprietary unices). In this context, C is much more portable than C++ in my experience. If you look at most open source projects which use C++ (mozilla, some google code) , they limit themselves to a very restricted subset of C++.

Now, for strings handling, I would say that both C and C++ are quite bad languages :) I would certainly look at something much higher level, with good support for unicode string handling.

David Cournapeau