C and C++, advantages/disadvantages lazarus / 8-Other ---------------------------------------------------------------------- Handoko · 2016-06-03 16:14 Hello friends. I ever learned Assembly, Basic, VBA, MS Access, and Pascal the one I like most. But if I look for examples for game related tricks, I usually get the codes in C and C++. So I'm thinking to learn C or C++. Because I do program for hobby, I can't spend too much time for it. So I will pick only one: C or C++. Seniors, please share your experience about C and C++. I'm not asking which one is the better. But I want to know what are their advantages/disadvantages compare to the other. Please no flame wars. ---------------------------------------------------------------------- marcov · 2016-06-03 16:32 Well, this is the wrong forum for that question but definitely C++. C is cumbersome to make sizeable programs but the most embedded ones. The big problem is not just language though, but also what IDE, specially if you want it multi platform. ---------------------------------------------------------------------- lainz · 2016-06-03 16:47 C++ is better and has OOP like Pascal. If you don't have much time, try http://www.tutorialspoint.com/cplusplus/ I use Dev-C++ IDE, other good one is Code::Blocks, both are cross- platform. Of course if you want to make a GUI you need to download the things apart. But you can install Visual Studio 2015 if you want only Windows, but make sure you choose to download the C++ tools, if not only you will get C# ones. ---------------------------------------------------------------------- Handoko · 2016-06-03 16:52 Sorry, if I'm in wrong forum. Actually, I don't think I will use C nor C++ to write programs. I just want to learn it for better understanding when I get code write in C/C++. You know, most game/OpenGL examples are written in those language. Maybe someday I will  use it to write library to use in my Lazarus program. Quote from: lainz on June 03, 2016, 06:47:31 pmIf you don't have much time, try http://www.tutorialspoint.com/cplusplus/ Thanks for the link. ---------------------------------------------------------------------- Thaddy · 2016-06-03 16:55 Quote from: lainz on June 03, 2016, 06:47:31 pmC++ is better and has OOP like Pascal. It is not. Even the inventor of C++, Bjarne Stroustrup, has stated that many times. He dislikes his own child in many ways and often compares it with e.g. among others  Pascal like languages and where he erred It is just different and more professional people use it. From a compute point of view there is not much difference except Object Pascal  is more readable in most cases. (Because I can also write readable c++) I recommend learning both languages and some more. That also gives you the insight on what and why you prefer one language over another. That boils often down to: whatever is better for the task at hand. I see a lot of C++ code on a daily basis. If it is really readable code chances are way better than 80%that it is written by somebody with a Pascal background. FACT! ---------------------------------------------------------------------- Handoko · 2016-06-03 17:00 Quote from: Thaddy on June 03, 2016, 06:55:22 pmI recommend learning both languages and some more. I heard: QuoteC++ is a superset of C, and that virtually any legal C program is a legal C++ program. Is that mean if I learn C++, I will able to use C automatically? ---------------------------------------------------------------------- Thaddy · 2016-06-03 17:06 Well, C is really shorthand for Pascal. Curly brackets instead of begin/end. Nothing more. There is some truth in that C is one of the core languages I recommend all serious programmers should be proficient in. But Pascal is also high on my list and I prefer it over C and its poor cousin C++. Adding python for the serious amateur plus level and perl for pro's. But there is much more. A language is just a way of expression. Never assume it is meant to be a definitive choice. It isn't. It's a tool. And learn C first. Then learn C++. And keep your treasured knowledge of Object Pascal to show C++ people how it should be done in the first place. ---------------------------------------------------------------------- BeniBela · 2016-06-03 17:11 C++ has much better containers  classes, set, map, unordered set, unordered map, priority queue With templates they work for every data type; In Pascal you never know which class to pick, if it even exists And with RAII you never need to call constructors or destructors, because it all happens automatically ---------------------------------------------------------------------- lainz · 2016-06-03 17:12 Quote from: Thaddy on June 03, 2016, 06:55:22 pmQuote from: lainz on June 03, 2016, 06:47:31 pmC++ is better and has OOP like Pascal. It is not. Even the inventor of C++, Bjarne Stroustrup, has stated that many times. He dislikes his own child in many ways and often compares it with e.g. among others  Pascal like languages and where he erred Did you understand what I compared? C vs C++ not vs Pascal ok? ---------------------------------------------------------------------- Thaddy · 2016-06-03 17:20 Quote from: BeniBela on June 03, 2016, 07:11:37 pmC++ has much better containers  classes, set, map, unordered set, unordered map, priority queue Which can also be done for Object Pascal.... silly. Just find or write a proper implementation of what you want. QuoteWith templates they work for every data type; In Pascal you never know which class to pick, if it even exists Not true. QuoteAnd with RAII you never need to call constructors or destructors, because it all happens automatically That has nothing to do with a language but with memory management. Do we really need to take you serious? seriously? Your are in my ill-informed filter. did you know that? ---------------------------------------------------------------------- Thaddy · 2016-06-03 18:02 Quote from: lainz on June 03, 2016, 07:12:12 pmompares it with e.g. among others  Pascal like languages and where he erred Did you understand what I compared? C vs C++ not vs Pascal ok? That was not really obvious. In that case I also disagree in part: C++ has many ways of hiding the beautiful simplicity that C has and in many ways also self-explains what you are doing. Because it is so close to the metal   That's good and bad. Anyway: one viking copied something from another viking and the copy proved to be more popular. What it really tells us you really should have studied computer science in Denmark... Just to avoid Kernigan and Ritchie. ---------------------------------------------------------------------- Thaddy · 2016-06-03 18:30 Quote from: Thaddy on June 03, 2016, 07:20:56 pmQuote from: BeniBela on June 03, 2016, 07:11:37 pmC++ has much better containers  classes, set, map, unordered set, unordered map, priority queue Which can also be done for Object Pascal.... silly. Just find or write a proper implementation of what you want. QuoteWith templates they work for every data type; In Pascal you never know which class to pick, if it even exists Not true. QuoteAnd with RAII you never need to call constructors or destructors, because it all happens automatically That has nothing to do with a language but with memory management. Do we really need to take you serious? seriously? Your are in my ill-informed filter. did you know that? How about: "C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off." which is a famous quote from Bjarne Stroustrup himself. Anyone using C++ without knowing about the reservations the creator (and still guardian) of C++ has should not be anywhere near a C++ compiler. Actually should be shot. Not necessarily deadly, but sufficiently painful. ---------------------------------------------------------------------- Leledumbo · 2016-06-03 19:09 Quote from: Handoko on June 03, 2016, 07:00:04 pmIs that mean if I learn C++, I will able to use C automatically? Not quite these days, since both languages have departed further and now has much less common subset than they were years ago. For the sake of understanding (and basis for code porting skills), learning both languages could be a necessity depending on fields of application. C is more often met in lower level stuffs, while C++ in higher ones. ---------------------------------------------------------------------- Thaddy · 2016-06-03 20:44 Quote from: Leledumbo on June 03, 2016, 09:09:24 pmQuote from: Handoko on June 03, 2016, 07:00:04 pmIs that mean if I learn C++, I will able to use C automatically? Not quite these days, since both languages have departed further and now has much less common subset than they were years ago. For the sake of understanding (and basis for code porting skills), learning both languages could be a necessity depending on fields of application. C is more often met in lower level stuffs, while C++ in higher ones. WHAT! C++ is still alive because it lives on, is bolt on, plain C. Please have that corrected in your brains and any future comments on the issue at hand. Or study informatics. (Recommended) ---------------------------------------------------------------------- ykot · 2016-06-04 02:44 Quote from: Handoko on June 03, 2016, 06:14:30 pmSeniors, please share your experience about C and C++. I'm not asking which one is the better. But I want to know what are their advantages/disadvantages compare to the other. Please no flame wars. As others mentioned, this might not be the best place to ask such question and you might not want to take opinions seriously because it is very easy for people to suffer from dunning-kruger side-effect. In my own experience: C++, when compared to C, in terms of information to learn and keep in your head, is huge - especially after C++11 was introduced, and now with C++14 and C++17, even current C++ experts still have a lot to digest and learn about, including language developers themselves. There are many ways to do the same thing, yet many of which might already be "not recommended", so even when you have multiple options to do the same thing, you need to investigate which would be the most "recent" or "acceptable". Overall, be prepared to be learning about the language for a big portion, if not the rest of your life. Whether this is a good or bad thing  in C++ - is up to you to decide. Quote from: Thaddy on June 03, 2016, 10:44:32 pmPlease have that corrected in your brains and any future comments on the issue at hand. Or study informatics. (Recommended) Isn't this a bit arrogant? Also, this SO answer doesn't seem to agree with you. In my own experience, C and C++ tend to be considered as separate languages in professional industry, so if you are proficient in C++, don't expect to get automatically accepted into C jobs and vice-versa. ---------------------------------------------------------------------- Leledumbo · 2016-06-04 03:49 Quote from: Thaddy on June 03, 2016, 10:44:32 pmWHAT! C++ is still alive because it lives on, is bolt on, plain C. Please have that corrected in your brains and any future comments on the issue at hand. Or study informatics. (Recommended) Correct your brain instead of mine, even the simple different pointer type assignment is not compatible in the two languages. void* in C is assignment compatible with all other  including user defined pointer types, while in C++ it is not. And that's only one issue, there are still more. You can write that compiles in both language, in a little subset that both languages share, strictly. A little violation and it breaks already. P.S: I have a CS degree, that's American way of saying Informatics. My campus is a C language family lover, so no need to doubt my fluency in those languages. ---------------------------------------------------------------------- Handoko · 2016-06-04 04:40 Quote from: Thaddy on June 03, 2016, 07:06:42 pmAnd learn C first. Then learn C++. Good suggestion. I think before I decide which one I will go deeper, I will first learn some basic of the both. And I will start with C. Quote from: BeniBela on June 03, 2016, 07:11:37 pmC++ has much better containers  classes, set, map, unordered set, unordered map, priority queue With templates they work for every data type; In Pascal you never know which class to pick, if it even exists And with RAII you never need to call constructors or destructors, because it all happens automatically Thanks for mentioning out the features of C++. Quote from: Leledumbo on June 03, 2016, 09:09:24 pmQuote from: Handoko on June 03, 2016, 07:00:04 pmIs that mean if I learn C++, I will able to use C automatically? Not quite these days, since both languages have departed further and now has much less common subset than they were years ago. I thought if I learn C++ only, I will able to use C too. Now, I know I'm wrong. Thanks for correcting my thought. Quote from: ykot on June 04, 2016, 04:44:54 amIn my own experience: C++, when compared to C, in terms of information to learn and keep in your head, is huge - especially after C++11 was introduced, and now with C++14 and C++17, even current C++ experts still have a lot to digest and learn about, including language developers themselves. There are many ways to do the same thing, yet many of which might already be "not recommended", so even when you have multiple options to do the same thing, you need to investigate which would be the most "recent" or "acceptable". Overall, be prepared to be learning about the language for a big portion, if not the rest of your life. Whether this is a good or bad thing  in C++ - is up to you to decide. Wow, it sounds scary to me. Well, thank you all for sharing your experience. Language is only the tool. It is programmer who creates good software. I will learn both of them before I decide which one suits my need. ---------------------------------------------------------------------- Thaddy · 2016-06-04 05:57 I seem to have inadvertently angered some people. Note that the fact (not opinion) that C++ is a bolt on language on C is stated by Bjarne Stroustrup himself in the first chapter of "The C++ Programming Language"(2nd edition). Now, who would you believe? Santa Claus or Bjarne? Although I am fully aware it looks like the languages are starting to digress. I am not sure that is a good thing or actually the case: although I can write code that behaves wildly different between a plain C and C++ compiler (exactly the same code). I can do the same in Pascal too btw. Furthermore: in both cases I can explain WHY that is the case. I remain of the opinion that C++ is just that: a set of fancy macro's on top of C. And even in FPC the macro facility is good enough to do similar things (change outcome of syntax) ') Yup fpc++ is here to bug you! ---------------------------------------------------------------------- Handoko · 2016-06-04 06:06 It's okay sir. We are free to share what we know. To be a good programmer, we should open to hear and learn from different sides. ---------------------------------------------------------------------- Thaddy · 2016-06-04 06:12 Yes. but please be aware of the difference between facts and opinions. Also be aware and wary of people who state that a certain language can do more than a certain other language. Or features when what it really is are libraries and not language features. Clear your mind and ignore those kind of people. If a language is Turing complete you can express anything in it. Can solve the same problems in it. That's the elegance of Turing's proof: Computationally universal. And yes, a language is just a tool and you should master the tools you need. For Leledumbo: I used to teach CS at university. Not just take the course I am retired now. ---------------------------------------------------------------------- Leledumbo · 2016-06-04 14:57 Quote from: Thaddy on June 04, 2016, 08:12:59 amFor Leledumbo: I used to teach CS at university. Not just take the course I am retired now. So did I, I don't just graduate and leave, I taught longer than I studied. And my knowledge is updated as standards go by. Bjarne may state whatever he wants on his C++ book, but the fact is C++ is no longer his own language, but controlled by an international committee which departs a lot from his original creation. I would trust the compiler implementing the standards (as they often drive the next standard) instead of old fact that no longer valid today. He did explain the incompatibilities and "well written C" which implicitly states the subset which are valid in both languages, not merely said all valid C is a valid C++. ---------------------------------------------------------------------- ykot · 2016-06-04 16:51 Quote from: Thaddy on June 04, 2016, 07:57:06 amI seem to have inadvertently angered some people. Note that the fact (not opinion) that C++ is a bolt on language on C is stated by Bjarne Stroustrup himself in the first chapter of "The C++ Programming Language"(2nd edition). Now, who would you believe? Santa Claus or Bjarne? Nobody is opposing the fact that originally when Bjarne designed C++, he took C as a base. But that was long time ago and quite a few things happened since then. In another quote, Bjarne mentioned that after introduction of C++11, he felt this was like a new language altogether. ---------------------------------------------------------------------- jls890 · 2016-06-04 20:14 I think you should learn both, but C++ is, of course, much better. P.S. I would like to program in C++, but I can't give up from this Lazarus Ide thing. I have tried "qt creator", "fltk fluid", "Glade", but they do not seem simple to me. Is there a free Ide/RAD Tool/GUI Builder like Lazarus for C++? Can we have one day a C++ version of Lazarus? I know about Embarcadero C++ builder, but it is not free. ---------------------------------------------------------------------- ykot · 2016-06-04 21:19 Quote from: jls890 on June 04, 2016, 10:14:34 pmI would like to program in C++, but I can't give up from this Lazarus Ide thing. I have tried "qt creator", "fltk fluid", "Glade", but they do not seem simple to me. Is there a free Ide/RAD Tool/GUI Builder like Lazarus for C++? Can we have one day a C++ version of Lazarus?...Actually, in another thread, I mentioned that it would be great to have a tool similar to Lazarus along with something like LCL but for C++. I believe that such equivalent in C++ doesn't exist yet (at least not to the same degree of quality, functionality, etc.), although there are many similar options, including those that you mentioned. ---------------------------------------------------------------------- marcov · 2016-06-04 22:00 Quote from: ykot on June 04, 2016, 11:19:04 pmQuote from: jls890 on June 04, 2016, 10:14:34 pmI would like to program in C++, but I can't give up from this Lazarus Ide thing. I have tried "qt creator", "fltk fluid", "Glade", but they do not seem simple to me. Is there a free Ide/RAD Tool/GUI Builder like Lazarus for C++? Can we have one day a C++ version of Lazarus?...Actually, in another thread, I mentioned that it would be great to have a tool similar to Lazarus along with something like LCL but for C++. I believe that such equivalent in C++ doesn't exist yet (at least not to the same degree of quality, functionality, etc.), although there are many similar options, including those that you mentioned. Even Dev Cpp originally was a delphi program, which says about enough about the state of GUI and C++. Everything is possible, little is easy. ---------------------------------------------------------------------- jls890 · 2016-06-05 23:48 Quote from: marcov on June 05, 2016, 12:00:06 amQuote from: ykot on June 04, 2016, 11:19:04 pmQuote from: jls890 on June 04, 2016, 10:14:34 pmI would like to program in C++, but I can't give up from this Lazarus Ide thing. I have tried "qt creator", "fltk fluid", "Glade", but they do not seem simple to me. Is there a free Ide/RAD Tool/GUI Builder like Lazarus for C++? Can we have one day a C++ version of Lazarus?...Actually, in another thread, I mentioned that it would be great to have a tool similar to Lazarus along with something like LCL but for C++. I believe that such equivalent in C++ doesn't exist yet (at least not to the same degree of quality, functionality, etc.), although there are many similar options, including those that you mentioned. Even Dev Cpp originally was a delphi program, which says about enough about the state of GUI and C++. Everything is possible, little is easy. And I finally tried a bad joke called Microsoft Visual Studio, community version, which used 6.0GB, and installed more than 40 other things that I cannot even uninstall, and which takes several minutes to build a Hello World program in VB. P.S. Did the OP try JavaScript? It is simple and I am having a good time conding in JS+html5, and I think sintaxe is very close to those of C/C++ which, maybe, would make examples in these language easily portable. ---------------------------------------------------------------------- AlexK · 2016-06-08 04:23 C++ and Javascript can't be fixed. C is a language that's usually mandatory, not just a language worth of interest. Without C it's impossible to understand how high level languages operate, motivations behind implementation decisions, etc. ---------------------------------------------------------------------- ArtLogi · 2016-06-08 09:10 Quote from: AlexK on June 08, 2016, 06:23:05 amC is a language that's usually mandatory, not just a language worth of interest. Without C it's impossible to understand how high level languages operate, motivations behind implementation decisions, etc. Mmm... I agree that C is mandatory, and that is because it is everywhere, I suppose mainly because a) It is sexy for young nerds b) it is product of even more sexier Bell Labs c) it is used (or subset of it) in every single low level chip and device instead of much more tasking, but faster ASM. d) Along the time it taken market leader position in pretty much any technology platform from satellites to PCs so you should know it in some extend if you work with electronic devices (Computers included). e) A blind like followers (see section A) of Gods gurus of the C and nix world. On the other hand next line is 99% BS: "Without C it's impossible to understand how high level languages operate, motivations behind implementation decisions, etc." Only partial truth behind is the "motivation behind implementation decisions" and that is only because so many other languages copy the different routines build or honed to perfection (because industry standard have enough manpower behind it) first (but not in original C implementation as shown in Ansi-C book) in C (again because it is defacto standard in industry). C fanboyism makes me sick. ---------------------------------------------------------------------- Handoko · 2016-06-08 09:48 I want to learn C/C++ because it's everywhere. I think programming is an endless learning process. We always need to learn from others codes. But the codes I get usually are written in C/C++. So I will get much benefit if I can understand C/C++. I don't think I will use C nor C++ to write programs, because I'm now happy with what Lazarus/FPC can give me, the ease, performance and cross-platform results. Other languages that I might consider to learn in future are Python, Lua, D, Java also PHP. I hear a lot of them. Unfortunately, my 'real' job is not programming related, I'm a computer technician and graphics designer. The time I can spend for programming is limited. I wish I can have 48 hours everyday. ---------------------------------------------------------------------- Graeme · 2016-06-08 10:34 Quote from: Handoko on June 08, 2016, 11:48:25 amOther languages that I might consider to learn in future are Python, Lua, D, Java also PHP. I've recently been familiarising myself with the Java language, and later switched from using a plain text editor to using Eclipse IDE to write my code. Wow, was I pleasantly surprised with Java and Eclipse. I could use compiled .class files created with Java 5, even though    I'm using Java 8. No recompile of the old code needed.Renaming a class in Eclipse is a single change - Eclipse even takes    care of the file name change.Because Java doesn't have a header unit (.h) or a Interface section,    renaming methods, types etc is a single edit change. No search and    replace needed.Write code that doesn't exist yet (eg: calling a method of a class    and with arguments). Then press Ctrl+1 and Eclipse implements that    method with the correct parameter types for you, in the correct file    and class. Awesome - especially if you code in the TDD style like    I do.Using Eclipse, I don't actually have to Compile my code - Eclipse    does it continuously in the background - that is also how it manages    to report errors or improvements against your code.Even though I'm using Java 8, I can tell Eclipse to recommend better    code, API usage etc against any earlier Java version. It knows    exactly what Java version supported what language syntax and    features. So the code generator will not generate code where certain    features did not exist in the selected compatibility Java version.Eclipse has an Outline Window, which shows you what a Pascal    Interface section would show. So even though Java doesn't have an    explicit Header or Interface section - it really isn't needed at    all, because the Outline Window tell you everything. Plus, simply    double click a method there and the code editor takes you to that    code. Want to rearrange the order of methods or fields? No problem,    and no need for Cut & Paste either. Simply select and drag them    around in the Outline Window, and Eclipse will move the actual code    for you.Enable Format on Save - so even if your indentation, alignment etc    are not according to the code formatting style you specified,    Eclipse will reformat your code on Save (all lines, or only changed    lines can be processed).Eclipse's Refactoring support is out of this world! And that's just what I discovered in 2 days! I'm really starting to like Java (and Eclipse) a lot. It has improved so much since my initial introduction to Java from the late 90's. QuoteI wish I can have 48 hours everyday. Don't we all!! ---------------------------------------------------------------------- Handoko · 2016-06-08 10:56 Thanks for sharing your experience with Java+Eclipse. It sounds interesting.