Jump to content

Is C relevant for a competition?

Gat Pelsinger

I am applying for a programming competition. 3 hours for 26 questions, and I AM SLOW. I don't care about getting first, which is not going to happen at all because probably millions of people will be competing and even some of the practice questions are hard for my level (I am still beginner tbh). I have been doing some data structures and algorithms but only in C and sometimes in Java (yes I know a little bit of Java), and I have always been thinking to move onto Python or learn the full core Java course or maybe even C++ ain't bad.

 

Will I be able to do ok in C? Heck, they won't even let me copy my OWN code, and that is why I am also hesitant to use Java. I like C because it gives you a lot of power and you can implement almost everything by yourself, but on the other hand, Python can sum up a whole Hash Table search in one line. I am honestly not even that competitive and most of my time will go in thinking about the logic rather than implementing a DS/ALG, that is unless I have done it several times that I can just copy paste it in the code from my brain, which I can't...

 

But without worrying to much, upon the practice papers, it is not deeply dependent on DS/ALG and it has a little more to do with logic and understanding. I mean, I have to get the input from literally stdin, so you probably understand.

Microsoft owns my soul.

 

Also, Dell is evil, but HP kinda nice.

Link to comment
Share on other sites

Link to post
Share on other sites

9 minutes ago, Gat Pelsinger said:

most of my time will go in thinking about the logic

That's great then. It's so fundamental that any practice is worthy.

Unless you want to specialize in only that and can end up in a setting where integration is done by someone else your structures and algos are useless without proper logic around it, and the logic is often more of the work.

 

F@H
Desktop: i9-13900K, ASUS Z790-E, 64GB DDR5-6000 CL36, RTX3080, 2TB MP600 Pro XT, 2TB SX8200Pro, 2x16TB Ironwolf RAID0, Corsair HX1200, Antec Vortex 360 AIO, Thermaltake Versa H25 TG, Samsung 4K curved 49" TV, 23" secondary, Mountain Everest Max

Mobile SFF rig: i9-9900K, Noctua NH-L9i, Asrock Z390 Phantom ITX-AC, 32GB, GTX1070, 2x1TB SX8200Pro RAID0, 2x5TB 2.5" HDD RAID0, Athena 500W Flex (Noctua fan), Custom 4.7l 3D printed case

 

Asus Zenbook UM325UA, Ryzen 7 5700u, 16GB, 1TB, OLED

 

GPD Win 2

Link to comment
Share on other sites

Link to post
Share on other sites

Personally, I wouldn't use C in a programming competition. It's powerful, but it also doesn't have any of the built-in data structures that other programming languages have. I know you said the competition isn't very dependent on DSA, but if there ever comes a time when you need it, you'd have to write them yourself. Given the time limit, I don't think that's at all feasible.

 

Python seems to be the preferred language for competitive programming because of how fast it is to write. There are a few cases when Python is too slow for a solution to be accepted, such as in problems involving lots of recursion. If this happens, you can just switch to a faster language - this is typically C++ since it has the speed of C with many data structures already built into the standard library. Java is a good middle ground between the two.

 

That being said, if C is the language you're most comfortable using, then you should use it. Having to learn a new language during a competition would not be fun.

Computer engineering grad student, cybersecurity researcher, and hobbyist embedded systems developer

 

Daily Driver:

CPU: Ryzen 7 4800H | GPU: RTX 2060 | RAM: 16GB DDR4 3200MHz C16

 

Gaming PC:

CPU: Ryzen 5 5600X | GPU: EVGA RTX 2080Ti | RAM: 32GB DDR4 3200MHz C16

Link to comment
Share on other sites

Link to post
Share on other sites

28 minutes ago, Gat Pelsinger said:

I like C because it gives you a lot of power and you can implement almost everything by yourself, but on the other hand, Python can sum up a whole Hash Table search in one line.

I would pick the language you're most familiar with. The less you have to think about the language and can focus on the implementation instead, the better.

 

~edit: Of course higher level languages like Java have the big advantage that they bring a ton of tools along and that errors are way easier to debug.

Remember to either quote or @mention others, so they are notified of your reply

Link to comment
Share on other sites

Link to post
Share on other sites

I have personally seen a lot more people do casual competive programming in Java, javascript or python than everything else out there(it strongly correlates with how popular and widely used the languages are) but for tournaments in which judges used actual profiler to narrow down the execution time to the milliseconds, C++ is usually the way to go but honestly, things like this should be standardized so every participants is all using the same programming language, compiler, language version and ect ect. 

Sudo make me a sandwich 

Link to comment
Share on other sites

Link to post
Share on other sites

7 hours ago, Gat Pelsinger said:

I like C because it gives you a lot of power

The power to shoot yourself into the feet.

 

One of the issues with C is that if logic suggests a concept should be allowed it is allowed. To provide an example:

It is possible to jump into and exit  a for loop with a goto. Other languages would throw errors and reject this construct for good reasons. 

C-strings are also a very dangerous construct. 

People never go out of business.

Link to comment
Share on other sites

Link to post
Share on other sites

4 hours ago, FlyingPotato_is_taken said:

The power to shoot yourself into the feet.

Isn't that a synonym for Programmers?

Microsoft owns my soul.

 

Also, Dell is evil, but HP kinda nice.

Link to comment
Share on other sites

Link to post
Share on other sites

it all depends on what the rules and goals of the competition are... if it's a bunch of conceptual problems where performance is irrelevant and you have limited time to come up with a solution, C is a terrible choice. It will only slow you down. On the other hand if code performance matters and the questions are related to optimization and efficiency, then C is an ok choice. Many programming competitions will require a specific language or at least ask you to pick from 2 or 3 at most

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

28 minutes ago, Gat Pelsinger said:

Isn't that a synonym for Programmers?

Kind of.

 

But more modern languages make it harder to shoot yourself in to foot. And give you much better tools to figure out what went wrong. Which means more time working on a solution to the actual problem, rather than working on getting your code to do what you want. They also provide you with more power in the sense that more advanced concepts, such as multi-threading, are way easier and at the same time safer to pull off.

 

A fully optimized C program may be able to do something the fastest and the least memory hungry. But if it takes months (and years of experience) to optimize a C program to this point, while another language can achieve maybe 95% of the same performance in a couple of days, with much less effort, that language still wins in my book.

Remember to either quote or @mention others, so they are notified of your reply

Link to comment
Share on other sites

Link to post
Share on other sites

@Eigenvektor

 

Yeah, I knew all along that C is great but you can't get some ACTUAL work done with it. Nobody really hates Python and probably love it because it is just easy and I don't have to care much about memory management and managing data structures myself. 

 

Before I had figured this out and heard that Python is used in machine learning, I was like wait, don't you need performance for that? But ML is such a complicated topic that just getting your code running and working is more than enough rather than oh, let me right inlined AVX512 assembly in C.

 

And at the end of the day, probably what you implemented in C, if not highly optimized, will probably result in it being slower than Java or Python's built in implementations in those language themselves.

 

"With great power, comes great responsibility" I can see why.

 

Pretty much no realistic developer wants to care about performance and just wants to get things working, and use utilities that make your life much easier and at least lets you actually do stuff. If you try to be realistic, C is not harder than Python. It just lets you do less, and Python lets you do more (of course at a cost). 

 

If you use C, then you would have to write everything by yourself again and again, and if you keep doing this, life itself will get insufficient for your aims.

Microsoft owns my soul.

 

Also, Dell is evil, but HP kinda nice.

Link to comment
Share on other sites

Link to post
Share on other sites

25 minutes ago, Gat Pelsinger said:

Pretty much no realistic developer wants to care about performance and just wants to get things working, and use utilities that make your life much easier and at least lets you actually do stuff. If you try to be realistic, C is not harder than Python. It just lets you do less, and Python lets you do more (of course at a cost).

Not a Python developer, so I can't really comment on it. My language of choice is either Java or preferably Kotlin.

 

The code I write for a living wouldn't benefit from the low level nature of C, nor would it get much (if any) performance boost. On the flip side I'm way more productive than I could ever be in C.

 

That doesn't mean I don't care about performance. I very much do. What I'm saying is, I can spend a lot more time on performance tuning simply because the program is up and running that much faster.

 

If you've got limited time to implement something, the faster you have a working prototype the more time you get to spend on polishing it.

 

52 minutes ago, Gat Pelsinger said:

And at the end of the day, probably what you implemented in C, if not highly optimized, will probably result in it being slower than Java or Python's built in implementations in those language themselves.

Exactly. If you have a time limit and it takes you all that time just to get a running prototype in C, while Java allows you to get it done in a day and spend the remaining time on polish and performance, guess which program will be both more stable and performant?

 

If you have enough time, the C program might eventually outperform the work done with a higher level language. But in the meantime that program is on version 5.12 with a ton of features you have no realistic chance to catch up with.

 

37 minutes ago, Gat Pelsinger said:

If you use C, then you would have to write everything by yourself again and again, and if you keep doing this, life itself will get insufficient for your aims.

C libraries are a thing. There is no point in reinventing the wheel all the time.

Remember to either quote or @mention others, so they are notified of your reply

Link to comment
Share on other sites

Link to post
Share on other sites

On 4/27/2024 at 3:16 PM, Gat Pelsinger said:

Will I be able to do ok in C?

Yeah, sure, you may be able to get one or two questions done within that time depending on the level of this competition.

On 4/27/2024 at 3:16 PM, Gat Pelsinger said:

most of my time will go in thinking about the logic rather than implementing a DS/ALG, that is unless I have done it several times that I can just copy paste it in the code from my brain, which I can't...

This would be the case if you were fast and practiced enough in C to implement your DS/ALG quick enough to just think about the logic, but given what you said before it seems like you'll spend most of your time implementing basic stuff like a hash table, a trie, a graph or some other DS.

 

On 4/27/2024 at 3:16 PM, Gat Pelsinger said:

But without worrying to much, upon the practice papers, it is not deeply dependent on DS/ALG and it has a little more to do with logic and understanding. I mean, I have to get the input from literally stdin, so you probably understand.

Well, when I used to take part in programming competitions (the ones from ICPC), it was just reading from stdin and providing the correct output, but the whole point of the competition was making proper use of DS/ALGs to get the correct output within the time frame. Their input samples were also large enough so that Big O stuff was really relevant, meaning that you couldn't just brute force the answer with the given time.

 

As said above, most people I knew used either Cpp or Java, since those were fast enough and had lots of stuff built-in already so you wouldn't waste much time with that.

 

3 hours ago, Gat Pelsinger said:

Yeah, I knew all along that C is great but you can't get some ACTUAL work done with it

Many big projects are done in C. However, for non-system stuff and more web-like it's really wasteful in terms of time-to-release compared to other stuff.

3 hours ago, Gat Pelsinger said:

Before I had figured this out and heard that Python is used in machine learning, I was like wait, don't you need performance for that? But ML is such a complicated topic that just getting your code running and working is more than enough rather than oh, let me right inlined AVX512 assembly in C.

As per your example, most ML frameworks are actually written in Cpp or the likes, and python is only a wrapper on top of those that allows you to easily build stuff upon it. The core part is fast, the glue code doesn't need to be.

3 hours ago, Gat Pelsinger said:

If you use C, then you would have to write everything by yourself again and again, and if you keep doing this, life itself will get insufficient for your aims.

In the real world you have libraries and whatnot, and for a big project you would only write that kind of stuff once and re-use them across the project.

FX6300 @ 4.2GHz | Gigabyte GA-78LMT-USB3 R2 | Hyper 212x | 3x 8GB + 1x 4GB @ 1600MHz | Gigabyte 2060 Super | Corsair CX650M | LG 43UK6520PSA
ASUS X550LN | i5 4210u | 12GB
Lenovo N23 Yoga

Link to comment
Share on other sites

Link to post
Share on other sites

Many exploits made use C

Linux uses C

Embedded systems use C

GTK uses C

OpenGL, SDL, RayLib, CSFML all use C

Encoding, decoding and compression algorithms are made in C too

 

Scientific / Numerical computing / Plotting (GSL, GnuPlot, FFTW, apophenia, libBlas, ATLAS and more)

Machine learning ( FANN, DarkNET).

Crypto ( openSSL, libsodium)

File processing ( jsonC, Libcsv)

 

The list goes on and on. C is very relevant and its going to be like that for years to come(hopefully )

Read this reddit post if your interested @Gat Pelsinger 

 

When I say C I mean C not C++

 

That said if your in a competition do C++ and not C since it has more high level stuff to make your life easier. Personally since time is the essence in competitions like your doing python would be your go to. 

Link to comment
Share on other sites

Link to post
Share on other sites

@goatedpenguin

 

I never said C is not relevant. I said that with the context of a programming competition. Of course I know that C is the under infrastructure of literally everything.

Microsoft owns my soul.

 

Also, Dell is evil, but HP kinda nice.

Link to comment
Share on other sites

Link to post
Share on other sites

On 4/29/2024 at 1:50 AM, Gat Pelsinger said:

@goatedpenguin

 

I never said C is not relevant. I said that with the context of a programming competition. Of course I know that C is the under infrastructure of literally everything.

Tell us how it went and try to use cpp or python in competition.(if you alr know them ofc, if not use something you are comfortable with)

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×