Hello. I've been using C++ for about a year now, and now I've gotten to the point where I do not like it anymore (for a number of reasons). Is there a modern programming language similar to C++ that, when compiling, searches through the code once and finds all the class / function declarations, and then compiles so that a class / function can be used before being declared?
For example:
Foo(123,123);
void Foo(int arg1, int arg2)
{
...
}
I would rather a new programming language altogether rather than a workaround sort of thing for C++, since theres other aspects I dislike about it.
Modern Programming Language???
Started by valente500, Jun 21 2010 04:04 AM
10 replies to this topic
#1
Posted 21 June 2010 - 04:04 AM
|
|
|
#2
Posted 21 June 2010 - 04:11 AM
Have you not heard of function macros or prototypes?
You may wish to look into using an interpreted language, which would better provide tokenization of classes in your asked requirements.
foo(int, int);
foo(123, 210);
void foo(int arg1, int arg2) {
printf("%d and %d accepted, before declared.", arg1, arg2);
} From your question I would assume you were not proficient in any one language. You cannot move to a new language that does not reflect or respect the fundamentals of basic programming, they do not exist. And as per your "modern" question, Java is modern, but it is similar for the exact same reason, you will run into the same "problems" as any C varient language.You may wish to look into using an interpreted language, which would better provide tokenization of classes in your asked requirements.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
#3
Posted 21 June 2010 - 05:19 AM
Well, I don't know the other reasons why you dislike C++, but maybe C# is what you're looking for.
Greets,
artificial
Greets,
artificial
#4
Posted 21 June 2010 - 09:44 AM
Indeed, prototyping is already a feature of C++. If there are other problems you are having with C++, you should first probably reevaluate your mastery of the language.
#5
Posted 21 June 2010 - 04:19 PM
I've already heard of function prototyping, what I don't like is that you need to prototype everything in a header before you start writing stuff in source files when you start using multiple files in one program. Maybe I'll try an interpreted language, if not I'll try to fix the problems I'm having.
Thanks for your replies :D
Thanks for your replies :D
#6
Posted 25 June 2010 - 10:28 AM
You don't need to use multiple files, you can just write all the prototypes first in your cpp file (if the functions aren't used elsewhere), if you can't well, 2x the files won't hurt too much :D
If this still bothers to have twice the files, you can see the .h file as the documentation file, it's important not just for the looks and the prototypes, but also to be able to grasp what a module.cpp file does without having to read through the code.
If this still bothers to have twice the files, you can see the .h file as the documentation file, it's important not just for the looks and the prototypes, but also to be able to grasp what a module.cpp file does without having to read through the code.
#7
Posted 26 June 2010 - 05:36 AM
@valente500: I understand you very well. The problem is that the compilation / build system in C++ was taken from 70s (reads: ancient) - they just took the compilation paradigms from C directly, without even thinking that this model was totally irrelevant to OOP. Any modern language doesn't have all these issues - doesn't require you to write stupid prototypes or declare things before they are seen (yes: it is XXI century and multipass / multistage compilers were invented a long time ago), or doesn't base its core features on hacks like dumb text inclusion (pseudo-modules) or text substitution (macros, templates, LOL).
If you want a extremely well thought, multiparadigm, platform independent, modern (first release ca 2005) language, Scala is for you.
If you want a extremely well thought, multiparadigm, platform independent, modern (first release ca 2005) language, Scala is for you.
#8
Posted 26 June 2010 - 06:01 AM
From a different view, I like the idea of protoyping. It allows you to think of the interface first, rather than the implementation. Design before code so to speak. Jumping in and hitting the low level straight away isn't always the best idea. It also allows you only to expose the interface part of your code when having api's etc, although that argument is diluted as things like Java are easier to distrubute as an api.
#9
Posted 26 June 2010 - 06:06 AM
There is no point in writing C style function prototypes, when the language HAS a better builtin feature exactly for this: interfaces (Java) and traits (Scala).
#10
Posted 26 June 2010 - 10:10 AM
I can't speak for Scala...But java...
What do you mean interfaces are better than a C style function prototype?? An interface is really just a namespaced collection of prototypes (for a single implementation, or an virtual base class for multiple implementations), how is this any better? Not only would you need to define the interface, you'd also need to create another class that matches the interface and then write your code. That's even before we get onto C++ which has support for interfaces, but doesn't define extra keywords just to call them that.
I get that the original poster didn't like defining what he was writing before he wrote it...But, what I was saying is that is bad design, you shouldn't be coding by coincidence, you should think about what you code before you code it.
Now I'm not saying that C++'s build system is the best, It can be a big pain with big complex projects especially when you have certain code modules which start to cross reference. Then your in a world of hurt.
What do you mean interfaces are better than a C style function prototype?? An interface is really just a namespaced collection of prototypes (for a single implementation, or an virtual base class for multiple implementations), how is this any better? Not only would you need to define the interface, you'd also need to create another class that matches the interface and then write your code. That's even before we get onto C++ which has support for interfaces, but doesn't define extra keywords just to call them that.
I get that the original poster didn't like defining what he was writing before he wrote it...But, what I was saying is that is bad design, you shouldn't be coding by coincidence, you should think about what you code before you code it.
Now I'm not saying that C++'s build system is the best, It can be a big pain with big complex projects especially when you have certain code modules which start to cross reference. Then your in a world of hurt.
#11
Posted 26 June 2010 - 11:58 AM
Quote
Not only would you need to define the interface, you'd also need to create another class that matches the interface and then write your code
1. in the header of the "interface"
2. in the header of the implementing class
3. in the definition of the implementing class (and you cannot copy paste the signature - the syntax is slightly different)
And while strict C prototypes really behave like interfaces - they provide code encapsulation, the C++ class headers fail miserably at this - the private section is in the headers. And if you use templates, there is no encapsulation at all - everything is exposed. So, no this is not
as clean as interfaces in Java.
In fact, headers and prototypes were not added to provide interfaces. They just provided a poor-man's method of splitting large project into many files in the world where compilers did not understand the concept of "module".


Sign In
Create Account

Back to top









