I was looking into learning C , C++

I want to learn a fast programming language, I looked for some so that I could have more then one choice. I only found three C ( and it’s partner C++,) scheme, and assembler. I noticed that an assemble language though probably faster the C would take forever to write the simplest program scheme useing the pre scheme package was supost to be an alternative to C but, it was in the contrib repo wich is now deprecated and it was not moved to the offical repo.
So I decided I should learn C or C++.

1: I wanted to know what ( free ) resources are avalible for the beginner???
2: I think it’s kinda stupid to pay someone so you can learn to work on computer programs for free.

On Fri, 10 Aug 2012 17:56:02 +0000, ballsystemlord wrote:

> 1: I wanted to know what ( free ) resources are avalible for the
> beginner???

http://www.cprogramming.com/ looks like a good starting point. “learn c
programming” as a search on Google turns up lots of good resources.

> 2: I think it’s kinda stupid to pay someone so you can learn to work on
> computer programs for free.

I’m not sure what this has to do with anything - but OK. <shrug> I
taught myself C on a Commodore 64 back in the early 80’s, had to buy the
compiler and a book on C programming. The “Learn C in 21 days” type book
seems quite popular.

Jim

Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

Thanks I know that their are many recources but I was seeking your advice because I’ve read that C, C++ is a difficult language which can easily be made worse by people who write badly or understand the language to a point.

You mentioned that part of my post may not have anything to do with the subject; I’ve been advised by other people who work in computers to buy stuff to learn about them, and so, as to not get stuck in that free ware incompatible ( or semi incompatible, ) idiolagy I wrote the above explanation of my objection to that advice.

Again thanks!

On Wed, 05 Sep 2012 20:06:01 +0000, ballsystemlord wrote:

> Thanks I know that their are many recources but I was seeking your
> advice because I’ve read that C, C++ is a difficult language which can
> easily be made worse by people who write badly or understand the
> language to a point.

That’s certainly true, but it’s true of pretty much any language you
could learn. It’s possible to write bad code regardless of the language,
whether it’s C, C++, C#, BASIC, Pascal, Ada, … the list goes on and on
and on.

Start with structured programming would be my advice. Take a look at
scripting languages or interpreted languages as a good starting point -
Python is considered a good language to start with.

C (in particular) and C++ (to a lesser extent) are very unforgiving
languages, and some things aren’t done best in them - string handling/
manipulation, for example, is much more involved in C-based languages
than in a language like Pascal, which has built-in data types for string
handling. C and C++ treat strings as an “array of characters”, but when
you start dealing with arrays, in C you end up dealing a lot with
pointers, and that’s a more advanced topic. Pointers are IMHO the #1
thing that bite new C programmers in the backside - especially when you
start dealing with multiple levels of pointers (pointers to pointers).

A language that abstracts that will be easier to learn and will teach you
the fundamentals of structured programming in a more forgiving
environment.

> You mentioned that part of my post may not have anything to do with the
> subject; I’ve been advised by other people who work in computers to buy
> stuff to learn about them, and so, as to not get stuck in that free ware
> incompatible ( or semi incompatible, ) idiolagy I wrote the above
> explanation of my objection to that advice.

Sometimes it’s easier and more expedient to purchase a book tailored to
your needs, or to pay for a class that will get you the interaction that
helps you learn the best. (I spent about a decade doing technical
training and learning development, so I have some knowledge/expertise in
this field).

Jim

Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

As someone who develops in C++ with Qt, I highly recommend this book Introduction to Design Patterns in C++ with Qt4 and Videos | Qt Developer Network . C++ honestly isn’t that hard by the way. When people complain about it being hard they’re usually complaining about the fact that it grants you the ability to manage memory yourself, which Qt makes essentially painless, and there are Garbage Collectors for C++ if one must have one. One thing that is important to know as well because a lot of people screw up explaining this, is that a pointer is merely a pronoun, they try to get too technical and miss what it actually is in terms of a lanugage. Also with Qt and even STL Strings the perfectly fine to deal with and not an “array of characters”.

On Sat, 15 Sep 2012 01:16:01 +0000, LukeWolf wrote:

> As someone who develops in C++ with Qt, I highly recommend this book
> ‘Introduction to Design Patterns in C++ with Qt4’
> (http://cartan.cas.suffolk.edu/oopdocbook/opensource/) and ‘Videos | Qt
> Developer Network’ (http://qt-project.org/videos) . C++ honestly isn’t
> that hard by the way. When people complain about it being hard they’re
> usually complaining about the fact that it grants you the ability to
> manage memory yourself, which Qt makes essentially painless, and there
> are Garbage Collectors for C++ if one must have one. One thing that is
> important to know as well because a lot of people screw up explaining
> this, is that a pointer is merely a pronoun, they try to get too
> technical and miss what it actually is in terms of a lanugage. Also
> with Qt and even STL Strings the perfectly fine to deal with and not an
> “array of characters”.

That’s all fine if you write to QT, but not all C++ coders write to QT.
The beauty of C and C++'s extensibility is also something of a curse for
new programmers, because if you start learning using extended non-
standard libraries, when confronted with a system that doesn’t have those
libraries, you get stuck.

That’s the difference between learning a language’s syntax and learning
how to program, IMHO.

It’s a semantic difference between “it grants you the ability to manage
memory yourself” and “it requires you to manage memory yourself” - a
matter of spin, or “marketing”.

I like the analogy about a pointer, though (although a street address is
usually easier to understand) - the thing in C in particular (but that
carries over to C++) that most find confusing is the difference between
addressing modes and the syntax for declaring a pointer vs. referencing
the value at a pointer.

That’s what tripped me up when I started learning C in the early 80’s.
It took me learning assembly language to really understand handling
pointers properly; until I did that, I operated largely on trial and
error in getting the syntax right.

But the declaration:

char *string1;

(which requires that you malloc the memory unless you want to ultimately
segfault)

vs.

char string2[10];

Means that if you want to reference the address of the array string1, you
do so with the variable “string1”. But don’t forget to null terminate or
do bounds checking when adding to the string (or to increase the
allocated memory), or you’ll run into all sorts of weird issues and
crashes.

If you want to reference the address of the array string2, you do so with
“&string2”.

Things get more complicated with more involved data structures - for
example, arrays of strings (strings being arrays of chars themselves).
Managing memory for those can be tricky.

C and C++ both are great languages to shoot yourself in the foot.
Firsthand experience with that - and in some instances, intentional
firsthand experience (ie, I was writing code specifically designed to try
to crash a system - testing memory protection systems, for instance).

Forgetting to null-terminate the char array can lead to problems with
some functions as well.

Yes, C and C++ can be extended with string handling libraries. Those
libraries may or may not be portable. You can also typedef a “string”
type, but that doesn’t mean that you’ve created a string primitive so
much as created an alias between a user-defined type called “string” and
a char array.

But talking about whether C or a language like Pascal is better/easier to
handle strings with, I can say that my experience has to do with ACM
programming contests - the winningest teams (at least in the early 90s
when the choices were C or Pascal) were not CS teams programming in C,
but engineering teams programming in Pascal. I had the privilege to
train alongside coders on one of the top teams in the world at the time.

That team’s coach explained very specifically that Pascal was the only
language his teams used because of its superior string handling (as most
ACM contest problems involved heavy amounts of string handling and could
not require libraries beyond the standard libraries included with the
compiler provided for competition).

But ultimately, when learning about programming, I stand by picking an
easier language than C or C++ as a starting point in order to learn
structured programming. The most successful programmers I know didn’t
learn a language’s syntax first (other than to be able to build a working
program), but the language facilitated learning about structured
programming techniques (and in later years, OOP principles as well).

If you start by learning an overly complex language’s syntax, you get
stuck with a language and a syntax. If you start by learning about
structured programming principles and OOP principles, then the syntax
will naturally come as you apply the understanding of the underlying
“Latin” of structured programming/OOP.

For me, that was a very good approach, and I highly recommend it for a
number of reasons. It’s not always the easiest approach, but it gives
the most flexibility in applying principles to code written in a very
wide variety of situations, rather than locking you into dealing with the
one language you know, regardless of what libraries are available.

Jim

Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

First off it’s Qt not QT :P. Anyway, while that’s a fair there’s very few situations where Qt won’t be available (I’m programming an android app for instance in Qt), and that book at least in my perspective does a pretty good job of handling both sides of things. Really what’s important is the conceptual stuff anyway, as that is the real difference between learning syntax and learning programming. As then it becomes transferrable.

Actually it’s not really marketing because you don’t actually have to manage it yourself. There are garbage collectors out there that will clean up after you if you so desire so that you never have to call delete yourself. Personally I don’t rely upon one since the parent-child hierarchy of Qt is more efficient but eh… that’s a personal decision.

Glad you like it, although it’s actually just the proper linguisitic term for it, the street address analogy only served to confuse me when I learned about pointers myself. It was the recognition of them as pronouns that really made them “click” in my mind.

ah but you see that’s the entire point of the STL in C++, to provide a set of datatypes and functions that you’ll have even if you have nothing else with C++. You’re always assured that you have std::string, std::cin, std::cout, etc…

Well, C-Strings are pretty bad to deal with but std::string which you can use with C++ isn’t at all. Actually you don’t even have to deal with arrays directly at all if you’re relying on the STL.

Well I definitely wouldn’t want to throw him into C, that much we can agree upon. C++ however is a very different story indeed. Particularly as C++ is structured while having the ability to choose to program in objected oriented design or not, and Qt is actually excellent for teaching OOP and various Design Principles. Infact it’s kind of it’s two guiding principles of “Code Less, Create Mode” and “Write once, Run Everywhere”.

I’ll grant you have some points against C, but I didn’t see anything there that really worked against C++.

To give kind of an example of the whole pronoun thing, let’s consider the following statement:

“He walked down the street”

Well starting off with, just who is “he”? We’ve got the english equivalent of a null pointer exception.

it’s basically equivalent to


Person* He;
He->walk("Down the street");

In contrast:

Peter walked down the street. He is going to the grocery store.

In this particular case we’ve declared who we’re talking about and implicitly created a Person* He that is pointing at Peter, so this english statement is roughly equivalent to


Person Peter;
Person* He = &Peter;
Peter.walk("Down The Street");
He->setDestination("Grocery Store");

And all the problems you have with pointers show up in pronouns and vice versa because they’re linguistically the same.

I know that any language can have bad docs however unlike, lets say, perl, C, C++ would no offical websit as it was invented before the web! It has, as far as I’m aware, no support community or enthusiastic users who want to teach it to you. In fact I’ve only here of unhappy users who use it!:’(
I would not tie to the qt or gtk toolkit rather I’d probably use the powerful FOX toolkit (Though I’m also interested in looking as newt cause it’s nifty).
I was going to learn more C then C++ (I’ve never heard of C# before,) because if I wanted some good code examples the Linux kernel justy happens to be writen in C. I don’t C why garbage management is a head ache, I mean all I have to do is keep a number at the bottom of my source file indicating how many variables I have to declare nil at the end of my program. I’d also use python3 for text manipulation and the like and then use a C, C++ program to pass parameters to for fast proccessing and execution.
I actually want to, at least currently, use my knowlage of C, C++ to help me create python3 bindings to some packages which I thought were really interesting that I found while browsing through my packages that I could install. Why rewrite already existing code when you could bind to it?

Am 18.10.2012 18:16, schrieb ballsystemlord:
> I actually want to, at least currently, use my knowlage of C, C++ to
> help me create python3 bindings to some packages which I thought were
> really interesting that I found while browsing through my packages that
> I could install. Why rewrite already existing code when you could bind
> to it?
>
Use Cython to make python to C bindings not plain C.


PC: oS 12.2 x86_64 | i7-2600@3.40GHz | 16GB | KDE 4.8.5 | GeForce GT 420
ThinkPad E320: oS 12.2 x86_64 | i3@2.30GHz | 8GB | KDE 4.9.2 | HD 3000
eCAFE 800: oS 11.4 i586 | AMD Geode LX 800@500MHz | 512MB | lamp server

Thought I’d just share my thoughts as someone who routinely writes in C++ and ia32/64 assembler every day. There’s a few things you probably need to take onboard:

  1. If you’re a beginner at programming, you’re initial code will not be fast whichever language you use. You need to know about computer architectures to write something really fast. To give you a flavour, have a look at Agner’s software optimization resources: Software optimization resources. C++ and assembly. Windows, Linux, BSD, Mac OS X

  2. Don’t fall for programming religion: one language doesn’t rule them all. There’s no reason why you can’t use different languages in the same application. Which language you use will depend on a number of things e.g.:

a) Do you need to program a graphical interface? (if yes, then you need to choose an architecture such as QT or GTK which may influence your choice of language).
b) Do you really need raw number-crunching speed for very specific applications? (if yes, then might consider using assembler modules or inline assembler embedded in a C++ module for example).
c) Do you just need fast array numerical operations? If so, then you can save yourself a lot of work by exploiting linear accelerated libraries such as BLAS/LAPACK - in which case learn Python and use NumPy because that will be much faster than your slow C++ code (unless you inline-assembler the array routines). To learn Python (which comes preinstalled on openSUSE as well as NumPy), I’d recommend Learn Python The Hard Way by Zed Shaw.

  1. Ask yourself why you want to learn programming. If it’s for fun, then start with something easy which will introduce you to the concepts (e.g. OOP) rather than getting bogged down with complex syntax (as Jim suggests). I wouldn’t start with C/C++/assembler because they are not easy (they are too simple :slight_smile: ). Personally, I wouldn’t start with Pascal, Fortran, or BASIC either because they are not routinely used. I’d start with Python because:

a) It’s already in installed (in openSUSE)!
b) It’s easy, easy to read, but very powerful.
c) It’s flexible accommodating OOP and procedural coding.
d) It’s routinely used so learning the (easy) syntax is useful.
e) It happily interfaces with GUI architecture (e.g. QT).
f) It can be interfaced with modules written in other languages (e.g. SWIG-wrapped C/C++).

HTH

On Thu, 18 Oct 2012 16:16:01 +0000, ballsystemlord wrote:

> I know that any language can have bad docs however unlike, lets say,
> perl,
> C, C++ would no offical websit as it was invented before the web!

That’s not actually correct. Most languages do have an official “home”
of some sort on the web, regardless of when they were invented.

Similarly, you’ll find that on USENET (as one example) there are
communities for most programming languages.

Prolog, for instance, is a language I was first introduced to in around
1987. Well before the 'net as we know it.

http://www.swi-prolog.org

That’s the second hit, and standards-based Prolog implementation of
standard Prolog. Or

http://www.gprolog.org

The GNU Prolog site.

FORTRAN’s been around since the '60s…You’ll find a thriving community
around that language with the G77 implementation that’s part of the
standard GNU compiler collection.

Looking at it the other way (because what you wrote isn’t completely
clear to me), if you think C has an “official website” because it wasn’t
invented before the Internet…well, you’re wrong about that, too. K&R
C was developed in '69-'73, and C++ was around in 1990. Perl development
started in 1987.

These are not “new” languages.

Jim

Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

I did not mean that I would write the python bindings in C/C++ though perhaps I did not state that clearly.
I always thought that the intranet was invented after C/C++ becuase it would be very hard to write it in asssembler language but for that matter it might have been originally writen in basic or something.
I half knew that the speed of your program depended on how well you wrote it but I did not know how pronounced the effect would be.
I have main three resons for learning C/C++
1: It’s fast.
2: It’s what most programs and librarys apper to be writen in.
3: It can do almost anything. (Whats the linux kernel writen in? How about the graphically intensive games? How about the X windows system? How about gimp? and KDE? etc.)
These things convice me it would be a good investment of time to learn C/C++ despite the fact that I am still a beginner to programming.
The only thing that convices me that learning it is a bad idea is that “everyone” complains about it, but if it were really that bad then why do so many programs use it?
Are there no other fast languages out there?

On Tue, 04 Dec 2012 20:06:01 +0000, ballsystemlord wrote:

> I did not mean that I would write the python bindings in C/C++ though
> perhaps I did not state that clearly.

That’s something that comes with experience of having worked in various
languages.

> I always thought that the intranet was invented after C/C++ becuase it
> would be very hard to write it in asssembler language but for that
> matter it might have been originally writen in basic or something.

It’s only difficult if you don’t know how to use it effectively.

> I half knew that the speed of your program depended on how well you
> wrote it but I did not know how pronounced the effect would be.
> I have main three resons for learning C/C++
> 1: It’s fast.

It can be. It can also be slow - a lot comes down to the design of the
algorithm and how it’s implemented in the code.

> 2: It’s what most programs and librarys apper to be writen in.

Depends on the need.

> 3: It can do almost anything. (Whats the linux kernel writen in? How
> about the graphically intensive games? How about the X windows system?
> How about gimp? and KDE? etc.)

Well, sure.

> These things convice me it would be a good investment of time to learn
> C/C++ despite the fact that I am still a beginner to programming.

Sometimes it’s better to learn to walk before you learn to run. Focus on
structured programming first using a more forgiving language so you’re
not getting tripped up by syntax issues - It’s been my experience that
starting with something that’s forgiving can let you focus on learning
how to structure a program first, then you can move on to more advanced
languages.

> The only thing that convices me that learning it is a bad idea is that
> “everyone” complains about it, but if it were really that bad then why
> do so many programs use it?
> Are there no other fast languages out there?

There are plenty of “fast” languages out there - and all can be used
properly or improperly.

I recently took up Python for a project I’m working on - and I’ve found
it to be a very easy language to learn syntactically and easy to work
with when debugging. I highly recommend it as a starting language.

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

Hello again after a long break from the thread it appears!

I have to admit I find it hard to comprehend these two sentences fully, but maybe it’s a language thing. The internet (which is what I assume you mean by `intranet’ was indeed invented after C, but I do not understand how this would affect your choice of coding language.

The effect can be huge. A poorly written program can easily take ten times as long as an efficiently written version even if they’re written in the same language. Understanding the concepts of loops, memory handling, branch-point prediction, and cache misses are common to many program languages and optimising these things is much more important than just learning syntax.

You don’t need to justify your choice of programming language to anyone else! If you spent the time from your original post to now learning C/C++, you’d already be able to write basic programs. If you discover you’re not to keen, there’s nothing wrong with starting another language.

[For the record X Window has no `s’ :slight_smile: ]. I’m not sure most programs in the modern era are purely written in C/C++. But since it seems you’ve decided, then good luck!

I think it’s slightly unfair to suggest `“everyone” complains it. We are just giving advice. Yes, C++ is one of the fastest and flexible languages out there. But the speed comes at a price - it’s very unforgiving for many reasons:

a) You must take full responsibility for memory handling. If you don’t do this 100% correctly, your program could easy give rise to memory leaks, access violations, and random exceptions.
b) All data types for all variables must be declared before being assigned a value, which means you should know how many bits/bytes each variable type (int, float, etc…) take up. Indirect addressing these variables (very much the `art’ of good C/C++ code) requires declaration of other variables called pointers (or references), which even experienced C/C++ users can find difficult.
c) C/C++ code can often be incredibly difficult to read and debug although it’s still much easier to read than assembler. This isn’t necessarily much of a problem for own code but it can make reading third-party code very tough.
d) Optimisation of C/C++ code is very compiler-dependent, and even very sensitive to the settings you configure the compiler. To understand how changes to your code/compiler affect the execution, you need to look at the resulting assembler instructions.
e) Although C/C++ was devised in attempt to accommodate cross-platform compatibility, it mostly fails. Each compiler has it own suite of compiler-specific macros/flags/commands so you’re often end up writing code that can realistically only be optimised for one platform with a single compiler.

Now don’t let this put you off because it seems you’ve already made up your mind. But if you become frustrated with programming very quickly, do not blame the advice we gave you! :slight_smile:

EDIT: While writing this, Jim posted a more concise response! And everything he says is correct (at least on this occasion! :p).

On 2012-12-04 21:06, ballsystemlord wrote:
> I always thought that the intranet was invented after C/C++ becuase it
> would be very hard to write it in asssembler language but for that
> matter it might have been originally writen in basic or something.

Don’t disregard Basic that fast.

When I started programming for money, I found out that most of the code
of the place I was working for was made in Basic, and that company was
not the exception. Apparently many programs were made by engineers that
knew their stuff (mechanics, electronics, math, fluids, engines…
whatever), and Basic was something that they could play with and get
things done with a computer. So they wrote fantastic software with that
language…

They did not create operating systems, of course. But they paved the way.


Cheers / Saludos,

Carlos E. R.
(from 12.1 x86_64 “Asparagus” at Telcontar)

I was trying to explain my resoning not to justify myself as I know that even a basic understanding will be eventually nessesary.

I think it’s slightly unfair to suggest `“everyone” complains it. We are just giving advice. Yes, C++ is one of the fastest and flexible languages out there. But the speed comes at a price - it’s very unforgiving for many reasons:

a) You must take full responsibility for memory handling. If you don’t do this 100% correctly, your program could easy give rise to memory leaks, access violations, and random exceptions.
b) All data types for all variables must be declared before being assigned a value, which means you should know how many bits/bytes each variable type (int, float, etc…) take up. Indirect addressing these variables (very much the `art’ of good C/C++ code) requires declaration of other variables called pointers (or references), which even experienced C/C++ users can find difficult.
c) C/C++ code can often be incredibly difficult to read and debug although it’s still much easier to read than assembler. This isn’t necessarily much of a problem for own code but it can make reading third-party code very tough.
d) Optimisation of C/C++ code is very compiler-dependent, and even very sensitive to the settings you configure the compiler. To understand how changes to your code/compiler affect the execution, you need to look at the resulting assembler instructions.
e) Although C/C++ was devised in attempt to accommodate cross-platform compatibility, it mostly fails. Each compiler has it own suite of compiler-specific macros/flags/commands so you’re often end up writing code that can realistically only be optimised for one platform with a single compiler.

I did not realize the troubles C/C++ has.

Now don’t let this put you off because it seems you’ve already made up your mind. But if you become frustrated with programming very quickly, do not blame the advice we gave you! :slight_smile:

Yes, I have made up my mind, but I will take your advice and learn some good programming first.
Thanks again.

i believe you have started programming recently

Any language/Development environment which can produce more tangible and visually appealing output would be much more interesting than creating creating pipes in c or something like that.

You can check out cool simple programs here which really require minimal programming skills and you can see a tangible output. I experienced this while programming in VB .

The link provides you tutorials to multiple languages and produce the same output like an image viewer in c ,python etc but it is more of GTK toolkit centric. Interesting nevertheless.