Instant Messaging App in C++ // Code Review

  Рет қаралды 51,961

The Cherno

The Cherno

Күн бұрын

Пікірлер: 100
@TheCherno
@TheCherno Жыл бұрын
Thanks for watching, hope you enjoyed! ❤ Let me know if you want to see more Walnut Code Reviews! You can try everything Brilliant has to offer-free-for a full 30 days! Visit brilliant.org/TheCherno - the first 200 of you will get 20% off Brilliant’s annual premium subscription!
@obinator9065
@obinator9065 Жыл бұрын
how you doin bro
@clintonreisig
@clintonreisig Жыл бұрын
Security? Privacy?
@harshsulakhe2720
@harshsulakhe2720 5 ай бұрын
Hey when I double click on .bat file , I am not getting anything installed Error : system cannot find the path specified
@szirsp
@szirsp Жыл бұрын
17:25 (TCP, UDP) ports are limited to 16 bit, not sockets. A socket is just a descriptor to identify an endpoint for communication. It can be a combination of domain, (IP) address and port number. So in theory you could need 48 bit for TCP/IPv4 and 144 bit for IPv6. And that's just for one domain+type (TCP = SOCK_STREAM). You add UDP and non IP connections like Unix sockets, IPX... But there is an OS limit (10k ..10 million) (max open files on Linux for example) ... ...uint32 will probably be fine for a while (unless you are using a supercomputer as a port scanner ;)
@МаксимПерчук-н2т
@МаксимПерчук-н2т Жыл бұрын
Hey, Yan. I really appreciate what you do, but there's a thing I want to mention I understand that you want your videos to be pretty short. I also understand that you're a type of programmer who wants to get a deep understanding of things and propagate that knowledge to the audience. But when I clicked at this video, I expected to see you explaining the architecture of your chat app. But what I saw instead was you talking about pointers, headers and forward declaration. For my opinion it'd be better if you moved this kind of stuff into your c++ playlist and talked about the thing that's in the title of the video. Thank you!
@aname9806
@aname9806 Жыл бұрын
Holiday in Germany as well, Servus!
@GabrielVeloz-x4q
@GabrielVeloz-x4q Жыл бұрын
These videos are really useful for learning c++ thanks for this!
@Sultan___
@Sultan___ Жыл бұрын
cherno is the best !!11!!!1!!
@gstreetgames2530
@gstreetgames2530 Жыл бұрын
Any chance you would ever make a video about contributing to an open source privacy project like Session, Element, or for C++ Hush?
@midnqp
@midnqp Жыл бұрын
Congratulations 🎉 on your 800th video on KZbin ✨
@fishinker
@fishinker Жыл бұрын
Would love to see the rest of the code review!
@mingm
@mingm Жыл бұрын
im interested in how does the network thread push the received messages to the UI thread safely. multithreading feels so hard
@imjens.k
@imjens.k Жыл бұрын
I would love to see a server dev series specifically tailored towards game dev. Particularly with subjects like how to efficiently validate collision detection and raycasting from the server side without the availability of a gpu.
@ltstaffel5323
@ltstaffel5323 Жыл бұрын
Collision detection would be the same on the server as on a client/singleplayer game except that when a collision happens (like the player running into a wall) the server would simply disregard any further attempts to walk forwards. Usually servers store the location of every player and when a player presses W it sends a message to the server saying the player wants to move forward. From there the server does collision detection and updates the player's position then sends back the position to the client. This is a little bit of a naive implementation in some ways but that's the idea. Raycasting would not be done server-side because that's purely visual, and servers don't do anything visual if they're well-made. It'd be up to the client to receive a list of the objects in sight of the player from the server and then the client would render and raycast itself.
@simplegamer6660
@simplegamer6660 Жыл бұрын
Why batch/shell scripts? Why lua scripts? Why not to use CMake? CMake + vcpkg workflow is an absolute fire, try it out. All you might need for this is to set a few environment variables besides installing the mentioned apps, and boom, now your C++ has a package manager, like every modern language! No more need in manual copying of dlls, libs and headers, no more booooring project set-up stage where you adding all your dependencies in your VS project settings!
@TheCherno
@TheCherno Жыл бұрын
I’ve tried it out, I hate it
@simplegamer6660
@simplegamer6660 Жыл бұрын
@@TheCherno Why so?
@dave7244
@dave7244 Жыл бұрын
@@simplegamer6660 I use CMake on my own projects and quite frankly it can be a PITA. Build systems in general are pretty crap. At least it isn't JavaScript.
@simplegamer6660
@simplegamer6660 Жыл бұрын
@@dave7244 I wanna ask, if you're using bare cmake, or in conjunction with the vcpkg, because it's like two different worlds: in the first case I'm gonna agree with you, and in the second case I'm curious, because it's working perfectly for me.
@dave7244
@dave7244 Жыл бұрын
@@simplegamer6660 I am relatively new to C++, but I am not new to software development. I dunno what vcpkg is or does, but just looking quickly at the homepage it looks like a dependency manager. I also try to stay away from anything that is built by Microsoft these days. I've tried Conan and it gave me more problems than it really solved. I personally am fed up of dependency managers. I normally either using FetchContent_Declare and the use or just vendor the repo itself as a git submodule and then just tell CMake where to look. It works for that I am doing at the moment. The longer I work in Software Development. The less "clever" I want. I personally might just go back to using Makefiles (I use them with Go/Python already).
@dany4977
@dany4977 Жыл бұрын
Beautiful! thank you for your consistent effort in making your work clean
@sk4d3
@sk4d3 Жыл бұрын
Remembering to correct types on Lib update seems a bit tedious (17:32). I think it could be useful to use static_assert(sizeof(HSteamNetPollGroup )==sizeof(uint32_t)) at the cpp top to check type sizes so it would give a more visible hint (also abstract all HSteamNetPollGroup in hpp with typedef instead of uint32_t to make it easier to update). As the Compiler would simply cast instead of throw an error, no?
@JohnSmith-hi5vy
@JohnSmith-hi5vy Жыл бұрын
Also, it would be even better to use type_traits to check types at compile time. Here's how it would look like: #include static_assert(std::is_same::value, "Type mismatch"); This is much better, as it handles this case: static_assert(sizeof(float) == sizeof(int), "fail"); // fine This option will pass, but this one won't: static_assert(std::is_same::value, "Type mismatch"); // error
@tomaskot9278
@tomaskot9278 Жыл бұрын
Just a small note - there is an alternative way how to forward declare a class that in my opinion in cases like this is more clear and adds less noise to the code. You don't have to say "class ISteamNetworkingSockets;" somewhere at the top of the code, you can just simply add the word "class" in front of the type directly at the place where it is used, so "class ISteamNetworkingSockets* m_Interface = nullptr;"
@and_then_I_whispered
@and_then_I_whispered Жыл бұрын
The forward declaration is better, because the word class in front is a C-style thing I guess and most people don't know about it, which I didn't know either until you mentioned 😂.
@ahmadalastal5303
@ahmadalastal5303 Жыл бұрын
One side note here is that you can't use the forward declared variable before you declare it in the code, that is why I prefer to do it at the top of the file, but sometimes I use it exactly as you said for exactly the same reason you mentioned
@user-dh8oi2mk4f
@user-dh8oi2mk4f Жыл бұрын
I prefer the forward declaration at the top of the code, but to each their own.
@nepp9574
@nepp9574 Жыл бұрын
Makes it more confusing imo. If you use it twice, then one gets it and the other one doesn’t. If you remove one of them, all of a sudden your code stops working. It feels like including header files halfway your code, makes no sense to me. It’s possible but I really don’t see the point.
@tomaskot9278
@tomaskot9278 Жыл бұрын
@@and_then_I_whispered And that's why I wrote the comment, because it is not so widely known (and thus? not so widely used).
@cnb_kevin
@cnb_kevin Жыл бұрын
Autofocus on the camera was a bit distracting. These networking videos are good to have for the future. I do have future game projects that will require Not-Hazel(that's not the name, but it draws some inspiration from Hazel) to support networking. It would be interesting to see how one should handle timeout (let's say a client does not exit gracefully) or if GNS has something for that already.
@nordicus666
@nordicus666 Жыл бұрын
watched first 6 minutes and got a question: how did you solve the problem of receiving message mid-typing your own message in console clients? won't it get split and ruin all visuals? when i was trying to create similar apps in the past - i haven't found a workaround
@contentprogramming
@contentprogramming Жыл бұрын
not 100% sure but , i think you can get full access/control on the console text buffer , so if a new message is received you can take a copy of the typing text , then put the received text in that line , then put back that copy of typing to the next new line 🤔🤔
@mattshu
@mattshu Жыл бұрын
I'm sure you've mentioned this before but can you tell us which font you use for these programming videos? Love this theme and everything!
@koftabalady
@koftabalady Жыл бұрын
Hi, Cherno. when my friend tries to connect to my chat app in Java, it doesn't work or connect him although I gave him my public IP and port. what am I doing wrong?
@ltstaffel5323
@ltstaffel5323 Жыл бұрын
if your friend is not at your house then the issue is most likely port forwarding, which is a setting you need to configure on your home router for the port that your app uses.
@koftabalady
@koftabalady Жыл бұрын
Wow, thanks for replying after all of this time. I forgot I made this comment. but I have read a book about networking and figured the problem out, it was about DMZ. anyways, I appreciate your help even after all of this time...@@ltstaffel5323
@jackpioneer3566
@jackpioneer3566 Жыл бұрын
Is it save to execute callbacks in a different thread? I always use thread-safe queues to store the messages for my main thread and poll them on tick 🤔
@desperateee
@desperateee Жыл бұрын
what theme is he using
@aftostok6080
@aftostok6080 Жыл бұрын
Networking is cool , Can you make a video on how to deploy this server?
@nepp9574
@nepp9574 Жыл бұрын
It is in the previous video.
@SETHthegodofchaos
@SETHthegodofchaos Жыл бұрын
Are we going to look into netcode aka client side prediction and server side rewind?
@that404nerd
@that404nerd Жыл бұрын
Hopefully you will make videos about file i/o ! Great video btw
@herbnord5351
@herbnord5351 Жыл бұрын
What color theme is he using in Visual Studio? I thought it was gruvbox but it seems different though
@MaxMohammadi
@MaxMohammadi Жыл бұрын
Hey Cherno, could you do a crypto or stock screener GUI in C++. That would be a cool portfolio project for quant developers
@Jacksama-o8i
@Jacksama-o8i Жыл бұрын
Before start the video, I want to read the source code and where to get it?
@y4ni608
@y4ni608 Жыл бұрын
Man i hoped so much he would review my game engine when i saw the "Code Review" in the title
@martinprochazka3714
@martinprochazka3714 Жыл бұрын
Actually if you mix up class/struct in forward declaration, g++ won't give a crap and clang will give you a warning that MSVC *doesn't like that* 😂 What's the actual issue with MSVC I have no idea as I don't do Windows. But if someone cares to elaborate you're more than welcome 🙂
@JohnSmith-ze7sv
@JohnSmith-ze7sv Жыл бұрын
Hey Cherno. Question : I'm a dev comming from C# Why do Cpp developers have their own custom typedefs for primative types? If i want an unsigned interger for example - I will simply type 'unsigned int' as opposed to defining a type 'uint32' I know we want all this shorthand for convenience. But if it isn't in the standard library, or as part of the actual language itself - why bother? We just end up with a hundred custom ways of defining the same basic types over and over again. For example you have a typedef of 'ClientID' which is essentially a uint32_t. Why not just leave it there? A ClientID is a uint32.... No need to have it defined as its own type. My main gripe is that In order to find out what data I am passing into an interface I have to look in through all of those typedefs to find out "Oh - it's just an int"
@nbhjbhyvgbhyuvbhuynnjbhu
@nbhjbhyvgbhyuvbhuynnjbhu Жыл бұрын
The primitive types can be different sizes on other platforms. A long is 32 bits on Windows and 64 bits on Linux. If you have to use something like ClientID, it's for semantics but you will always set it with the API that defined it.
@theEndermanMGS
@theEndermanMGS Жыл бұрын
There are a bunch of possible reasons. Semantic type naming (ex: size_t vs unsigned int for indices), making porting easier when you need type sizes to remain consistent across platforms with different primitive sizes, making templates easier to work with (ex: containers all have iterator aliases for convenience), making it easier to change the underlying type if necessary, and so on.
@v01d_r34l1ty
@v01d_r34l1ty Жыл бұрын
The above 2 comments mention the primary reason for it: cross-platform compatibility. 2 additional reasons could be: generalized specifications (not tailored to any specific language) and variable acquisition / usage association. For example 1: OpenGL is a specification, who's to say it has to be implemented in C/C++ instead of say Rust? For example 2: Say you have a couple methods, generateID(uint32_t id) and bindID(uint32_t id). It's pretty obvious how it's used, but who's to say you can't just make up your own ID and try to bind it? Does generateID just kick back a random number or does it have to register something? Not to mention header files do not have to include variable names (relevant to IntelliSense). Instead, having a ClientID type makes it more clear that you have to somehow acquire this specific ClientID instead of just giving a random number. Documentation and comments aren't everything. Code should be self-explaining and this can be a way of doing just that.
@dingoDogMan
@dingoDogMan Жыл бұрын
Hey guys hey great is coffee!! zoom in zoom in coffee is great isnt it?
@bradfry2259
@bradfry2259 Жыл бұрын
I wish I knew what any of this meant, not even sure why I am watching this but it's interesting.
@skypuff
@skypuff Жыл бұрын
This dude is a genius,
@badassopenpolling
@badassopenpolling Жыл бұрын
Hey Cherno - Can you enlighten us with Matching Engineer in C++ which covers Networking, Multithreading and design architectures In my opinios - It would be nice hands on which covers wide variety of C++ with real time problem.
@psinghLD
@psinghLD Жыл бұрын
I am assigned to write exe code, that communicates with web code on server, My task is to call its API or URL to send some data and on the other hand server can request data from me. What are all possible ways to do this bidirectional communication?
@teksatan4699
@teksatan4699 Жыл бұрын
Hm wonder why my comment got deleted. Odd.
@KarabauPlay
@KarabauPlay Жыл бұрын
Communist youtube
@theEndermanMGS
@theEndermanMGS Жыл бұрын
@@KarabauPlaySo a privately-owned company doing capitalism at a massive scale is apparently communist for exercising control over its private property. Make it make sense.
@hassanalmasri3935
@hassanalmasri3935 Жыл бұрын
Please sir,i need help I want to learn OpenGL and i need to link the glfw and glut libraries in order to continue but i am using vsCode and i tried lot's of things on the internet but nth worked. Please can you help me ?
@ouardito
@ouardito Жыл бұрын
Cpp is fun
@ipizza9941
@ipizza9941 Жыл бұрын
This is way to high level for me to understand. Can someone maybe recommend a bit more beginner friendly networking tutorial in c++.
@ipizza9941
@ipizza9941 Жыл бұрын
Did he just say making an instant messaging app is the hello world of networking?
@acidrazor
@acidrazor Жыл бұрын
Geezas christ, I heard "pedo file" several times and were wondering wtf they were and how this sounded..... then I realized he was saying header files. Thank goodness
@anon_y_mousse
@anon_y_mousse Жыл бұрын
Aren't weird accents fun?
@Jkauppa
@Jkauppa Жыл бұрын
sauce code
@Jkauppa
@Jkauppa Жыл бұрын
vs studio makes the code management harder, gcc is better by hand
@Jkauppa
@Jkauppa Жыл бұрын
C is lien
@Jkauppa
@Jkauppa Жыл бұрын
if something is complex, ie too hard, its confusing dev, not helping it, at all
@Jkauppa
@Jkauppa Жыл бұрын
and reason "you need to do this" is nonsense always
@Jkauppa
@Jkauppa Жыл бұрын
whomever do it yourself lmao, yep the work and leave fearing others out
@MrCubo2009
@MrCubo2009 Жыл бұрын
Hey Cherno, I CHALLENGE you to make a programming language in C++, it is an interesting project, could you accept?
@x-root3017
@x-root3017 Жыл бұрын
Please sir may you make a course about git and github 😁👍
@osamaalbanna2200
@osamaalbanna2200 Жыл бұрын
What are your thoughts about Rust?
@anon_y_mousse
@anon_y_mousse Жыл бұрын
If he's like every other intelligent person then he'll think it's garbage.
@lark-6381
@lark-6381 Жыл бұрын
why do you looks like mr beast💀
@craigkinney853
@craigkinney853 Жыл бұрын
Slooooow dooooown.
"Please Tear My Code Apart" // Code Review
46:37
The Cherno
Рет қаралды 47 М.
The Importance of Scalable Code // Code Review
32:10
The Cherno
Рет қаралды 141 М.
Каха и лужа  #непосредственнокаха
00:15
КОГДА К БАТЕ ПРИШЕЛ ДРУГ😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 8 МЛН
Using AI to help me with C++
24:31
The Cherno
Рет қаралды 111 М.
Performance Bottlenecks in My Game Engine
22:45
The Cherno
Рет қаралды 43 М.
Why Didn't He Get the Job? Let's Find Out! // Code Review
27:25
The Cherno
Рет қаралды 146 М.
How I use C++: a line-by-line code review
1:40:40
strager
Рет қаралды 277 М.
I HAD to fix this immediately // Code Review
31:47
The Cherno
Рет қаралды 30 М.
Is this the WORST CODE I've EVER SEEN? // Code Review
24:28
The Cherno
Рет қаралды 67 М.
Why Are Open Source Alternatives So Bad?
13:06
Eric Murphy
Рет қаралды 677 М.
IS THIS SOFTWARE DEV? | Prime Reacts
19:17
ThePrimeTime
Рет қаралды 443 М.
BEST WAY to read and understand code
17:24
The Cherno
Рет қаралды 163 М.
Каха и лужа  #непосредственнокаха
00:15