User avatar
morphy_richards
Posts: 1603
Joined: Mon Mar 05, 2012 3:26 pm
Location: Epping Forest
Contact: Website

Re: Lol- The joking thread

Thu Jun 02, 2016 6:10 pm

I say, I say, I say.
My dog has no nose.

User avatar
croston
Posts: 703
Joined: Sat Nov 26, 2011 12:33 pm
Location: Blackpool
Contact: Website

Re: Lol- The joking thread

Thu Jun 02, 2016 6:14 pm

morphy_richards wrote:I say, I say, I say.
My dog has no nose.
How does is smell?

Wall-e
Posts: 37
Joined: Thu Jul 09, 2015 7:02 pm

Re: Lol- The joking thread

Thu Jun 02, 2016 6:26 pm

Knock Knock!

Who's there?

.........java.
Who the heck is Kernel panic and why is he killing my computer!

Heater
Posts: 13902
Joined: Tue Jul 17, 2012 3:02 pm

Re: Lol- The joking thread

Thu Jun 02, 2016 6:35 pm

Java who?

ECMAScript 2015.
Memory in C++ is a leaky abstraction .

Heater
Posts: 13902
Joined: Tue Jul 17, 2012 3:02 pm

Re: Lol- The joking thread

Thu Jun 02, 2016 6:38 pm

Guy goes to visit his doctor.

Doctor says, "Hello, I haven't seen you for a long time"

Guy says, "No, I've been ill"
Memory in C++ is a leaky abstraction .

Heater
Posts: 13902
Joined: Tue Jul 17, 2012 3:02 pm

Re: Lol- The joking thread

Thu Jun 02, 2016 6:42 pm

After a Spitfire flown by a Polish pilot crashed during the Second World War, the crash investigation report concluded:

"The accident was caused by a failure of the control system, a simple pole in the complex plane".
Last edited by Heater on Wed Sep 21, 2016 12:10 pm, edited 1 time in total.
Memory in C++ is a leaky abstraction .

User avatar
morphy_richards
Posts: 1603
Joined: Mon Mar 05, 2012 3:26 pm
Location: Epping Forest
Contact: Website

Re: Lol- The joking thread

Thu Jun 02, 2016 7:08 pm

croston wrote:
morphy_richards wrote:I say, I say, I say.
My dog has no nose.
How does it smell?
Terrible!

hippy
Posts: 6244
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Lol- The joking thread

Thu Jun 02, 2016 7:51 pm

rurwin wrote:FWIW, I can't see any problem with the last example, but 'fooNaN'? that's crazy. ;)
I guess that's also just operator precedence ... foo' + + foo ... 'foo' + ( + 'foo' ) ... so makes sense as a string concatenated with a number( which isn't really a number ) converted to a string. Entirely logical, consistent and predictable from language definition even if it may seem odd if expecting something else.

Having written a few small compilers; I tend to favour no automatic type promotion, but integer to float usually ends up as an exception to the rule. I would throw an error on anything which created a not-a-number but can see why some find it useful to have that as a unique value.

blaablaaguy
Posts: 623
Joined: Sun Sep 27, 2015 3:26 pm

Re: Lol- The joking thread

Thu Jun 02, 2016 8:07 pm

rurwin wrote:No comment
Javascript.png
I didnt fully believe that untill i tried it in the JS console. O_o
This signature intentionally left blank.

Heater
Posts: 13902
Joined: Tue Jul 17, 2012 3:02 pm

Re: Lol- The joking thread

Fri Jun 03, 2016 9:55 pm

bertwert,
World War Eleven?
Yes. We turned it up as far as we could.

https://www.youtube.com/watch?v=KOO5S4vxi0o
Memory in C++ is a leaky abstraction .

Heater
Posts: 13902
Joined: Tue Jul 17, 2012 3:02 pm

Re: Lol- The joking thread

Fri Jun 03, 2016 10:07 pm

blaablaaguy,
I didnt fully believe that untill i tried it in the JS console.
This is C:
printf("%d\n", 2500000000 + 2500000000);
Produces: 705032704

This is Javascript:
console.log(2500000000 + 2500000000)
Produces: 5000000000

Who is laughing now?

All languages have their weirdness. Especially your spelling above :)
Memory in C++ is a leaky abstraction .

User avatar
rpdom
Posts: 15584
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Lol- The joking thread

Fri Jun 03, 2016 10:15 pm

Heater wrote:This is C:
printf("%d\n", 2500000000 + 2500000000);
Produces: 705032704
and when compiling you will quite rightly get a warning that you have done something stupid
"warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long int’"

so when you put the correct code in
printf("%ld\n", 2500000000 + 2500000000);
you get the correct result: 5000000000

Yes, you can break most languages if you try hard enough :lol:

blaablaaguy
Posts: 623
Joined: Sun Sep 27, 2015 3:26 pm

Re: Lol- The joking thread

Fri Jun 03, 2016 10:27 pm

rpdom wrote:
Heater wrote:This is C:
printf("%d\n", 2500000000 + 2500000000);
Produces: 705032704
and when compiling you will quite rightly get a warning that you have done something stupid
"warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long int’"

so when you put the correct code in
printf("%ld\n", 2500000000 + 2500000000);
you get the correct result: 5000000000

Yes, you can break most languages if you try hard enough :lol:
This is too much for my brain to handle. I suppose all that matters is that you can actually use the language.
This signature intentionally left blank.

Heater
Posts: 13902
Joined: Tue Jul 17, 2012 3:02 pm

Re: Lol- The joking thread

Fri Jun 03, 2016 10:30 pm

rpdom,
and when compiling you will quite rightly get a warning that you have done something stupid
"warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long int’"
That is true is you if are talking about constants. But:

Code: Select all

$ cat junk.c
#include <stdio.h>

int main (int argc, char* argv[])
{
    int x = 2500000000;
    int y = 2500000000;
    int z  = x + y;
    printf("%d\n", z);

    return (0);
}

$ gcc -Wall junk.c
$ ./a.out 
705032704
FAIL.

I find it amazing that in 2016 programming languages still silently produce totally the wrong result when doing simple arithmetic. It's not just C of course.
Memory in C++ is a leaky abstraction .

User avatar
Burngate
Posts: 6100
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Lol- The joking thread

Sat Jun 04, 2016 9:17 am

Heater wrote:I find it amazing that in 2016 programming languages still silently produce totally the wrong result when doing simple arithmetic. It's not just C of course.
Did it produce the wrong answer, or was it that what you told it to do and what you thought you told it to do were different?
So it's not the computer or the compiler or the language that's at fault, it's you?

@Bertwert: I was going to make some snarky comment about Roman numerals, but then I went to Wikipedia and discovered there's a lot more to the subject than I'd realised!
So thanks for that!

User avatar
DougieLawson
Posts: 36560
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Lol- The joking thread

Sat Jun 04, 2016 10:13 am

Burngate wrote: @Bertwert: I was going to make some snarky comment about Roman numerals, but then I went to Wikipedia and discovered there's a lot more to the subject than I'd realised!
So thanks for that!
Sixteen years ago a friend of mine gave me a REXX program to convert Arabic numbers to Roman numerals and Roman numerals back to Arabic numbers. I re-wrote that code in JavaScript and published it, it's still out there, it's still 100% pointless.

http://www.javascriptsource.com/page-de ... erals.html is one half, don't know if I've got the other half. (It's probably sitting on a hard disk somewhere.)
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

Heater
Posts: 13902
Joined: Tue Jul 17, 2012 3:02 pm

Re: Lol- The joking thread

Sat Jun 04, 2016 10:14 am

Burngate,
Did it produce the wrong answer, or was it that what you told it to do and what you thought you told it to do were different? So it's not the computer or the compiler or the language that's at fault, it's you?
That is an oft stated opinion about such programming mistakes.

If we carry that train of thought to the extreme then we could ask:

Why does the compiler issue any syntax or other errors, it should just compile whatever you give it as best it can. If you have it wrong it's your fault.

Why have exceptions for divide by zero, or out of bounds memory access. Just return random numbers like numeric overflow does. If you have it wrong it's your fault.

And so on.

I'm not about to suggest that C be changed to do this. That would hurt performance. If we really want such checks we can use Ada.

The core of the problem is that CPU's don't offer any help in this matter.
Memory in C++ is a leaky abstraction .

User avatar
DougieLawson
Posts: 36560
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Lol- The joking thread

Sat Jun 04, 2016 10:29 am

Heater wrote: The core of the problem is that CPU's don't offer any help in this matter.
That's because the hardware makers still haven't introduced the DWIM instruction to fully enable that type of fuzzy logic.










DWIM - Do What I Mean
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

Heater
Posts: 13902
Joined: Tue Jul 17, 2012 3:02 pm

Re: Lol- The joking thread

Sat Jun 04, 2016 10:48 am

Fuzzy Logic?

Are suggesting the random number generator we have now is better?

Did you mean the DIMWIT instruction?

I'm all up for that idea.

:)
Memory in C++ is a leaky abstraction .

User avatar
DougieLawson
Posts: 36560
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Lol- The joking thread

Sat Jun 04, 2016 11:32 am

Heater wrote:Fuzzy Logic?

Are suggesting the random number generator we have now is better?

Did you mean the DIMWIT instruction?

I'm all up for that idea.

:)
The DIMWIT instruction is already in hardware and used everyday by the folks who can't survive without being assimilated into the Faceborg.

The DWIM (do what I mean) will revolutionise computing, we'll be able to stop blaming all of those bugs on moths dying on our circuit boards.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Lol- The joking thread

Sat Jun 04, 2016 4:56 pm

Heater wrote:The core of the problem is that CPU's don't offer any help in this matter.
Unless the ARM is highly unusual, the CPU will correctly raise the overflow flag. It may even attempt to signal an exception. If the user's code doesn't check the former and disables the latter, it isn't the CPU's fault.

C was designed to be fast and to allow all sorts of messing about that a decent language would object to, because those are the sorts of things you have to do when you are talking to hardware and wringing every last bit of performance out. The languages about at the same time C was developed -- Pascal, Basic, Fortran, Algol, Cobol, Ada, Coral, Modula, etc., etc. -- were developed for higher-level purposes and do indeed check for overflow and array bounds and all the other stuff that C doesn't do. Even Lisp silently upgrades an integer to long if required, just like Javascript. Unfortunately C took over the world and not only is it being used for projects that should be using a more defensive language, but its laissez faire attitude has become the new normal.

User avatar
rpdom
Posts: 15584
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Lol- The joking thread

Sat Jun 04, 2016 7:10 pm

rurwin wrote:
Heater wrote:The languages about at the same time C was developed -- Pascal, Basic, Fortran, Algol, Cobol, Ada, Coral, Modula, etc., etc. -- were developed for higher-level purposes and do indeed check for overflow and array bounds and all the other stuff that C doesn't do.
One of the main problems I remember when I was using COBOL-74 was that it didn't check things like array bounds or anything like that.

The majority of problems that I had to diagnose for people was where data had been written past the end of an array (OCCURS) and overwritten other variables with all sorts of invalid values.

timrowledge
Posts: 1289
Joined: Mon Oct 29, 2012 8:12 pm
Location: Vancouver Island
Contact: Website

Re: Lol- The joking thread

Sat Jun 04, 2016 8:07 pm

Y'have to remember that C is just a lot of complex wrapping around a PDP-8 assembler. It isn't *meant* to do much to help you with problems like bounds checking etc. It *is* meant to help you plunder and pillage memory.

The ontological mistake with C++ is the attempt to provide very high level concepts such as object oriented programming *without* stopping the utterly antithetical plunder-and-pillage. Crazy.
Making Smalltalk on ARM since 1986; making your Scratch better since 2012

User avatar
DougieLawson
Posts: 36560
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Lol- The joking thread

Sun Jun 05, 2016 2:39 pm

rpdom wrote: One of the main problems I remember when I was using COBOL-74 was that it didn't check things like array bounds or anything like that.

The majority of problems that I had to diagnose for people was where data had been written past the end of an array (OCCURS) and overwritten other variables with all sorts of invalid values.
Which is why COBOL-92 includes SSRANGE - subscript range checking.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

Wall-e
Posts: 37
Joined: Thu Jul 09, 2015 7:02 pm

Re: Lol- The joking thread

Tue Jun 07, 2016 8:01 pm

ARM Processor...
Image
Who the heck is Kernel panic and why is he killing my computer!

Return to “Off topic discussion”