Question: Picking A Programming Language And Where To Begin
11
gravatar for Travis
7.2 years ago by
Travis2.8k
USA
Travis2.8k wrote:

Hi,

I traditionally use Perl but as I am exposed to more and more NGS type work it seems that it may be time to learn a 'programming language'.

Does C++ seem like a good option?

If so can anyone recommend a good starting point? I've done Perl for the past 8 years and had a little experience in Java prior to that so the starting point should be tuned to that...

ADD COMMENTlink modified 6.7 years ago by Palani Kannan40 • written 7.2 years ago by Travis2.8k
29
gravatar for brentp
7.2 years ago by
brentp22k
Salt Lake City, UT
brentp22k wrote:

As an alternative to the mostly logical viewpoints already posted, I'll add this whimsical one:

Use whatever language makes you happy.

You'll likely spend a lot of time writing, re-writing, reading and WTF'ing through your code, so if Java via NetBeans or Eclipse does it for you, then go that way. If C via Vim makes you giggle, then that might be a good choice.

In my experience, most "slow" languages will offer you a way to improve speed using libraries or language constructs.

Since you already have perl as a scripting language, it's often good to follow the libraries. For example, R has very good libraries for microarray's, if you do a lot of that, doing R+bioconductor will save you from reinventing a complicated wheel.

In the long-run, it can't hurt to learn more languages.

ADD COMMENTlink written 7.2 years ago by brentp22k
4

can I vote twice ?

ADD REPLYlink written 7.2 years ago by Pierre Lindenbaum112k
2

You mean computing is meant to be fun?!? x_o --> +1

ADD REPLYlink written 7.2 years ago by Eric Normandeau9.9k
1

Inspiring! From now on, I'm writing all my programs in なでしこ! ;)

ADD REPLYlink written 7.2 years ago by Michael.James.Clark550

.............+1

ADD REPLYlink written 7.2 years ago by Yogesh Pandit490

Claiming that programming should be related to programmer's happiness is a TOTAL lack of respect to a lot of people dedicated to computer programming pedagogy. And YES it hurts to learn programming languages, because 1) you need TIME, and 2) you must un-learn all the bad habits of crappy programming languages. It is really SAD how experts bioinformaticians support this naive opinion of it's ok to learn everything or anything. For the love of all gods, take seriously what you put in your head, learn how and why some programming languages were invented.

ADD REPLYlink written 6.7 years ago by michaelfaraday10

@michaelfaraday, I can't tell if you're agreeing or disagreeing (likely the latter). Can you elaborate on what you think is SAD? in the context of what you're replying to above?

ADD REPLYlink written 6.7 years ago by brentp22k

@michaelfaraday What languages do you use that are so perfect and serious?

Why would people DO programming if it didn't make them happy? What is so wrong with enjoying what you're doing?

"it's ok to learn everything or anything" Sounds like a good life to me.

ADD REPLYlink written 6.7 years ago by Madelaine Gogol5.0k
19
gravatar for lh3
7.2 years ago by
lh331k
United States
lh331k wrote:

If you want to go into the area of algorithm development, learning a compiled language is necessary; otherwise, you can stick to Perl. When you come to compiled languages, C/C++ and Java are the only viable options for beginners.

Personally, my worry about Java was: what if some day I had to write an extremely fast program requiring huge memory? When that day came, I would have to fall back to C/C++ because Java is still slower, even though not much, and is a famous memory hog. Thus several years ago, I recommended C/C++ to all my friends. Nowadays, I realize that >95% of people do not ever want to write something extremely fast or that take huge memory. Furthermore, although when we are proficient in C/C++, the development time in C/C++ and Java do not differ much, it takes much longer to be a reasonably good C/C++ programmer than a Java programmer. Many people stop before they get there. Now I think 95% of people who want to learn a compiled language should go for Java. C/C++ is only preferable for those <5% of people who care about extreme efficiency.

Below are some of my other views towards programming languages, which may help or may not.

  1. C/C++ vs. D/Go. C/C++ is still the best choice if you really want something efficient. However, the most nasty "feature" of all is the unsafe memory access. Even experienced programmers with an appropriate tool may spend a long time on pinpointing a tiny out-of-boundary bug. Memory leak is also frequently annoying, though easier to solve. D and Go largely resolve this major issue in C/C++. They are much richer in features and easier to work with. They have learned the advantages of most modern programming languages. However, because they are relatively new, there are essentially no 3rd-party libraries in Bioinformatics. You have to do everything from scratch. If you are choosing the first compiled language, D and Go are not an option. They are more suitable for experienced programmers who want to explore something exciting.

  2. C vs. C++. I prefer C over C++. The latter I think is unnecessarily complicated. Nonetheless, I do agree that C++ helps to organize a large project. C++ has a more friendly library interfaces and this is why you tend to have more well-formed libraries in C++ than in C. Also, even if you choose C, you should learn the basic of C++. This is necessary when you want to understand C++ programs written by others and may help you to design your own projects.

  3. Java vs. C++. If we look at the language implementation itself, Java is about ~1.8X as slow as C/C++, which is consistent in a couple of benchmarks. Being twice as slow is not a big issue for most of tasks. In addition, several benchmarks have pointed out that it is easier to write inefficient programs in C++ than in Java because C++ has more pitfalls related to the use of libraries -- if you learn C++ and Java each for one month, your Java programs may look more professional and be actually faster. However, the major problem with Java is its memory management. Java is a memory hog especially when you are not very good at it yet. When your program requires a lot of memory, Java will make it much worse. That is why almost no NGS read mappers are written in Java.

  4. C/C++/Java vs. Python/Perl. For text processing, python and perl are not far from those compiled languages in speed. Another post in this forum (I could not find the link) shows that when you do not use C++ properly, your long C++ program can be times slower than a much simpler Python/Perl script. Furthermore, Python has a JIT compiler Pypy, which may make your python script 10-100X faster for computation intensive tasks (e.g. Smith-Waterman alignment and numerical things).

EDIT: just saw brentp's answer. He does have a good point which I second. Picking up a programming language is sort of like a marriage: you choose the language and the language chooses you, too. If you do not fit a programming language or vice versa, go for something else and do not push yourself too hard.

ADD COMMENTlink modified 7.2 years ago • written 7.2 years ago by lh331k
4

Have a primary language and keep the rest as mistresses (or paramours) :)

ADD REPLYlink written 7.2 years ago by Farhat2.8k
2

I like the marriage metaphor ... but just one problem, I am in love with quite a few languages :)

ADD REPLYlink written 7.2 years ago by Haibao Tang3.0k
10
gravatar for Istvan Albert
7.2 years ago by
Istvan Albert ♦♦ 77k
University Park, USA
Istvan Albert ♦♦ 77k wrote:

I found that there are no slow languages only ineffectively written programs. I don't think C++ is more of a programming language than Perl and for the majority of cases you will get the job done faster with Perl than C++ (total time = development + runtime)

I would advise to do the exact opposite, learn concepts at a higher level, become familiar with libraries, packages, samtools, bedtools, various bridges to R, learn how to interface and integrate these into Perl. I would steer away from trying to implementing in a lower level language.

ADD COMMENTlink written 7.2 years ago by Istvan Albert ♦♦ 77k
1

Every answer is different and every answer makes sense :) I guess R would make sense too since I don't know a statistical language.

ADD REPLYlink written 7.2 years ago by Travis2.8k

If you go with R, check out the Rcpp and inline packages, they are "easy" bridges to mix R with c/c++ code which can prove to be very powerful.

ADD REPLYlink written 7.2 years ago by Steve Lianoglou4.9k
9
gravatar for Farhat
7.2 years ago by
Farhat2.8k
Pune, India
Farhat2.8k wrote:

What kind of work are you doing with NGS? C++ is a good option, as is C, but I would suggest Python if speed is not an absolute concern. Python is syntactically cleaner to work with compared to Perl and some of the object-oriented concepts from Java will translate to Python (though not all).

ADD COMMENTlink written 7.2 years ago by Farhat2.8k
4

I'd agree. The speed-up you might get from C++ comes at the cost of having to learn, write, and maintain C++ code. Also, C++ is zero fun when it comes to tasks like text manipulation (something you will no doubt be doing constantly with NGS data). If you really need a compiled language, go with Java. The included data structures, string processing tools, and memory management will make development go much faster. The idea that Java is too slow is an old myth that just won't die. Picard, GATK, snpEff, IGVTools - all NGS tools in Java. Download Eclipse, google 'learning java', and get going.

ADD REPLYlink written 7.2 years ago by Jim Vallandingham340
2

The GATK which is widely used pipeline for SNP detection is written in Java/Scala. http://www.broadinstitute.org/gsa/wiki/index.php/The_Genome_Analysis_Toolkit

ADD REPLYlink written 7.2 years ago by Ido Tamir4.9k

Currently working on SNP/Indel and RNA-Seq type work. Using existing tools only but I would like to give myself the option of editing existing programs or creating my own. I would like to try something which is a complete departure from Perl. Python seems similar in some ways. Any good starting points for C/C++?

ADD REPLYlink written 7.2 years ago by Travis2.8k
7
gravatar for Rm
7.2 years ago by
Rm7.8k
Danville, PA
Rm7.8k wrote:

Apart from C++ as suggested by above all, I would suggest to have "awk" skills for easy handling/analysis of NGS data.

ADD COMMENTlink written 7.2 years ago by Rm7.8k
6
gravatar for Gmoney
6.7 years ago by
Gmoney200
Gmoney200 wrote:

As mentioned above, use the language that you feel most comfortable with.

That being said, I have become a generalist as time goes on.

I use R to make nice graphs, python for automation/text sifting, php for webifying my scripts so other scientists can use them. By using many tools, you can lean on individual language strengths, and not use them in places that they seem weak.

R's I/O speed can be dreadful, so beforehand I would use python to reformat/clean data, then feed it to R for pretty picturing. I have called C/C++ programs from python to benefit from their speed if some serious computation needs to be done.

In bioinformatics, the results are what matter, not the language used. To me, a stack of programs each with a strength is also good for maintainability. You can make sure the formats farther up the pipeline stay the same, so that you can replace parts as they get better.

A one size fits all is definitely no good for a field moving so fast.

Disclaimer: I'm a C guy who used to use Perl, and now uses Python.

ADD COMMENTlink written 6.7 years ago by Gmoney200

Completely agree. Learn programming logic, not syntax. If you understand the logic, syntax is pretty easy to pick up.

ADD REPLYlink written 6.7 years ago by Damian Kao15k
5
gravatar for Samuel Lampa
7.2 years ago by
Samuel Lampa1.2k
Stockholm
Samuel Lampa1.2k wrote:

Very recently having been in a similar situation as you, I've decided to:

  1. Use Java for the time being
  2. At the same time keeping an eye on the progress of the D programming language.

Why?

I'm going with Java, since as somebody pointed out, there's really a lot of tools already available in Java, Java has over the years come to have very good speed (I've heard things like 90% of the speed of C/C++ code), and you get going much faster since you have garbage collection and a much cleaner language than C/C++. (Also Eclipse is a great platform, on which you can build interesting, very modular stuff, such as Bioclipse)

I keep an eye at D, since from almost everybody I hear it is a great, clean and powerful language, that fixes the annoying flaws in i.e. C++, while still being a compiled (and thus potentially fast) language. Like Java, it has garbage collection, but the syntax is said to be even cleaner than that of Java, plus you can do really close-to-the system programming/optimization (even write inline assembler code) if needed.

(Much of this, you can read in this question on D, here on BioStar)

Finally a word on python: I think python's ability to compile to C-code with just the addition of typing the variables, with the Cython package, is very neat, and might solve many performance-demanding tasks, if you have reasons to stay in the scripting-world.

ADD COMMENTlink modified 7.2 years ago • written 7.2 years ago by Samuel Lampa1.2k
2
gravatar for Pasta
7.2 years ago by
Pasta1.3k
Switzerland
Pasta1.3k wrote:

If I were you I would forget about Java: too slow ! My own opinion of course.

C++ seems to be a better option. As a Java-guy initially I found C++ easy to learn, though more complicated than Java.

Moreover you will find plenty of C++ biology-oriented libraries like:

ADD COMMENTlink modified 5.8 years ago by audrius.meskauskas90 • written 7.2 years ago by Pasta1.3k
4

can you support your opinion -java being too slow- by numbers? http://shootout.alioth.debian.org/u32/which-programming-languages-are-fastest.php

Java certainly lacks genomics libraries.

ADD REPLYlink written 7.2 years ago by Ido Tamir4.9k
1

@Travis: Start slowly with the "Hello world" program. After you can have a look at other developers' programs, that really helps. I used the tutorials on http://www.learncpp.com/

@Ido : Sorry, nothing to show, just my own experience ;)

ADD REPLYlink written 7.2 years ago by Pasta1.3k

Thanks. Any tips on a good starting point e.g. a relevant book or tutorial?

ADD REPLYlink written 7.2 years ago by Travis2.8k

@pasta If your program is limited in speed by the startup time (e.g. HelloWorld), then the performance of the language you choose will likely matter very little. thoughts?

ADD REPLYlink written 7.2 years ago by brentp22k

It is a common approach to use two languages - one for heavy lifting (C, C++, FORTRAN, used to be assembler but now is uncommon) and another just to connect algorithms and do various computationally non intensive tasks. The idea is that a lot of short lived, single use throwaway code must be written in that "glue" language so it must be highly productive even at expense of performance (Perl, Python, Ruby and of course Java also can do for you). Probably C++ could play both roles at once, who knows. Java currently is not actually slow but of course you can squeeze more from C.

ADD REPLYlink modified 5.8 years ago • written 5.8 years ago by audrius.meskauskas90
2
gravatar for ff.cc.cc
7.2 years ago by
ff.cc.cc1.2k
European Union
ff.cc.cc1.2k wrote:

I suggest you C++. Python is nice and elegant, excellent for prototyping or linking sw modules written in different languages, but C++ is much more EFFECTIVE.

I would also suggest you to keep far from GUI programming (at least for the beginning...) in c++, write good and reusable command line tools and leave the graphical interface to java or web server.

Good starting point are books from Deitel and from Eckel, but also many others. C bible is the book from kernighan & ritchie. C++ bible is the text from stroustrup

Do not write everything completely from the ground ! learn how to link libraries and/or template libraries, (e.g. getopt for command line parsing, gsl or eigen for matrix and linear algebra).

The next step will be STL and boost.org

ADD COMMENTlink written 7.2 years ago by ff.cc.cc1.2k
2
gravatar for Marvin
7.2 years ago by
Marvin800
Marvin800 wrote:

Learn both C (without the ++) and a truly high level language (e.g. Haskell). You will want the high level language most of the time, lest you get bogged down in chasing down segfaults, but you might occasionally need C, both to write that one tight inner loop, and to understand how to call into libraries written in C.

Forget about C++. It is a step up from C, but that tiny step isn't worth the complexity of this Rube Goldberg language. I the end, you'll write C++ programs and combine with a scripting language, probably bash. While the idea is right, it make more sense to use a higher-level scripting languages and a lower-level workhorse.

If Haskell is too alien for your taste, try Lua for a scripting language that combines well with stuff written in C. Oh, and all that is just my personal opinion. YMMD.

ADD COMMENTlink written 7.2 years ago by Marvin800

I was thinking in this way too ... even borrowing my collegue's C book ... but then found out about D, and realized that will be the way to avoid segfaults (D has GC), while still writing fast code :)

ADD REPLYlink written 7.2 years ago by Samuel Lampa1.2k
1
gravatar for Palani Kannan
6.7 years ago by
Cologne, Germany
Palani Kannan40 wrote:

I am also a bioinformatic programmer who started with Perl language. Currently I am using Ruby. It was created with the inspiration of perl.

Currently, I am working with genome data. In terms of processing bulk data, Ruby is better in terms of memory management.

I tried three different programming languages perl, python and ruby for parsing xml formatted genome data. Ruby showed a better response.

It have several features similar like perl with many more advanced features and addon modules.

Learning C and C++ programming is very good for developing an applications with binary level usages and considerations. Ruby have default features in memory management and binary usages.

Ruby supports multiple programming paradigms, including functional, object oriented, imperative and reflective. It also has a dynamic type system and automatic memory management; it is therefore similar in varying respects to Smalltalk, Python, Perl, Lisp, Dylan, Pike, and CLU.

http://en.wikipedia.org/wiki/Ruby_(programming_language)

ADD COMMENTlink written 6.7 years ago by Palani Kannan40
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1551 users visited in the last hour