Learning C as an existing programmer

Discussion in 'C Programming' started by rammy, Jun 24, 2012.

  1. rammy

    rammy Guest

    Hi

    I need to learn C for numerical analysis as part of my Masters research.

    I already have quite a lot of experience with BASIC (my progression was GW
    BASIC -> QBASIC -> Visual BASIC -> VB.net) so I want to find an
    introductory book on "C for BASIC programmers".

    I looked through the campus bookstore and didn't really find anything.
    Can you recommend some learning materials that will leverage my existing
    programming knowledge?

    Thanks in advance!
     
    rammy, Jun 24, 2012
    #1
    1. Advertising

  2. rammy

    Ian Collins Guest

    On 06/25/12 09:52 AM, rammy wrote:
    > Hi
    >
    > I need to learn C for numerical analysis as part of my Masters research.
    >
    > I already have quite a lot of experience with BASIC (my progression was GW
    > BASIC -> QBASIC -> Visual BASIC -> VB.net) so I want to find an
    > introductory book on "C for BASIC programmers".
    >
    > I looked through the campus bookstore and didn't really find anything.
    > Can you recommend some learning materials that will leverage my existing
    > programming knowledge?


    "The C Programming Language". C is sufficiently different to justify
    reading through the whole book.

    --
    Ian Collins
     
    Ian Collins, Jun 24, 2012
    #2
    1. Advertising

  3. "Ian Collins" <> wrote in message
    news:...
    > On 06/25/12 09:52 AM, rammy wrote:
    >> Hi
    >>
    >> I need to learn C for numerical analysis as part of my Masters research.
    >>
    >> I already have quite a lot of experience with BASIC (my progression was
    >> GW
    >> BASIC -> QBASIC -> Visual BASIC -> VB.net) so I want to find an
    >> introductory book on "C for BASIC programmers".
    >>
    >> I looked through the campus bookstore and didn't really find anything.
    >> Can you recommend some learning materials that will leverage my existing
    >> programming knowledge?

    >
    > "The C Programming Language". C is sufficiently different to justify
    > reading through the whole book.
    >


    To understand C well... you have to understand the way C uses pointers.
    Pointers are very basically machine memory addresses, and C uses them in
    special ways. IMHO.


    --

    numerist at aquaporin4 dot com
     
    Charles Richmond, Jun 25, 2012
    #3
  4. rammy <> writes:

    > I need to learn C for numerical analysis as part of my Masters research.
    >
    > I already have quite a lot of experience with BASIC (my progression was GW
    > BASIC -> QBASIC -> Visual BASIC -> VB.net) so I want to find an
    > introductory book on "C for BASIC programmers".
    >
    > I looked through the campus bookstore and didn't really find anything.
    > Can you recommend some learning materials that will leverage my existing
    > programming knowledge?


    If your application makes extensive use of arrays or of complex numbers,
    you might want to find out if you have access to an implementation of
    the 1999 standard of C. Many of the books about C concentrate on 1990 C
    (often called, rather confusingly, "ANSI C") but C99 added complex
    numbers and some array facilities that might be helpful for numerical
    programs.

    --
    Ben.
     
    Ben Bacarisse, Jun 25, 2012
    #4
  5. rammy

    Stefan Ram Guest

    "Charles Richmond" <> writes:
    >To understand C well... you have to understand the way C uses pointers.
    >Pointers are very basically machine memory addresses, and C uses them in
    >special ways.


    An object o of type T is a region of memory that is just
    large enough to store a single value of T.

    The address »a« of such an object is written as »&o«
    using the unary prefix operator »&« (»address of«).
    We say that »&o« »referred« to the object or location o.

    The type of »a« is written as »T*«. This is a pointer type.
    An object of pointer type can store a value of such a
    pointer type.

    Given »a«, to get the value of the object »o«, we use »*a«,
    with the unary prefix operator »*«. One says that this
    »dereferred« »a«.

    *&o = o

    »&o+1« is the address just behind this object »o«, that
    can be obtained by skipping the size of the object »o«
    once. »&o+i« are i such skips.

    For an int value »i«, »a« means »*(a+i)«.

    *a = a[0]
    a+i = &a

    »T*p;« declares »p to be a pointer to an object of type »T«.

    »p=0« makes »p not to point to anything, directly after this
    »p« is a »null pointer«. A null pointer cannot be used for
    anything else than to mark the absence of a pointer that
    refers an object.

    Pointers can be compared with »==« and »!=« (even the null
    pointer) and be compared with »>« and so on when reasonable.

    if(p)statement

    for a pointer p is equivalent to

    if(p!=0)statement

    , the corresponding assertion holds for the ?:-operator and
    iteration statements.

    »T*const p;« declares a constant pointer (it cannot be
    changed after initialisation).

    »T const*p;« declares a read-only pointer (it cannot be used
    to write to the object whose address it referss).

    »T const*const p;« a constant read-only pointer.

    A pointer to void has the type »void*«, it cannot be used
    with the above pointer operators »*« and »+«, but can be
    used where an object of pointer type »T*« is expected
    and can also represent a value of any other pointer type.

    Explicit pointer type conversions can be done using the
    cast operator, but are not recommended for beginners.

    There is no portable string representation of pointer
    values, but an implementation might print an
    implementation-specific representation of a pointer value
    when the format specifier »%p« is used with a pointer to
    void.

    One can only use and derefer pointer values when reasonable,
    they need to refer to certain reasonable locations, such as
    declared or allocated objects or certain special places
    (just behind an array), and one can only derefer pointers
    referring a declared or allocated object.

    For two pointers »p« and »q«, when reasonable, the
    difference »p-q« is defined and has type »ptrdiff_t« of the
    »<stddef.h>« header, so that for an array »a« the difference
    »&a[j]-&a« has the value »j-i« of this type.

    »+« and »-« with pointers are called »address arithmetics«.

    The value of a string literal is a pointer referring its
    first char, and has type »char const*«.

    A pointer to a function represents that function as a
    pointer. it cannot be dereferred or used with address
    arithmetics or combined with object pointers. When »f«
    names a function, »&f« is a pointer to that function and
    can be used instead of »f« in calls.
     
    Stefan Ram, Jun 25, 2012
    #5
  6. rammy

    Joe. Guest

    "rammy" <> wrote in message
    news:js8275$cpo$...
    > Hi
    >
    > I need to learn C for numerical analysis as part of my Masters research.


    Fucking liar.

    >
    > I already have quite a lot of experience with BASIC


    OK, then NO experience. Noted. One must ask, WTF are they teaching in
    "universities"? (been there, done that, don't like 'em).

    > (my progression was GW
    > BASIC -> QBASIC -> Visual BASIC -> VB.net) so I want to find an
    > introductory book on "C for BASIC programmers".


    You should forget about programming and get into some labor job or politics
    at minimum wage. Thinking is not your forte.

    >
    > I looked through the campus bookstore


    And she rejected you cuz she saw you as the dud you are?

    > and didn't really find anything.


    Disallusionment.

    > Can you recommend some learning materials that will leverage my existing
    > programming knowledge?


    You don't have any programming knowledge.

    >
    > Thanks in advance!


    **** you beforehand.
     
    Joe., Jun 25, 2012
    #6
  7. rammy

    Joe. Guest

    "Ian Collins" <> wrote in message
    news:...
    > On 06/25/12 09:52 AM, rammy wrote:
    >> Hi
    >>
    >> I need to learn C for numerical analysis as part of my Masters research.
    >>
    >> I already have quite a lot of experience with BASIC (my progression was
    >> GW
    >> BASIC -> QBASIC -> Visual BASIC -> VB.net) so I want to find an
    >> introductory book on "C for BASIC programmers".
    >>
    >> I looked through the campus bookstore and didn't really find anything.
    >> Can you recommend some learning materials that will leverage my existing
    >> programming knowledge?

    >
    > "The C Programming Language". C is sufficiently different to justify
    > reading through the whole book.
    >


    You are so aberrated! (I don't spell check).
     
    Joe., Jun 25, 2012
    #7
  8. rammy

    Joe. Guest

    "Charles Richmond" <> wrote in message
    news:js87rt$nd9$...
    > "Ian Collins" <> wrote in message
    > news:...
    >> On 06/25/12 09:52 AM, rammy wrote:
    >>> Hi
    >>>
    >>> I need to learn C for numerical analysis as part of my Masters research.
    >>>
    >>> I already have quite a lot of experience with BASIC (my progression was
    >>> GW
    >>> BASIC -> QBASIC -> Visual BASIC -> VB.net) so I want to find an
    >>> introductory book on "C for BASIC programmers".
    >>>
    >>> I looked through the campus bookstore and didn't really find anything.
    >>> Can you recommend some learning materials that will leverage my existing
    >>> programming knowledge?

    >>
    >> "The C Programming Language". C is sufficiently different to justify
    >> reading through the whole book.
    >>

    >
    > To understand C well... you have to understand the way C uses pointers.
    > Pointers are very basically machine memory addresses, and C uses them in
    > special ways. IMHO.
    >


    Your "humble" opinion is no longer relevant. C and snake oil are related
    how? If you can't answer that question, then you are a <something>. It's one
    thing to be a "bullshitter", quite another to be a victim of bullshitters.
    Or in the "worst" case, bullshit politics. Ha! Are not politics and bullshit
    the same thing?

    :( BS is casual. Politics hurt, maim and kill people.

    Don't everyone think you make me think. Apparently that is Warren Buffet's
    job? Apparently he is so fucking "rich" he can't even give away what he did
    legally. Hmm? What does an old man with a lot of money have to say?
    Rhetorical, cuz we know what he said.

    Peace be with you, "rich" man.
     
    Joe., Jun 25, 2012
    #8
  9. rammy

    Joe. Guest

    "Stefan Ram" <-berlin.de> wrote in message
    news:p-berlin.de...
    > "Charles Richmond" <> writes:
    >>To understand C well... you have to understand the way C uses pointers.
    >>Pointers are very basically machine memory addresses, and C uses them in
    >>special ways.

    >
    > An object o of type T is a region of memory that is just
    > large enough to store a single value of T.
    >


    How does it feel to be a textbook instead of a person?
     
    Joe., Jun 25, 2012
    #9
  10. בת×ריך ×™×•× ×¨×שון, 24 ביוני 2012 22:52:37 UTC+1, מ×ת rammy:
    > Hi
    >
    > I need to learn C for numerical analysis as part of my Masters research.
    >
    > I already have quite a lot of experience with BASIC (my progression was GW
    > BASIC -> QBASIC -> Visual BASIC -> VB.net) so I want to find an
    > introductory book on "C for BASIC programmers".
    >

    Everything works in C more or less as you would expect, with a few exceptions.

    Types are strict. So a variable must be either a double-precison float, or a single precision float, or an integer, and so on. There's not much intelligent mixing of types.

    You declare structures to create compound types,a nd this is used heavily.

    Strings are just arrays of chars.

    Virtually everything is a function. C itself just does logic. There's no real difference between a built-in fucntiona nd one you write yourself. So there's no print statement, instead you call a function.


    Pointers are the heart of C, and the thing that C does rather differently to other languages. Pointers are essentially raw memory addresses, Peek and Poke in old-fashioned Basic. Basically a C program consists of passing about pointers, and reading and writing to them, doing calculations and moving data about in memory.

    malloc() is very heavily used. Usually you won't know the length of an array at compile time. So you malloc() a block of memory to use for the array. Also you often use malloc() to create structures like trees and linked lists.
     
    Malcolm McLean, Jun 25, 2012
    #10
  11. rammy

    Weland Guest

    On 2012-06-25, Joe. <> wrote:
    > How does it feel to be a textbook instead of a person?


    You owe me a new keyboard, I just spilled coffee all over mine when I burst
    into laughter.

    --

    SDF Public Access UNIX System - http://sdf.org
    % grep me no patterns and I'll tell you no lines
     
    Weland, Jun 25, 2012
    #11
  12. rammy

    Rui Maciel Guest

    David Brown wrote:

    > Do you have to use C? There are other languages that might be a better
    > choice - Python with SciPy / NumPy comes to mind - then you can
    > concentrate more on the numerical analysis, and less on the details of
    > programming.


    For numerical analysis, if it's not possible to use Fortran then the next
    best option is plain old C.

    And numerical analysis boils down to details of programming, as the main
    purpose is to squeese as much computational juice out of a computer as
    possible. You don't get that by simply toying with algorithms. Hence,
    Fortran and C being the standards for real world number crunching
    applications.

    Even if a user wants to toy around with numerical analyis stuff without
    having to look too much under the hood, Python is still not an adequate
    option; there is Matlab/Octave for that.


    Rui Maciel
     
    Rui Maciel, Jun 25, 2012
    #12
  13. "Rui Maciel" schrieb im Newsbeitrag news:js9dn4$62l$...

    David Brown wrote:

    > Do you have to use C? There are other languages that might be a better
    > choice - Python with SciPy / NumPy comes to mind - then you can
    > concentrate more on the numerical analysis, and less on the details of
    > programming.


    >For numerical analysis, if it's not possible to use Fortran then the next
    >best option is plain old C.


    I would not recommend the old version of C, but the C99 Standard instead.
    Complex Numbers are important for quantum Physics applications.
    Also to mention is the complex eletric current.

    >And numerical analysis boils down to details of programming, as the main
    >purpose is to squeese as much computational juice out of a computer as
    >possible. You don't get that by simply toying with algorithms. Hence,
    >Fortran and C being the standards for real world number crunching
    >applications.


    Numerical Analysis is not the Analysis of Algorithms.

    Next, what difference between Fortran 2008 and C?
    New Fortran standards introduce features as operator overloading and
    object oriented Programming. C99 does not do that: C++ does the job.
     
    Ronald Benedik, Jun 25, 2012
    #13
  14. rammy

    Jorgen Grahn Guest

    On Mon, 2012-06-25, Rui Maciel wrote:
    > David Brown wrote:
    >
    >> Do you have to use C? There are other languages that might be a better
    >> choice - Python with SciPy / NumPy comes to mind - then you can
    >> concentrate more on the numerical analysis, and less on the details of
    >> programming.

    >
    > For numerical analysis, if it's not possible to use Fortran then the next
    > best option is plain old C.


    Over at comp.lang.c++ they say it's C++.

    /Jorgen

    --
    // Jorgen Grahn <grahn@ Oo o. . .
    \X/ snipabacken.se> O o .
     
    Jorgen Grahn, Jun 25, 2012
    #14
  15. rammy

    Rui Maciel Guest

    Ronald Benedik wrote:

    > "Rui Maciel" schrieb im Newsbeitrag
    > news:js9dn4$62l$...
    >
    > David Brown wrote:
    >
    >> Do you have to use C? There are other languages that might be a better
    >> choice - Python with SciPy / NumPy comes to mind - then you can
    >> concentrate more on the numerical analysis, and less on the details of
    >> programming.

    >
    >>For numerical analysis, if it's not possible to use Fortran then the next
    >>best option is plain old C.

    >
    > I would not recommend the old version of C, but the C99 Standard instead.
    > Complex Numbers are important for quantum Physics applications.
    > Also to mention is the complex eletric current.


    The "plain old" bit was only an idiomatic expression (like "good old X", in
    contrast with brand spanking new Python). It wasn't a reference to K&R or
    any specific standard. But you are right, C99 does offer some nice
    features, particularly if complex numbers are required.


    >>And numerical analysis boils down to details of programming, as the main
    >>purpose is to squeese as much computational juice out of a computer as
    >>possible. You don't get that by simply toying with algorithms. Hence,
    >>Fortran and C being the standards for real world number crunching
    >>applications.

    >
    > Numerical Analysis is not the Analysis of Algorithms.


    Who said it was?


    > Next, what difference between Fortran 2008 and C?
    > New Fortran standards introduce features as operator overloading and
    > object oriented Programming. C99 does not do that: C++ does the job.


    Why is that relevant? There is quite a lot of fundamental libraries which
    are used in this very day that are written with Fortran 77, and don't even
    have a Fortran90 version available.


    Rui Maciel
     
    Rui Maciel, Jun 25, 2012
    #15
  16. Malcolm McLean <> writes:
    <snip>
    > Pointers are the heart of C, and the thing that C does rather
    > differently to other languages. Pointers are essentially raw memory
    > addresses, Peek and Poke in old-fashioned Basic.


    That's not a helpful thing to say to someone new to C. You don't have
    to go into details but C's pointers, crucially, have a type. The type
    is used to give a more useful meaning to the operations done on them,
    just like the type a variables are used to determine the meaning of
    operations like / (integer or floating division). C pointer operations
    will be baffling if they are seen as raw addresses.

    <snip>
    > malloc() is very heavily used. Usually you won't know the length of an
    > array at compile time. So you malloc() a block of memory to use for
    > the array.


    Unless you can use "modern" C with its flexible arrays. They don't
    behave exactly like malloced storage does, but they are often more
    appropriate for numerical programs.

    <snip>
    --
    Ben.
     
    Ben Bacarisse, Jun 25, 2012
    #16
  17. "Rui Maciel" schrieb im Newsbeitrag news:js9fbp$abr$...

    >> Next, what difference between Fortran 2008 and C?
    >> New Fortran standards introduce features as operator overloading and
    >> object oriented Programming. C99 does not do that: C++ does the job.


    >Why is that relevant? There is quite a lot of fundamental libraries which
    >are used in this very day that are written with Fortran 77, and don't even
    >have a Fortran90 version available.


    I wanted to give the Basic programmer an idea about Fortran and C
    differences.
     
    Ronald Benedik, Jun 25, 2012
    #17
  18. On 2012-06-25, Rui Maciel <> wrote:
    > Even if a user wants to toy around with numerical analyis stuff without
    > having to look too much under the hood, Python is still not an adequate
    > option; there is Matlab/Octave for that.


    Python with NumPy/SciPy can be a perfectly adequate option, when
    compared to Octave, especially for people with no Matlab background.

    Octave might provide a larger amount of functions (especially if
    counting the octave-forge package collection), but the NumPy/SciPy API
    is by no means barren. (Even if it is a bit messy.)

    As far as performance goes, they use largely the same libraries (ATLAS,
    LAPACK, ARPACK, FFTW, ...) for heavy lifting, and for the odd loop (that
    can't be easily turned into a matrix operation) here and there Octave
    can be really very slow. In some random benchmarks NumPy performance
    has been somewhere in-between Matlab and Octave for matrix-handling
    code, and orders of magnitude better than Octave for "regular" code that
    you might also want to have in the same program. (YMMV, as always; the
    benchmarks I found weren't especially comprehensive.)


    --
    Heikki Kallasjoki
     
    Heikki Kallasjoki, Jun 25, 2012
    #18
  19. rammy

    gwowen Guest

    On Jun 25, 11:50 am, Ben Bacarisse <> wrote:

    > > malloc() is very heavily used. Usually you won't know the length of an
    > > array at compile time. So you malloc() a block of memory to use for
    > > the array.

    >
    > Unless you can use "modern" C with its flexible arrays.  They don't
    > behave exactly like malloced storage does, but they are often more
    > appropriate for numerical programs.


    Really? Only if they're (i) of bounded size or (ii) of trivially small
    size. Otherwise you're just asking for horrible, undetectable stack
    overflow bugs, because VLAs have no failure mechanism.
     
    gwowen, Jun 25, 2012
    #19
  20. rammy

    Rui Maciel Guest

    David Brown wrote:

    > I take it you have no experience with Python or SciPy, but are merely
    > prejudice against Python because it is interpreted?


    What?


    > Of course you can
    > get greater speed with C than with straight Python.


    Exactly. The rest is just noise.


    Rui Maciel
     
    Rui Maciel, Jun 25, 2012
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nrm
    Replies:
    3
    Views:
    577
  2. Hal Vaughan
    Replies:
    7
    Views:
    521
  3. myheartinamerica

    learning from an existing project's code

    myheartinamerica, Mar 24, 2008, in forum: C Programming
    Replies:
    4
    Views:
    313
    Bill Reid
    Mar 27, 2008
  4. Replies:
    0
    Views:
    216
  5. Andrey Popp

    [I'm learning C]: Learning to use ucontext

    Andrey Popp, Jan 29, 2012, in forum: C Programming
    Replies:
    5
    Views:
    805
    Keith Thompson
    Jan 31, 2012
Loading...

Share This Page