[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gsl] Should I learn C or C++
From: |
John Gehman |
Subject: |
Re: [Help-gsl] Should I learn C or C++ |
Date: |
Sat, 7 Apr 2012 09:10:16 +1000 |
I am compelled to suggest a corollary to this question over C vs C++ ...
I also program all my numerical methods almost exclusively in C ^[1], as I
(also) can't see the point to most of the higher level object oriented
abstractions to do the same thing. By the time I figure out the C++ way of
doing something, I would have already had it done with C.
That said, however, the structure of almost everything I program these days
*is* object oriented -- it is so much easier and more tidy to manage large
tasks by creating objects (classes), each with their own characteristics and
methods, than to create more or less linear code. The main difference, for me,
is that all methods (subroutines) for an object have access to everything about
that object, so that one isn't constantly passing umpteen difference variables
in and out of each subroutine.
I've always been a bit of a hack, no formal training, so everything has been
trial and error for me, and always with some pressing need, so there's never
been any time to stop and really figure out how to do something properly. At an
intermediate stage in my programming experience, I was creating formal
structures (struct) to house my variables. These are like objects, but without
the methods (subroutines). So while it was ostensibly more tidy to pass a
(void) pointer to a structure into a subroutine that I designed to operate on
that struct, I still had to re-interpret all the struct's components for use in
the subroutine, which took lots of lines of messy syntax.
Suffice it to say that I believe it *is* valuable to learn the logic of C++,
insofar as the logic of classes will help the code that *you* write, but I
whole-heartedly concur with all other respondents that traditional C syntax is
the better thing to learn, especially for use with gsl.
footnote:
1. file handling {ifstream ifile; ifile.open(filename,ios::in); } and
ifile.getline into a "string" buffer I think would be the exceptions, although
I sscan(buf.c_str(),"... ) to read that line.
Good Luck!
john
==== === == = = = = = = = = = =
John Gehman
ARC Future Fellow
School of Chemistry
Univ. of Melbourne
VIC 3010 Australia
"Science really suffers from bureaucracy. If we hadn't broken
every single WHO rule many times over, we would never
have defeated smallpox. Never."
-- Isao Arita, final director of the WHO smallpox eradication program
==== === == = = = = = = = = = =
On 07/04/2012, at 5:55 AM, Alexander Gallego wrote:
> OK, thanks to all!!!
> I'm going to learn C first, then I would jump to C++ if needed.
> Thanks, again.
>
> Il giorno 05 aprile 2012 18:58, Alexander Gallego <address@hidden> ha
> scritto:
>
>> Hi,
>> I need to implement the GSL but I'm not sure if I should better learn C or
>> C++ in order to make a correct and fast use of the library.
>> Which language do you recommend?
>>
>> Thanks too much.
>>
>> --
>> Alexander Gallego C.
>> Instituto de Física, Facultad de Ciencias Exactas Y Naturales.
>> Universidad de Antioquia.
>>
>>
>
>
> --
> Alexander Gallego C.
> Instituto de Física, Facultad de Ciencias Exactas Y Naturales.
> Universidad de Antioquia.
==== === == = = = = = = = = = =
John Gehman Office +61 3 8344 2417
ARC Future Fellow Fax +61 3 9347 8189
School of Chemistry Magnets +61 3 8344 2470
Bio21 Institute Mobile +61 407 536 585
30 Flemington Rd address@hidden
Univ. of Melbourne
VIC 3010 Australia
http://www.chemistry.unimelb.edu.au/staff/jgehman/research/
failsafe in smtp roulette: address@hidden
"Crooked nails hold better" (JDG, unpublished data)
==== === == = = = = = = = = = =
- Re: [Help-gsl] Should I learn C or C++, (continued)
Re: [Help-gsl] Should I learn C or C++, Francesco Abbate, 2012/04/06
Re: [Help-gsl] Should I learn C or C++, Sumit Adhikari, 2012/04/06
Re: [Help-gsl] Should I learn C or C++, Alexander Gallego, 2012/04/06