« first day (166 days earlier)      last day (4791 days later) » 

12:04 AM
hi
 
why is it so many people like C?
it's such a suck language
 
its sipl
simple*
 
yeah, simple enough that you have to manually free memory and check buffer indices
 
it's not expressive, i agree, but it's simple to learn
 
Beats assembly
There is also Objectionable C. You still have to free memory manually...
 
12:46 AM
Ask Linus why he likes C. It's not because he's not smart enough to use C++.
 
 
6 hours later…
7:12 AM
@WarrenP I think it is because he is. not smart enough to use c++.
Which is to say, I subscribe strongly to the idea that c++ is perhaps too complex for smart people to use correctly.
What chance do I have? I'm too ... stupid to realize my limits, so I continue to use it.
 
C++ is definitely overly-complex.
 
it would be rather funny at this point
if the c-standards committee
added some oo extensions to c
because, I for one, would probably switch.
 
7:29 AM
hello y'all
 
7:47 AM
the sheer silence, all still asleep?
 
not quite
 
awake!
 
@GMan, I got lost into projections yesterday
 
Like camera projections?
 
yea, the projection from where you look at a scene
I got into it cause I read about projection matrices
which i still haven't got to
so I still donno how they're used
 
8:01 AM
How well do you understand matrices?
 
okish, not bad, but I'm no expert by any means
 
8:48 AM
for an open source project, its frikken hard to get the source code for dd-wrt
 
9:18 AM
The problem with OO extensions in C is that it would become C++ :)
I mean, seriously, is there really any other direction that it could evolve into?
Is there anywhere better OO on to of C design than C++?
Objective-C IMHO is not that.
Personally, I do not see much point writing plain C except for legacy code. You can do C in C++ very well, too, if you need to.
 
@wilx objective-c is, in many respects, far more elegant
 
sbi
@wilx That's wrong. C++ is a lot more than just OO. In fact, major parts of its standard library aren't OO at all. (The fact that they still use classes make them as much OO as OO using functions make it Structured Programming.) And I like that a lot. According to Stroustrup, C++ was always envisioned as a multi-paradigm language, and that's an aspect where he very much succeeded.
 
@wilx I think the opposite is true. The problem with OO extensions to C is that it'd be C with OO extensions, rather than C++
OO isn't important
4
 
sbi
@jalf Uh oh. Now you said it. I tried to not to mouth the heresy loudly. :)
 
@sbi: I never said C++ was just OO.
 
9:27 AM
@jalf please expand
 
sbi
@wilx Well, you didn't say it explicitly, but it kind of follows from the premise that a SP language with OO bolted onto it would resemble C++, don't you think?
 
@ChrisBecke on what? C++ isn't an OOP language, it's a multi-paradigm language, as @sbi said, and that's what makes the language worth using
 
sbi
@ChrisBecke That's easy. Major parts of the std lib aren't OO, because their paradigm is a lot better than OO.
 
A "pure" OOP" extension to C would be missing all the (non-OOP) things that make C++ useful
 
I would dare to say, make c++ and unusable mess
 
9:28 AM
@ChrisBecke a mess, certainly, but unusable? That would seem to be contradicted by the fact that people are actually able to use C++
 
use c++ to do what though?
 
I'd even give you "hard to use", but certainly not "unusable"
 
It is certainly, on the face of it, more convenient than straight c
 
@ChrisBecke pretty much everything. There's a lot of C++ being written, in case you hadn't noticed
 
but its impossible to write correct code in c++
in part because it does have this underlying c legacy
 
9:30 AM
@ChrisBecke it's impossible to take a claim like that seriously
@ChrisBecke So you're saying that C++ is hindered by its C legacy, and therefore, throwing away all teh unique features of C++, while keeping the C legacy would result in a better language?
your approach to logic baffles me
 
i would have expected a multi paradigm language to lend more support to the idea that explicit error handling is just as correct as exceptions. and/or that garbage collection is just as valid as, well whatever new & delete count as
 
multi != omni. C++ supports multiple paradigms, it does not support every paradigm.
 
sbi
@ChrisBecke Really, Chris, why is it that you're even here? Haven't you just accidentally bumped into the wrong room? Or do you silently enjoy the shaking of heads you're causing by spitting out such nonsense day after day?
 
I'd love to see a language which supported every paradigm and every programming technique well. C++ is not it, but does that mean the language is broken?
 
@jalf No, im saying that C++, being freed from c's legacy, might have done multi paradigm better with less in the way of gaping holes left in the name of compatability
and that C, with objects, might be a better oo language to develop in, if it didnt try to be so multi paradigm
 
9:34 AM
@ChrisBecke and a minute ago you were saying you'd prefer a language which kept the C legacy, but threw away all the other C++ things
 
sbi
@ChrisBecke I could prove your implicit assertion wrong, that C++ does not support all that, but it's not worth the effort. No matter how often you've been shown that your arguments are nonsense, you still come forth with more of them.
 
C with objects would very likely be a better OOP language than C++
But as I said before, I don't care about that. I care about how good the language is overall
 
sbi
@jalf You mean Not C with Objects, right? :)
 
@sbi I'm not sure. I think he's saying that a multi-paradigm language based on C is a bad idea, but a dual-paradigm language based on C, but with OOP built on top would be awesome
and an omni-paradigm language would, apparently, be great too, but I'm not sure if that is with or without a C legacy
@ChrisBecke what I'm getting at is that OOP isn't a very good paradigm. It has its uses, in a few corner cases, or as an auxillary tool to use within other paradigms, but an "OOP language" is intrinsically flawed because it tries to elevate OOP above all other paradigms, which is just stupid and counterproductive.
 
sbi
@jalf Any C With Anything language would always be hindered by the C in it. If you want a language that's good at something, then, unless that something is an unhealthy mix of arcane syntax and wildly unsafe semantics, then you'd better leave C out of the picture.
Well, maybe portability is C's strong point.
I shouldn't have forgotten about that.
 
9:38 AM
@sbi and popularity. If you want a language to catch on, basing it, directly or indirectly, on C isn't a bad idea either
but yeah, I agree
anyway, off to lunch!
 
sbi
@jalf Bon appetite! (And I'll go back to hacking...)
 
@jalf and what paradigms are there that arn't based on at least the concepts of oo?
 
@ChrisBecke I can't think of a single paradigm that is based on the concepts of OO
there are paradigms that have ideas in common, but which aren't based on OO in any way (and in most cases, they predate OO)
 
what we have in c++ is a dated oo abstraction, that can't support gc.
combined with a terrible meta programming template syntax.
 
structured programming, procedural, functional and generic programming, neither of those are "based on the concepts of OO", partially or completely, but they share a few common-sense ideas.
logic programming doesn't even share these common sense ideas
I can't think of any other paradigm.
 
9:43 AM
an stl, put together by someone with a vague grasp of english.
 
no, what we have here is a fool who for some reason likes to display his lack of knowledge, and change the subject when he gets called on it
tell me a programming paradigm which is "based on the concepts of OO"
just one
And how do you justifiy this obsession with OO and GC? Why does C++'s deficiencies in those language cancel out every strength the language has? Why do none of the language's strengths matter at all?
 
9:56 AM
@jalf and how do you do generic programming in c++, without objects?
 
@ChrisBecke It is difficult to do anything even in the common subset of C and C++ without using C++ notion of object...
 
ok. so. outside of c++, generic programming can be seen, in an abstract way, to not be based on oo.
Ill take that point.
but, in c++, generic programming is a layer over oo.
 
No. OO depend on the use of virtual function, generic programming can be easily done without.
From what I know of Java and C#, there generic programming could be a layer over OO.
 
polymorphisim depends on virtual
oo > poly
 
Ho, you are using an Humpty Dumpty definition of OO and of polymorphism.
 
sbi
10:09 AM
@jalf AOP? :)
 
i am? since when has oop been totally defined by polymorphisim?
 
sbi
@ChrisBecke I've said it just a few minutes ago: GP is based on OO in the same sense that OO is a layer over Structured Programming. I'm almost sorry to say, but what you're arguing for is, again, nothing but bovine excrements.
 
Genericity is a form of polymorphism (aka parametric polymorphism) as are inclusion polymorphism and overloading and coercision.
 
sbi
@ChrisBecke No, it doesn't. There's static polymorphism, for starters.
 
OO means a lot of different things to different people. AFAIK. The only things common to all is a use of inclusion polymorphism combined with a dynamically resolved overloading.
 
sbi
10:12 AM
@AProgrammer This does require inheritance, which I'd use as another fundamental concept needed for OO.
Oh, and encapsulation.
 
sigh but OO is a layer over SP. And GP is a layer over OO.
so, we are disagreeing to agree then?
 
sbi
@ChrisBecke Yeah, and SP is a layer over assembler, which is a layer over machine code, which is just a layer over wielding a soldering iron. That's as useless a concept as I've ever seen one.
 
@sbi It requires subtyping. Inheritance is just a convinient way to provide subtyping, especially in statically typed languages. You don't need inheritance for instance in SmallTalk (and if SmallTalk is not an OO language, I'm no more sure about what we are speaking)
 
sbi
@AProgrammer Ah, Ok. I don't know any dynamic OO languages, so I take your word for it.
 
@sbi Encapsulation has been provided by non OO languages -- Ada is the one which I know best -- and is provided only by convention in some OO language. IMHO, even if some discovered encapsulation along with OO, it was just an already existing best practice when OO design was being popularized and kept.
 
sbi
10:19 AM
@AProgrammer Of course. Other aspects have been provided by other languages as well. But I thought encapsulation to be a fundamental concept of OO?
 
@sbi it's usually considered to be one, sure, but I also think it's such a general (and widely used/supported) concept it's a bit silly to think of it as an OO thing specifically
 
sbi
@jalf Ok. I always thought of it as a corner-stone of OO, but I might have been wrong about that.
 
@sbi I'd not object really to a prescriptive definition of OO which requires encapsulation, I'd object to a descriptive definition of OO which does. There are too many languages which provides encapsulation without OO. There are languages which provides OO and encapsulation as near-orthogonal features (Ada95 is one).
 
sbi
@AProgrammer Um, what's a "prescriptive" definition compared to a "descriptive" one? dict.leo.org deserted me on this one.
 
@sbi well, it is. But it's also a cornerstone of FP, or any other sane paradigm
anyoen who's programmed for 20 minutes will have realized that "hey, encapsulation would be a pretty good idea"
of course different paradigms implement/support it in different ways
 
10:29 AM
@sbi (virtually flagged as offensive) I think that discussing the qualities and defects of C++ is pretty much on-topic here, and since off-topic discussions are also encouraged even if it was off-topic this chat room would be as fine as any other. I prefer people coming over and keeping polite discussions rather than leading people away from the place.
 
In the first I give a definition and then look how the world can be classified with that definition. In the second I look at the world use of the word and then try to give a definition.
 
sbi
@jalf Is it? How so? My own experience with FP is quite limited (a few lab hours with LISP during my studies), but I can't remember any possibility to hide any functions from others.
@AProgrammer Thanks. I'll make another attempt at cracking your sentence now...
 
@jalf Isn't C++ the result of C with Objects? What am I missing? It was even called C with classes in the beginning of time, and that has lead us to where we are.
 
just now you will be arguing that you can't do oo in c.
 
@ChrisBecke I don't think that hierarchy is correct. You can have generic programming without OO. There is no single dimension.
 
sbi
10:32 AM
@DavidRodríguezdribeas Yeah, but I'm really losing my temper over the guy. This all wouldn't be as embarrassing for him as it is if he would ask for what others think, trying to learn, instead of blurting out his ignorance (over topics where he obviously and seriously lacks knowledge) as judgments as often as possible. Well, that and changing the subject as soon as he's shown the dead end he's heading for at full speed.
 
Anyone that defends that C with objects would be better than C++, do you care to explain what in C++ can be improved to that extent?
 
no, but all the practical examples of gp I know of are using gp to genericize objects.
 
@ChrisBecke ML is in no way OO, but quite a major generic language,
 
@sbi :) Fair enough. That is the reason that I only virtually consider it offensive. My experience, I can be completely fooled though, tells me that you are not one of those: if you don't agree feck off type of guys
@ChrisBecke STL anyone?
 
and even then. the concept of gp is a form of compile time polymorhhisim.
 
10:35 AM
Again, on understanding polymorphism: lucacardelli.name/papers/onunderstanding.a4.pdf
 
sbi
@DavidRodríguezdribeas Well, I'd like to think the same of me, but who am I to judge my character? :)
 
polymorphism isn't an OOP thing either. Again, the concept (and the term) are widely used in FP, just not implemented using inheritance and all the other OOP cruft
 
I must't confuse std::string with an "object" then?
 
@ChrisBecke I cannot agree with that.
 
10:37 AM
@ChrisBecke Genericity is not constrained to be compile time even if it is the case in all major languages. Someone once even pointed me several research languages where genericity was run time, but I don't remember their names. I'd have to look out for them.
 
Python?
 
Pointers to functions are polymorphism? Storing addresses on registers based on some condition is polymorphism?
 
Isn't it generic in a sense?
 
re. encapsulation, it is common in FP languages to have some kind of module system where types or functions are declared within a module (or similar), and only a certain subset of it is exported in the module's interfacae
 
when you write a function template, you write a generic pattern by which actual functions are instantiated, you don't create one function that will behave differently depending on the actual types.
 
10:40 AM
@DavidRodríguezdribeas cann't agree with what? What is the STL an example of?
 
At any rate, it would be in the opposite direction: polymorphism is a limited form of genericity
STL contains a good example of generic programming without being OO. All algorithms, and iterators are very unlike OO
 
Again, genericity is a kind of polymorphism...
 
and what are the iterators iterating if not objects?
 
@AProgrammer Are we discussing the term or the semantics that are bound to the term by common use?
 
@DavidRodríguezdribeas It's educational, perhaps, to look at all of these as basically databases of functions. Looked at from that direction, single inheritance corresponds to a hierarchical database. Multiple inheritance to a network database. Generic programming corresponds to a relational database. Just as it was long ago proved that the network model was a superset of hierarchical, and relational a superset of network, so generic programming is a strict superset of OO.
 
10:44 AM
@JerryCoffin I got lost in the reasoning :)
 
sbi
@ChrisBecke Pointers?
 
hierarchical:network:relational =~= single inheritance:multiple inheritance:generic programming.
 
@ChrisBecke objects my the meaning of C++ object, which is basically anything, including int or struct pod { int x; } that are not objects in the OO sense of it (data and operations that are performed on the data)
 
they are the data, that operations are performed on.
 
@JerryCoffin my problem really is that I don't know enough of DB to understand the left hand side of that relation, so I cannot really tell you whether I can or cannot agree with that implication
 
10:47 AM
I view a c program that defines structs, and functions that operate on those structs, as an oo program.
 
So C is an object-oriented language, as it has types, and structs and operations that are performed on them?
 
why do programmers always act so surprised when they discover that commonly used terms are incompletely defined, inconsistent and self-contradicting?
 
Assembler and assembly functions are also OO? At the end they apply operations to data... I think that the understanding of what OO means is quite different this at both sides of my keyboard
 
@DavidRodríguezdribeas no. c is a multi paradigm language. allowing structural and oo methodologies.
 
@DavidRodríguezdribeas Probably not asm, since it doesn't let you define new types where those properties hold
 
10:49 AM
@ChrisBecke In that case you're back to play Humpty-Dumpty. The rest of the world long ago agreed that inheritance was an essential ingredient of object oriented programming. Without it, you have (at most) what they've agreed to call object based programming.
 
imo, anyway
 
sbi
@jalf Neither does C.
 
@JerryCoffin not sure about that. The languages where the term OOP was first defined didn't use inheritance, afaik
then Java came along and mutilated the definition ;)
 
@ChrisBecke I am actually considering starring this... but I am not sure the irony of it would be caught by others looking only at the starred list on the right
 
@sbi doesn't it? C allows you to to define a new type, on which only certain operations are valid. You can't use arbitrary functions or operators on your newly defined struct.
of course, it falls down on the polymorphism and encapsulation, but C certainly allows you to define new types consisting of data on which certain operations can be applied
 
10:53 AM
The next thing is affirming that C has generic programming, after all I implemented a generic vector in C while at school by means of void* and an interesting amount of casting... Or given a less intricate example, Java up to 1.4... Vector could contain any generic type
 
sbi
@jalf And can't you do the same in assembler? You can assume a certain piece of memory to house data in a certain layout, and add functions ("operations") manipulating that data.
 
@jalf Yes, they did. Simula 67 and Smalltalk (for a couple of obvious examples) most assuredly used inheritance. In any case, that was practically a direct quote from Object Oriented Analysis and Design (Booch). WRT to the terminology of Object orientation, that's as close to an absolute authority as you can get.
 
@DavidRodríguezdribeas And you can do that with the preprocessor, too.
.tmpl file with actual type being a macro, #define/#include/#undef combo, and here's kind-of template in C.
 
You could argue that inheritance is really the wrong term -- it's subtyping that's truly crucial, but C doesn't provide either.
 
@jalf encapsulation can be done in c. declare the struct in a header, define it in its .c file
 
10:55 AM
@sbi asm has no mechanism to limit which operations can be applied to a custom datatype (to the extent that custom data types exist)
also, I'm not really sure what we're arguing at teh moment.
 
and polymorphisim can be done by simply adding typedef'd function pointers to the structs.
as is done in SSL's BIO objects.
 
@ChrisBecke s/done/simulated/
 
Ugh, don't mention OpenSSL.
 
sbi
@jalf Neither has C. If I have a struct my_type, I can do whatever I want with its data.
 
@ChrisBecke yes, OOP can be done in C. Does that make C an OOP language though?
 
10:56 AM
What would the definition of subtyping be? For a long time network protocols have used some sort of subtyping (in one of the possible implementations not using unions:
struct header {...};
struct msg1 { header hdr; ... };
struct msg2 { header hdr; ... };
 
nope.
oo is what programmers do. sometimes despite the language
 
@sbi can you? What happens if I call sqrt on an instance of your my_type
 
You can hide the struct in C.
 
sbi
@jalf I thought we were talking user defined types?
 
and programmers are quite capable of taking an oo language, and using it in a non oo way too
 
10:57 AM
It's even better than C++'s private without PImpl.
 
Which is basically the same as subtyping, with just a required "upcast" from msg1 to header:
void foo( struct header *hdr );
struct msg1 m;
foo( (header*)m ); // ok, more commonly seen as foo( m.hdr )...
 
sbi
8 mins ago, by jalf
@DavidRodríguezdribeas Probably not asm, since it doesn't let you define new types where those properties hold
 
@sbi yes?
 
sbi
@jalf This is where I pointed out that C can't do that either.
 
why not?
you can define a struct, and then define a handful of functions which take that struct as a parameter
and presto, you have a custom datatype with certain operations associated with it
 
sbi
10:59 AM
@jalf You can't define your own type in C that behaves (mostly) like a built-in. You can emulate that using conventions, but you can do the same using asm.
 
@sbi but is it a requirement for OOP that your type has to behave like a built-in one?
 
@DavidRodríguezdribeas Subtyping, at a minimum requires a subtype and a supertype. The usual definition of a "type" is something like "a value and its associated operations". At least if we accept that, it becomes almost impossible to call a C struct a type at all, which pretty much eliminates the possibility of a (user-defined) subtype or supertype.
 
I was just pointing out that in C you can define a datatype with certain operations associated with it, which is one of the keystones of OOP, which can't be done in asm
I never claimed C to be an OOP language
 
sbi
@jalf And I was pointing out that you can do the same in asm, which you had denied.
 
not really. In asm it's all convention. In C, the language enforces it
 
sbi
11:02 AM
@jalf No, it doesn't. I can just as easily reach into any struct, bypassing the functions created for manipulating it, as I can do in asm.
 
in asm there's nothing to stop you from taking the square root of a file handle.
 
@ChrisBecke OO is object oriented. A programmer can write an object oriented program in basically any language they want, but that does not mean that the language itself is object oriented. In the same way that you can dig a hole with a screwdriver, but that does not make the screwdriver a digging tool.
 
@sbi sure, you can bypass it. But for an object foo of some user-defined type, I can only call f(foo) if the operation f is defined for that type.
in asm, you have one or more types of registers, and a fixed set of operations that can be applied to each type of register. Anything beyond that is convention and nothing else
are we discussing whether or not C is an OO language, btw?
 
@jalf Not so -- quite a few assembly languages provide a great deal more than that. In fact, TASM (for one example) started to provide real objects with real inheritance and such around TASM 4.0 or so. Assembly language is not restricted to simply what the processor's instruction set provides.
 
sbi
@jalf: afk for lunch
 
11:06 AM
@JerryCoffin Wow... OO-assembly!
 
@JerryCoffin that seems like moving the goalposts a bit though ;)
or just redefining the term "assembly"
I was using a "naive" definition, which works as I said before, with basically a 1-1 mapping to the hardware
but yeah, if you define a superset of that with OOP features then yes, you'll end up with an ASM'ish language with OOP features
I'm not sure what that proves, other than that if you bend your definitions, you can prove pretty much anything :)
 
@jalf Not at all, really. Assemblers have provided structures for years. An assembler that allows you to define a structure as a subtype of another structure isn't particularly different, and what you're dealing with is still clearly assembly language (mnemonics for the instructions implemented in the hardware, direct access to registers, etc.)
In any case, it has little to do with pointing out the problems with the notion that you can stretch the definitions to the point of including C as "OO", without simply rendering the term completely meaningless.
 
anyone to help ?
 
@JerryCoffin well, even the ability to define structures goes above and beyond what I'd consider a "true" assembly language. But I agree, once you have structures, subtyping another structure is a pretty minimal change
 
@Parkhid It's easier and faster to just ask the question, instead of asking first if the question can be asked. ;)
 
11:22 AM
@jalf If you eliminate structures, you're basically saying that the last "true" assembler was written ~60 years ago. The oldest ones I've worked with (for a PDP-8 and a Control Data mainframe) both had structures decades ago. In fact, when I was in college, the data structures classes were taught using assembly language, because the higher level languages of the time lacked such facilities...
 
@jalf My belief is that the whole discussion is about bending the definitions. If OO is any language in that you can write object oriented code, and we are to accept that C is OO, I don't see that particular case as bending the definition much more. If we talk about the naïve interpretations of the terms, we are back at square one: C is procedural, C++ multiparadigm
@JerryCoffin Oh my, how old are you?
 
@JerryCoffin probabyl true, but I don't really see how it matters. What I feel characterizes an assembly language is that it provides human-readable mnemonics for the hardware's instructions and registers. Structures aren't really a part of that, even if they're a convenient extension
@DavidRodríguezdribeas square one suits me fine ;)
 
@DavidRodríguezdribeas I'm not exactly young, but it's less about my age, than having gone to a college that was rather poorly funded, so we had lots of ancient machines still in use. I grew up in South Dakota. The last time I checked SD was in 50th place out of 50 states for funding their schools (elementary, secondary and post-secondary).
 
11:45 AM
the discussion here started with the premise that Linus prefers C to C++ because perhaps C++ was too hard for him.
And its a premise I think has merit. C++ is too complex for mere humans to use.
 
Well, I think I'm off to a quick nap before a conference call in a few hours. Good...whatever, all.
@ChrisBecke I think it's complete nonsense. As much as I might like the idea of being able to claim superhuman abilities (or being noticeably smarter than Linus) the fact is that I'm simply less prejudiced (at least on this particular subject).
2
 
in your own opinion perhaps.
not that im stating your opinion is more wrong than linus's
just that the merits or failures of c++ always devolve down into the kind of argument over semantics that religious arguments fall into. Which means weve given up trying to understand each others point of view.
The fact is, just looking at the questions posted here on SO that are given the "c++" tag - almost no one thats not academically invested in c++ gives a @#$% about its multi paradigm nature.
they care that it gives them some kind of oo-ish abstraction, with a procedural programming style, because thats how normal brains think.
 
C++ is much easier to use than C, IMO (especially when it comes to safe memory management). The advanced stuff is there, but you can live well without ever touching it, and it still be easier than trying to handle errors in C.
 
outside of acedemia, c++ is used as "c with objects". A job which it has come to do badly. as a result, real developers would probably benefit more from a language that tries to do c with objects better, more than exposing powerful generic programming features.
or worse, trying to get normal developers to express their business logic or games programming problems in terms of functional programming.
@PiotrLegnica Thats rubbish. Programmers have to choose to use the safe pointer wrappers. And they get it wrong. Look at the number of questions on SO that are resolved because auto_ptr is used in place of shared_ptr or something.
You don't really get a choice in c++. the so called "advanced stuff" is not actually optional.
 
12:01 PM
In C++ you don't allocate from heap nearly as often as in C.
 
in c++ its just hidden.
 
Not directly, at least.
And hidden is good.
 
no. because c++ hides it badly
there are so many ways you need to be explicitly aware of what you are doing, or you will do something appalling.
at least, with malloc and free, you know where you are.
 
Like where?
 
with c++, and new, and delete, you can't trust any of your code paths.
code that looks balanced isn't
void foo(string& a){
    string b;
    a = b;
}
c++ developers, depending on the frameworks they are exposed to, are given totally conflicting guidelines as to the best practices and when to pass by value or implicit or explicit reference.
 
12:10 PM
@ChrisBecke translation: "badly written C++ code will break when used incorrectly". How is that different from every other language?
 
@DavidRodríguezdribeas For me polymorphism has a quite precise definition and an existing classification of the different kind. I've already pointed to Cardelli's paper which is usually referenced when a definition is needed. In some contexts, one kind is implied -- inclusion polymorphism in OO language, parametric language in the ML community -- but I take that usage as synecdoche.
 
@jalf it doesnt require a phd to write correctly written <other language>. Just some common sense usually.
 
When OOP and GP are both present in the context, the use of a synecdoche is not welcome and polymorphism should mean the more global concept. Note that OOP implies also a use of another form of polymorphism -- overloading -- while GP is used as a synonym for parametric polymorphism. But it is the addition of overloading (in the form of specialization) to GP which give C++ templates their power.
 
most of the time programmers dont want to give a @#@$ what section 13.5 says about how some language feature behaves.
no language before c++ required me to know what the hell an rvalue was vs an lvalue, and why theyre insufficient and we now need xvalues and two other's as well.
 
@DavidRodríguezdribeas There is OO design, which is more or less independent of the language used for the implementation but make use of subtyping relationship and the possibility of having a per type implementation of some functions.
Then there are OO languages, which provides feature to implement OO design. But with more effort, you can implement them in most languages, included ASM and C (there are even macro packages to help that).
@jalf SmallTalk has inheritance, but subtyping doesn't depend on it IIRC.
 
12:25 PM
hello
 
@jalf Serious ASM programming was always done with powerful macro assembler. Not using them is even more cripling than not using the C preprocessor in C.
@DavidRodríguezdribeas C isn't an OO language. You've to use casts or playing tricks to implement subtyping, you have to play with function pointers to implement dynamic dispatch. In my book, OOL have a type system aware of subtyping (relying on inheritance or not) and have a dynamic dispatch mechanism.
 
Are people using singletons in C++?
 
@AProgrammer I find that C's dynamic dispatch style, as implemented in the COM C API, far more convenient and powerful that C++'s more immutable version using virtuals.
 
@ChrisBecke That's the first time I see my humanity doubted. :-)
 
@Nils when there is an explicit need for a singleton, perhaps, but I haven't used one... there's only very few cases that need singletons I think
 
12:35 PM
@ChrisBecke I've no doubt that some use it like this, but those which aren't and aren't in academia do form a strong enough minority of the C++ programmers I know.
 
I have two classes which depend on each other
using a singleton I could eliminate one reference
 
@Nils: No, you just hide it
in the worst possible way ever
 
However I could also merge them, resulting in a rather large class..
@DeadMG ?
 
@Nils Yes, too many of them. So many that it has become the canonical example of anti-pattern and some fight its use even when it is appropriate.
 
@Nils: All you've done is make that reference global and therefore much harder to control
 
12:40 PM
Singletons are usually more trouble then they're worth
2
 
in CPP it's probably also harder to get right then in Java
 
@Nils Or cut one class or two and break out the circular dependency.
 
So the class is basically assisting another class with data conversion it requires an instance to the class assisting as well as instances to some other classes..
 
@Nils: Suggests to me like you just need to re-think your class descriptions and duties
 
@AProgrammer Yes but then I end up with a rather large class which does many things..
@DeadMG Maybe
 
12:42 PM
@Nils remember the Single Responsibility Principle....
 
when you start considering Singleton as an answer to a problem, you know you've fucked up
6
 
:)
 
@DeadMG couldn't agree more :)
 
@Nils You start with two classes, I suggest to cut them in two, and you complain the result would have too big classes? I've missed something.
 
Cut two classes in two so I have four? Ok I was thinking about merging them @AProgrammer
Humm the single responsibility principle is not violated.
I have the following classes:
- A ParticleCloud, which holds particle objects together and is able to move them on the CPU or on the GPU (both methods do the same, but one one the CPU and the other one on the GPU)
- A TrackGPU class, which does all GPU related stuff like uploading data, invoking kernels, this class is used to hide the inner workings of CUDA, classes which use this class do not need to know about CUDA.
- A class GPUHelper, which converts the C++ classes to 1d arrays for the use on the GPU. It requires a reference to t
Any suggestions?
humm
 
1:06 PM
sorry little busy right now
 
user379888
Can anyone help me out with project reports?What is the standard format of a software report?
 
there's a question and answer site out there
it's called StackOverflow.com
 
@Nils Which class would you make a singleton? What state would it have?
 
The helper
 
I'm not familliar with the problem. What state does it have? Why a free function would not do the work?
 
1:23 PM
how is "A TrackGPU class, which does all GPU related stuff" not a violation of the SRP?
the same could be said for your ParticleCloud. It holds particle objects together and it moves them between CPU and GPU?
 
@ChrisBecke I work in a company that builds high performance latency analysis, we are trying to push the limits, with real time network analysis while decoding market protocols and performing network captures at over 5Gbps. If you look a the code base you will find the different paradigms being used in different layers. The core network analysis is limited to the C subset of C++.
 
@AProgrammer I used free functions first, but some of them need to access the same objects, so I turned it into a class.. Just forget about it I merged it with the Cloud, not the most beautiful solution but works for now
 
@AProgrammer I never said anything about "serious ASM programming". Why do people assume that every time I say that X has some property, then it must implicitly mean that X is superior to everything else?
I simply described what I feel defines an assembly language. I never said that an assembler which does this, and nothing else, is ideal.
 
Configuration, the command line interface, the network APIs (clients connect to extract information) are regular C++, with some templated code, STL containers, inheritance, exceptions... regular C++. Message decoders are heavily templated metaprogramming, allowing very simple to write implementations that are at the same time translated into high performing code, at the same performance that hand tuned code
@ChrisBecke There are not that many questions on what smart pointer to use as there are on how to manually manage memory, which in C is the only option and in C++ you can actually resolve it by using smart pointers.
C does care as much as C++ on l-value/r-value s, try to do this:
struct X foo();
struct X* p = &foo();
in pure C and come back if you don't get the same problems as with C++. Now C++ contains *references* so arguably you have to care in more places.
 
1:46 PM
If I declare a function, but then don't implement it should I get a warning?
 
@Nils An error at link time is what I expect. At run-time is possible with some form of dynamic loading.
 
that's what I got
anyways I'm off cu
 
2:24 PM
debug builds can get a bit pedantic
 
hello
can anyone explain me the difference between

int *p

and

int a[10]
 
uninitialized pointer to ints, vs an array of 10 ints (initialized elements).
 
so why when I try to do this a = a + 1 it says cannot convert from int* to int[10] and when I try to do this p = a + 1 it works.
is that because you cant change the value of a pointer in an array variable?
 
@cyberrog :) Arrays decay very easily to pointers to the first element, in particular in most places where they are used as an rvalue, including arithmetic. The whole process is that the code is transformed by the compiler into the equivalent of:
 
If a + 1 the array is implicitly converted to a pointer to its first element before the addition of 1. So the result is a pointer which can not be assigned to an array but can be assigned to a pointer.
 
2:36 PM
a = &a[0] + 1;
And the types in the expression fail, the rhs is an int* while the lhs is an int[10] (which by definition is unassignable, as arrays are unassignables)
 
because a is an pointer variable with a modifier const, that make any sense?
but a[10] can be considered as an pointer, right??
 
in the case of p = a + 1 the same transformation is performed p = &a[0] + 1 but in this case, the type of the rhs is an int*, as is the type of the lhs
 
a is an array, not a pointer even if in most context it is converted to a pointer to its first element (which would be written &a[0] as David indicated).
 
int a[10] is an array, later a[10] is an int (ill defined, as it points beyond the end of the array, but a[9] would be fine)
 
the book im sutdying confuses me then..
 
2:40 PM
There is a high amount of confusion about arrays in C and C++ in many text books, as many authors believe that they can make things simple by saying that arrays are (somehow like) pointers, which is a fallacy
I have read it in many a place
 
@cyberrog Why am I not surprised? Being clear on the relationship between pointer and arrays is a good qualitity test for C books.
 
it says, p and a are both pointer variables:

int a[10];
typedef int* IntPtr;
IntPtr p;
 
(A good C++ introduction book would probably not write about arrays at all, or leave the subject to an annex)
 
If that is spelled as such, it is outright wrong
 
and it says more: as 'a' is a pointer that points to a variable of the type 'int'(the variable a[0]) , the value can be atributted to the pointer variable 'p':

p = a;
so it says a points to the first position of the array, so its a pointer, right?? or not; =/
 
2:44 PM
@cyberrog In p = a, indeed the array a is converted in a pointer to its first element. That conversion is not a property of variable, it would occurs for any array (say m[42] where m is a bidimentional array)
 
Now, that is less of a fallacy, depending on the translation or the exact phrase. In the expression int * p = a;, the identifier a is an rvalue expression of type int*
 
and it says more: after 'p = a', 'p' points to the same memory position pointed by 'a'. So, p[0], p[1], ... p[9], refers to the indexed variables a[0], a[1],...a[9].
 
Not that a as a variable is a pointer, but that a as the use of that variable in that expression is (decayed into) a pointer to the first element of the array
 
so, should a treat it a as an pointer variable or as just an array in this case?
when it says p = a, it says p receives the address of the first positionof a. right??
 
@cyberrog correct
 
2:46 PM
ok. got it.
 
The use of the array name a in that expression is silently translated into &a[0]
 
but i think also that i couldnt make that atribution to a (a = a + 1), maybe because it has a 'const' implicit. An array variable is not of the type int* but its type is a version of const int*.
for(index = 0; index < 10; index++)
        a[index] = index;

	p = a;

for(index = 0; index < 10; index++)
		p[index] = p[index] + 1;
	cout << "-" << endl;


	for(index = 0; index < 10; index++)
		cout << a[index] << " " << endl;
	cout << "-" << endl;
I have atributed the address of a to p. so if I change the index using p as the array like this p[index] += 1, it automatically change it when using in a. Right??
 
I deleted the last post after rechecking... the use of two overloads void f( int* ) and void f( int (&)[10] ) with an argument of type int[10] is ambiguous
`a` is NOT a `const int*`. Simple test:
const int * cp;
int a[10];
std::cout << sizeof a << ", " << sizeof cp << std::endl;
The pointer p points to the address of the first element of a, and if you modify through that pointer as in p[x]=... you will be modifying a[x], as the pointer refers to elements in a
20
Q: How do I use arrays in C++?

FredOverflowC++ inherited arrays from C where they are used virtually everywhere. C++ provides abstractions that are easier to use and less error-prone (std::vector<T> since C++98 and std::array<T, n> since C++0x), so the need for arrays does not arise quite as often as it does in C. However, whe...

 
@DavidRodríguezdribeas got it.
 

« first day (166 days earlier)      last day (4791 days later) »