473,322 Members | 1,494 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Simple Question I hope

Airslash
221 100+
Hello,

Perhaps it might seem a silly question to some but I want to know the following:

I'm handy with C++. I won't claim to be an expert, but I can get most common things done in C++. Now I want to focus a bit more on C itself.

I've tried getting my hands on the C manual book, but unfortunalty they bookstore couldn't get it anymore.

So my little question is : how hard is it to switch to learning and using C if you're moderate in C++ ?
Aug 20 '08 #1
14 1348
newb16
687 512MB
What for? Working on legacy project or on legacy compiler that doesnt support c++? I for one never worked on pure C projects, but it seems to be rather annoying than difficult - no containers, no strings, just pointers and in-house containers if any. And no "for(int i=0; ... )" stuff.
Aug 20 '08 #2
r035198x
13,262 8TB
How hard it is depends on the person I suppose. Get yourself a copy of the standard ...
Aug 20 '08 #3
arnaudk
424 256MB
I went from C to C++ and it beats me why you'd want to do the opposite, it's like trading your Aston Martin for a Mini. However, the standard book for C is "The C Programming Language", 2nd ed. by Kernighan and Ritchie.
Aug 20 '08 #4
Airslash
221 100+
The reason I'm asking this, is because I want to have more understanding about some points, mostly due programming for the gaming industry.

But thanks for the anwsers so far, it's given me a good understanding of the issue
Aug 20 '08 #5
Banfa
9,065 Expert Mod 8TB
I went from C to C++ and it beats me why you'd want to do the opposite, it's like trading your Aston Martin for a Mini. However, the standard book for C is "The C Programming Language", 2nd ed. by Kernighan and Ritchie.
C has it's place but that is mostly low level, micro-processor platforms that don't support C++, operating systems still tend to be written in C rather than C++.
Aug 20 '08 #6
weaknessforcats
9,208 Expert Mod 8TB
I have no idea why you would use C if you know C++.

If you just use the C features in C++, you have C.

The reason C++ was developed was to replace C.
Aug 20 '08 #7
arnaudk
424 256MB
operating systems still tend to be written in C rather than C++.
Correct me if I'm wrong, but I always assumed the only reason for this was a historical one.
Aug 20 '08 #8
boxfish
469 Expert 256MB
I thought C was used for operating systems because it's faster than C++, and that being object oriented was what made C++ slow. Not that C++ is slow.
Aug 20 '08 #9
arnaudk
424 256MB
I thought C was used for operating systems because it's faster than C++, and that being object oriented was what made C++ slow. Not that C++ is slow.
I used to think the same thing but now I'm convinced that properly written C++ code is not noticeably slower than C code. In some rare cases, this might mean you should avoid the runtime overhead of certain OO features (like polymorphism which incurrs vtable lookups in favour of compile-time polymorphism through the use of templates, for example) but this doesn't mean C++ is generally any slower, though.
Aug 20 '08 #10
Banfa
9,065 Expert Mod 8TB
Correct me if I'm wrong, but I always assumed the only reason for this was a historical one.
My understanding is there is (or has been a big debate raging as to whether C++ should be allowed in the Linux Kernel.

The closest I can seem to come up with at the moment is

[quote=http://kernelbook.sourceforge.net/kernel-hacking.pdf]Using C++ in the kernel is usually a bad idea, because the kernel does not provide the necessary runtime
environment and the include files are not tested for it. It is still possible, but not recommended. If you
really want to do this, forget about exceptions at least.
[/code]

The target platform(s) for the OS is likely to have some effect on the decision, for instance it would be foolish to write a portable lite OS aimed at micro controllers in C++ since that particular group of processors are the ones where you still find C compilers but no C++ compilers in some instances.

Other reasons I can see for using C rather than C++ are complexity. It is easy to think of the difference between C and C++ as small, C++ is just C with classes. But this is wrong (and is also what leads to the vast number of C programmers who think they can program C++ when in fact all they know is the slightly altered syntax). C++ is actually vastly more complex than C, which is of course one of the reasons it is more powerful.

C++ does not have all the problems and pits falls that C does, but that doesn't mean it is perfect, it has it's own problems and pitfalls and it is just as it is possible to shoot yourself in the foot with C if it is not used correctly so it is equally possible to do it with C++ if not used correctly just in more interesting and esoteric ways.

However because C is less complex than C++ it is (IMO necessarily) easier to test the codes hardness or robustness which say in military project would have a high importance.

I readily admit that none of these sound like particularly strong reasons for using C rather than C++ for an OS (apart from lack of a C++ compiler for the platform in question) but I can only say that I have had contact with 5 - 10 OSs during my career so far and without exception all of them were written in C.

However if you search for OSs written in C++ using Google you will find some although they appear relatively new projects, not particularly well developed.

I imaging that history is something to do with this, OSs have been around longer than C++ (and C for that matter) the ones people know well have had time to develop and mature. Perhaps it is simply that when the foundations of these OSs (1991 for Linux) where laid down C++ was not mature enough to be considered as a option for writing the OS. Maybe in 10 years time OSs in C will be the exception rather than the rule.


Anyone Want to start a "Lets Write and Operating System in C++" thread?
Aug 20 '08 #11
Airslash
221 100+
No thanks... :)

tried it once on a different forum and the result was actually a big fight instead of usable code coming from it
Aug 20 '08 #12
JosAH
11,448 Expert 8TB
Anyone Want to start a "Lets Write and Operating System in C++" thread?
The Symbian OS was written in C++ and it is a wonderful little and elegant OS.
Those folks who wrote it certainly knew what they were doing.

kind regards,

Jos
Aug 20 '08 #13
Banfa
9,065 Expert Mod 8TB
The Symbian OS was written in C++ and it is a wonderful little and elegant OS.
Those folks who wrote it certainly knew what they were doing.
Excellant :D I will have to investigate I have to admit to assuming Symbian was a Linux/Unix variant.
Aug 20 '08 #14
Banfa
9,065 Expert Mod 8TB
tried it once on a different forum and the result was actually a big fight instead of usable code coming from it
Don't worry I wasn't serious it was a oblique reference to a "I'm Writting an OS in Visual Basic, who wants to join in" thread we had on this forum once.
Aug 20 '08 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Patchwork | last post by:
Hi Everyone, Please take a look at the following (simple and fun) program: //////////////////////////////////////////////////////////////////////////// ///////////// // Monster Munch, example...
4
by: ³\¥\»\ | last post by:
I have reviewed all famous and mature CMS but there are ALL too complicated, too fancy and the result is that you can not totally control what you want in your website. I hope there is a CMS with:...
6
by: francisco lopez | last post by:
ok , first of all sorry if my english is not so good, I do my best. here is my problem: I don´t know much javascript so I wrote a very simple one to validate a form I have on my webpage. ...
7
by: Jim H | last post by:
I'm new to gui programming. I'm just doing some testing with forms. I've dropped a com control on a form. When a user clicks and holds the mouse down on the control I'd like to drag the form...
5
by: Stephanie_Stowe | last post by:
Hi. I am trying to get used to AS.NET. I have been doing ASP classic for years, and am now in a position to do ASP.NET. I am in the stumbling around until I get my bearings phase. I hope you will...
6
by: Brian | last post by:
Hello, I am using a beginners book on VB .net and already stumped....when using this code (below) , it will tell me that MsgBox is not valid. This is a very simple program and I can't figure out...
6
by: kamazoo | last post by:
I have no programming experience whatsoever, but nevertheless am I currently responsible for an update of a website, where a few hotels can be booked using an orderform. The website is built with...
1
by: tomer.ha | last post by:
Hi there, I'd like to send emails from a Python program using Simple MAPI. I've tried this code: http://mail.python.org/pipermail/python-list/2004-December/298066.html and it works well with...
6
kenobewan
by: kenobewan | last post by:
Congratulations! You are one of the few who realise that over 80% of errors are simple and easy to fix. It is important to realise this as it can save a lot of time. Time that could be wasted making...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.