You can do stuff like putting callbacks on a handle to do async-io when you have a pointer to work with.
You can do stuff like putting callbacks on a handle to do async-io when you have a pointer to work with.
The main difference I know of is that file descriptors are sequential, while handles are random. That is, a function like open() will always return the lowest-numbered available file descriptor, while CreateFile() can return any available handle.
Other than that, both are basically identical as far as I know: both are just keys to an in-kernel table which points to the real object.
Is it an API guarantee, or just an irrelevant implementation detail?
"[...] atomically allocate the lowest numbered available (that is, not already open in the calling process) file descriptor [...]"
One small detail is that HANDLE covers more things with the same table. So for example, a process, a thread, a cross-process semaphore or mutex - those are handles, whereas Unix-like systems have different types for each of those (pid_t, pthread_t, sem_t, etc.).
But then Linux started introducing fds as synchronization primitives too - like signalfd(2) or eventfd(2).
One of the more annoying things about Windows handles is there is no equivalent of dup2(2) - you can't swap the kernel object of an existing HANDLE with another existing HANDLE. This makes imitating certain unix idioms involving redirecting I/O after the process has already started kind of clumsy.
[Worth noting in a discussion of the HANDLE typedef that the type is literally a void pointer, and some user-mode code abuses that to make them pointers to heap objects instead of a proper kernel handle - for example FindFirstFile()'s handle is not a true kernel handle, which is for example why you need to close it with FindClose and not the normal way to close handles.]
Was this difference so good that it was incorporated on other platforms?
I really liked the idea of the PowerShell, but somehow it felt to me that it never really became "a thing" and the Windows Subsystem for Linux move from MS felt like they gave up on the whole shell thing in the end. :\
The PS and WSL story seemed like they tried to do better but gave up.
But what can I say, I'm no Windows guy, just talking from an outside view :)
The PowerShell story is pretty simple: a cross-platform, object oriented shell. Having used it, I attempted to locate a similar Linux solution, to no avail. I'm tired of cutting text and object translation makes my life a great deal more straightforward.
As for WSFL, it seems "Windows can run everything. Docket support is stellar" is a much more likely story than "we gave up and are slowly becoming Linux with a GUI".
I like Bash but writing anything remotely complex in it is... not recommended
Yes, it's very popular with Windows sysadmins, which is more or less who it was designed for.
This included the object-oriented nature of PowerShell. The ones who have fully accepted that it is a command line wrapper for .Net like it way better than they did when they were trying to use it as a crappy version of bash.
I, on the other hand, routinely astound them with my ignorance about the brave new world of build tools that assume that you have constant access to the internet (among many other points of my ignorance).
I'm now trying to get re-accustomed to Unix-style command line tools, and it's irritating as anything not to be able to ().somepropertyname to get exactly what I want :)
We're generally not as publicly chatty as developers, and don't tend to do Windows platform admin as a hobby. We have varying levels of programming experience.
For us, PowerShell has been nothing short of miraculous, though some people are put off by anything that's not a GUI. It's a shallow initial learning curve and easy enough for semi-automating some very repetitive user management tasks. The more skilled scripters can switch pretty easily into C# once they need the performance, because they already understand the .Net framework from mucking around with it in PowerShell.
And if you're ever at a small conference where Jeffrey Snover is speaking, say hi - he's generally eager to talk with PowerShell users.
It hasn't really taken off outside of Windows. Unless you're in a mostly Windows environment, PowerShell on the Mac or on Linux doesn't make a lot of sense.