Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #85804 > unrolled thread
| Started by | NOSPAM.Alan.Beck@darkrealms.ca (Alan Beck) |
|---|---|
| First post | 2022-08-08 09:43 +0000 |
| Last post | 2022-08-27 23:15 -0700 |
| Articles | 20 on this page of 114 — 19 participants |
Back to article view | Back to comp.lang.c++
To C or not to C++ NOSPAM.Alan.Beck@darkrealms.ca (Alan Beck) - 2022-08-08 09:43 +0000
Re: To C or not to C++ Paavo Helde <eesnimi@osa.pri.ee> - 2022-08-08 20:02 +0300
Re: To C or not to C++ Juha Nieminen <nospam@thanks.invalid> - 2022-08-09 05:38 +0000
Re: To C or not to C++ Ralf Fassel <ralfixx@gmx.de> - 2022-08-09 11:07 +0200
Re: To C or not to C++ Manfred <noname@add.invalid> - 2022-08-10 02:25 +0200
Re: To C or not to C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-08-09 17:52 -0700
Re: To C or not to C++ Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2022-08-09 21:39 -0700
Re: To C or not to C++ Muttley@dastardlyhq.com - 2022-08-10 07:45 +0000
Re: To C or not to C++ scott@slp53.sl.home (Scott Lurndal) - 2022-08-10 19:50 +0000
Re: To C or not to C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-08-10 13:13 -0700
Re: To C or not to C++ Manfred <noname@add.invalid> - 2022-08-11 04:29 +0200
Re: To C or not to C++ Juha Nieminen <nospam@thanks.invalid> - 2022-08-10 02:41 +0000
Re: To C or not to C++ Muttley@dastardlyhq.com - 2022-08-10 07:39 +0000
Re: To C or not to C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-08-10 10:11 -0700
Re: To C or not to C++ Muttley@dastardlyhq.com - 2022-08-12 08:23 +0000
Re: To C or not to C++ Juha Nieminen <nospam@thanks.invalid> - 2022-08-12 12:12 +0000
Re: To C or not to C++ Muttley@dastardlyhq.com - 2022-08-12 14:41 +0000
Re: To C or not to C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-08-12 12:09 -0700
Re: To C or not to C++ David Brown <david.brown@hesbynett.no> - 2022-08-13 10:28 +0200
Re: To C or not to C++ Muttley@dastardlyhq.com - 2022-08-13 09:37 +0000
Re: To C or not to C++ Paavo Helde <eesnimi@osa.pri.ee> - 2022-08-12 15:55 +0300
Re: To C or not to C++ Muttley@dastardlyhq.com - 2022-08-12 14:43 +0000
Re: To C or not to C++ Paavo Helde <eesnimi@osa.pri.ee> - 2022-08-12 18:07 +0300
Re: To C or not to C++ Muttley@dastardlyhq.com - 2022-08-12 15:14 +0000
Re: To C or not to C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-08-12 12:11 -0700
Re: To C or not to C++ Muttley@dastardlyhq.com - 2022-08-13 09:38 +0000
Re: To C or not to C++ David Brown <david.brown@hesbynett.no> - 2022-08-13 17:56 +0200
Re: To C or not to C++ Paavo Helde <eesnimi@osa.pri.ee> - 2022-08-24 11:32 +0300
Re: To C or not to C++ Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-08-24 11:33 +0100
Re: To C or not to C++ Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2022-08-24 04:37 -0700
Re: To C or not to C++ Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-08-24 13:31 +0100
Re: To C or not to C++ Muttley@dastardlyhq.com - 2022-08-24 14:09 +0000
Re: To C or not to C++ Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-08-24 15:31 +0100
Re: To C or not to C++ Muttley@dastardlyhq.com - 2022-08-24 14:38 +0000
Re: To C or not to C++ Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-08-24 15:57 +0100
Re: To C or not to C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-08-24 10:41 -0700
Re: To C or not to C++ Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-08-24 21:48 +0100
Re: To C or not to C++ "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2022-08-25 07:34 +0200
Re: To C or not to C++ Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-08-25 11:29 +0100
Re: To C or not to C++ Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2022-08-25 04:14 -0700
Re: To C or not to C++ Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-08-25 12:36 +0100
Re: To C or not to C++ Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2022-08-25 05:16 -0700
Re: To C or not to C++ Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-08-25 17:16 +0100
Re: To C or not to C++ David Brown <david.brown@hesbynett.no> - 2022-08-25 20:35 +0200
[OT] Bad CS course, no cookie (Was: To C or not to C++) Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-08-25 21:32 +0100
Re: [OT] Bad CS course, no cookie (Was: To C or not to C++) David Brown <david.brown@hesbynett.no> - 2022-08-25 23:16 +0200
Re: [OT] Bad CS course, no cookie Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-08-26 00:33 +0100
Re: [OT] Bad CS course, no cookie David Brown <david.brown@hesbynett.no> - 2022-08-26 10:39 +0200
Re: [OT] Bad CS course, no cookie Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-08-26 10:57 +0100
Re: [OT] Bad CS course, no cookie David Brown <david.brown@hesbynett.no> - 2022-08-26 12:49 +0200
Re: To C or not to C++ Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2022-08-25 19:56 -0700
Re: To C or not to C++ David Brown <david.brown@hesbynett.no> - 2022-08-26 10:47 +0200
Re: To C or not to C++ Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2022-08-26 02:48 -0700
Re: To C or not to C++ David Brown <david.brown@hesbynett.no> - 2022-08-26 13:02 +0200
Re: To C or not to C++ Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2022-08-26 04:57 -0700
Re: To C or not to C++ David Brown <david.brown@hesbynett.no> - 2022-08-26 14:55 +0200
Re: To C or not to C++ Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2022-08-26 06:20 -0700
Re: To C or not to C++ Manfred <noname@add.invalid> - 2022-08-27 18:44 +0200
Re: To C or not to C++ David Brown <david.brown@hesbynett.no> - 2022-08-28 11:30 +0200
Re: To C or not to C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-08-25 10:06 -0700
Re: To C or not to C++ Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2022-08-25 10:32 -0700
Re: To C or not to C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-08-25 11:36 -0700
Re: To C or not to C++ David Brown <david.brown@hesbynett.no> - 2022-08-25 20:47 +0200
Re: To C or not to C++ Manfred <noname@add.invalid> - 2022-08-26 03:11 +0200
Re: To C or not to C++ David Brown <david.brown@hesbynett.no> - 2022-08-25 09:21 +0200
Re: To C or not to C++ scott@slp53.sl.home (Scott Lurndal) - 2022-08-25 12:58 +0000
Re: To C or not to C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-08-25 10:23 -0700
Re: To C or not to C++ David Brown <david.brown@hesbynett.no> - 2022-08-25 20:51 +0200
Re: To C or not to C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-08-25 12:14 -0700
Re: To C or not to C++ scott@slp53.sl.home (Scott Lurndal) - 2022-08-24 13:56 +0000
Re: To C or not to C++ Paavo Helde <eesnimi@osa.pri.ee> - 2022-08-24 17:18 +0300
Re: To C or not to C++ Muttley@dastardlyhq.com - 2022-08-24 14:25 +0000
Re: To C or not to C++ scott@slp53.sl.home (Scott Lurndal) - 2022-08-12 16:46 +0000
Re: To C or not to C++ Juha Nieminen <nospam@thanks.invalid> - 2022-08-15 06:16 +0000
Re: To C or not to C++ Muttley@dastardlyhq.com - 2022-08-15 19:01 +0000
Re: To C or not to C++ Bo Persson <bo@bo-persson.se> - 2022-08-15 22:22 +0200
Re: To C or not to C++ David Brown <david.brown@hesbynett.no> - 2022-08-16 08:48 +0200
Re: To C or not to C++ Muttley@dastardlyhq.com - 2022-08-16 19:19 +0000
Re: To C or not to C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-08-16 12:56 -0700
Re: To C or not to C++ Muttley@dastardlyhq.com - 2022-08-17 18:47 +0000
Re: To C or not to C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-08-17 14:49 -0700
Re: To C or not to C++ Muttley@dastardlyhq.com - 2022-08-18 14:49 +0000
Re: To C or not to C++ Manfred <noname@add.invalid> - 2022-08-19 03:10 +0200
Re: To C or not to C++ d thiebaud <thiebauddick2@aol.com> - 2022-08-18 22:12 -0400
Re: To C or not to C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-08-18 20:08 -0700
Re: To C or not to C++ Muttley@dastardlyhq.com - 2022-08-19 10:39 +0000
Re: To C or not to C++ Juha Nieminen <nospam@thanks.invalid> - 2022-08-17 06:45 +0000
Re: To C or not to C++ Muttley@dastardlyhq.com - 2022-08-17 18:48 +0000
Re: To C or not to C++ Muttley@dastardlyhq.com - 2022-08-16 19:16 +0000
Re: To C or not to C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-08-12 12:03 -0700
Re: To C or not to C++ David Brown <david.brown@hesbynett.no> - 2022-08-10 10:13 +0200
Re: To C or not to C++ Manfred <noname@add.invalid> - 2022-08-11 04:25 +0200
Re: To C or not to C++ Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2022-08-11 01:03 -0700
Re: To C or not to C++ Juha Nieminen <nospam@thanks.invalid> - 2022-08-11 08:11 +0000
Re: To C or not to C++ David Brown <david.brown@hesbynett.no> - 2022-08-11 13:53 +0200
Re: To C or not to C++ Manfred <noname@add.invalid> - 2022-08-13 04:13 +0200
Re: To C or not to C++ David Brown <david.brown@hesbynett.no> - 2022-08-13 21:13 +0200
Re: To C or not to C++ Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2022-08-13 12:29 -0700
Re: To C or not to C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-08-13 13:12 -0700
Re: To C or not to C++ David Brown <david.brown@hesbynett.no> - 2022-08-14 00:44 +0200
Re: To C or not to C++ Öö Tiib <ootiib@hot.ee> - 2022-08-12 02:54 -0700
Re: To C or not to C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-08-12 12:12 -0700
Re: To C or not to C++ Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2022-08-12 16:22 -0700
Re: To C or not to C++ Öö Tiib <ootiib@hot.ee> - 2022-08-12 17:49 -0700
Re: To C or not to C++ Manfred <noname@add.invalid> - 2022-08-13 03:16 +0200
Re: To C or not to C++ Öö Tiib <ootiib@hot.ee> - 2022-08-13 09:08 -0700
Re: To C or not to C++ Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-08-15 14:44 -0700
Re: To C or not to C++ Ralf Fassel <ralfixx@gmx.de> - 2022-08-10 12:06 +0200
Re: To C or not to C++ Juha Nieminen <nospam@thanks.invalid> - 2022-08-11 07:04 +0000
Re: To C or not to C++ Bonita Montero <Bonita.Montero@gmail.com> - 2022-08-09 12:31 +0200
Re: To C or not to C++ Muttley@dastardlyhq.com - 2022-08-09 15:59 +0000
Re: To C or not to C++ Frederick Virchanza Gotham <cauldwell.thomas@gmail.com> - 2022-08-19 04:09 -0700
Re: To C or not to C++ "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-08-13 12:17 -0700
Re: To C or not to C++ "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-08-27 23:15 -0700
Page 1 of 6 [1] 2 3 4 5 6 Next page →
| From | NOSPAM.Alan.Beck@darkrealms.ca (Alan Beck) |
|---|---|
| Date | 2022-08-08 09:43 +0000 |
| Subject | To C or not to C++ |
| Message-ID | <2868500762@darkrealms.ca> |
//Hello All,// I decided I wanted to learn C programming so I can solve problems with software instead of hardware. I have an arduino and am learning it. Shouod I be learing C,C++ or Arduino "sketch" language. I have books for all three.l Thand beforo hand Regards, Alan Beck
[toc] | [next] | [standalone]
| From | Paavo Helde <eesnimi@osa.pri.ee> |
|---|---|
| Date | 2022-08-08 20:02 +0300 |
| Message-ID | <tcrfk0$vvq4$1@dont-email.me> |
| In reply to | #85804 |
08.08.2022 09:43 Alan Beck kirjutas: > > //Hello All,// > > I decided I wanted to learn C programming so I can solve problems with > software instead of hardware. > > I have an arduino and am learning it. > > > Shouod I be learing C,C++ or Arduino "sketch" language. > The wikipedia page for Arduino says it can be programmed either in C or C++, and "sketch" seems to be a specific C or C++ program composed in Arduino IDE. So it looks like you will probably need Sketch and either C or C++. When choosing, note that C is at least 10 times smaller and easier to learn than C++, but this also means you will need to make everything by yourself. You can think of C as a hand saw and C++ as a lathe machine. In principle you can make everything with a hand saw, it just takes more effort, whereas using machines means more initial investments.
[toc] | [prev] | [next] | [standalone]
| From | Juha Nieminen <nospam@thanks.invalid> |
|---|---|
| Date | 2022-08-09 05:38 +0000 |
| Message-ID | <tcsrs5$tnp$1@gioia.aioe.org> |
| In reply to | #85804 |
Alan Beck <NOSPAM.Alan.Beck@darkrealms.ca> wrote: > //Hello All,// > > I decided I wanted to learn C programming so I can solve problems with > software instead of hardware. > > I have an arduino and am learning it. > > Shouod I be learing C,C++ or Arduino "sketch" language. I suppose it depends on the kind of programming you would be doing. The syntax and standard library of C may be the quickest to learn because it's not very large. And C as a programming language is quite ok for many types of application. However, because of its bare-minimum simplicity some things are extraordinarily hard and/or tedious (and error-prone) to do with it (especially when it comes to dynamic memory management and generic data containers. The more complicated the dynamic data container, the more difficult, tedious and error-prone it will be to do in C. Not all applications need such containers, though, so it depends.) C++ is a significantly larger language, with a significantly larger syntax and standard library. However, in terms of efficiency it has nothing to lose to C, and many things are much easier and safer to do with it (the standard library provides many generic dynamic data containers that are quite easy to use and which handle dynamic memory allocation and deallocation automatically, without you having to bother, as long as you follow a few rules). There are many things that are much easier to do in C++ than in C. (The other way around doesn't really exist because pretty much anything you can do in C you can also do in C++ in the exact same way, or extremely similar way.) On the other hand, the amount of documentation on syntax and standard library is vastly larger. So there are pros and cons. I have never even heard of the "sketch" language so I can't comment. If I had to make a completely wild guess it's probably some kind of "higher-level" language with its own pros and cons compared to both C and C++.
[toc] | [prev] | [next] | [standalone]
| From | Ralf Fassel <ralfixx@gmx.de> |
|---|---|
| Date | 2022-08-09 11:07 +0200 |
| Message-ID | <ygah72lu6nv.fsf@akutech.de> |
| In reply to | #85807 |
* Juha Nieminen <nospam@thanks.invalid> | I have never even heard of the "sketch" language so I can't comment. | If I had to make a completely wild guess it's probably some kind of | "higher-level" language with its own pros and cons compared to both | C and C++. On the Arduino, you usually only write the loop() (in C/C++) which handles incoming events, plus interrupt functions etc, whereas main() is provided by the IDE. This code piece is called a 'sketch', which you compile and download to the arduino. R'
[toc] | [prev] | [next] | [standalone]
| From | Manfred <noname@add.invalid> |
|---|---|
| Date | 2022-08-10 02:25 +0200 |
| Message-ID | <tcutte$11jl$1@gioia.aioe.org> |
| In reply to | #85810 |
On 8/9/2022 11:07 AM, Ralf Fassel wrote: > * Juha Nieminen <nospam@thanks.invalid> > | I have never even heard of the "sketch" language so I can't comment. > | If I had to make a completely wild guess it's probably some kind of > | "higher-level" language with its own pros and cons compared to both > | C and C++. > > On the Arduino, you usually only write the loop() (in C/C++) Note that the expression (C/C++) is considered a Bad Word nowadays. The fact is that, even if in principle a C code fragment can be compiled as C++ code, which might suggest the two languages are closely related, in truth they are now very different languages, so that they can't be mixed with each other. If you are writing code that compiles both as C and C++, then you are in fact writing C code, not C++. It may or may not be important to you, but if you show up at a job interview talking about C/C++, you will effectively show up as someone who does not know what they are talking about, so beware. which > handles incoming events, plus interrupt functions etc, whereas main() is > provided by the IDE. > > This code piece is called a 'sketch', which you compile and download to > the arduino. > > R'
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Date | 2022-08-09 17:52 -0700 |
| Message-ID | <87pmh8q5r9.fsf@nosuchdomain.example.com> |
| In reply to | #85819 |
Manfred <noname@add.invalid> writes:
> On 8/9/2022 11:07 AM, Ralf Fassel wrote:
>> * Juha Nieminen <nospam@thanks.invalid>
>> | I have never even heard of the "sketch" language so I can't comment.
>> | If I had to make a completely wild guess it's probably some kind of
>> | "higher-level" language with its own pros and cons compared to both
>> | C and C++.
>> On the Arduino, you usually only write the loop() (in C/C++)
>
> Note that the expression (C/C++) is considered a Bad Word nowadays.
> The fact is that, even if in principle a C code fragment can be
> compiled as C++ code, which might suggest the two languages are
> closely related, in truth they are now very different languages, so
> that they can't be mixed with each other.
Agreed, mostly.
> If you are writing code that compiles both as C and C++, then you are
> in fact writing C code, not C++.
Or you might in fact be writing C++ code. Which it is depends on which
compiler you intended to feed it to. It might be a fragment of a larger
C++ program that doesn't happen to use any C++-specific features.
Or you *might* have a good reason to want to write code that compiles
both as C and as C++, but such reasons are rare in my experience, and
are not what the term "C/C++" refers to.
(And of course you need to beware of the cases where the same code is
valid C and valid C++ but with different meanings.)
> It may or may not be important to you, but if you show up at a job
> interview talking about C/C++, you will effectively show up as someone
> who does not know what they are talking about, so beware.
Maybe. There's a fair chance that the person you're talking to thinks
"C/C++" actually means something.
> which
>> handles incoming events, plus interrupt functions etc, whereas main() is
>> provided by the IDE.
>> This code piece is called a 'sketch', which you compile and download
>> to
>> the arduino.
>> R'
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */
[toc] | [prev] | [next] | [standalone]
| From | Malcolm McLean <malcolm.arthur.mclean@gmail.com> |
|---|---|
| Date | 2022-08-09 21:39 -0700 |
| Message-ID | <b7be7acc-5bef-4660-9728-cd27a446696en@googlegroups.com> |
| In reply to | #85820 |
On Wednesday, 10 August 2022 at 01:52:58 UTC+1, Keith Thompson wrote: > Manfred <non...@add.invalid> writes: > > > It may or may not be important to you, but if you show up at a job > > interview talking about C/C++, you will effectively show up as someone > > who does not know what they are talking about, so beware. > Maybe. There's a fair chance that the person you're talking to thinks > "C/C++" actually means something. > Generally people who recruit programmers are competent. You don't reject a good candidate for that reason. C++ compilers always ship with C compilers, and it is quite common to see programs which are a mixture of C and C++ files. It's also quite common to see functions which are C, or effectively C, in C++ source. There are many reasons, but a common one is that the code is doing something which is algorithmically difficult. It can only be written by an expert, and is valuable. If it is written in C, it's likely easier to integrate into new programs.
[toc] | [prev] | [next] | [standalone]
| From | Muttley@dastardlyhq.com |
|---|---|
| Date | 2022-08-10 07:45 +0000 |
| Message-ID | <tcvnn1$d3g$1@gioia.aioe.org> |
| In reply to | #85824 |
On Tue, 9 Aug 2022 21:39:28 -0700 (PDT) Malcolm McLean <malcolm.arthur.mclean@gmail.com> wrote: >On Wednesday, 10 August 2022 at 01:52:58 UTC+1, Keith Thompson wrote: >> Manfred <non...@add.invalid> writes: >> >> > It may or may not be important to you, but if you show up at a job >> > interview talking about C/C++, you will effectively show up as someone >> > who does not know what they are talking about, so beware. >> Maybe. There's a fair chance that the person you're talking to thinks >> "C/C++" actually means something. >> >Generally people who recruit programmers are competent. You don't reject >a good candidate for that reason. >C++ compilers always ship with C compilers, and it is quite common to >see programs which are a mixture of C and C++ files. It's also quite common >to see functions which are C, or effectively C, in C++ source. >There are many reasons, but a common one is that the code is doing something >which is algorithmically difficult. It can only be written by an expert, and is > >valuable. If it is written in C, it's likely easier to integrate into new >programs. On most (all?) versions of Unix C++ has to be wrapped in a C API to be called from shared object files.
[toc] | [prev] | [next] | [standalone]
| From | scott@slp53.sl.home (Scott Lurndal) |
|---|---|
| Date | 2022-08-10 19:50 +0000 |
| Message-ID | <w_TIK.702378$5fVf.547150@fx09.iad> |
| In reply to | #85820 |
Keith Thompson <Keith.S.Thompson+u@gmail.com> writes: >Manfred <noname@add.invalid> writes: > >> If you are writing code that compiles both as C and C++, then you are >> in fact writing C code, not C++. > >Or you might in fact be writing C++ code. Which it is depends on which >compiler you intended to feed it to. It might be a fragment of a larger >C++ program that doesn't happen to use any C++-specific features. Or you might be writing code to solve a problem and realize that calling it C, C++, C/C++ or fred doesn't matter so long as the program solves the problem.
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Date | 2022-08-10 13:13 -0700 |
| Message-ID | <87edxnq2ki.fsf@nosuchdomain.example.com> |
| In reply to | #85838 |
scott@slp53.sl.home (Scott Lurndal) writes:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>Manfred <noname@add.invalid> writes:
>>> If you are writing code that compiles both as C and C++, then you are
>>> in fact writing C code, not C++.
>>
>>Or you might in fact be writing C++ code. Which it is depends on which
>>compiler you intended to feed it to. It might be a fragment of a larger
>>C++ program that doesn't happen to use any C++-specific features.
>
> Or you might be writing code to solve a problem and realize that
> calling it C, C++, C/C++ or fred doesn't matter so long as the
> program solves the problem.
It matters because it's not going to solve the problem unless you feed
it to a language-specific compiler. If you don't intend to do that,
you're writing pseudo-code.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */
[toc] | [prev] | [next] | [standalone]
| From | Manfred <noname@add.invalid> |
|---|---|
| Date | 2022-08-11 04:29 +0200 |
| Message-ID | <td1phm$7ui$1@gioia.aioe.org> |
| In reply to | #85838 |
On 8/10/2022 9:50 PM, Scott Lurndal wrote: > Keith Thompson <Keith.S.Thompson+u@gmail.com> writes: >> Manfred <noname@add.invalid> writes: > >> >>> If you are writing code that compiles both as C and C++, then you are >>> in fact writing C code, not C++. >> >> Or you might in fact be writing C++ code. Which it is depends on which >> compiler you intended to feed it to. It might be a fragment of a larger >> C++ program that doesn't happen to use any C++-specific features. > > Or you might be writing code to solve a problem and realize that > calling it C, C++, C/C++ or fred doesn't matter so long as the > program solves the problem. Or you might use Java, Python, Perl, ADA, Fortran, COBOL, ECMAScript - and solve the same problem. Does it mean they are all the same language?
[toc] | [prev] | [next] | [standalone]
| From | Juha Nieminen <nospam@thanks.invalid> |
|---|---|
| Date | 2022-08-10 02:41 +0000 |
| Message-ID | <tcv5rv$18ij$1@gioia.aioe.org> |
| In reply to | #85819 |
Manfred <noname@add.invalid> wrote: > If you are writing code that compiles both as C and C++, then you are in > fact writing C code, not C++. Not really. Just because it might compile if interpreted as C doesn't mean it's actually intended to be compiled as C. For example if you write a 'const' variable at the global scope you might not be intending for it to have external linkage. If you write an 'inline' function, it may so happen to compile as C, but it doesn't actually make it valid C (because in C 'inline' has more requirements than it does in C++).
[toc] | [prev] | [next] | [standalone]
| From | Muttley@dastardlyhq.com |
|---|---|
| Date | 2022-08-10 07:39 +0000 |
| Message-ID | <tcvnc2$940$1@gioia.aioe.org> |
| In reply to | #85819 |
On Wed, 10 Aug 2022 02:25:18 +0200 Manfred <noname@add.invalid> wrote: >On 8/9/2022 11:07 AM, Ralf Fassel wrote: >> * Juha Nieminen <nospam@thanks.invalid> >> | I have never even heard of the "sketch" language so I can't comment. >> | If I had to make a completely wild guess it's probably some kind of >> | "higher-level" language with its own pros and cons compared to both >> | C and C++. >> >> On the Arduino, you usually only write the loop() (in C/C++) > >Note that the expression (C/C++) is considered a Bad Word nowadays. >The fact is that, even if in principle a C code fragment can be compiled >as C++ code, which might suggest the two languages are closely related, >in truth they are now very different languages, so that they can't be >mixed with each other. >If you are writing code that compiles both as C and C++, then you are in >fact writing C code, not C++. > >It may or may not be important to you, but if you show up at a job >interview talking about C/C++, you will effectively show up as someone >who does not know what they are talking about, so beware. Depends on the job requirements. Some places require knowledge of both languages and someone good with C++ isn't always good at writing efficient C.
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Date | 2022-08-10 10:11 -0700 |
| Message-ID | <87iln0owgr.fsf@nosuchdomain.example.com> |
| In reply to | #85828 |
Muttley@dastardlyhq.com writes:
> On Wed, 10 Aug 2022 02:25:18 +0200
> Manfred <noname@add.invalid> wrote:
>>On 8/9/2022 11:07 AM, Ralf Fassel wrote:
>>> * Juha Nieminen <nospam@thanks.invalid>
>>> | I have never even heard of the "sketch" language so I can't comment.
>>> | If I had to make a completely wild guess it's probably some kind of
>>> | "higher-level" language with its own pros and cons compared to both
>>> | C and C++.
>>>
>>> On the Arduino, you usually only write the loop() (in C/C++)
>>
>>Note that the expression (C/C++) is considered a Bad Word nowadays.
>>The fact is that, even if in principle a C code fragment can be compiled
>>as C++ code, which might suggest the two languages are closely related,
>>in truth they are now very different languages, so that they can't be
>>mixed with each other.
>>If you are writing code that compiles both as C and C++, then you are in
>>fact writing C code, not C++.
>>
>>It may or may not be important to you, but if you show up at a job
>>interview talking about C/C++, you will effectively show up as someone
>>who does not know what they are talking about, so beware.
>
> Depends on the job requirements. Some places require knowledge of both
> languages and someone good with C++ isn't always good at writing efficient C.
Sure, but "C/C++" isn't a good way to say that. You never see "C/Java".
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */
[toc] | [prev] | [next] | [standalone]
| From | Muttley@dastardlyhq.com |
|---|---|
| Date | 2022-08-12 08:23 +0000 |
| Message-ID | <td52mp$5st$1@gioia.aioe.org> |
| In reply to | #85836 |
On Wed, 10 Aug 2022 10:11:00 -0700 Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote: >Muttley@dastardlyhq.com writes: >> On Wed, 10 Aug 2022 02:25:18 +0200 >> Manfred <noname@add.invalid> wrote: >>>On 8/9/2022 11:07 AM, Ralf Fassel wrote: >>>> * Juha Nieminen <nospam@thanks.invalid> >>>> | I have never even heard of the "sketch" language so I can't comment. >>>> | If I had to make a completely wild guess it's probably some kind of >>>> | "higher-level" language with its own pros and cons compared to both >>>> | C and C++. >>>> >>>> On the Arduino, you usually only write the loop() (in C/C++) >>> >>>Note that the expression (C/C++) is considered a Bad Word nowadays. >>>The fact is that, even if in principle a C code fragment can be compiled >>>as C++ code, which might suggest the two languages are closely related, >>>in truth they are now very different languages, so that they can't be >>>mixed with each other. >>>If you are writing code that compiles both as C and C++, then you are in >>>fact writing C code, not C++. >>> >>>It may or may not be important to you, but if you show up at a job >>>interview talking about C/C++, you will effectively show up as someone >>>who does not know what they are talking about, so beware. >> >> Depends on the job requirements. Some places require knowledge of both >> languages and someone good with C++ isn't always good at writing efficient C. > > >Sure, but "C/C++" isn't a good way to say that. You never see "C/Java". Last time I looked you couldn't compile C with a java compiler.
[toc] | [prev] | [next] | [standalone]
| From | Juha Nieminen <nospam@thanks.invalid> |
|---|---|
| Date | 2022-08-12 12:12 +0000 |
| Message-ID | <td5g31$1mem$1@gioia.aioe.org> |
| In reply to | #85864 |
Muttley@dastardlyhq.com wrote: >>Sure, but "C/C++" isn't a good way to say that. You never see "C/Java". > > Last time I looked you couldn't compile C with a java compiler. I'm somewhat certain that if you search enough you'll find a polyglot program that will compile both as C and Java. C is not 100% compatible with C++ either, so any "C code" that you might write that just happens to compile and work the same in C++ is technically speaking a C/C++ polyglot. (Sure, it's infinitely easier to write a C/C++ polyglot program than eg. a C/Java one, but still. C is not a pure subset of C++.)
[toc] | [prev] | [next] | [standalone]
| From | Muttley@dastardlyhq.com |
|---|---|
| Date | 2022-08-12 14:41 +0000 |
| Message-ID | <td5oq3$1ato$1@gioia.aioe.org> |
| In reply to | #85874 |
On Fri, 12 Aug 2022 12:12:19 -0000 (UTC) Juha Nieminen <nospam@thanks.invalid> wrote: >Muttley@dastardlyhq.com wrote: >>>Sure, but "C/C++" isn't a good way to say that. You never see "C/Java". >> >> Last time I looked you couldn't compile C with a java compiler. > >I'm somewhat certain that if you search enough you'll find a polyglot >program that will compile both as C and Java. I rather doubt that. You could #define "class", some class name and "public" to nothing but you're not going to be able to do much about the extra curly brackets around main() and C compilers don't like that. >C is not 100% compatible with C++ either, so any "C code" that you might >write that just happens to compile and work the same in C++ is technically >speaking a C/C++ polyglot. (Sure, it's infinitely easier to write a C/C++ >polyglot program than eg. a C/Java one, but still. C is not a pure subset >of C++.) So what. Its enough of a subset to work 99.9% of the time.
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Date | 2022-08-12 12:09 -0700 |
| Message-ID | <87pmh5e0sg.fsf@nosuchdomain.example.com> |
| In reply to | #85879 |
Muttley@dastardlyhq.com writes:
> On Fri, 12 Aug 2022 12:12:19 -0000 (UTC)
> Juha Nieminen <nospam@thanks.invalid> wrote:
>>Muttley@dastardlyhq.com wrote:
>>>>Sure, but "C/C++" isn't a good way to say that. You never see "C/Java".
>>>
>>> Last time I looked you couldn't compile C with a java compiler.
>>
>>I'm somewhat certain that if you search enough you'll find a polyglot
>>program that will compile both as C and Java.
>
> I rather doubt that. You could #define "class", some class name and "public"
> to nothing but you're not going to be able to do much about the extra curly
> brackets around main() and C compilers don't like that.
>
>>C is not 100% compatible with C++ either, so any "C code" that you might
>>write that just happens to compile and work the same in C++ is technically
>>speaking a C/C++ polyglot. (Sure, it's infinitely easier to write a C/C++
>>polyglot program than eg. a C/Java one, but still. C is not a pure subset
>>of C++.)
>
> So what. Its enough of a subset to work 99.9% of the time.
99.9%? I doubt it. And why would you want to?
Do you really write code *and then* decide whether you're going to
compile it with a C compiler or a C++ compiler?
C++ has facilities for interfacing with C code.
There are rare valid reasons to write code that can compile as
both C and C++ with the same semantics (and you have to exercise
some care to avoid a few pitfalls where the same code can have
different meanings).
Much valid C code is valid C++ code. Most valid C code can be
made into valid C++ code without a lot of effort (casting malloc,
for example). Very little *good* C code is good C++ code.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */
[toc] | [prev] | [next] | [standalone]
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Date | 2022-08-13 10:28 +0200 |
| Message-ID | <td7ncb$2pli2$1@dont-email.me> |
| In reply to | #85895 |
On 12/08/2022 21:09, Keith Thompson wrote: > Muttley@dastardlyhq.com writes: >> On Fri, 12 Aug 2022 12:12:19 -0000 (UTC) >> Juha Nieminen <nospam@thanks.invalid> wrote: >>> Muttley@dastardlyhq.com wrote: >>>>> Sure, but "C/C++" isn't a good way to say that. You never see "C/Java". >>>> >>>> Last time I looked you couldn't compile C with a java compiler. >>> >>> I'm somewhat certain that if you search enough you'll find a polyglot >>> program that will compile both as C and Java. >> >> I rather doubt that. You could #define "class", some class name and "public" >> to nothing but you're not going to be able to do much about the extra curly >> brackets around main() and C compilers don't like that. >> >>> C is not 100% compatible with C++ either, so any "C code" that you might >>> write that just happens to compile and work the same in C++ is technically >>> speaking a C/C++ polyglot. (Sure, it's infinitely easier to write a C/C++ >>> polyglot program than eg. a C/Java one, but still. C is not a pure subset >>> of C++.) >> >> So what. Its enough of a subset to work 99.9% of the time. > > 99.9%? I doubt it. And why would you want to? > This all depends on how you count your percentages. If you are talking about percentages of C files, only a small proportion of files could compile error-free as C++. If you are talking about the number of lines of the C files that need to be changed to make the C into valid C++, a very high percentage of C code is valid C++. It only takes one uncasted malloc() in a 1000 line file to make the file unable to compile as C++. > Do you really write code *and then* decide whether you're going to > compile it with a C compiler or a C++ compiler? > > C++ has facilities for interfacing with C code. > > There are rare valid reasons to write code that can compile as > both C and C++ with the same semantics (and you have to exercise > some care to avoid a few pitfalls where the same code can have > different meanings). There is the extremely common case of C header files that are used directly in C++ (usually with a conditional extern "C" wrapping). These are more declarations than code, but you might have the odd static inline function there. For headers, it's usually not a problem to stick to a common subset of the languages (and also keep it common across different language standards). While I have, at a customer's request (always a valid reason!), written code that is directly compilable as C and C++, I agree it's rare. I disagree with those that think it is hard or particularly limiting compared to pure C coding, however. gcc has a warning flag "-Wc++-compat" for C code. Presumably it exists because at least some people wanted to write code that worked equally as both languages. > > Much valid C code is valid C++ code. Most valid C code can be > made into valid C++ code without a lot of effort (casting malloc, > for example). Very little *good* C code is good C++ code. >
[toc] | [prev] | [next] | [standalone]
| From | Muttley@dastardlyhq.com |
|---|---|
| Date | 2022-08-13 09:37 +0000 |
| Message-ID | <td7rdf$101q$1@gioia.aioe.org> |
| In reply to | #85895 |
On Fri, 12 Aug 2022 12:09:51 -0700 Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote: >Muttley@dastardlyhq.com writes: >>>C is not 100% compatible with C++ either, so any "C code" that you might >>>write that just happens to compile and work the same in C++ is technically >>>speaking a C/C++ polyglot. (Sure, it's infinitely easier to write a C/C++ >>>polyglot program than eg. a C/Java one, but still. C is not a pure subset >>>of C++.) >> >> So what. Its enough of a subset to work 99.9% of the time. > >99.9%? I doubt it. And why would you want to? You wouldn't if starting from scratch. But old codebases have to be maintained. >C++ has facilities for interfacing with C code. Phew, glad you cleared that up, was getting worried. >for example). Very little *good* C code is good C++ code. Depends on what you're doing.
[toc] | [prev] | [next] | [standalone]
Page 1 of 6 [1] 2 3 4 5 6 Next page →
Back to top | Article view | comp.lang.c++
csiph-web