The Lounge is rated PG. If you're about to post something you wouldn't want your
kid sister to read then don't post it. No flame wars, no abusive conduct, no programming
questions and please don't post ads.
I'd venture to say that Simonyi had at least the second and third of these at his disposal, and he still found Hungarian Notation useful.
He had no more access to documentation at that time than any other developer did.
This is just not true. It's possible to force behavior like that using typecasts (even C# has its little workarounds), but the behavior you're describing is fundamentally opposed to how C actually operates.
C methods do not do type checking. C compilers can use prototypes in headers to do type checking HOWEVER.
1. The prototype must be available.
2. The prototype must be correct.
And the above is irrelevant because it did NOT exist when hungarian was created.
Some of your earlier comments make me think that you believe this to still be the case on modern C compilers
And your comments make me think that you forgot the point of the thread.
At one time there were non-trivial problems for which hungarian notation seemed to offer something like a solution.
NOW, especially with languages created after C, some of the problems do NOT exist. And the remaining problems, even the rationalized ones, are trivial.
In item 1, what you're saying is that the people who actually have to deal with ambiguous Windows API types are just so knowledgeable that they don't need Hungarian Notation
Something is wrong with that statement. When you are writing a wrapper for the first time you are looking at the windows API methods. If you find that it is ambiguous when you are looking at the documentation itself then that is another discussion. So, I can only suppose that you are referring to the hungarian notation that Microsoft uses in their API. Which has nothing to do with my point. My point is about the code that you write to create the wrapper. You don't need to create new hungarian named id variables at that time to understand the Microsoft API.
They faced the same basic issues of type ambiguity,
I wrote C code for years before there was an ANSI standard. I know exactly what sort of ambiguities could arise from using others APIs as well as using my own.
And no the same problems do not exist now. Not even in C. And most definitely not in C#, C++ and Java.
Did they just do something silly, that you don't agree with?
I suggest that you re-read what I said. I didn't say it was silly then. And I used it then. The only problem then was that just as it was being widely popularized C++ was rapidly gaining ground and C++ always did do explicit method type checks. I continued to use it will C++ for a number of years until I realized there was no point.
...They are still not complete in their attempts to resolve the type ambiguity issues of the Windows API, though. If you hover over a method name in Visual Studio, for example, and see "IntPtr,"
Which of course is completely missing my original point. If you need to use a API method - create a wrapper. Then you would never be hovering over a IntPtr in the first place.
Beyond that, all of these notions that some fundamental change has occurred (e.g. that C didn't check parameter types, whereas new languages do) are just not correct.
You are mistaken.
C99 required function prototypes. C90 did not but allowed them. Before that compilers were free to do what they wanted but as C90 neared finalization they tended towards that standard of inferring one - but BASED on the parameters of the first usage.
Microsoft C 3.0 was released in 1985, the same year as Windows 1.0, and it supported function prototypes.
Which doesn't alter the fact that the use was entirely optional. So if you didn't include the header your code still worked - if you got the call correct.
And are you sure that that version of windows did parameter validation? There is a difference between validating the method and validating the parameters.
Your assertion that Hungarian Notation is basically an outgrowth of the pre-ANSI "K&R" C language is an interesting one (and it might even have been true for you, if you didn't have access to Microsoft C 3.0) but it's not backed up by actual history.
I used Microsoft C version 3.0.
Simonyi joined Microsoft in 1981. Simonyi came up with the idea before joining Microsoft.
Are you claiming that prototypes were widely available before 1981 and Simonyi developed hungarian notation despite that?
Others who think that hungarion notation is no longer useful.
When .NET code wants to call an API function, it's necessary to prototype the API function in the .NET language. The developer writing the prototype gets to select the names of the formal parameters. This developer should select names that are meaningful (even if you don't think these DLLImport declarations will be worked with very often).
So in terms of prototyping the the pinvoke method itself - the developer should choose a name that most closely mimics that of the documentation for the method itself. Regardless of what that name is.
Hungarian Notation seems like the obvious way to do this
The obvious way is to use exactly the same name as that used in the documentation for the method.
Then .NET code (likely a wrapper) must be written around these DLLImport declarations. This code will presumably declare IntPtr variables to pass into the Windows API functions
Nope. Not as parameters into the wrapper itself. It might need to use a IntPtr but in that case
1. The wrapper should paass appropriate C#/.Net data types to the method.
2. The method constructs a IntPtr using the passed in values as appropriate.
The above limits the scope of the IntPtr to the wrapper method itself. It is not visible outside the wrapper.
, and one can either use Hungarian Notation or avoid it. The issue is still there, though.
Nope. The scope of the code makes it obvious that one is constructing a data type like an IntPtr and how one is using it, the method only, means it need do nothing else special. One isn't "avoiding" it because the local scope makes it obvious. A more meaningful name choice is one that reflects the nature of the parameter that the IntPtr represents.
That seems like a very odd (and uncommon) way to write code. I can't imagine too
many people did that.
Quite easy for me to think that people forgot to include them.
Quite easy for me to think that, because they were optional, that some developers would consider them unnecessary and thus intentionally leave them out.
And I am sure that Simonyi's variable-naming style (which is all this really is)
evolved over his entire career.
Which is regardless of the point that it originated before he joined Microsoft and also that the original popularzation occurred very early.
"He developed the Hungarian notation convention for naming variables. These standards were originally part of his doctoral thesis."
"He received his Ph.D. in computer science from Stanford in 1977 with a dissertation on a software project management..."
Regardless, you're facing the same issues Windows 1.0 application developers
I just re-read the entire thread. Again what I said was that if you need to use a C API method then you wrap it.
If there is any exposure from that point then parameters that are passed are NOT interop types but are in instead .Net types. Requirements vary but pinvoke method usage is often simple and thus the only need for those types is to expose the functionality the rest of the .Net application via an API that takes C# native types. So there are no IntPtrs.
If more complexity in the API into the functional layer is required then it should definitely represent .Net native types because the layer API should not be a direct map to the C API (otherwise it would be a simple mapping or require additional mapping.)
Your statements however appear to be about local scope usage only. Again if it was me I would probably mimic the parameter names that appear ni the C API. And that has nothing to do with the hungarian notation that the names might or might not have but is instead based on the documented name any nothing else. Why someone else chose that name is irrelevant to why I use it.
Having been using Windows 8 for the past couple months, I wouldn't say I agree. Sure, it is a paradigm shift, just like Windows 95 was but it isn't horrible. Once you figure out that the start menu is now full-screen (the Metro desktop), things become a lot clearer. Personally, I hate going back to Windows 7 now (it took me a few weeks before I could say that). Search is amazing, the integration of touch is actually really helpful, and the metro app look and feel (full screen, no menus visible, etc.) actually works. There is a lot left to do to get it right, but it is a great attempt at a new way of looking at the PC/tablet/phone.
You cannot innovate if you aren't willing to leave the safety of the known behind. Iteration is not true innovation.
I tried it on a desktop without a touch screen - who the heck wants a touch screen, if you can't use a keyboard and mouse you should use a track-pad or track-ball. ...I use my phone to make phone calls - and I refused the touch screen version as you never know if you are going to call something expensive from your back pocket!
Windows 8 was a pain on a regular PC like most people have - I would detail the ways but it doesn't rate the effort, especially since so many others have covered them.
Windows 7 rocks!
- Life in the fast lane is only fun if you live in a country with no speed limits.
- Of all the things I have lost, it is my mind that I miss the most.
- I vaguely remember having a good memory...
Yes, the RS4 had just left my house off to pastures new. Guy came up from Leeds (350 miles away) on the train this morning. Checked over the car, happy it was as discussed, transferred the funds, and left a happy bunny. It has been an awesome car over the last 5 years and sad to see it go.
But hey, it is only a car and still have the Merc!
Now just need to resist all temptation to spend the money now!