Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

As Java is to Scala, C++ is to ...?

Tags:

Although C++0x is quite an improvement to C++ (type inference, anonymous functions, and so on), I have to say that Scala seems even better. The thing is that Scala only runs on the JVM, although it seems like it can also run on top of C#.

Ideally, I would like a language as nice as Scala, but running "on top of" C++ -- using the standard libraries, easily linking against C/C++ object files, the whole deal. I do a lot of numerical programming built of top of well established C/C++ libraries (fast and reliable), and that is not something I can walk away from.

Is anyone of aware of such a language?

Update:

The features I am looking for are:

  • Seamless integration with C/C++ libraries, just like Scala can access Java libraries without the need for bindings to be generated/maintained

  • A strong type system, with a well designed type inference system that keeps me from having to write verbose and redundant type annotations

  • Functional and OO features built into the language, with the support of its own libraries instead of only relying on the standard C/C++ libraries.

It seems like a lot of the clang/LLVM work being done right now may facilitate work along these lines, but it would be nice to find that something like this is already being worked on.

like image 630
Marcus P S Avatar asked Dec 29 '10 02:12

Marcus P S


People also ask

What is Java and Scala used for?

Scala is a statically typed programming language whereas Java is a multi-platform, network-centric, programming language. Scala uses an actor model for supporting modern concurrency whereas Java uses the conventional thread-based model for concurrency.

Is Scala similar to C?

Like Java, Scala is object-oriented, and uses a syntax termed curly-brace which is similar to the language C.

Is Scala same as Java?

Scala is a mixture of both object oriented and functional programming. Java is a general purpose object oriented language. Scala is less readable due to nested code. Java is more readable.

Is Scala related to Java?

Scala is a statically typed language that is based on Java. Thus, anyone who's well-versed with Java's syntax will find it pretty easy to learn Scala.


2 Answers

I wonder why no one has yet mentioned the D programming language. It is a perfect fit for your requirements.

like image 75
Madoc Avatar answered Nov 26 '22 04:11

Madoc


You might want to think about Haskell. It has as much niceness as any language out there (in its own way, of course), but it is ardent in its adherence to functional programming so the barrier to learning is substantial. Still, it can be used to call C/C++, and it's surprisingly high-performance on its own.

You also should decide whether you need the language itself to be capable of fairly high-performance computing. If not, it's pretty easy to create Python bindings to C/C++, and Python has quite a few nice features. Or you could use something like Matlab, which is designed for numeric computing as I'm sure you well know, and can integrate with C code pretty well via mex files. If you do need the language to be one in which you can currently write high-performance code, you might even consider taking on the nontrivial task of creating C++ bindings for Scala (it's not that bad if you use JNI or JNA for Java, and then call that Java from Scala), and then only use that for the most important numeric work while Scala handles the less time-critical (but still somewhat important) parts.

like image 28
Rex Kerr Avatar answered Nov 26 '22 05:11

Rex Kerr