Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replacement language for C++?

When working on hobby projects I really like to program in low-level languages (in the sense that C and C++ are low level). I don't want to work with managed languages with garbage collection and whatnot that takes all the fun away (yeah, we're all different ;-) ).

Normally I use C++ for these type of projects. C++ is rather complex and not so elegant so I have been looking for a language to replace it. Anybody can give me suggestions?

Preferences (not requirements):

  • should be low-level (like C and C++)
  • compile to native code (kind of follows from the above but no harm in being explicit)
  • preferrably target win32/win64
  • object oriented
  • statically typed

I have looked at Objective C but I don't like it.

like image 382
David Nordvall Avatar asked Jun 11 '09 14:06

David Nordvall


People also ask

Can Python replace C?

Answer: NO. C and C++ form the basis of every programming. Python is in fact built on C with web programming in mind. So there is no possibility that Python will replace fundamental languages like C or C++ at least not in the near future.

Is C++ replace C?

C++ is a prolific language for doing low-level stuff. However, because Carbon is a modern alternative that is designed to equal C++ performance while being able to connect with existing C++ code, it may “replace” C++. “replaced” not that C++ will no longer be useful, but in terms of relevance.

Is C better than Rust?

However, Rust programs also optimize quite well, sometimes better than C. While C is good for writing minimal code on byte-by-byte pointer-by-pointer level, Rust has powerful features for efficiently combining multiple functions or even whole libraries together.


4 Answers

D? (Wikipedia page)

The D language is statically typed and compiles directly to machine code. It's multiparadigm, supporting many programming styles: imperative, object oriented, and metaprogramming. It's a member of the C syntax family, and its appearance is very similar to that of C++. For a quick comparison of the features, see this comparison of D with C, C++, C# and Java.

I think that covers everything in your requirements except Windows support, which it has too.

Note that it has garbage collection, but your question seems to associate garbage collection with being managed - they're not the same thing. I believe garbage collection can be pretty tightly controlled in D.

I should note that I have absolutely no experience in the language whatsoever :)

like image 78
Jon Skeet Avatar answered Oct 31 '22 17:10

Jon Skeet


  • Ada - http://en.wikipedia.org/wiki/Ada_programming_language
  • Oberon - http://en.wikipedia.org/wiki/Oberon_(programming_language)
  • Modula 3 - http://en.wikipedia.org/wiki/Modula-3
like image 22
mamboking Avatar answered Oct 31 '22 17:10

mamboking


Delphi? Pascal syntax, but still quote powerful and just a little more high-level than C++.

like image 43
OregonGhost Avatar answered Oct 31 '22 19:10

OregonGhost


Requesting no gc is rather strong and eliminate almost every modern language - things like Ocaml, for example, fill all the other requirements.

There is also ADA which fill every of your desire, but that's a very strict language. The syntax is somewhat similar to Pascal I think, and the language has much less holes compared to C. It has built-in support for threads and 'modules' (better than C headers).

like image 45
David Cournapeau Avatar answered Oct 31 '22 19:10

David Cournapeau