The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Alternatives to C/C++

Coming from a kernel background, I tend to write most things in C.  Well, I'm now writing userland code, in particular a server application that targets Linux and FreeBSD.

I have a few requirements. Performance is key, right down to having good control over memory allocations and buffer copies.  The code must be easily hideable.  The hidability that compiled C/C++ programs offers is enough, the hidability of a Python .pyo is not.  There are a couple cases where I have to access system specific stuff which must be done in C, but these are narrowed down to their own specific modules and could be access with a slim protocol to a daemon.

Right now I see Java as the only alternative language to C and/or C++?  Are there other languages I should be considering as well?

Thanks.
Jason Send private email
Monday, December 18, 2006
 
 
I should mention that the application is already a real product, a mix of C and Python.  But we are at a point where we are rearchitecting major components, so it would be an ideal time to re-evaluate the underlying languages and frameworks being used.

Currently I'm leaning towards C++.
Jason Send private email
Monday, December 18, 2006
 
 
By "hideability", are you referring to preventing reverse engineering, or employing "data hiding", or simply the act of providing public, protected, and private members to classes?

If the later, then Python *does* provide hideability.
If the former, then Java or most other bytecode ocmpiled languages do not provide hideability, unless you investigate obfustication.
Arafangion Send private email
Tuesday, December 19, 2006
 
 
There are decompilers for C and C++ code available nowadays, so I think the obfuscation thing is just not even possible any more without taking extreme measures of encrypting the binary or such.

Fine control over memory allocation and high performance is assembly, C, C++ and that's it. C++ a multi-paradigm language so you can do various things with it. I think that's what you want given the things you mentioned.
Meghraj Reddy
Tuesday, December 19, 2006
 
 
There is also D.
Achilleas Margaritis Send private email
Tuesday, December 19, 2006
 
 
Hideability as in preventing people from getting at the source code.

Compile C/C++ is sufficient for our needs.  It usually takes a little more effort to decompile than Python and Java, and the end result isn't as readable as say, a decompiled Python module.

Looks like I'm leaning towards a C++ solution, and allowing modules to be written in Python.
Jason Send private email
Tuesday, December 19, 2006
 
 
Given Jason's particular needs, I would discourage him from learning a new language at this time. I think Lisp, Haskell, Erlang, Scheme et al may be worth looking into for the future, but if they're already re-engineering an existing product, they likely just don't have the time to get proficient enough to do performance tuning in Lisp etc.
TheDavid
Tuesday, December 19, 2006
 
 
Ada.

- Nate.
Nate Send private email
Tuesday, December 19, 2006
 
 
Obfuscated Haskell

But seriously, I have to call into question the motives of making sure people can't "decompile" your application.  Is it just management paranoia?
John Cromartie Send private email
Tuesday, December 19, 2006
 
 
You can easily compile python into an exe.
You can also overload the python .pyo loader to read encrypted .pyo files.
I once did something similair to allow signed modules.
Martin Send private email
Tuesday, December 19, 2006
 
 
Isn't obfuscated Haskell redundant?  ;)

Tuesday, December 19, 2006
 
 
No personal experience but this could be useful.
http://pawsense.com/python..obfuscator/
Martin Send private email
Tuesday, December 19, 2006
 
 
I like python a lot, but Lua is much more lightwieght and easily embeddible given your original requirements.
Grant
Tuesday, December 19, 2006
 
 
C++

Wednesday, December 20, 2006
 
 
I think you have no other real alternatives. Your requirements are tipycally covered by the c/c++ languages. Any other alternative will break or not satisfy all of them.
So the main question is imho: what are the requirements, which are not satisfied by the c/c++ and you need them now? WHY would you find other languages/platforms?
foldip
Wednesday, December 20, 2006
 
 
I don't NEED another language, just out there hunting for possible alternatives.  Even if not used now, to be used in the future.

Looks like C++ it is.

Thanks.
Jason Send private email
Wednesday, December 20, 2006
 
 
Well... if you just want future possibilities, you really can't go wrong just picking one at random and playing with it for a couple of weeks, then picking another and seeing how that works.

If I may channel Joel and paraphrase him, this is an excellent time to learn new ways of...  structuring your program; if you've never done functional programming, pick a language in that family. If you've never done rules based programming or used a 4th Generation Language, try one of those. Even playing with Assembly and low level languages will open your eyes. You've obviously done object oriented programming or I'd suggest that too.

In all probability, these won't help with your current application, but you will get to a point where you're more comfortable saying "use C++ to solve these kinds of problems" and "use Erland to solve those kinds of problems."
TheDavid
Wednesday, December 20, 2006
 
 
Going off topic now.. But functional languages have been on my list of to-learns.  Any suggestions what to tackle?  Haskell? Erlang?  Which would be better for commercial software development in the future?  Which integrates better with C (if needed)?

Back in school I hated lisp and prolog, but I think venturing into functional languages is a must at some point - at least for me.

Thanks.
Jason Send private email
Wednesday, December 20, 2006
 
 
Right now I get the impression that Haskell is a bit better supported by the community than Erlang. This is just an opinion though.

You might also want to consider learning Scheme or Smalltalk instead of revisiting Lisp and Prolog. There are more Smalltalk resources available that I know of, but MIT's OpenCourseWare program supposidly offers you everything you really need to get going with Scheme.

Let us know in a later post if you do decide to experiment, and what your thoughts were. I admit that since you raise the question here, I've been toying with the idea of learning some Scheme during the holiday break.
TheDavid
Wednesday, December 20, 2006
 
 
Erlang is cool! :) And it integrates wth C easily. But it's mostly a server-side language, rarely used at client side.
The main problem with lisp is, that the community is fragmented by the dialects. :(
foldip
Thursday, December 21, 2006
 
 
If you want a C++ altenative, D is the closest you can get.

For functional programming, learn Haskell. It's the best.
Achilleas Margaritis Send private email
Thursday, December 21, 2006
 
 
Ok, D is an alternative to C++, more easy to use it, without the complexity of this one.

But is it a mature language ? The first official version (1.0) of the compiler ( and the language ) will be to release to the 1st January
Stephane Wirtel Send private email
Thursday, December 21, 2006
 
 
D is nice, but it's GPL licensed:

"You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License."

And programs created with a compiler certainly "in whole or in part contains or is derived from the Program or any part thereof".
Meghraj Reddy
Thursday, December 21, 2006
 
 
Wow, hello world in D is a mere 230k. Yeah, just like C. (?)
Meghraj Reddy
Thursday, December 21, 2006
 
 
> There are decompilers for C and C++ code
> available nowadays

There are. Where?
Jussi Jumppanen
Thursday, December 21, 2006
 
 
Which compiler do you use ? dmd or gcc (with gdc) ?

Good morning :d ( in Belgium, it's 7:00 AM )
Stephane Wirtel Send private email
Friday, December 22, 2006
 
 
I find Freepascal to be pretty nice.

Fast builds, fast execution, very readable language.
It's also quite a small language, meaning that you don't really have to rely too much on IDE support.

It lacks a few things (for example generics) and it's harder to find ready made stuff for it.
Else than that - I love it.
OP Send private email
Friday, December 22, 2006
 
 
"good control over memory allocations and buffer copies"
...
"I see Java as the only alternative language"


Huh? Reality breakdown alert!
Jimmy Jones
Saturday, December 23, 2006
 
 
"And programs created with a compiler certainly "in whole or in part contains or is derived from the Program or any part thereof"."

You are talking nonsense.  Please do not attempt to give people legal advice on a subject you know nothing about.  The very concept that all D programs might have to be GPL'd is ludicrous.

It's worth noting that the FSF, the rabidly anti-copyright authors of the GPL who actually _invented_ viral licensing in the first place, do not believe that a GPL'd compiler infects the programs it compiles: see http://www.gnu.org/licenses/gpl-faq.html#CanIUseGPLToolsForNF for their discussion of the issue.
Iago
Wednesday, December 27, 2006
 
 
"Please do not attempt to give people legal advice on a subject you know nothing about"

Shit man, all I did was quote their freaking license and you wigged out. You GPL zealots are all alike - you'll say anything to get folks to sample the crack.
Meghraj Reddy
Saturday, December 30, 2006
 
 
"Shit man, all I did was quote their freaking license and you wigged out. You GPL zealots are all alike - you'll say anything to get folks to sample the crack."

ROFL.

Off to a great start of the new year!

- Nate.
Nathaniel L. Walker Send private email
Tuesday, January 02, 2007
 
 
While I haven't made professional use of it the D language is intriguing.

All the power of C/C++, but with many of the feature you find in Java.  You can also use garbage collection or manage the memory yourself.

D also compiles down to native machine code like C/C++ so it runs faster than Java, C#, or any of the other intermediate languages.  In addition I believe D is binary compatible with modules written in C/C++ so you are free to mix preexisting code.
Code_For_Dollars
Thursday, January 04, 2007
 
 
>And programs created with a compiler certainly "in whole or in part contains or is derived from the Program or any part thereof".

The bit you quoted out of context refers to programs derived built using the source of the compiler. Not programs compiled using the compiler. Otherwise everything ever compiled using gcc would be GPL'd. Duh.

Friday, January 05, 2007
 
 
ocaml: http://caml.inria.fr/ocaml/

Ocaml may be the least foreign, from the perspective of a C programmer, of the popular functional languages.  It uses static typing (unlike lisp and erlang), uses strict evaluation (unlike haskell), and is not image-based (unlike lisp and smalltalk).  It has a native-code compiler and can interface with C.

Here is a slide presentation from a corporation that tried Ocaml and now loves it: http://www.galois.com/cufp/slides/2006/YaronMinsky.pdf
Eric Send private email
Sunday, January 07, 2007
 
 
I should also mention that ocaml is quite at home in a Unix environment.  The mastermind behind the language (Xavier Leroy) is also the original author of LinuxThreads.
Eric Send private email
Sunday, January 07, 2007
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz