ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Please do consider using stl vector, map, and string classes instead of your own homebrew ones.
You have really VERY SLIGHT chance to come out with the code which is better than in STL.
Quote:
It uses strcmp instead of comparing the pointers.
Code:
typedef map<const char*, LangObject, strcmp> LangMap; // a MAP which uses strcmp form string comparaison
Please do consider using stl vector, map, and string classes instead of your own homebrew ones.
You have really VERY SLIGHT chance to come out with the code which is better than in STL.
Code:
typedef map<const char*, LangObject, strcmp> LangMap; // a MAP which uses strcmp form string comparaison
The better advice would be "do not reinvent the wheel".
Anyway, (IMO) when somebody is going to shoot himself into the foot, you shouldn't stop them unless they ask you whether doing this is actually a good idea. The logic is simple - when people learn things the hard way, they remember the lesson forever, but when you offer unwanted advice, they ignore it or forget about it (but you'll waste time writing the advice).
//Personal opinion
The OP already wasted 4 months writing this thing (while 1 month should be enough to design and finish everything), had been given advice to use STL multiple times, and still insist on doing things his own way. Also, the code smells of C, uses garbage collection unnecessarily, plus there are obvious design problems (no proper OOP, void casts, etc) that will bite him back later. At this point giving advice is pointless, and the proper solution would be to let him spend 8 more months trying to finish it, until he sits down, rethinks his life, takes a 2week break, changes his way about C++ programming, and redesigns the whole thing. Nothing personal against OP, though, learning programming just works this way.
The better advice would be "do not reinvent the wheel".
Anyway, (IMO) when somebody is going to shoot himself into the foot, you shouldn't stop them unless they ask you whether doing this is actually a good idea. The logic is simple - when people learn things the hard way, they remember the lesson forever, but when you offer unwanted advice, they ignore it or forget about it (but you'll waste time writing the advice).
//Personal opinion
The OP already wasted 4 months writing this thing (while 1 month should be enough to design and finish everything), had been given advice to use STL multiple times, and still insist on doing things his own way. Also, the code smells of C, uses garbage collection unnecessarily, plus there are obvious design problems (no proper OOP, void casts, etc) that will bite him back later. At this point giving advice is pointless, and the proper solution would be to let him spend 8 more months trying to finish it, until he sits down, rethinks his life, takes a 2week break, changes his way about C++ programming, and redesigns the whole thing. Nothing personal against OP, though, learning programming just works this way.
It all depends on the objective. I learned more about C and C++ reinventing numerous wheels than I would have otherwise; however, my objective wasn't to come up with something for others, or even for myself, to use long term. I started out on a C++ forum hosted by the "proprietary IDE" I was using to learn on and almost all responses to my posts were "always use the STL", "don't ever write your own containers", and "don't ever use operator new". I ignored most of that advice so I could learn how those things worked; however, for "real" code I use the STL as much as possible. Then again, a lot of people scoff at the STL, preferring boost as their prewritten functionality of choice.
As I understand it, OP has been working on an interpreted language of his own for some time now. Such a pursuit is a good way to gain a thorough understanding of C and C++ because it requires knowledge of a wide range of concepts.
Kevin Barry
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.