Sunday, October 19, 2014

Digest for comp.lang.c++@googlegroups.com - 25 updates in 7 topics

comp.lang.c++@googlegroups.com Google Groups
Unsure why you received this message? You previously subscribed to digests from this group, but we haven't been sending them for a while. We fixed that, but if you don't want to get these messages, send an email to comp.lang.c+++unsubscribe@googlegroups.com.
Andrea <NOSPAM@NOSPAM.COM>: Oct 19 12:55PM +0200

I saw this framework and it seems very interesting (I have done some
tests with the Qt Creator editor and are positively surprised).
 
Does anyone use it? Opinions?
 
--
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Oct 19 05:16AM -0700

Qt's licensing model can be undesirable for some. It is a solid
framework though. Have you tried wxCrafter?
 
Best regards,
Rick C. Hodgin
Victor Bazarov <v.bazarov@comcast.invalid>: Oct 19 08:17AM -0400

On 10/19/2014 6:55 AM, Andrea wrote:
> I saw this framework and it seems very interesting (I have done some
> tests with the Qt Creator editor and are positively surprised).
 
> Does anyone use it? Opinions?
 
My opinion is that some folks use it. Some companies even use it in the
foundation of their commercial products. I think you can find some
testimonials on the web site...
 
V
--
I do not respond to top-posted replies, please don't ask
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Oct 19 05:19AM -0700

http://en.m.wikipedia.org/wiki/WxWidgets
 
Best regards,
Rick C. Hodgin
Andrea <NOSPAM@NOSPAM.COM>: Oct 19 03:22PM +0200

19/10/2014 14:19, Rick C. Hodgin write:
> http://en.m.wikipedia.org/wiki/WxWidgets
 
> Best regards,
> Rick C. Hodgin
 
Thanks for the reply.
 
Maybe I'm wrong, but WxWidgets it only for the GUI. Qt can be used for
the database, file system etc... Now I'm testing class for tcp socket
and it's not complicated. For now, my vote is positive, but I wanted to
know an opinion from people with more experience than me :)
 
--
Andrea <NOSPAM@NOSPAM.COM>: Oct 19 03:31PM +0200

On 19/10/2014 14:17, Victor Bazarov wrote:
> My opinion is that some folks use it. Some companies even use it in the
> foundation of their commercial products. I think you can find some
> testimonials on the web site...
 
Thank for the reply.
 
I am follow this group for a few months, and I never saw discussion
about Qt. I thought that is not used or that it's a bad product... and I
wanted to know an opinion from /skilled/ people in this group before
lose my time with this framework :)
 
--
"Öö Tiib" <ootiib@hot.ee>: Oct 18 05:10PM -0700

On Sunday, 19 October 2014 00:39:00 UTC+3, Emanuel Berg wrote:
 
> ++i (instead of i++) looks backward and it is
> confusing as it doesn't serve a clear purpose (or
> any?).
 
No difference either way as separate sentence for 'int' so how can
it be confusing?
 
In general '++X' means "increase X". 'X++' means "increase X but return
what it was before". So '++X' might be what we want to do on most cases
and 'X++' feels like for special, more complex cases.
 
We pick 'X++' because it was that way in for loops of the books written
by wise guys that we did read as novices ... there are no other reasons.
 
> You can put the declaration of i within the for loop
> if you pass either of -std=c99, -std=gnu99, -std=c11
> or -std=gnu11 to gcc.
 
Lot of people are forced to write C that is compatible with Microsoft C
compiler that AFAIK does not let to declare that 'i' there. It feels like
Microsoft has huge pile of legacy C somewhere that no one of them can
maintain and so the decades pass but they can't modernize their
compiler, otherwise some curse comes out and half of their world blows
up.
Luca Risolia <luca.risolia@linux-projects.org>: Oct 19 03:15AM +0200

Il 11/10/2014 13:24, JiiPee ha scritto:
 
> What I said is that first learn proper C++ way, then after that C... so
> the other way around :). But I guess one can learn both at the same time
> when just being careful understanding that not using C ways in C++ code.
 
If you want to be able to appreciate and write elegant code, start to
learn C++ from the beginning, don't waste your time on C.
Emanuel Berg <embe8573@student.uu.se>: Oct 19 03:21AM +0200


> The context is that someone wants to learn C++ --
> surely no promotion is needed?
 
OK, if someone wants to learn C++ he or she should do
C++.
 
> mention object orientation -- why? It was popular in
> the 1990s, but today noone forces you to do it, not
> in C++ at least.
 
I'm old-school! :) But I agree you can do everything
with C++. It doesn't have to be Haskell or Lisp or SML
to be functional programming. But to do OO in C or
some SQL-like data-oriented programming in C++ (or C)
will just be a lot of unmotivated work. But I don't
see much you could do in C that you couldn't do in
C++. And that's logical as C++ is an extention of C.
 
> safety, exceptions and the standard library: good C
> programs have to make do with arrays or home-grown
> linked lists, and manual memory management.
 
No, good programs solve a problem - the intended,
whole problem, and none other. Many programs that run
every day and have done so for ages aren't what any of
us would call good programs if we were to look at the
source. Just compile the Linux kernel and you get
hundreds of warnings from the compiler. Take a look at
the source code and you might immediately dislike the
indentation style and naming conventions and...
whatever. It doesn't matter to you unless you are
writing it, in what case of course you want a program
whose source conforms with your views and style.
 
> program, but rarely see a need for run-time
> polymorphism, abstract interfaces, design patterns
> and so on. YMMV.
 
No, that is CS schoolbook stuff that will only make
your head spin. In practice old tricks are the best.
 
--
underground experts united
Emanuel Berg <embe8573@student.uu.se>: Oct 19 03:33AM +0200


> But it is not a proper subset, and neither is it
> "huge".
 
I used that word informally, and I don't think it will
be worthwhile to somehow do a weighted quantification
to find out, but I'm still rather confident that some
techno-historian one thousand years or so from now
will come to the conclusion that C was a huge part of
C++ both in terms of technology and as regards the
human aspects of it.
 
> ... so one would need to learn the usage of basic
> looping constructs twice
 
All the better!
 
> inside function also has unnessecary and harmful
> restrictions in C, so learning the C way first is
> actually harmful when learning C++.
 
No, the more you learn, the better. Manny Pacquiao and
the Klitschko brothers are all boxing champions. What
sport did they start with? Kickboxing! (or Muay Thai)
So, training kickboxing didn't make them worse boxers
even though in boxing you are not allowed to kick.
They went on to become boxing champions nonetheless.
Learning is never harmful, it is always positive *for
everything*!
 
Don't worry about it!
 
--
underground experts united
"J. Clarke" <jclarkeusenet@cox.net>: Oct 15 03:05AM -0400

In article <XnsA3C754D1FD1A3myfirstnameosapriee@216.196.109.131>,
myfirstname@osa.pri.ee says...
> correct as the minilanguage is not type-safe). All these aspects are
> cured in C++ thanks to the features which are not OO-related: RAII,
> function overloading and templates.
 
You seem to be conflating the existence of a particular kind of object
in the language with being an object oriented language. If you work
hard enough you can make something that works like an object in assembly
language, but that doesn't make assembly language object oriented.
 
An object oriented language is one which has facilities for creating new
kinds of object and their associated methods and properties. Does C
have these other than doing it by brute force and awfulness?

David Brown <david.brown@hesbynett.no>: Oct 15 10:26AM +0200

On 15/10/14 09:05, J. Clarke wrote:
 
> An object oriented language is one which has facilities for creating new
> kinds of object and their associated methods and properties. Does C
> have these other than doing it by brute force and awfulness?
 
Paavo did not claim that C was an object oriented language - he claimed
that snippets like the ones he gave are as much "object oriented" in C
and C++.
 
His point (I believe) is that /neither/ code snippet makes use of real
OO coding - they just make use of an object. It is not until you are
using more powerful features of classes, such as inheritance and
polymorphism, that the term "object oriented" becomes relevant.
 
And yes, C /does/ support object oriented development. It is certainly
easy to make use of objects in C, as shown by Paavo's snippets. But C++
makes OO development easier and more efficient for the developer, more
efficient at run-time, and has it as an integrated part of its standard
library - /that's/ what makes C++ an "object oriented language".
 
"J. Clarke" <jclarkeusenet@cox.net>: Oct 18 11:53PM -0400

In article <8ef2fcad-5949-4ea8-94f6-25f436c823b7@googlegroups.com>,
ootiib@hot.ee says...
> > or -std=gnu11 to gcc.
 
> Lot of people are forced to write C that is compatible with Microsoft C
> compiler that AFAIK does not let to declare that 'i' there.
 
Where does one obtain this "Microsoft C compiler"? The only Microsoft
compiler I am aware of that is commonly available, current, and accepts
C code is the Visual Studio C++ compiler which accepts that syntax just
fine unless you expelicitly set it to accept C rather than C++ code.
 
> maintain and so the decades pass but they can't modernize their
> compiler, otherwise some curse comes out and half of their world blows
> up.
 
Huh? If that was an issue then all that would be needed was an
appropriate command line option.
Emanuel Berg <embe8573@student.uu.se>: Oct 19 06:25AM +0200

> size(&str) - it is not object oriented programming.
> You could get the same effect in C by adding nothing
> more than function overloading.
 
Well then, what is your definition of OO? The one I
like the best is the coupling of data and the
algorithms that modify that same data. Which is the
case here. It doesn't really matter if that is
implemented as syntactic sugar or not. OO is all about
interfaces anyway. (Well, all good programming is, I
would argue.)
 
--
underground experts united
Paavo Helde <myfirstname@osa.pri.ee>: Oct 19 02:27AM -0500

Emanuel Berg <embe8573@student.uu.se> wrote in
 
> Well then, what is your definition of OO? The one I
> like the best is the coupling of data and the
> algorithms that modify that same data.
 
Yes, but in this example this is done by the implementors of
std::basic_string, not by the user (the end programmer). The program does
not magically turn into OO style by using a std::string variable instead
of a char array. Zero knowledge about OO is needed for using a
std::string variable, it's just slightly different calling syntax.
 
> case here. It doesn't really matter if that is
> implemented as syntactic sugar or not. OO is all about
> interfaces anyway.
 
This somewhat contradicts your previous claim that OO is all about
coupling of data and algorithms working on the same data. These both
sound more like implementation details, not directly interface related.
Paavo Helde <myfirstname@osa.pri.ee>: Oct 19 03:41AM -0500

Emanuel Berg <embe8573@student.uu.se> wrote in
> will come to the conclusion that C was a huge part of
> C++ both in terms of technology and as regards the
> human aspects of it.
 
I very much doubt it, because even nowadays I think no expert would agree
with you. I do not consider myself a true expert, but I have learned
enough C++ to see that the common C subset is constituting a quite small
part of it (maybe 5% or 10% if I were forced to give a number). I hope I
learn more in the future, and that will make the C subset part even
smaller because it is effectively frozen; new features are added in the
C++ part. Some new features in the C language like variable size arrays
are not going to be adopted into C++, which means that the languages will
diverge more in the future and the common subset of them will effectively
diminish yet more.
 
Historically C has been very important for C++, and nowadays it's very
important because many library and OS interfaces are defined in C. This
does not mean that C and C++ languages have a large common subset, it
just means they can be interfaced very well.
 
>> looping constructs twice
 
> All the better!
> the more you learn, the better.
 
Sure, but this is not the topic of this thread. The question posed by OP
was: "should one first learn C before learning C++?"
 
Cheers
Paavo
Bo Persson <bop@gmb.dk>: Oct 19 12:46PM +0200

On 2014-10-19 06:25, Emanuel Berg wrote:
> implemented as syntactic sugar or not. OO is all about
> interfaces anyway. (Well, all good programming is, I
> would argue.)
 
I think the confusion here is that you call the "C with classes" subset
of C++ "Object oriented" when some of us see it as merely "Object
based". :-)
 
A small but significant difference, see
 
http://en.wikipedia.org/wiki/Object-based_programming
http://en.wikipedia.org/wiki/Object-oriented_programming
 
 
Bo Persson
pkoniusz@gmail.com: Oct 18 05:17PM -0700

Dear Stefan and Robert.
 
I don't mind if I get this behaviour on a specific platform only. Portability is not an issue at this point at all. I use linux with the following kernel.
 
3.11.10-100.fc18.x86_64
#1 SMP Mon Dec 2 20:28:38 UTC 2013
x86_64 x86_64 x86_64 GNU/Linux
 
Any chance I'd get the behaviour of realloc that Stefan talks about on this platform?
 
Seems like 'memory collapse' would do the job, or some way to force allocation of two memory blocks to be exactly next to each other in the first place.
 
Another option is to dump all data on a hard drive and reload and shrink on the fly, though, this would be too slow. The main reason for operating on such large continuous blocks is speed.
Melzzzzz <mel@zzzzz.com>: Oct 19 02:59AM +0200

On Sat, 18 Oct 2014 17:17:00 -0700 (PDT)
 
> Seems like 'memory collapse' would do the job, or some way to force
> allocation of two memory blocks to be exactly next to each other in
> the first place.
 
Try to allocate with mmap directly.
 
 
 
--
Manjaro all the way!
http://manjaro.org/
Paavo Helde <myfirstname@osa.pri.ee>: Oct 19 02:34AM -0500

pkoniusz@gmail.com wrote in
 
> Dear Stefan and Robert.
 
> I don't mind if I get this behaviour on a specific platform only.
> Portability is not an issue at this point at all. I use linux with the
 
On Linux, use mmap() and mremap(). The latter seems like a direct hit for
your concerns.
 
Cheers
Paavo
alakh92@gmail.com: Oct 18 09:38PM -0700

How can i get remissership.
My name is alakh bharti, i am from jaipur. My contact no. Is 9261653094.
"Jouko Koski" <joukokoskispam101@netti.fi>: Oct 15 11:14AM +0300

"Juha Nieminen" wrote:
> So are you saying it wouldn't work with functions inside namespaces
> (such as fseek)?
 
Would something stop current argument-dependend lookup working?
 
--
Jouko
"J. Clarke" <jclarkeusenet@cox.net>: Oct 15 05:04AM -0400

In article <87eguaw206.fsf@debian.uxu>, embe8573@student.uu.se says...
> but instead possibly be setup as an interrupt.
 
> Right now I don't know what to do except that I'm not
> happy with polling.
 
It sounds like what you want to do is set up the performance counters to
trigger an interrupt when a threshold number of LLC misses occurs.
 
I don't know of a facility in Linux that supports this--you may have to
create or modify an interrupt handler. You can download the docs for
the processors from
http://www.intel.com/content/www/us/en/processors/architectures-
software-developer-manuals.html and you might want to check into "perf",
which doesn't seem to provide an api for you to use to hook the
interrupt but may have pieces that you can modify to suit your need.
"J. Clarke" <jclarkeusenet@cox.net>: Oct 15 05:04AM -0400

In article <87eguaw206.fsf@debian.uxu>, embe8573@student.uu.se says...
> but instead possibly be setup as an interrupt.
 
> Right now I don't know what to do except that I'm not
> happy with polling.
 
Forgot to mention, a simpler approach might might be to just turn off
LLC read-caching on the "BE" core, which will slow it down but also
reduce interference with the crtical core. This is also discussed in
the Intel software manual
<http://www.intel.com/content/www/us/en/processors/architectures-
software-developer-manuals.html>
David Brown <david.brown@hesbynett.no>: Oct 15 10:48AM +0200

On 15/10/14 03:04, Rick C. Hodgin wrote:
> be joined together into a single component, such as with the number 999.99
> being converted to [999][decimal point][99], and then being converted into
> a single [number:999.99] form. I call those "natural groupings".
 
Fair enough, the variable names are meaningful for your code. But that
still does not mean it makes sense to declare all your variables at the
start of the function.
 
>> using "i" as a loop variable. But good programming practice
 
> Never use "i" for a local variable name. That's my advice. I use
> something like "lnI" for [local][numeric][i].
 
I hope you won't feel insulted if I ignore your advice. I have seen
many pieces of code with such conventions, and many sets of coding rules
that insisted upon them - I have never seen any code in which such
things did not make code uglier and harder to follow.
 
 
> I think it's good practice. All variables are located at one place
> and I don't have to go hunting (reading) line-by-line to try to find
> where this one's defined, and that one's defined.
 
Why single out variable definition for such special treatment? How
variables are used is just as important as their definitions - yet you
are happy to spread their usage around in the code. It is a common idea
that putting the definitions in one place somehow makes things clearer,
but that is not the case. Remember, the convention of putting
definitions at the start of a function is due to limitations on compiler
technology in the good old days of K&R - it was never picked as an
active choice or suggested as a good idea.
 
>> write it the way you want. All anyone else can do is give you
>> suggestions.
 
> It goes both ways.
 
Absolutely true. Even the most experienced developers can sometimes
learn things from other people's habits and conventions. But after due
consideration of the points above, I've rejected your conventions :-)
 
(On a more positive note, your code is laid out neatly and consistently,
which is a good habit.)
 
> being an issue to worry about it.
 
> But, here is the output from GCC (I had to remove the line after lfHertz4
> which bypasses the warning to get it to generate that warning):
 
 
The way to deal with warnings is to understand them and use them as
hints to correct or improve your code. It is very rare that I accept
/any/ warnings on final code - and I use a lot more of gcc's warnings
than you do here (I start with "-Wall -Wextra" and add others). In this
particular case, I think your code would be clearer and your warnings
would disappear (or reveal real errors) if you used local variables
properly.
 
You should also remove the "-Wno-" flags - any warnings hidden by those
flags are almost certainly coding errors.
 
And you should use separate compilation for your modules - don't lump
everything together in one huge combined file. Modular programming
exists for a reason - it gives you clearer, neater code, better static
error checking, better code re-use, and easier development.
 
 
I think that's probably enough advice for today.
 
 
 
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: