# Which language is better for competitive coding?

**URL:** <https://discuss.codechef.com/t/which-language-is-better-for-competitive-coding/6296>\
**Category:** general\
**Tags:** c, c-plus-plus, competition, java\
**Created:** [July 14, 2014, 10:21am UTC](https://discuss.codechef.com/t/which-language-is-better-for-competitive-coding/6296 "2014-07-14T10:21:41Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![himanshu\_9419](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@himanshu\_9419](https://discuss.codechef.com/u/himanshu_9419)\
**Post date:** [July 14, 2014, 10:21am UTC](https://discuss.codechef.com/t/which-language-is-better-for-competitive-coding/6296/1 "2014-07-14T10:21:41Z")

</div>

**Which language is better for competitive coding?** Given I already knew C and Java(only basic) and I code in C.  
but I am unable to improve performance.Please suggest me language with why that language is good.

---

<div class="post-metadata">

**Author:** ![the65bit](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@the65bit](https://discuss.codechef.com/u/the65bit)\
**Post date:** [July 14, 2014, 11:34am UTC](https://discuss.codechef.com/t/which-language-is-better-for-competitive-coding/6296/2 "2014-07-14T11:34:39Z")

</div>

If you know C and java than you can either move to C++ or java .

C++ :  
Less running time and STL library is available which is very good .

Java : It can handle big integers easily .

But you can choose any language , because if your algorithm is right than choice of language doesn`t matter much . Every code which can be done in C++ can also be done in java and vice - versa . It depends on you which language you find yourself comfortable take that language .

Happy Coding !!!

---

<div class="post-metadata">

**Author:** ![dev8546](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@dev8546](https://discuss.codechef.com/u/dev8546)\
**Post date:** [July 14, 2014, 1:45pm UTC](https://discuss.codechef.com/t/which-language-is-better-for-competitive-coding/6296/3 "2014-07-14T13:45:45Z")

</div>

I think language does not matter much other than when you do submit code on SPOJ. I code in C# and if you have correct algorithm in place it will pass in all the coding contest like codechef , codeforces , hackerrank etc. I have only found that on SPOJ if the question has lot of input data C# do have the TLE issue otherwise C# also works great. Choose any language that you are comfortable with it . Sometime some language has in build functions but still you can manage in your own language

---

<div class="post-metadata">

**Author:** ![tech\_boy](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@tech\_boy](https://discuss.codechef.com/u/tech_boy)\
**Post date:** [July 14, 2014, 5:30pm UTC](https://discuss.codechef.com/t/which-language-is-better-for-competitive-coding/6296/4 "2014-07-14T17:30:12Z")

</div>

Hi @himanshu_9419

According to my research, people use c++ over c for **stl**

and C++ over Java for time of execution as it is less in c++ over Java…

Now coming,to C++ v/s Java…

I have found many of the universities teaches first C or C++ to the beginners or either most programmer begin with C++ over Java…which all points to be more flexible and enjoyable with **C++** …

Hope it helps!

Happy coding…🙂

---

<div class="post-metadata">

**Author:** ![shivamsharma](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@shivamsharma](https://discuss.codechef.com/u/shivamsharma)\
**Post date:** [July 14, 2014, 6:11pm UTC](https://discuss.codechef.com/t/which-language-is-better-for-competitive-coding/6296/5 "2014-07-14T18:11:50Z")

</div>

@himanshu_9419

Basically Language doesn’t matter but the algorithm should be correct.Therefore codechef provides lots of languages of your choice.Every Language has its own benefits like C has good Time of execution over Java,Python but Java ,C++ or Python already has predefined functions which make coding faster.But at the end without algorithm languages doesn’t matters here.I hope you get the point.

---

<div class="post-metadata">

**Author:** ![michelangelo](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@michelangelo](https://discuss.codechef.com/u/michelangelo)\
**Post date:** [July 14, 2014, 7:21pm UTC](https://discuss.codechef.com/t/which-language-is-better-for-competitive-coding/6296/6 "2014-07-14T19:21:32Z")

</div>

Assuming that by competitive coding, you refer to ICPC or time-bound coding contests, mastery of C++ with a basic knowledge of Java will get you through it.

Most competitive programmers prefer C++ over C because of the in-built functions associated with it. In C++, you can simply use sort(a, a+n) to sort an array a[] of size n, or use lower\_bound(a, a+n, num) to binary search a number instead of writing the entire code (imagine the benefits in a time bound contest).  
Moreover there are inbuilt data structures like vector (resizeable arrays), list, queue, stack, etc. in C++.

Java, albeit slower, has a powerful BigInteger, String Processing, HashTable and GregorianCalendar API.  
Suppose you have to calculate the factorial of 25 (the answer has 26 digits), creating a C/C++ code from scratch will take time and effort, whereas a Java solution is this:

```auto

BigInteger fac = new BigInteger.valueOf(1);  
for (int i = 2; i <= 25; i++)  
  fac = fac.multiply(BigInteger.valueOf(i)); // wow :)  

```

Bottomline: To actually excel in these contests, use better data structures and algorithms. No kidding. If you encounter a graph problem and you are not familiar with graphs, it doesn’t really matter which language you are using.

---

<div class="post-metadata">

**Author:** ![topcoder\_7](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@topcoder\_7](https://discuss.codechef.com/u/topcoder_7)\
**Post date:** [October 21, 2014, 8:33pm UTC](https://discuss.codechef.com/t/which-language-is-better-for-competitive-coding/6296/7 "2014-10-21T20:33:39Z")

</div>

Excuse me brother,

> <https://stackoverflow.com/questions/3380993/why-do-programming-competition-contestants-use-c-and-java>

> <https://softwareengineering.stackexchange.com/questions/125576/why-is-c-predominant-in-programming-contests-and-competitions>

By the way everything is relative in this world, there’s nothing absolute. If you know a certain programming language get proficient in it because as long as a certain language is allowed for a problem, it means solving it is possible in that particular language so cool bro.

---

<div class="post-metadata">

**Author:** ![himanshu\_9419](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@himanshu\_9419](https://discuss.codechef.com/u/himanshu_9419)\
**Post date:** [July 14, 2014, 12:46pm UTC](https://discuss.codechef.com/t/which-language-is-better-for-competitive-coding/6296/8 "2014-07-14T12:46:10Z")

</div>

Thanks for answer.

---

<div class="post-metadata">

**Author:** ![the65bit](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@the65bit](https://discuss.codechef.com/u/the65bit)\
**Post date:** [July 14, 2014, 1:10pm UTC](https://discuss.codechef.com/t/which-language-is-better-for-competitive-coding/6296/9 "2014-07-14T13:10:14Z")

</div>

Welcome @himanshu_9419

---

<div class="post-metadata">

**Author:** ![himanshu\_9419](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@himanshu\_9419](https://discuss.codechef.com/u/himanshu_9419)\
**Post date:** [July 14, 2014, 5:17pm UTC](https://discuss.codechef.com/t/which-language-is-better-for-competitive-coding/6296/10 "2014-07-14T17:17:43Z")

</div>

@dev8546 Thanks for Answer. I think language matters as a beginner because you can’t optimize a code after some extent. What I see is C++ is used more than any other coding language I don’t know why? But I want somebody to answer that why C++ is preferred over C, java and C#.

---

<div class="post-metadata">

**Author:** ![himanshu\_9419](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@himanshu\_9419](https://discuss.codechef.com/u/himanshu_9419)\
**Post date:** [July 14, 2014, 5:40pm UTC](https://discuss.codechef.com/t/which-language-is-better-for-competitive-coding/6296/11 "2014-07-14T17:40:55Z")

</div>

@tech_boy thanks for answer

---

<div class="post-metadata">

**Author:** ![tech\_boy](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@tech\_boy](https://discuss.codechef.com/u/tech_boy)\
**Post date:** [July 14, 2014, 5:47pm UTC](https://discuss.codechef.com/t/which-language-is-better-for-competitive-coding/6296/12 "2014-07-14T17:47:59Z")

</div>

you can accept it as well

@himanshu_9419 your welcome 🙂

---

<div class="post-metadata">

**Author:** ![vicfred](https://discuss.codechef.com/user_avatar/discuss.codechef.com/vicfred/32/310490_2.png) [@vicfred](https://discuss.codechef.com/u/vicfred)\
**Post date:** [July 14, 2014, 6:16pm UTC](https://discuss.codechef.com/t/which-language-is-better-for-competitive-coding/6296/13 "2014-07-14T18:16:43Z")

</div>

If you are not going to participate in the ACM ICPC or the IOI you don’t need java to handle big integers (which is the only reason some people use it even though they hate it), you can use python to do that even easier (by default).

---

<div class="post-metadata">

**Author:** ![himanshu\_9419](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@himanshu\_9419](https://discuss.codechef.com/u/himanshu_9419)\
**Post date:** [July 15, 2014, 10:23am UTC](https://discuss.codechef.com/t/which-language-is-better-for-competitive-coding/6296/14 "2014-07-15T10:23:12Z")

</div>

@michelangelo Thanks for answering in such detail.

---

<div class="post-metadata">

**Author:** ![amitt001](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@amitt001](https://discuss.codechef.com/u/amitt001)\
**Post date:** [July 15, 2014, 1:05pm UTC](https://discuss.codechef.com/t/which-language-is-better-for-competitive-coding/6296/15 "2014-07-15T13:05:33Z")

</div>

don’t be so rude. Use any language, it doesn’t matter which language you are using, until or unless your logic is correct

🙂

---

<div class="post-metadata">

**Author:** ![himanshu\_9419](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@himanshu\_9419](https://discuss.codechef.com/u/himanshu_9419)\
**Post date:** [July 15, 2014, 6:54pm UTC](https://discuss.codechef.com/t/which-language-is-better-for-competitive-coding/6296/16 "2014-07-15T18:54:23Z")

</div>

@amitt001 I don’t understand why you are saying rude but I have a suggestion for you. It seems to me that you think language does not matter at all than leave c++ and start submitting code in c. After having experience of submitting code in both language( not for easy level but for medium or hard one) than comment back. Please don’t comment on thing which you don’t know.

---

<div class="post-metadata">

**Author:** ![himanshu\_9419](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@himanshu\_9419](https://discuss.codechef.com/u/himanshu_9419)\
**Post date:** [October 21, 2014, 8:51pm UTC](https://discuss.codechef.com/t/which-language-is-better-for-competitive-coding/6296/17 "2014-10-21T20:51:03Z")

</div>

My friend I know this but you can’t start everything from scratch at the time of contest.Write a code in c++ for hard problem than write it in C you will come to know you have wasted you lot of time in comparison to code writing in c++.  
Here I take c and C++ only for example.
