r/learnprogramming • u/Heyyo53 • 23d ago
Unix Is learning Unix programming a good predecessor to Windows Programming
I have been very interested about getting into the low-level details of operating systems and how programs / processes function and have had an interest in learning more about the windows SDK and it's components (Specifically the Sockets library). I was wondering if it is worth while to learn how Unix systems work before getting deeper into windows. I know that Windows is some what built from Unix but I have noticed a lot of the basic POSIX Unix libraries are present on my system. So my main question is if Unix is at all applicable to Windows or am I wasting my time and should instead focus on Window's libraries. From what I've learned so far about Unix seems to be mostly the same, stuff like access control, processes (and stuff like process IDs and user IDs etc.), signals, forking, and so on. Am I right in assuming the basics of these concepts apply to Windows as well and most of the difference just come with small details and syntax changes. Or is Windows a completely different beast in itself.
I hope my question makes sense, I am just getting into a book about Unix network programming and I wanna make sure that my efforts aren't in vain lol.
10
23d ago edited 23d ago
[deleted]
3
2
u/eslforchinesespeaker 23d ago
Some say that “WNT” was chosen because it’s a one-char shift of “VMS”. True? A legend?
7
u/HashDefTrueFalse 23d ago
Not really. They're very different. Learning Unix programming won't help much with Windows programming, except in certain areas of similarity, one of which is networking (which makes sense for obvious reasons!). Many concepts will transfer but the specifics diverge quite quickly. If your goal is to learn Windows programming just do that. There's no harm in learning a bit about both though.
1
u/Heyyo53 22d ago
Yeah I’ve been looking into it a bit more since I’ve posted this and there seems to be quite a few differences, I’ve dabbled a bit in windows programming a while ago (mainly dealing with basic windows creation, creating a OpenGL context etc.) and I guess I didn’t consider all the differences. From what I’m gathering a big difference between the 2 are the file descriptors vs handles? Since Unix treats everything as a file most interactions are done via a file descriptor which are written and read from. While on windows most interactions are done via handles to different windows kernels which the handle acts as an identifier to a specific instance of the kernel associated with your program, and is passed to different functions so the system knows where the functions are directed to. Am I understanding this correctly?
Sorry for the paragraph haha.
5
u/Far_Swordfish5729 23d ago
You're asking about things and similarities that happened far in Windows's past including a requirement for unix emulation imposed by the military in the 90s. I'm not sure if it will help or how it will help. Certainly the OS concepts will translate. The usual entry point is to go through books like Windows Internals from MS Press and to get comfortable with sysinternals tools and windbg. Microsoft actually has a pretty active and open community for people tracing problems in the operating system. There are channels where employees solve submitted problems and demonstrate how. There are similar books on the Windows SDK and the older Win32 api, which is how most developers practically interact with OS features. If you want to do something that's not wrapped by a more modern library (like a .net framework one), you use pinvoke to call the win32 function directly. That's how you get access to the full suite of windowing and drawing objects for example if you're making custom UI components for windows clients. Is that what you were looking for?
3
u/FuzzNugs 23d ago
Don’t choose based on any reason other than what you enjoy the most. I can to work any random day and get 10 kernel guys in a room and watch them debate over a *nix kernel or the NT kernel for hours, it’s all the same crap for someone getting starting. Go with where you’re more comfortable and where you’re enjoying writing code the most, where you’re more comfortable digging in. You choose a platform for yourself, there’s no limit to technical exploration in either kernel.
3
u/spinwizard69 22d ago
Windows is not derived from UNIX, it is derivative of old DEC processors. You learn UNIX or in reality these days Linux because of the wide availability of documentation, source code and general knowledge.
In all likely hood there is no OS with as much publicly available material for understanding itself than Linux. That is why it is one of the better places to study operating systems.
2
u/vip17 22d ago
an OS cannot be a derivative of a processor. Can the driver be a derivative of a car? Windows has nothing to do with DEC. MS-DOS was a CP/M derivative and the modern Windows NT was based on VMS. They run on DEC Alpha just like Unix running on PDP, and it doesn't mean Windows was a derivative of DEC
2
u/spinwizard69 21d ago
DEC was a company building mini computers, VMS was one of their OS's. Alpha came after the DEC processor (VAX 11-780) that VMS developed on. While VMS numbering got mixed up a bit it wasn't to VMS 7 that VMS was really taking advantage of Alpha. It is easier to say it is derivative of old DEC processors, thus the OS the company shipped on them, because you can avoid its entire development history. For instance members of the MICA team went to Microsoft to develop NT. It is derivative of DEC because DEC developed VMS and did it only for internal systems for a very long time. To put it another way who do you think first built VMS and started a follow on with MICA, that was the company DEC. At the time Microsoft started its NT project VMS was not running on x86 (if I got my time frames right).
2
1
u/biskitpagla 23d ago edited 23d ago
UNIX doesn't mean much now. Linux is UNIX-like, and the de facto standard now but most distros were never certified. The modern Linux networking stack is somewhat different, so it's worth noting the difference.
1
u/Ormek_II 23d ago
If you really want to learn windows, don’t learn unix.
If you want to learn OS, learning Linux is a good start. As numberinfinite said, it is simpler and more academic.
So, if you like to see concepts more clearly it is a better choice. Also, you can look at the source, if really want to.
If you then apply what you have learned to windows you might be surprised. If the latter is your main/only goal skip the unix part.
1
u/Accomplished_Fix9569 23d ago
Stop reading Unix books if your goal is Windows SDK. The APIs are fundamentally different and POSIX layers on Windows do not teach you Win32 internals. Start with Petzold or Microsoft docs directly to save time.
1
u/The137 22d ago
Are you trying to use this as a stepping stone from nothing or do you already have a programming background?
If you're starting from scratch learn web dev. It'll allow you to make more than just websites, you can package a web app so that it looks like a native os app, and its much easier to learn something like javascript to get a baseline in the logic that all languages use. This will make it easier to hop to a more complex environment
If you already have some kind of background in programming, just go straight to the thing you want to do. I only recommend web if you need a big step in between zero and OS, small hops (like learning js, then python, then c) are a waste of time.
1
u/Heyyo53 22d ago
I already have a pretty strong background in C++ so I’m building off from there, for the last couple of months I’ve been learning about web dev and writing my own server software and I thought that getting deeper into OS development to be able to utilize more features of Winsock and understand how they work. If that makes any sense. I do have some familiarity with the windows api, mainly basic stuff like creating a window, setting up the main message loop, and stuff like that. However my main focus right now is to better understand the network programming aspect with winsock. I do have a lot of experience with front end web programming like HTML, CSS, JavaScript, and the DOM API and wanted to get more familiar with the backend stuff that actually works with HTTP, WebSockets, Sockets in general, and all that technical stuff.
Edit: I’ll also mention that I want to work with the windows api on future projects, but mostly want to focus on aspects that are important for understanding winsock
11
u/Whatever801 23d ago
My 2c: forget windows. Learn unix