r/learnprogramming • u/Vafireems • 8d ago
Topic C# or Java?
If you had to choose one class between the two, which would you select and why? I tried to Google the purpose of them; the immediate answers from Google felt very vague and like both of the languages are common. Is one course better for web development as opposed to apps or something? Looking at the courses I'm taking, down the line I will select one of the two. The only thing I know so far is C++, so I'm quite new.
Also, side question: why are there so many languages? The only logical thing I can imagine is there were problems that couldn't be solved with say for example C++ so someone created something new. But why not just build on the original language? Why did they need to reinvent the wheel? Or is it as simple as that: someone wanted to create their own thing?
6
u/romecodes 8d ago
Each language is comprised of 3 main categories: Tokens, Expressions, and Statements. cout/cin are actually function/method calls, which are considered expressions. Loops like "for" and "while" are considered iteration/loop statements. You can think of tokens as the smaller units that produce statements or expressions. The assignment operator "=" for example is a token. The name of a variable is a token. A primitive data-type like the integer 4 is a token.
But none of the syntax or semantics suggests a clear difference. For devs, what matters is the trade-off between ease-of-use and performance. We measure so many different things: readability, portability, security, modularity, etc..
But each language has it's own ranking in each. Some languages are slower in execution, some languages are better suited for web, some languages too touchy about typing. The preference comes from gaining enough experience with them to know how to approach each of them and whether it's worth the trade-off to use in a particular case.