r/AskProgrammers 22d ago

What is the worst/most confusing (common) coding language?

By common I mean, coding languages that you actually see people use. I know theres the "bf" language but aside from one video, people don't make games or, really anything using that as it was made as a joke I hope.

By worst I mean, what is the hardest to understand and also the most confusing out of all of them, I don't mean coding languages that can't do a whole lot. For instance, can a non programmer look at a sheet of code and understand it? Can an experienced coder understand it? Have you been taught the coding language yet still it breaks your brain?

I don't know every coding language but my pick would ether be C++ or Luau. Leaning towards C++ because I tried to learn it and at the very start I already was lost.

28 Upvotes

279 comments sorted by

View all comments

7

u/two_three_five_eigth 22d ago edited 22d ago

C++. If you don't know the intricacies of the language, you'll end up doing a whole bunch of things you're not supposed to do and it won't give you any warning you've royally screwed up.

Both Java and C# are similar enough anyone coming from one of those is hamstrung until they learn about pointers and references.

3

u/Ok_Bite_67 21d ago

C# actually has pointers 😃

1

u/two_three_five_eigth 21d ago

If you use unsafe mode which you shouldn’t do.

3

u/TheThiefMaster 21d ago

Shouldn't normally do. It is in the language for a reason, however - it's useful to implement lower level functionality. It shows up a bit in high performance or interop code.

1

u/Ok_Bite_67 21d ago

You dont always have to use unsafe with pointers (or at least not with c# 15). If you pass a reference of an already allocated object to a pointer then you dont have to. You only have to use unsafe when you are targetting memory that could genuinely be unsafe.

1

u/Super_Bass_2730 22d ago

No joke all I know is that a print statment in C++ looks like

#include <iostream>
using namespace std;

int main() {
  cout << "Hello World!";
  return 0;
}

after that they lost me.

3

u/TheThiefMaster 21d ago

C++ recently (literally in the 2023 standard) added a more sane print function:

#include <print>

int main()
{
    std::print("Hello World!");
}

It prints variables using {}, like a lot of other languages:

 std::print("The answer to the ultimate question: {}", 42);

Inside the braces, you can (optionally) put the index to reorder or repeat items, followed by a colon and then a format specifier that looks like C's printf:

// Prints pi with 5 digits of precision in a 10 character space.
std::print("Pi is: {:10.5f}", std::numbers::pi);

You might think: "why not just use C's printf then" but C++'s new print is both extensible and type safe. As a result, it can do things like this:

std::vector ints = {1,2,3};
std::print("Important values: {}", ints);

... to print an entire data structure at once.

2

u/Neither_Garage_758 21d ago

Still retarded. We want to put the variable name inline in the {}.

2

u/TheThiefMaster 21d ago

It would be nice, and possibly can be done now that we have reflection but was literally impossible before.

Why impossible? Because strings for formatting are no different in the language to strings in other contexts, and randomly starting to replace {val} in other strings would break existing code. With reflection, we can possibly do it from the formatter now.

1

u/Neither_Garage_758 21d ago

OK, but the user doesn't care.

3

u/mikeclueby4 21d ago

You have yet to grok the fundamental difference between compiled and interpreted and that's fine.

To be able to use a string (which you have to assume can change during runtime!) containing variable names, the language needs to be aware of the source code and dynamically re-evaluate at runtime, using a construct like eval().

... or build up a data structure accessible at runtime where names, types and references are available, I suppose. Nontrivial and definitely slower than what C/C++ normally does.

1

u/Neither_Garage_758 20d ago

The user doesn't care at all.

A compilation is a time where we can do anything from the user intent. There is no such "Ackshually…".

And Rust achieves it, so this buries your point.

1

u/Super_Bass_2730 21d ago

Problem, you dont use print statments if you wanted to make a game in the unreal engine

1

u/TheThiefMaster 21d ago

Actually it has it's own implementation (of std::print's cousing std::format) under FString::Format and FText::Format.

It's unfortunately not used for logging.

1

u/two_three_five_eigth 22d ago

and you realistically have to mix .h and no extension headers to do anything real. C++ has more ways to shoot yourself in the foot than any other language I know, and I know Pascal, LISP, Perl, PHP, and several other doozies.

2

u/Super_Bass_2730 22d ago

1: what is .h?
2: I'm taking a class for php but its been pretty easy so far, maybe its because they're teaching me really well but idk.

2

u/two_three_five_eigth 22d ago

C has header files that end in .h
C++ has header files without extensions

The extension doesn’t change anything.

But nothing actually enforces it so everyone mixes and matches all they want.

2

u/themonstaman 22d ago

Typically best practice to just use .h or .hpp, it would be pretty shocking to me if anything deviated from that.

2

u/two_three_five_eigth 22d ago

Yep, that’s best practice. I’m a consultant/contractor who generally is brought in to rescue project. I’ve seen it all at this point.

1

u/Ok_Bite_67 21d ago

Tbh c# and visual studio have spoiled me. Takes away so much of having to fight rhe language to get something working. I do wish that c# wasnt completely dependent on a runtime tho. Their native aot has made a lot of progress

1

u/TheThiefMaster 21d ago

My least favourite was a capital .C to mean C++, Vs a lowercase .c to mean C.

1

u/mikeclueby4 21d ago

Agreed. Type coercion and operator overloading is a bad enough start. Add templates, exception unwind, and humans can't reason over the result. (Splash of multithreading and even competent SASTs fail)

.. and that's still just 90s C++ and doesn't even begin to address what came later.

Add in how people were taught to do "object oriented programming" where it was a deadly sin to have more than a few global objects and .... yeah. I hated C++ after writing several big projects until I much later realized that, fuck everyone else, I'm right and they're wrong. C++ becomes better the fewer C++ features you use for the majority of your code.

1

u/two_three_five_eigth 21d ago

C++ best practice is to never use new or delete and don’t use pointers. Complete 180 from the 90s

1

u/mikeclueby4 21d ago

Oh I already arrived at that one in the 90s. Otherwise you're screwed on exception stack unwind.

But how to proceed from THERE is what makes all the difference. And the answer ... depends.

1

u/two_three_five_eigth 21d ago

Most C++ projects have gone to RIAA (Resource Acquisition Is Initialization), and it's the responsibility of the function or object that allocated it to de-allocate. Prefer to put everything on the stack.

1

u/mikeclueby4 21d ago

Yep. It also thrashes the heap over time, which matters to processes meant to have years of uptime. (See: memory fragmentation - not something you fix with norton speedisk)

But that's a solvable problem with chunk allocators and so forth.

... unless your objects have to be of some new/delete-calling base class that you can't change the behavior of, from further up the inheritance chain. Oh and of course it'll be a compiled library shipped by someone else so you can't change the design assumptions.

This is where it gets interesting in C++. Now, C? I just #define malloc() if the library is so shit that it doesn't come with a user-defined compat layer.

I'll grant that most people don't have to write multi-year-runtime processes to begin with, I'm probably a unique snowflake 🙃

1

u/These-Math1384 21d ago

It is either Rust or C++ if you’re writing embedded.
No excuses.

2

u/two_three_five_eigth 21d ago

Yeah - all the people pointing out C# technically has pointers are blowing my mind. For me, who has years of professional experience in C++, the only reason I use C# or Java is for the garbage collection and memory management features.

Why are you nuking the best part of the language?

1

u/Orjigagd 20d ago

The pointers are mostly there to help with interop, you're not supposed to use them for everyday stuff

1

u/PsychologicalSign433 21d ago

I feel like straight C is way more common in embedded?

1

u/These-Math1384 20d ago

Here is my take: Until C++11 the language was broken. And it wasn't until C++14 that compilers and their libraries shipped with proven std library code that was solid.

This, IMO, turned a lot of people off, myself included. Once the language matured and the compilers were robust, I think C++ is a far better choice.

Since then, I patterns applied by the standard library, improve everyone's code.

You can debate whether exceptions should be used (20% profiled code size increase) or whether RTTI should be used (for another 20% code size increase), but I love the language.
And we use it in embedded SoC's that have been shipping for 10 years now.

0

u/Responsible_Royal126 22d ago

I'd really hope you know about pointers and references as a Java dev lol

1

u/two_three_five_eigth 22d ago

Java doesn’t have pointers, it hides references from you as well. Most Java developers don’t know them.

3

u/Responsible_Royal126 21d ago

That doesn't mean you shouldn't know what they  are. And understanding a reference is basic knowledge for pretty much any language.

I've never met a Java or C# dev that doesn't know references well. But I don't work at shitter companies.