Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

My OO...

Name: Anonymous 2011-12-13 3:19

...it's violated!

http://programmers.stackexchange.com/questions/17031/when-c-handles-pop-in-your-c-code-and-break-your-pretty-oo-design

Anime avatar. Passive-aggressive rant. Autismal as fuck. That's gotta be someone from /prague/, amirite?

Name: Anonymous 2011-12-15 6:13

>>40
That's precisely my point. The idea that we should, for some reason, force developers to test their own code is ludicrous. That people think dynamic typing will help effect such incentives is at best comical, at worst incredibly dangerous.

Name: Cudder !MhMRSATORI!FBeUS42x4uM+kgp 2011-12-15 7:21

>>41
Learn formal verification.

Name: Anonymous 2011-12-15 7:55

embrace chaos

Name: Anonymous 2011-12-15 8:03

Woho, I got dubs!

(I think...)

Name: Anonymous 2011-12-15 8:04

emrase my dik

Name: Anonymous 2011-12-15 10:12

>>32
Says you.  Most people, including Wikipedia, say otherwise.  "Strongly typed" and "weakly typed" aren't well defined.  Well, not in a way that's widely accepted, anyway.

Name: Anonymous 2011-12-15 10:19

>>46
The only reason they aren't well-defined is because so many sepples fags insist it is a strongly typed language. They're wrong, and C++ is garbage. It's like saying evolution isn't well-defined or widely accepted because there are a bunch of creationist idiots.

Name: Anonymous 2011-12-15 11:15

>>47
No, it isn't like that at all, and you're no longer credible or welcome in this thread.

Name: Anonymous 2011-12-15 11:20

>>48
Lisp has stronger typing than C++. Deal with it.

Name: Anonymous 2011-12-15 11:25

>>49
That doesn't mean that C and C++ aren't strongly typed.  Deal with it.

Name: Anonymous 2011-12-15 11:32

>>50
They aren't. Look at the wikipedia page you mention. Here are the criteria mentioned:
* Absence of unchecked run-time type errors. C++: nope lol.

* Strong guarantees about the run-time behavior of a program before program execution, whether provided by static analysis, the execution semantics of the language or another mechanism. C++: nope lol.

Type safety; that is, at compile or run time, the rejection of operations or function calls which attempt to disregard data types. ... C++: partial credit, only because I omitted the rest of the paragraph.

* [Static typing bullshit omitted]

* Fixed and invariable typing of data objects. The type of a given data object does not vary over that object's lifetime. C++: nope lol.
* Omission of implicit type conversion, that is, conversions that are inserted by the compiler on the programmer's behalf. C++: nope lol

* Disallowing any kind of type conversion. Values of one type cannot be converted to another type, explicitly or implicitly. C++: nope, lol.

* A complex, fine-grained type system with compound types.
Brian Kernighan: "[..]each object in a program has a well-defined type which implicitly defines the legal values of and operations on the object. The language guarantees that it will prohibit illegal values and operations...
C++: nope lol

Name: Anonymous 2011-12-15 13:56

>>51
STOP BEING STUPID (not an insult -- I actually want you to take a moment and make an effort to be less stupid, for everyone's sake)

Those are examples under a heading that reads:
Some of the factors which writers have qualified as "strong typing" include:

They are listed to illustrate the fact that there is no widely accepted, consistent definition.

Right above that heading, there's a handy little table that looks like this:

┌───────────────────────────────────┬────────────────────────────────┐
│            Weak Typing            │         Strong Typing          │
├───────────────────────────────────┼────────────────────────────────┤
│Perl, PHP, Rexx, JavaScript, BASIC │ Java, C, C++, Python, C#, Vala │
└───────────────────────────────────┴────────────────────────────────┘


You can do this!  I believe in you!

Name: Anonymous 2011-12-15 15:51

>>52
Weak Typing
BASIC

Stop being retard. BASIC is like Haskell - strong and static:
http://en.wikipedia.org/wiki/Visual_basic
Typing discipline     Static, strong

Name: Anonymous 2011-12-15 16:29

>>52
The point, you dunce, is that in almost any sense in which one uses ``strong typing'' your beloved sepples fails hard, a feeling with which I am sure you are familiar.

Name: Anonymous 2011-12-15 17:50

>>54
I really tried, but you're stuck on your feelings being hurt, or something.  All I can do is refer you to the obvious, which is pointed out several times in this thread, probably most clearly here: >>29

I don't like C++ much, so your big nasty diss on my beloved language is misplaced.  But even my dislike of it (and yours) isn't enough to make it a weakly typed language.

Name: Anonymous 2011-12-15 17:53

>>53
There are a lot of BASICs in the world, and Visual Basic is probably the least "BASIC-like" of all of them.  But if you feel strongly about it, then you should go and fix the Wikipedia article.

Name: Anonymous 2011-12-15 19:04

>>55
Way to talk out of both sides of your mouth. First it is poorly defined (because, well, there's no consensus, which is an interesting definition of ``being well-defined''), and second it is strongly typed anyway. There are words for such arguments but a lesson in vocabulary will not further the conversation.

Sorry, but C++ isn't a strongly typed language. C is barely typed at all, and that's only if we follow the most trivial definition of "typing" to mean something like "there are keywords for types." C++ improved this not at all, because of course even though everything C is evil and wrong and dangerous, it should be compatible with C anyway.

I'm sure if one's interest is in defending C++ as a ``strongly typed language with support for object-oriented programming'' then one could come up with all matter of snake oil to rub on the warts. But those of us without any particular attachment to C++ can see plainly that C++'s types are approximately comments that are read by a compiler and little more. This is due strictly to its C roots, and C gets it from trying to be something like a portable assembler, and assemblers aren't generally typed for good reason. (Though there are of course typed assembly languages. For good reason.)

It is shameful that languages without explicit type annotation have better behavior than a language with it. Shameful. To then turn around and actually call such a language ``strongly typed'' for whatever non-trivial meaning is absolutely disgusting.

Name: Anonymous 2011-12-15 19:21

>>52
That table is nonsense and seems to be built on the idea that weak typing precludes static typing. Not only is C weakly typed, it behaves differently than stated:

concatenate(a, b) # not a type error, probably a segfault
add(a, b)         # not even wrong, just semantically different


You can even change "2" to 2.0, and it moves from the right column to the left column.

Name: Anonymous 2011-12-15 19:58

>>57
Look.  In perl, you can do this:


 $x = 5;
 $x = "string";


In C, you can't.  You have to explicitly type-cast or you get a compiler error.  In C++, the same is true for POD types and even classes, generally.  You can always circumvent the type system by casting, taking address-of, etc...  but that does not mean that the language is not strongly typed.

That's all there is to it.  It's "poorly defined" because there are many conflicting definitions for it.  But by the most commonly accepted definition -- which, from the beginning of this discussion, has been equivalent to "statically typed" -- C is absolutely, positively, "strongly typed."

You are confusing this extremely simple statement of a fact with "defending" a language which is misleading.  It's convenient to just assume that everyone who disagrees with you does so because they're in love with a particular language, but it seems like the reverse is true...  You want C or C++ to be weakly typed just because you hate it.  Being weakly typed isn't even necessarily a bad thing.  You calling C++ weakly typed wouldn't be an insult to the language even if it were true.

Name: Anonymous 2011-12-15 20:03

>>58
You can even change "2" to 2.0, and it moves from the right column to the left column.
NO!  This is 100% completely false, and your misunderstanding is apparently common to nearly every poster in this thread.

If you take the example on the right side of the table as C, then it would have to look like this:


int a = 2;
char *b = "2";
 
concatenate(a, b);
add(a, b);


See that?  Variables are declared with a static type.  Changing the first line to this:


int a = 2.0;


does not change a to type float.

Name: Anonymous 2011-12-15 20:06

>>59
You can always circumvent the type system by casting, taking address-of, etc...  but that does not mean that the language is not strongly typed.
In sepples fantasy land, sure.

``It's a great house! It's only missing a roof, but that's 5 out of six sides covered!!''

Name: Anonymous 2011-12-15 20:14

>>61
That's the point!  Yes, that would be a shitty house.  But it would still be a house.  Yes, C and C++ are shitty, but they are indeed strongly typed.  That doesn't make you any less of a man!

Name: Anonymous 2011-12-15 20:38

>>59
In C, you can't.  You have to explicitly type-cast or you get a compiler error.
int main()
{
    char * x;
    x = 5;
    x = "Hello";
    return 0;
}


GCC:
Compiling: main.c
main.c: In function 'main':
main.c:4: warning: assignment makes pointer from integer without a cast
Linking console executable: bin\baka1.exe
Output size is 25.11 KB
0 errors, 1 warnings


OpenWatcom:
Compiling: main.c
main.c(4): Warning! W101: Non-portable pointer conversion
main.c(4): Note! N2003: source conversion type is 'int '
main.c(4): Note! N2004: target conversion type is 'char *'
Linking console executable: bin\baka2.exe
Output size is 32.01 KB
0 errors, 3 warnings


Digital Mars:
Compiling: main.c
    x = 5;
         ^
main.c(4) : Error: need explicit cast to convert
from: int
to  : char *
--- errorlevel 1
1 errors, 0 warnings

Name: Anonymous 2011-12-15 20:38

I'M TYPING SO HARD RIGHT NOW

Name: Anonymous 2011-12-15 20:38

>>62
But it would still be a house.
Only if you live in sepples-land.

Name: Anonymous 2011-12-15 20:47

>>58,60
Ah, shit.  I just realized that I misread your example.  You're suggesting something more like this:


int a = 2;
float b = 2.0f;

add(a, b);


And you're right, that would be allowed by any C compiler I've ever used.  Yes, there are special rules for "arithmetic promotion."  It's still misleading to call that dynamic typing, though.  It amounts to some temporary anonymous variables to convert from float to int during the call to the function.  Yeah, believe me, I fully understand how shitty C is.  Still, shitty does not necessarily imply weakly typed.

Name: Anonymous 2011-12-15 20:51

>>66
Why are you so desperate to defend C on false grounds when it is a perfectly useable language? Not being strongly typed is only an insult if one is used to defend shit languages, of which C is not a member. C++, of course, is fucking trash and deserves heaps and stacks of scorn.

Name: Anonymous 2011-12-15 20:51

>>63
Thanks, but I don't think anyone needed you to go to all that trouble just to prove the statement.  Some compilers give you warnings and others give you errors.  Strictly compliant ones give you errors.

But more importantly, NO C compiler implicitly converts the string "Hello" into an integer.  If a compiler does actually generate code, you will (obviously) end up with the address of the literal in x.

Name: Anonymous 2011-12-15 20:53

>>67
Yeah, believe me, I fully understand how shitty C is.
Why are you so desperate to defend C

Name: Anonymous 2011-12-15 21:01

>>68
so, about that strong typing...

Name: Anonymous 2011-12-15 21:03

>>69
It's not strongly typed. That's not an insult, it is just life. The weaseling in this thread is totally ridiculous.

Name: Anonymous 2011-12-15 21:07

>>71
Well, ok.  You're free to choose to believe that it's dynamically typed.  And you're free to write int a = "2"; and pray to the magic typing unicorn that the value of 2 will actually end up in that variable.  And if you ever do actually use C one day, you can test your theory.  Until then, stick with your convictions.

Name: Anonymous 2011-12-15 21:18

>>72
And you're free to write int a = "2"; and pray to the magic typing unicorn that the value of 2 will actually end up in that variable.
It's cute that not only can you not actually succeed in your apologetics, you have to resort to made-up semantics for how you think I think C behaves to feel your hollow victory.

There's nothing wrong with C. It's just not strongly typed. That's not a complaint.

Name: Anonymous 2011-12-15 21:22

I feel C's typing reflects its low level assembler design as its types originally wasn't meant at all for safety but for specifying word size and register type behavior since the expression tree links are register bound. C++ can't have ML or Haskell-tier type safety and keep C compatibility.

Name: Anonymous 2011-12-15 21:32

Name: Anonymous 2011-12-15 21:38

>>66
Yes, there are special rules for "arithmetic promotion."
The distinction is useless (i.e. purely arbitrary) if you allow it for floats and not for pointers to char. This is why I'll tell anyone who says C isn't weakly typed they don't know C.

It's still misleading to call that dynamic typing, though.
It's not dynamic, it's static with an implicit conversion. Even C's explicit type conversions are not safe on the whole, esp. void.

Yeah, believe me, I fully understand how shitty C is.  Still, shitty does not necessarily imply weakly typed.
For one, I love C. There are a few things I wish were different but changes to the type system are very far down that list. I wouldn't call it shitty by any means. You've probably read those blog posts about "const poisoning" by Chicken Little—it's never difficult to resolve by those who actually write C without posting every challenge they encounter to their blog.

The 'strength' of the type system isn't a value judgment, it's a semantic one. The typing is weak because it's weakly enforced, in fact you won't get much weaker in a static language.

>>68
But more importantly, NO C compiler implicitly converts the string "Hello" into an integer.
#include <stdio.h>

int main(void) {
   printf("%d\n", 2 + "Hello");
   return 0;
}


You sure about that? Might want to check the assembly output.

Name: Anonymous 2011-12-15 21:49

>>76
You sure about that? Might want to check the assembly output.
Within the compiler, 2 + "Hello" is still a char *.

Name: Anonymous 2011-12-15 21:51

>>76
congrats you just printed out the pointer address

Name: Anonymous 2011-12-15 21:52

>>78
pointer address + 2 i should say *

also use %p or 2 + *"Hello"

Name: Anonymous 2011-12-15 21:58

>>78
Perhaps you should attempt to understand what this thread is about before responding.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List