[SlugLUG] Question on C

Peter Belew abcruzww at gmail.com
Tue Oct 10 10:39:21 PDT 2006


Sounds like the I/O should be done in C.
Beware of memory management problems in the handling of arrays
passed from C to Perl, and buffer overrun problems.

Peter

On 10/10/06, Erich Blume <eblume at ucsc.edu> wrote:
> Thank you for a lot of really great replies. I'll definitely consider
> learning C++ as I really /do/ need to learn an OO language besides java
> (it's the new BASIC - give me a break), but for now I'm going to tackle this
> in C.
>
> But to Suraj's comment that optimization should be language independent, I'd
> generally agree, but the application I want to optimize has only one
> bottleneck, and that's input/output. I need a high-speed
> single-character-at-a-time input device, and I have it from the #perl people
> on freenode that PerlIO isn't capable of delivering that speed.
>
> I believe I wrote about this on this list before, but I wrote a perl script
> that searches the human genome for the number of times an N-length query (or
> list of queries) is found.
>
> It's not *for* anything, but it's thoroughly in the spirit of UCSC
> bioinformatics.
>
> Thanks again,
> Erich
>
> On 10/10/06 9:43 AM, "Suraj N. Kurapati" <skurapat at ucsc.edu> wrote:
>
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > Erich Blume wrote:
> >> Problem is, while doing that, I completely forgot how to write C.
> >> I've re-trained myself up to the basics, but what I really want
> >> to do now is write a hash table implementation in C. I can't for
> >> the life of me figure out how to get started, though. I've
> >> written a few half-hearted structs, slapped down some frivolous
> >> typedefs, and even put in a few useless prototypes.
> >>
> >> So my question is: where can I get started for this particular
> >> project? Who knows of a good resource for easy to understand
> >> implementations of hash tables in C? If it's a book, that's fine,
> >> but it'd be better if you could point me to a web page or
> >> something.
> >
> > http://www.sparknotes.com/cs/searching/hashtables/section1.html
> >
> >> Also, something that's been bugging me is whether or not I should
> >> learn C++. Ever since I learned perl, I've been reluctant to
> >> learn C++, being as more or less the only time I ever plan on
> >> writing compiled code now will be to optimize. I'd rather
> >> optimize in C than C++.
> >
> > It doesn't matter what language is used when optimizing, because
> > optimization should involve choosing the correct data structures and
> > algorithms to solve the problem at hand. This will yield far greater
> > improvement than if you had randomly tweaked the code with pointer
> > tricks, etc.
> >
> > Also, to paraphrase Amdahl's law, "something is only worth
> > optimizing if it is used frequently." That is, don't waste your time
> > optimizing a bunch of slow code if that slow code is only used, say,
> > 2% of the time.
> >
> > This leads to the conclusion that in order to optimize, you have to
> > know what to optimize. And knowing what to optimize comes from
> > profiling!
> >
> >> But I've been doing a lot of reading and it sounds like maybe
> >> that wasn't such a good appraisal. From the context of a
> >> computational biologist, what's the safer bet?
> >
> > Here's what you do:
> >
> > 0. Compile with a high optimization level: gcc -O3
> >
> > 1. Profile your code and find the bottlenecks.
> >
> > 2. Improve your choice of data structures and algorithms used in
> > those bottlenecks.
> >
> > 3. If that doesn't help, try re-writing the really slow parts in a
> > lower-level language.
> >
> > 4. If even that doesn't work, go ahead and be tricksy with pointers
> > and loops. Perhaps if the planets have favorable alignment tonight,
> > those tricks might help you. ;-)
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v1.4.2.2 (GNU/Linux)
> >
> > iD8DBQFFK83PmV9O7RYnKMcRAhuFAJ9qN+2bRLlwjnNq52DpXd/FxuY8lACePpHW
> > h3+UJg0/lZhIsPIHUUaLgWk=
> > =36Ru
> > -----END PGP SIGNATURE-----
> > _______________________________________________
> > Sluglug mailing list
> > Sluglug at sluglug.ucsc.edu
> > http://sluglug.ucsc.edu/cgi-bin/mailman/listinfo/sluglug
>
>
> _______________________________________________
> Sluglug mailing list
> Sluglug at sluglug.ucsc.edu
> http://sluglug.ucsc.edu/cgi-bin/mailman/listinfo/sluglug
>


More information about the Sluglug mailing list