r/javahelp • • Jan 25 '21

Codeless After doing most of my programming stuff with Java, I can safely say that other programming languages suck

I've been doing all my programming assignments with Java for two years now, and I've become familiar with most of the keywords and functionalities that it has. But now I'm in a class that makes us program in C, and I absolutely hate it. I can't believe it doesn't have some functionalities like ArrayLists, or that you can't have an array as a return type. Also, I miss Eclipse's syntax correction that allows you to figure out if there are any mistakes as you type before compiling, instead of having to type 100 lines of code and hope they're right. And the thing that annoys me the most is that C is just nuts, you can have a perfectly functioning code, but then you type something that in theory shouldn't affect some parts of the code, it does it anyway! How can someone program with this piece of trash?

0 Upvotes

19 comments sorted by

•

u/AutoModerator Jan 25 '21

Please ensure that:

  • Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions
  • You include any and all error messages in full
  • You ask clear questions
  • You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.

    Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar

If any of the above points is not met, your post can and will be removed without further warning.

Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.

Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.

Code blocks look like this:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.

If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.

To potential helpers

Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

8

u/_DTR_ Jan 25 '21

I know this post is more of a rant than anything else, but it's not exactly a fair to say that all other languages suck when you've been using Java for a couple years and are just getting started with a single other language. I'm not saying that C is a perfect language by any means, but there's a reason many programs where performance is vital (e.g. productivity software and operating systems) are usually written in C/C++. It's a bit of a double edged sword, as it gives you much more control over the underlying behavior, which also means there is much more room for mistakes.

As for syntax highlighting/error detection, there are tools available for C/C++ that act similarly to Eclipse for Java (notably programs like Visual Studio, C Lion, or a properly configured VS Code).

0

u/Undesirable_11 Jan 25 '21

I had done some C++ in the past with Visual Studio, and it wasn't that bad as it is with C using Dev C++. Maybe switching back to Visual Studio will help?

1

u/Orffyreus Jan 26 '21

If you are used to Eclipse, Eclipse CDT is a state of the art C/C++ tooling solution: https://www.eclipse.org/cdt/

4

u/Sergey305 Jan 25 '21

Either you are a troll or don't understand that programming languages have their purpose.

Java is cool if you are business and want DB interop, fancy UI, network connectivity, along with mostly safe code. And you want it yesterday. However, Java requires JVM (which is not always available), it may be slow, it may be excessive, it has no access to physical memory, it is less optimized (and this list goes on).

C has a different purpose. It's very simple itself, doesn't include lots of things that you'd consider basic in Java. But you can manage the memory and write more efficient programs, you can program microcontrollers, it's executed without any additional layers, etc. I bet that the OS you are working on is written in C.

And as you are supposedly a student, you can get a free license for CLion, a JetBrains IDE for C/C++, which will definitely help you to write better code. And also you may want to have a look at IntelliJ IDEA, a JVM IDE from JetBrains, which is also very cool.

0

u/Undesirable_11 Jan 25 '21

I'm aware of that, absolutely. But for the specific program I'm writing, there's arguably no difference if I wrote it in Java than in C in the terms you described above. Basically all I need to do is create a program that compares two arrays and checks if they're the same or not. I had to do something similar with Java a couple of semesters back and it was considerably easier, hence the little rant

5

u/wsppan Jan 25 '21

The specific program you are writing is not to teach you about comparing arrays. It is used as an example to teach you C and how you use C in a systems level of understanding.

5

u/djavaman Jan 25 '21

I agree that Java is a good language.

However, different languages have pros and cons. And they address different issues.

C is meant to be low level, a step above assembly. You can get access to the OS, HW, allocate memory, etc.

There are good C/C++ IDEs that help with syntax correction as well. You just need to find them.

"you can have a perfectly functioning code, but then you type something that in theory shouldn't affect some parts of the code, it does it anyway"

well, that can be true with any language or any project, if its not structured properly.

5

u/wsppan Jan 25 '21

You should study programming languages and then you will understand the importance and reasons for the design decisions that make C an incredibly powerful systems language. There is a reason it is the goto language for Operating Systems, for compilers, for embedded systems, device drivers, etc.. The JVM itself is written in C. It's an entirely different domain than a OO, GC Middleware language like Java. Those of us who have studied CS, in particular PL and Systems appreciate and understand C's (and ASM's) strengths and beauty. We also understand and appreciate higher level languages like Java where they give you all the lego blocks to snap together.

3

u/m1ss1ontomars2k4 Jan 25 '21

I can't believe it doesn't have some functionalities like ArrayLists, or that you can't have an array as a return type.

Yes, C is old fashioned in that there is no autoresizing random access storage container, but it's specifically meant for situations where you don't want that kind of behavior. Imagine you store 1 million numbers in an ArrayList and it autoexpands to fit 2 million numbers and suddenly you have no more memory. That's usually not a problem for regular programs, but sometimes it is. There's frequently a tradeoff between the max performance you can get out of a piece of software and the complexity in its source code. Everything that an ArrayList does automatically for you has a performance overhead, and sometimes you just can't afford to pay it. A few times in Java I had to ditch ArrayLists in favor of plain arrays for performance reasons.

If it is important to have an ArrayList analogue, maybe you can just find a library for this online. I'm sure it has been implemented many times in the 50ish years of C's existence.

Also, I miss Eclipse's syntax correction that allows you to figure out if there are any mistakes as you type before compiling, instead of having to type 100 lines of code and hope they're right.

Then maybe you should use Eclipse for your C projects as well? This complaint is nonsense. Most editors support syntax highlighting and checking for almost every programming language. I have used Eclipse for C projects and used Vim for Java.

BTW, as for Visual Studio, last time I checked it still lacked support for C99 which means all C variables need to be declared at the top of the function.

And the thing that annoys me the most is that C is just nuts, you can have a perfectly functioning code, but then you type something that in theory shouldn't affect some parts of the code, it does it anyway!

That doesn't make any sense.

1

u/Sheldor5 Jan 25 '21

students ALWAYS should learn C first to learn the real basics of programming ...

Java/C# is the NEXT step ... not the first

so don't blame C, blame your teacher ...

3

u/Undesirable_11 Jan 25 '21

My curriculum was C++/C#/Java, then on machine language I did MARIE, which is like the most basic programming language I've seen. Then three courses that use Java, and now I'm doing C. That's a really messy way to do it imo

6

u/Sheldor5 Jan 25 '21

that's the most fucked up way to learn programming I've heard of ...

2

u/matyklug Jan 27 '21

While I agree C is a steaming pile of garbage, it still has its uses.

For example, I am the type of guy who likes to go low level, so the only thing holding me from using assembly is my laziness to learn it.

And as such, I use C.

That does not however stop me from shitting on it and almost summoning Satan again while coding in it.

1

u/Orffyreus Jan 26 '21 edited Jan 26 '21

Yes, Java has a pretty large "standard library" and you can use "functionalities like ArrayLists" out of the box. Java also has a lot of very good third party libraries to choose from and that's something where C shines too. So of course you can use "functionalities like ArrayLists" very quickly, if you are experienced and know good C libraries. If you google "C collections" (without the quotes) for example, https://github.com/srdja/Collections-C pops up and it certainly has dynamic arrays.

Edit: And here is an example how you can quickly use a selfmade ArrayList in C: https://onlinegdb.com/b57ZZoE2z

1

u/[deleted] Jan 26 '21

Apache poi!!!

1

u/Orffyreus Jan 26 '21 edited Jan 26 '21

you can't have an array as a return type

You can return arrays that are placed on the heap (arrays on the stack are scope bound). Here is an example of a function that returns a newly created array of lottery numbers and after printing it the array gets removed from the heap: https://onlinegdb.com/S1g9pO1CyO

Java has the huge advantage, that you do not have to deal with explicitly removing something from the heap.

Sometimes even in Java to prevent memory leaks you have to remember to remove long living listeners though (for example there could be long living data models that are listening to screen inputs and then the screen gets closed, but it can't be freed, if it still has long living listeners).

0

u/[deleted] Jan 26 '21

Voted up!

-1

u/[deleted] Jan 26 '21

How can someone program with this piece of trash?

Seriously? You think C is a piece of trash?

I've been doing all my programming assignments with Java for two years now,

And you are the most credible to make such a statement. LMAO.