LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-16-2011, 03:23 AM   #16
vadiml
Member
 
Registered: Oct 2003
Posts: 44

Rep: Reputation: 19

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
 
Old 09-16-2011, 06:28 AM   #17
SigTerm
Member
 
Registered: Dec 2009
Distribution: Slackware 12.2
Posts: 379

Rep: Reputation: 234Reputation: 234Reputation: 234
Quote:
Originally Posted by vadiml View Post
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.
 
Old 09-16-2011, 08:49 AM   #18
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Quote:
Originally Posted by SigTerm View Post
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
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Class inheritance terminology: super-classes or base classes? 2ck Programming 6 07-20-2011 10:17 AM
Classes in VC++ Diederick Programming 2 11-30-2005 10:57 AM
Possible uses for classes. RHLinuxGUY Programming 4 11-21-2005 10:10 PM
classes in C++ niteshadw Programming 2 07-05-2005 07:05 PM
OOP (PHP) classes and extended classes ldp Programming 3 03-05-2005 11:45 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration