Jump to content
  • Advertisement
Sign in to follow this  
Falling Sky

Things you could modify about C/C++/C#

This topic is 4627 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Sup guys, im doing a bit of research & was going to implement my own variation of a C language as my school project. Im just curious, if you could do whatever you wanted to a form of C, what would you modify about it? And since im also interested in games I wanted to supply a simple game, such as pong, as an example program made in my compiler. So please tell me your ideas to modify C/C++/C#(keep the idea in mind that if its more geared for games, thats great, that would give it some unique features to be geared for media)

Share this post


Link to post
Share on other sites
Advertisement
I would add a feature to let you reduce this:

ClassA *a = dynamic_cast<ClassA*>(object);
if (a != NULL)
{

}
else
{
ClassB *b = dynamic_cast<ClassB*>(object);
if (b != NULL)
{
...
}
}


into something like this:


dynamicswitch (object)
{
typecase ClassA(a)
{
a->function1();
} // implied break. user cannot create fall-throughs or goto a different typecase.

typecase ClassB(b)
{
b->function2();
}
}


Sure, there are invasive ways to add this to existing classes so that you can switch on a member variable defined in the base class, but why waste space when you probably have a vtable pointer anyway?

Share this post


Link to post
Share on other sites
Quote:
Original post by Nypyren
I would add a feature to let you reduce this:

ClassA *a = dynamic_cast<ClassA*>(object);
if (a != NULL)
{

}
else
{
ClassB *b = dynamic_cast<ClassB*>(object);
if (b != NULL)
{
...
}
}


into something like this:


dynamicswitch (object)
{
typecase ClassA(a)
{
a->function1();
} // implied break. user cannot create fall-throughs or goto a different typecase.

typecase ClassB(b)
{
b->function2();
}
}


Sure, there are invasive ways to add this to existing classes so that you can switch on a member variable defined in the base class, but why waste space when you probably have a vtable pointer anyway?


I like that (similar to pattern matching in languages like Ocaml and Haskell). Although, personally, I'd get rid of the typecases and change dynamicswitch to match.

Some other features you might want to think about are variant types (these work well with the feature Nypyren mentioned), coroutines and lambdas.

Share this post


Link to post
Share on other sites
Variants? Maybe.
Lambdas? Not sure what those are, im thinking there something to do with math/functional programming?

any more ideas? Cmon people! :-p

Share this post


Link to post
Share on other sites
Quote:
Original post by Azh321
Variants? Maybe.
Lambdas? Not sure what those are, im thinking there something to do with math/functional programming?

any more ideas? Cmon people! :-p


Lambdas are nameless functions. How about coroutines and/or continuations?

Share this post


Link to post
Share on other sites
Native regular expression goodness. C# might actually have that [I've no idea], and it can be added to c/c++, but it always seems so icky and contrived compared to something like perl's.

Share this post


Link to post
Share on other sites
I dont see much purpose in nameless functions or coroutines. I will probaly do variants though, cmon guys tell me what you really like about C# that you wish C++ had, tell me what you wish C++ had/didnt have!

Share this post


Link to post
Share on other sites
One example of where coroutines are useful are infinte lazy lists. Lambdas are useful for creating functions to pass to other functions (in some cases). For instance (using a hypothetical syntax):

map((\(int x) -> int { return x + 1; }), {1, 2, 3, 4}) // Returns {2, 3, 4, 5}


Here are a few more things you might want to consider:

  • Metaclasses

  • Continuations

  • Type inferred generics

  • Tail-recursion optimization (this isn't a language thing, although it's something to think about when implementing the compiler)

  • A nicer looking function pointer syntax

  • Templated typedefs

  • Closures and inner functions

  • Optional lazy evaluation

Share this post


Link to post
Share on other sites
Have you taken a look at Objective-C?

I would want to make changes directly to C because I think that C++ has too many features. The features that I would add to C are:

1. Classes
2. Inheritance
3. Interfaces
4. Optional Automatic Garbage Collection
5. Interpreter and compiler
6. Standard Graphics API based on OpenGL
7. Change primitives to int8, int16, int32, int64, int128, float32, float64, float128, boolean, char, and void
8. Clean import utility for importing classes and functions

I would remove:

1. Preprocessor - nothing but nightmares

Share this post


Link to post
Share on other sites
Quote:
Original post by AllTheLuck
1. Preprocessor - nothing but nightmares


Preprocessors aren't inherently bad, although (in my opinion) C implemented it badly. See hygienic macros.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!