473,796 Members | 2,916 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why no C++ in Windows itself?

It is a long time now that I am using "Dependency Walker for Win32" and
navigating through different Dlls in "System32" folder to find my target API
functions. The thing I have noticed is that, 'almost' all system .dll and
..exe
files are written in C and not C++. If C++ is a powerful OO language and
it's much greater than C for large application development, then why haven't
Microsoft used it in its operating system? Is there a compatibility issue
here that I am not aware of? Or something else?
---
Thanks for comments

Jul 21 '05 #1
12 1447
Herr Lucifer wrote:
It is a long time now that I am using "Dependency Walker for Win32" and
navigating through different Dlls in "System32" folder to find my target API
functions. The thing I have noticed is that, 'almost' all system .dll and
.exe
files are written in C and not C++. If C++ is a powerful OO language and
it's much greater than C for large application development, then why haven't
Microsoft used it in its operating system? Is there a compatibility issue
here that I am not aware of? Or something else?


How can you tell that they are written in C? Have you examined the
assembler to look for the presence of C++ startup code (such as the
running of global object constructors)? Remember that C++ code need not
dynamically link with the C++ runtime, and it need not present a C++
interface to the outside world.

Tom
Jul 21 '05 #2
The GDI system is written in C++, at least.
Herr Lucifer wrote:
It is a long time now that I am using "Dependency Walker for Win32" and
navigating through different Dlls in "System32" folder to find my target API functions. The thing I have noticed is that, 'almost' all system .dll and .exe
files are written in C and not C++. If C++ is a powerful OO language and
it's much greater than C for large application development, then why haven't Microsoft used it in its operating system? Is there a compatibility issue here that I am not aware of? Or something else?


How can you tell that they are written in C? Have you examined the
assembler to look for the presence of C++ startup code (such as the
running of global object constructors)? Remember that C++ code need not
dynamically link with the C++ runtime, and it need not present a C++
interface to the outside world.

Tom

Jul 21 '05 #3
I don't know what you think of C++, but in its earliest definition, C++ was
called "C with classes". So if there is no class in there, there is no C++
code; it is just pure C....
PS: dependency walker (version 2.1.36668) is able to show functions inside
their classes if their are C++. Take a look if you have VS.NET 2003
-----------------------
"Tom Widmer" <to********@hot mail.com> wrote in message
How can you tell that they are written in C? Have you examined the
assembler to look for the presence of C++ startup code (such as the
running of global object constructors)? Remember that C++ code need not
dynamically link with the C++ runtime, and it need not present a C++
interface to the outside world.

Tom

Jul 21 '05 #4

"Herr Lucifer" <"\n"HerrLucife r\n@microsoft.c om> wrote in message
news:el******** ******@TK2MSFTN GP10.phx.gbl...
I don't know what you think of C++, but in its earliest definition,
C++ was called "C with classes". So if there is no class in there,
there is no C++ code; it is just pure C....
PS: dependency walker (version 2.1.36668) is able to show
functions inside their classes if their are C++. Take a look if
you have VS.NET 2003


If the fundamental Windows API exported classes then surely it would
only be accessible to programs written in C++.

There *is* a version which exports classes - it is called MFC most
of which is a very thin wrapper around the Windows API. [And it
isn't particularly object-oriented.]

Dave
--
David Webber
Author MOZART the music processor for Windows -
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mzusers/mailinglist.htm
Jul 21 '05 #5
Herr Lucifer" <"\n wrote:
It is a long time now that I am using "Dependency Walker for Win32"
and navigating through different Dlls in "System32" folder to find my
target API functions. The thing I have noticed is that, 'almost' all
system .dll and .exe
files are written in C and not C++. If C++ is a powerful OO language
and it's much greater than C for large application development, then
why haven't Microsoft used it in its operating system? Is there a
compatibility issue here that I am not aware of? Or something else?


A great deal of Windows, especially in the user-mode components, is written
in C++. It simply exposes a pure-C API since that's the only ABI
(Application Binary Interface) defined for Windows. A C++ API would not be
callable by any language other than C++.

The Kernel is written almost entirely in C, with a very few bits of
assembler here and there.

-cd
Jul 21 '05 #6
Herr Lucifer wrote:
I don't know what you think of C++, but in its earliest definition, C++ was
called "C with classes". So if there is no class in there, there is no C++
code; it is just pure C....
PS: dependency walker (version 2.1.36668) is able to show functions inside
their classes if their are C++. Take a look if you have VS.NET 2003


Only if they are exported though! The *interface* is C (to allow
interoperabilit y with as many other languages as possible, such as C,
C++, Delphi, VB, etc.), but that doesn't tell you anything about the
language with which the dll is implemented. The DLL code could include
thousands of C++ classes, but the interface still be exposed as pure C.

For example, I've got a C++ DLL that I've written containing lots of
classes but it only exposes a C API (since Java JNI only interacts with
specific exported C functions). Dependency Walker doesn't show the
classes at all, and it doesn't tell you what language was used.

IOW, Dependency Walker is a useless tool for determining what language a
module was implemented with.

Tom
Jul 21 '05 #7
On Wed, 9 Feb 2005 14:07:44 +0330, "Herr Lucifer"
<"\n"HerrLucife r\n@microsoft.c om> wrote:
It is a long time now that I am using "Dependency Walker for Win32" and
navigating through different Dlls in "System32" folder to find my target API
functions. The thing I have noticed is that, 'almost' all system .dll and
.exe
files are written in C and not C++. If C++ is a powerful OO language and
it's much greater than C for large application development, then why haven't
Microsoft used it in its operating system? Is there a compatibility issue
here that I am not aware of? Or something else?
---


IMHO:

For time-critical issues, smaller code size, better memory
consumption, improved control over efficiency, improved code
generation, simpler interface to assembler, and easier debugging
(especially the kernel and low-level code) the guts of Windows are
mostly written in C.

Additionally, much of the Windows (NT) kernel is based on VMS, which
was written in Bliss32 and VAX assembly, which were much easier to
implement as C.

Microsoft's C++ code (for the shell, directx, COM, etc.) are bizarre
and obfuscated anyway. Were Windows internals written in C++, I would
cry.

--
Sev
Jul 21 '05 #8
Severian wrote:
On Wed, 9 Feb 2005 14:07:44 +0330, "Herr Lucifer"
<"\n"HerrLucife r\n@microsoft.c om> wrote:

It is a long time now that I am using "Dependency Walker for Win32" and
navigating through different Dlls in "System32" folder to find my target API
functions. The thing I have noticed is that, 'almost' all system .dll and
.exe
files are written in C and not C++. If C++ is a powerful OO language and
it's much greater than C for large application development, then why haven't
Microsoft used it in its operating system? Is there a compatibility issue
here that I am not aware of? Or something else?
---

IMHO:

For time-critical issues,


Do you mean that C is faster executing? Or that its performance is more
consistent (for a realtime system)? I don't think either statement is
particularly true, though some C and C++ features should be avoided in
code that should run in a bounded amount of time (e.g. no dynamic
allocation, no disk IO, etc.).

smaller code size, better memory consumption,
C does generally produce slightly smaller code, due to the overhead EH
and RTTI in C++. However, both of those may be avoided if desired.

improved control over efficiency,

How so?

improved code generation,
The code generation is generally worse in C, since I believe that type
based alias analysis isn't as good in C. Is there any other respect in
which you think C can generate better code?

simpler interface to assembler,

What do you mean?

and easier debugging (especially the kernel and low-level code)
But macros are far harder to debug than inline functions!

the guts of Windows are mostly written in C.


That I know nothing about, but it certainly sounds true. But I believe
much of the Linux kernel is now written in C++ (as was BeOS). C++ is
primarily a systems programming language - it was specifically designed
for writing OSes (among other things), hence the priniciple of "You
don't pay for what you don't use."

I'd definitely prefer to write an OS in C++ rather than C, and the
resulting OS would probably be faster and better for it (though possibly
not smaller).

Tom
Jul 21 '05 #9
On Thu, 10 Feb 2005 18:07:35 +0000, Tom Widmer
<to********@hot mail.com> wrote:
Severian wrote:
On Wed, 9 Feb 2005 14:07:44 +0330, "Herr Lucifer"
<"\n"HerrLucife r\n@microsoft.c om> wrote:

It is a long time now that I am using "Dependency Walker for Win32" and
navigating through different Dlls in "System32" folder to find my target API
functions. The thing I have noticed is that, 'almost' all system .dll and
.exe
files are written in C and not C++. If C++ is a powerful OO language and
it's much greater than C for large application development, then why haven't
Microsoft used it in its operating system? Is there a compatibility issue
here that I am not aware of? Or something else?
---

IMHO:

For time-critical issues,


Do you mean that C is faster executing? Or that its performance is more
consistent (for a realtime system)? I don't think either statement is
particularly true, though some C and C++ features should be avoided in
code that should run in a bounded amount of time (e.g. no dynamic
allocation, no disk IO, etc.).


Sorry, I wasn't trying to start a language war. I program in both C
and C++, and have seen plenty of good and bad examples of both. I was
comparing well-written C with well-written C++ (not simply C-like code
compiled by a C++ compiler).

But generally, when using the constructs that make C++ a great
language, it is very much simpler to estimate the overhead of C
statements vs. C++ statements. (I'm not talking about C code compiled
by a C++ compiler!)
smaller code size, better memory
consumption,
C does generally produce slightly smaller code, due to the overhead EH
and RTTI in C++. However, both of those may be avoided if desired.


In my experience, you have to know a lot more about C++ (and how it is
implemented on a particular platform) to make it as efficient (memory
and speed-wise) as well-written C.
improved control over efficiency,

How so?
Because, as examples, overloaded operators and virtual functions
introduce non-obvious overhead that is more explicit in C.
improved code
generation,
The code generation is generally worse in C, since I believe that type
based alias analysis isn't as good in C. Is there any other respect in
which you think C can generate better code?


You're probably right, in the general case of compiling simple C++
code; and in some cases (i.e., templates) even when generating complex
code. But once you start using the things that make C++ such a
wonderful language, the generated code tends, in my experience, to
become bloated and wasteful -- and much more difficult to debug.
simpler interface to assembler,

What do you mean?
I am speaking of calling assembly from C++ or vice versa, not inline
assembly, which is quite platform-specific.

One example: since assembly language has no concept of C++ objects,
you have to "deobjectif y" any data you want to access from assembler
(or C for that matter!), or know a lot about how a particular C++
compiler represents objects in memory and write extra assembly
language to work with them.
and easier debugging
(especially the kernel and low-level code)
But macros are far harder to debug than inline functions!


Most modern C compilers include inline functions, though by looking at
code generated by MS and GNU C++, macros are often much more
efficient, and thus often more appropriate for OS code.

The difficulty I was referring to was the semi-invisible things that
C++ does, that require you to know the implementation of classes you
use. Overloaded operators (-> and [] come immediately to mind) make
debugging a loathesome task unless you have access to the source code
for the original class. Even in those cases, it's often difficult to
figure out what exactly is going on behind the scenes.

I've seen well-written C++ code that is a joy to work with, but a lot
more of it is obfuscated (unintentionall y?) to the point of
hair-pulling. Most of Microsoft's C++ falls into the latter category!

When writing C++, I love STL and wish that MS had not tried to make
their own horrid messes first.
the guts of Windows are
mostly written in C.
That I know nothing about, but it certainly sounds true. But I believe
much of the Linux kernel is now written in C++ (as was BeOS). C++ is
primarily a systems programming language - it was specifically designed
for writing OSes (among other things), hence the priniciple of "You
don't pay for what you don't use."


I agree that well-written C++ code (in a _specific_ rather than
generic way) is very appropriate for operating systems, as long as
provisions are made for using the OS API from other languages.
I'd definitely prefer to write an OS in C++ rather than C, and the
resulting OS would probably be faster and better for it (though possibly
not smaller).


I think it boils down to whether the code is well-written or not; the
simpler basis of C makes it easier, in my opinion, to write efficient
and understandable code. That being said, I have worked with and
(hope) I have written efficient and easily maintainable C++ code as
well.

--
Sev
Jul 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
3688
by: sidd | last post by:
Hi All, i have some doubts on .net windows services.. please see if some one could help me understand this.. 1)is it possible to install a windows service which does not have a installer added to it, using installutil.exe OR is it must to have an installer to the service project to be able to
9
7273
by: SP | last post by:
Hi All, I wrote a windows service which is supposed to stop after specified amount of time. I am calling OnStop() after specified time. OnStop() methods executed but I dont see the service stopping. Please advise how to stop the service. Thanks, SP
4
5615
by: Blaxer | last post by:
I have read approximately 30 articles now on various methods to make your vb.net application automatically update itself and I can't see how they apply to a vb.net windows services projects. The goal of the project is to write a windows service in vb.net that runs on many workstations that can automatically update itself from a central web server or share (either or doesn’t matter). I do not want the service to re-install itself each time...
7
362
by: sidd | last post by:
Hi All, i have some doubts on .net windows services.. please see if some one could help me understand this.. 1)is it possible to install a windows service which does not have a installer added to it, using installutil.exe OR is it must to have an installer to the service project to be able to
8
9826
by: =?Utf-8?B?TWlrZVo=?= | last post by:
How Can Windows Service Application Reatarts itself? Thanks.
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10468
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10245
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10205
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9063
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7559
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2933
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.