I've had bugs because the original developer who wrote the code didn't understand that and it was causing duplicates in the 1 path where it was passing by reference
Well, java actually only has primitive "value" types and pointers.
C++ has both pointers and references.
It's very mindfuck, but they are not the same thing, java just renamed them because people were afraid of pointers, but it lives on under the hood (NullPointerException)
unsafe doesn't mean that it isn't safe. Just means that you have full control over the memory and as such need to think about how the memory you allocated gets freed later. You can do retarded memory shit in every language.
You can cause memory corruption by data races. Slices are fat pointers but are not written atomically. So if you change a slice from two different threads, you can observe false states like a pointer to the first slice's data but the length of a second. After which your code can read past the memory slice, a la c/c++
why no references? also why does C# have the ref keyword but requires the variable to pass be also ref (introduces some annoying syntax errors), its quite annoying since in my head I thought it was like rust's &mut
A variable passed using ref can be changed in ways that might not be expected if the person is expecting a normal function call, including having the underlying reference replaced entirely out from under them.
Reference types are always passed by reference by default - passing them with the ref keyword is 99% of the time unnecessary (and likely doesn't do what you want).
Passing a value type (aka, primitives/non-"classes") with ref is basically like passing T& instead of T, so it can be useful there, but generally you don't really need that keyword much
Imho, languages with references tends to be even more unintuitive than C++ as a first language. So I highly recommend to pick C++/Rust/Zig as a first language (and pls not C, it won’t teach you anything good for projects development).
Mutability may be unintuitive but there's much more unintuitive things about system languages in general that I think languages like Python, Java, or JavaScript end up being much better for beginners
C++ in particular I would never recommend to a beginner
At the time I found good teacher in IT school who taught C++ in a very good way. But it was 10 years ago or so.
So Ig Zig is the most right choice rn because Rust in particular teaches a lot of unusable-in-other-languages practices and architectural designs so I don’t really know which language is the beat for start now…
Honestly, after trying Python and C, Java is the one that sparked the flame of programming passion on me, so I’m really fond of it. I really like it and it’s the one I chose whenever I want to program something. though I guess the teacher also does a lot for the enjoyment ([at]BroCodez on YouTube).
Imho, Java is one of the best to start mainly because of its verbosity. I think it helps the programmer keep a better understanding of the program and it makes programs easier to read and decipher without needing a bajillion comments.
On the other hand, even the course I followed wasn’t that good and it bored me to death, I think C is also an excellent choice to start, because it forces the programmer to stay closer to the machine and that experience with lower level programming makes programming in higher level languages easier and more efficient, since the programmer learns stuff it would have otherwise been abstracted away with higher level languages. Also going from Python or C++ or Java to C is much harder than the opposite, precisely because one loses the libraries/abstractions of those higher languages that one has learnt to rely on.
PS: Sorry for the rambling. It’s 4:50 for me right now and my brain ain’t braining well no more :/
Kinda agree with Java but references are still kinda unexplained, if you are not familiar with memory models as a concept, it can potentially blow up your legs in the future. People need at least know how shared_ptrs work (or its alternatives).
I don’t think it’s a good first language, that’s it. As a C++ dev I regularly interact with it and wrote some programs, the main issue with C that it is quite struggling and unrewarding language in some way, especially when you wanna build some big projects. There is a reason why some projects are written in C++ initially and then C interop is added.
I mean it really depends on what your making. C is just so incredibly flexible while being one of the single most portable languages ever made and usually being pretty fast. I can see how something like c++ can be easier for larger projects tho. I do think c++ is a bit overcomplex for what it is and it isnt a first good lang due to that.
Lol i cant say anything on that i dont know much c++. my first bit in programming was an lsi11/03 processor manual. i only learned c like 2 years later and have used that almost only since
Imho, the inly purpose of the first language is to teach you pointers and memory model as well as build small application. If you have a good friend who knows programming/informatics well, Zig is way better choice than C or C++ but not sure about Rust tho except it’s language specific practices.
C++ has a solution for everything except complexity. Sometimes I have no clue what problem is being solved, but hey, there's more layers of complexity there!
126
u/FurieMan 16h ago
"We have no pointers!"
Looks inside: Only pointers.
59
u/IamSunka 17h ago
We can give you references, though.
25
u/Makonede 14h ago
138: Pointers
15
u/stupled 14h ago
I was expecting Rust
15
u/bwmat 15h ago
NullPointerException
2
u/AsaKeyholderUK 16h ago
CAmelCase variable names do not hide in key dreams. Mine is still isLoadingUserProfile from a project I finished in 2023.
1
u/Personal-Code-2496 4h ago
unsafe doesn't mean that it isn't safe. Just means that you have full control over the memory and as such need to think about how the memory you allocated gets freed later. You can do retarded memory shit in every language.
1
u/SoggyCaterpillar5773 2h ago
You should try Golang.
0
u/Puzzleheaded-Weird66 16h ago
why no references? also why does C# have the
refkeyword but requires the variable to pass be also ref (introduces some annoying syntax errors), its quite annoying since in my head I thought it was like rust's&mut0
u/drawkbox 4h ago
Everything worked out and was "safer" until Log4Shell and Java4Shell where Java was wide open for a decade.
-9
u/El_RoviSoft 16h ago
Imho, languages with references tends to be even more unintuitive than C++ as a first language. So I highly recommend to pick C++/Rust/Zig as a first language (and pls not C, it won’t teach you anything good for projects development).