Jump to content
Objectivism Online Forum

Software: C++ language code?

Rate this topic


Plato
 Share

Recommended Posts

Does anyone know how to learn c++ most effeciently? I have tried google but it didn't result in anything I wanted :worry:

If you're new to programming I wouldnt advise you to begin with C++ (in fact I wouldnt advise you to use it all, unless you believe that it will be necessary for your career at some point). But, assuming you do want to learn it, I think you're probably better off with an actual textbook rather than an online tutorial - online guides might give you the basics, but they tend to gloss over the details. I personally learned C++ using Teach yourself C++ in 24 hours and I think this series of books are generally quite good for introductory teaching.

In terms of online resources though, Bruce Eckel's entire textbook "Thinking in C++" is available here (yes, this is legal - he chose to publish it online). I've never read it so I can't make any specific comments regarding it. From reading the preface though, I think it assumes that the reader is already familar with programming, and specifically has knowledge of C.

Link to comment
Share on other sites

Thanks...but would perl be easier?

After spending many hours crunched over a keyboard trying to decipher cryptic Perl code, my answer would an emphatic “No!”

If you want to get started programming, I highly recommend that you get one of the Visual Studio 2005 Express Editions of Visual Basic, Visual Web Developer, or Visual C# from MSDN for – free!

Link to comment
Share on other sites

C++ is one of the tougher languages to learn. It's a mixture of a procedural language (C language) and an object oriented language. This means you'll be taking on a lot at once.

Learning C would be easier to start since it's purely procedural, or Java, since it's purely OO, then you can move onto C++. C is a subset of C++.

C++ is the language of choice for me, because it's fast and good for graphics programming, where fast running code is a must. I consider it to be the most powerful language out there for general purpose programming. It's also loaded down with lots of great tools. Most graphics programmers use C++.

Herb Schildt is, in my experience, the best explainer of code I've come across. He gives crystal clear descriptions of concepts, and then provides short code samples for demonstration. Look for books by him. I have his C++ reference book, but he also has a book geared towards learning the language: "C++ from the Ground Up".

Bruce Eckel's book is likely the best one you can find that's free. I recall him giving an excellent description of polymorphism and inheritence.

Perl is a very high level language, and very different from C++. It's not a fast language and not as versatile, in that it can't do as many things as C or C++. If you want to write web related code for handling text, then Perl is a good language. It has very powerful parsing techniques. It's a language that is heavily geared towards notation. What's great about it is the fact that in one line of code you can do several operations. This has the side effect that it can be very hard to read, as GreedyCapitalist rightly points out. It should be heavily commented. Python is a similar language.

You might want to ask yourself why you want to learn a language, that will help you determine which language to learn.

Link to comment
Share on other sites

Thanks...but would perl be easier?

Perl is infinitely superior to C++ and would also be easier to learn, but I don't think I'd recommend it for a first language. I would personally go with David's advice and start with C# - its a powerful language which is relatively easy to learn, and it'll allow you to begin writing graphical applications very quickly. If you're interesting in learning theory as well as writing applications (by theory I mean the sort of things you would do in a computer science degree), I'd also take a look at some of the less mainstream functional languages, Ocaml in particular. However I'm not sure I'd recommend this for a first language either, since its lack of popularity will make it difficult to find textbooks and help if you require it.

I wouldn't sweat too much over the language to be honest - once you've grasped the basics of programming (which you can do in pretty much any language) its a lot easier to learn new languages. Just don't go near C++ :)

After spending many hours crunched over a keyboard trying to decipher cryptic Perl code, my answer would an emphatic “No!”

Perl isnt a difficult language to learn. It has a lot of notational devices which save space, hence it can be difficult to read the code of others if they have decided to take advantage of a lot of them, but there's no reason why you cant write perl code which is legible, neat and elegant. It's probably not a good choice for a first language though since it tends to gloss over things which I think a beginner should get experience with as soon as possible (eg it has dynamic typing). It also takes a lot longer to be able to write 'fun' programs (with GUIs etc) in perl, which can make it a bit dull.

Link to comment
Share on other sites

If you wish to learn C++ from scratch, I'd suggest that you start with either Robert Lafore's C++ book or Stanley Lippman's C++ Primer. Once you get to know what's happening you definitely have to go for Bjarne Stroustrup's "The C++ Programming Language" which is definitely one of the best C++ books out there! And once you are done with that you can try Nicolai Josuttis's "The C++ Standard Library". That too is a great book!

Eckel's book is ok, I personally don't like the structure of the book!

I've been doing C++ for around 5 years now and I absolutely love the language and it's definitely worth a try! C++ enables you to write some really good code with the help of the Standard Template Library (STL) which is a fantastic library!

Go ahead, learn and enjoy :):)

Dinesh.

Link to comment
Share on other sites

Thanks...but would perl be easier?

Depending on what you want to accomplish with your program will dictate what language to write the program in. If your desire is to learn the basics of programming, I would highly recommend starting with Python.

Python is an ultra high level language similar to Perl. If you are just trying to get your feet wet and learn the basic logic of programming, Python is very easy to work with. You don't have to deal with all the confusing preprocessing commands and bizarre pitfalls that you run into with C++, Java and C#.

It makes no sense why university Computer Science departments don't start beginning programmers with a language like Python. 95% of the problems that beginning programmers have deal more with the intricacies of C++ rather than with the programming logic itself. Once you have a handle of the basics its a lot easier to move on to a more complicated language like C++ or Java.

python.org

Book: Learning Python

Link to comment
Share on other sites

Perl is infinitely superior to C++ and would also be easier to learn,

Perl's strength is its powerful notation and document parsing abilities. I love it's power, but I'd never claim it was on a par with C++, let alone better. C++ is an all purpose programming language, with more speed and power and fexibility for most applications.

You can do everything Perl does with C++, albeit without the beautiful notation, but can't do everything C++ does with Perl. Not even close.

but I don't think I'd recommend it for a first language. I would personally go with David's advice and start with C# - its a powerful language which is relatively easy to learn, and it'll allow you to begin writing graphical applications very quickly.
I've not used C#, but it's modeled after C++ and Java, and is itself purely OO. It's probably more akin to Java, as it was set up to be a competitor to Java.

If you wish to learn C++ from scratch, I'd suggest that you start with either Robert Lafore's C++ book or Stanley Lippman's C++ Primer.

I have Lippman's Primer. I agree it's a good book, but I believe Herb Schildt is better at explaining code. If you work through Lippman's book you have to work harder to get the meaning out.

Once you get to know what's happening you definitely have to go for Bjarne Stroustrup's "The C++ Programming Language" which is definitely one of the best C++ books out there
His would be the defacto standard.

I've been doing C++ for around 5 years now and I absolutely love the language and it's definitely worth a try! C++ enables you to write some really good code with the help of the Standard Template Library (STL) which is a fantastic library!

You're absolutely right! Not to mention your ability to make your own template classes. The joy of C++ is its immense versatility and scope. I'm always looking for a better language, and so far none has caught my eye.

Link to comment
Share on other sites

  I've not used C#, but it's modeled after C++ and Java, and is itself purely OO.  It's probably more akin to Java, as it was set up to be a competitor to Java.

C# is almost identical to Java. Looking at snippets of code, it is difficult to tell the difference at a glance.

  I have Lippman's Primer.  I agree it's a good book, but I believe Herb Schildt is better at explaining code.  If you work through Lippman's book you have to work harder to get the meaning out.
Lippman's Primer is a good reference but not a good book to learn from directly if you are completely ignorant of the language.

  You're absolutely right!  Not to mention your ability to make your own template classes.  The joy of C++ is its immense versatility and scope.  I'm always looking for a better language, and so far none has caught my eye.

C++ will be difficult to replace anytime in the near future based solely on the speed and efficiency of the C++ compliers. Executables created from C++ code are much faster than anything else. Compliers evolve as a language grows in popularity so it would be hard for another language to replace C++ right out of the chutes. With the ever-increasing speed of computers, this is becoming less of an issue, but it is still a primary concern.

Link to comment
Share on other sites

Perl's strength is its powerful notation and document parsing abilities.   I love it's power, but I'd never claim it was on a par with C++, let alone better.  C++ is an all purpose programming language, with more speed and power and fexibility for most applications.
I suppose C++ is all-purpose in the sense that it's equally bad at everything. For which specific tasks would you say that C++ is the language of choice? It's too low level to be properly used for most high-level functions (ie 99% of programming tasks), and inferior to Objective C for combining OO with C. I suppose you could use it for low level programming if you really didn't like C, but how much programming is actually done at that level?

   You can do everything Perl does with C++, albeit without the beautiful notation, but can't do everything C++ does with Perl.  Not even close.
I'm not sure what you mean here. Both langauges are turing complete so by definition anything you can do in one, you can do in the other. What do you think you can't do in perl? (if you think theres something specific that perl can't do, check on CPAN first). If you mean that you can't do things in perl as fast as you could in C++ then yeah, you're right.

I'm not saying that I'd advocate using perl for everything - quite the opposite. Perl was designed with a clear set of goals in mind, and it achieves them well. C++ was an attempt to make a language that "does everything", hence why its ended up as jack of all trades and master of none.

  I've not used C#, but it's modeled after C++ and Java, and is itself purely OO.   It's probably more akin to Java, as it was set up to be a competitor to Java.
Yeah, its very much like Java. Almost identical really, but from my (admittedly brief) experience with .NET, its preferably to the standard java APIs. You also don't have to rely on your users having a JRE installed, which makes it more feasible for client side apps.
Link to comment
Share on other sites

C++ will be difficult to replace anytime in the near future based solely on the speed and efficiency of the C++ compliers.  Executables created from C++ code are much faster than anything else.

Ocaml sometimes produces faster code than C++ and a lot of other languages come close (see here for some fairly comprehensive benchmarks).

In terms of popular programming languages there isnt that much difference between properly compiled Java and C++ in terms of speed for most normal tasks these days, although obviously you wouldn't use java for things like graphics routines where speed is a priority. Check here for an in-depth discussion of java v c++ in terms of performance. Java done badly in the above benchmark but see here for more recent tests).

Link to comment
Share on other sites

Ocaml sometimes produces faster code than C++ and a lot of other languages come close (see here for some fairly comprehensive benchmarks).

In terms of popular programming languages there isnt that much difference between properly compiled Java and C++ in terms of speed for most normal tasks these days, although obviously you wouldn't use java for things like graphics routines where speed is a priority. Check here for an in-depth discussion of java v c++ in terms of performance. Java done badly in the above benchmark  but see here for more recent tests).

Java is by no means "slow", but looking at the the benchmarks you provided, the results are contradictory.

I looked at the the first link you provided and the last one. First off, the last page showed a graph of benchmarks with no units at to what the bars on the graph indicate. All it said is "bigger is better", hardly scientific.

I tried to find a routine where both Server JVM and Client JVM results were noticeably higher than the g++ complier (as a side note, I had no idea about Server JVM. I am shocked at how much faster it is :) ). I saw "Word Count" at the bottom, showing both JVMs outperforming g++. I looked at the comprehensive benchmarks (first link) for a similar routine (word-frequency). It showed this:

 

Program          Full CPU Time(s)    Memory Use(KB)    CPU Time(s)  Code Lines

C++ g++              0.44                        1,000                0.44                84

Java                      3.24                      16,028                3.07                55

It shows that C++ is about 7X faster than Java. How could there be this large of a difference between the two benchmarks? :(

Link to comment
Share on other sites

I suppose C++ is all-purpose in the sense that it's equally bad at everything. For which specific tasks would you say that C++ is the language of choice?
For anything where you want speed and performance C++ is the language. Now, you can get better speed with assembly, but that isn't too practical except for small functions.

It's too low level to be properly used for most high-level functions (ie 99% of programming tasks),

But this is patently untrue. C++ is very efficient and effective for precisely this purpose. What do you mean by high level, then? With the STL's string function, I can do high level string parsing with great ease, for instance.

There is a great deal of elegance to C++, if you write it right.

Now, it doesn't give you the out of the box high level functions, say, a Visual Basic gives you, but Visual Basic gives you far less flexibiity. It's very hard to make things precisely the way you want, because you can't see inside the box, so to speak. I love VB for what it is, a great prototyping language. Great for slapping something together quickly.

and inferior to Objective C for combining OO with C. I suppose you could use it for low level programming if you really didn't like C, but how much programming is actually done at that level?

I've never used Objective C, and I haven't seen it much used. I'll need to look into that.

Perl is a slow language. It's really great for text parsing, and I'm sure you can use it for lots of other things, but lack of speed is a major draw back in a multitude of programming applications. It would be utterly impractical for graphics, for example.

Btw, here are some benchmarks for Perl, Python, Java, C++. Note the pure speed of C++.

Link to comment
Share on other sites

Java is by no means "slow", but looking at the the benchmarks you provided, the results are contradictory.

I looked at the the first link you provided and the last one.  First off, the last page showed a graph of benchmarks with no units at to what the bars on the graph indicate.  All it said is "bigger is better", hardly scientific. 

You have to click on the 'data' link :)

http://www.kano.net/javabench/data

  It showed this:

It shows that C++ is about 7X faster than Java.  How could there be this large of a difference between the two benchmarks?  :(

In all honesty, I'm not sure. Language benchmarks are notoriously difficult to do objectively.
Link to comment
Share on other sites

Thanks...but would perl be easier?

Plato, why do you want to learn to program?

The best language to learn depends on what your goals are.

Do you want to build websites? Are you a unix or DOS command-line junkie? Are you thinking about pursuing a career in software development? Scientific programming?

I think that the best way to learn to program is to have a goal. Have a specific task that you want to do. Try to pick something easy relative to what you already know. I find that it is easiest to learn when I have a specific problem at hand, and am learning incrementally.

Another tip: when possible, find some source code that already does something that is interesting to you. Take this source code and modify it to do more interesting things. Most of us learn to read before we learn to write.

Link to comment
Share on other sites

I'm sorry for not replying, I was out of town for the last two days and away from the internet.

Plato, why do you want to learn to program?
Right now, I want to learn it for learning's sake.

Right now, my "aim" is to build a really superb scientific/graphing calculator...one that is better than TI-90! But I want to know how to program for the sake of knowing it.

Link to comment
Share on other sites

Does anyone know how to learn c++ most effeciently? I have tried google but it didn't result in anything I wanted :(

The book I used to learn C++ was "Absolute C++" by Walter Savitch. I found this book to be really good in helping to learn the language. Also this book was the pre-req for comp sci at Deakin University [Australia]. I also found reading Ayn Rand's "Introduction to Objectivist Epistemology" , and recommend it to all who want to learn OO, to be of great help in dealing with Abstractions [Of course this book offers much more]. Abstractions, in my experience, is the hardest thing to learn for a novice OO programmer. But once they understand Abstractions, thanks to Ayn, OO becomes very easy. Note: This is just for interest sake that OO in comp sci at Deakin has a fail rate of about 75% to 85%. The exam for it is really extreme :lol: . I heard that one person got 6% out of 60%. Not good.

Anyway the Savitch book explain things pretty good and gives you many example programs in it. Though, I have talked to others in the industry about the book and they say the book takes the long approach to writing programs and that many of the examples could be cut down alot.

Ash :D

Link to comment
Share on other sites

  • 3 months later...
Does anyone know the basics to programming syntax/grammar? That may be the problem...

Yes. You should have no trouble becoming a proficient programmer by selecting a decent language and learning on your own. C++ is a terrible language for learning (heck, it's terrible for experienced programmers too)

That is C++'s big problem. It isn't always obvious when viewing a snippet of C++ code what is going on. The syntax is highly cryptic for one reason. And code locality is hurt by header file/implementation file concepts, macros, and so on.

I would recommend learning programming principles using a clean language, Visual Basic isn't a bad choice, as it is fairly easy to learn, is widely available, "fun", and the development environenment is very friendly and intuitive. Plus Visual Basic is used in many real world, industrial strength applications (unlike some toy languages that are designed specifically for learning).

I could bash C++ all day long, and discuss my favorite language Eiffel for years.

Bertrand Meyer is a genius (the inventor of Eiffel), and his understanding of what Object Oriented programming is (and should be). His book Object Oriented programming is a masterpiece and I highly recommend it to Objectivist software developers.

I implemented a chess engine using Eiffel with fairly decent performance (this is with full garbage collection). See http://www.stauffercom.com/hotbabe

(Obviously I am responding to an ancient post, but I love, love, love Eiffel and hate, hate, hate, C++ so I could not pass on adding my $0.02. and I have had 3 cups of coffee just now)

Link to comment
Share on other sites

I suppose C++ is all-purpose in the sense that it's equally bad at everything. For which specific tasks would you say that C++ is the language of choice? It's too low level to be properly used for most high-level functions (ie 99% of programming tasks), and inferior to Objective C for combining OO with C. I suppose you could use it for low level programming if you really didn't like C, but how much programming is actually done at that level?

Saying C++ is too low-level and therefore useless is missing the point. The main selling point of C++ is CONTROL. C++ is low-level by default, but you can bring it up as many tiers as you want with the use of libraries and API's (both your own and others'). And then modify them as it suits you.

It is true that you can't immediately code something useful in C++, but if you're willing to do the gruntwork of coding your own environment (think: making abstractions), the power it gives you is hard to let go of.

Link to comment
Share on other sites

Let the language wars begin.... I don't mind. I am up for the challenge.

But on an Objectivist/Ayn Rand specific forum? Yes. I think if this topic is moved to appropriate group.

I would love to see a critique of various computer languages. And Ayn Rand's epistemology could be the key to make such a topic relevent.

How does a language help the programmer respect the crow epistemology? How does the language allow the programmer to combine abstractions into higher level abstractions.

By the way, I don't believe the evolution of computer languages has anything to do with the computer. The trend from assembly to modern Object-Oriented languages is really about a new industry discovering the best way to organize programmatic information for the human to cope with. (This view differs from the view that the evolution of better and better languages is in some way implementing consciousness on the computer).

The computer is flipping switches, and if the switch settings came from assembly or from a visual basic representation has no effect on the execution of the computer.

Link to comment
Share on other sites

The quality of a language should be measured by its power. Power is the combined sum of two powerful qualities: The most you can express in a certain amount of code, and the extent and the closeness to which you can manipulate the computer at the concrete level. (In the old days, concrete would mean accessing the hardware directly; nowadays it means getting as close to the OS as possible).

Usually these two sub-components of the word "power" are also refered to as "power" (it would be ok to describe them as "powerful"); these need to be given new words to differentiate them.

I recommend the words "expressiveness" and "flexibility".

C++ is a language of very high flexibility, and user/programmer-dependant expressiveness, that defaults to very low expressiveness. C++ can be made into a highly expressive language, the extent to which that is achieved depends on the skill of the programmer. There is an upper-bound to how expressive you can make C++ before you have to turn it into another language.

I submit that C++ is POTENTIALLY the most powerful programming language in existence.

EDIT: Deleted my opening paragraph which was redundant.

Edited by iouswuoibev
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...