Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

AlsoD posted:

actually wait no, because i work in a immutable language it's

code:
let s = t

most strings in c are immutable, in the sense that trying to mutate them results in an mpu exception and a core dump :q:

also, in your language where most datatypes are immutable, you've got copy-on-write behind the scenes when you actually have to have a text buffer or whatever rather than a static string. one can reasonably argue that making this mostly transparent to the user is beneficial, but it isn't completely trivial; the distinction between value equality and reference equality still exists somewhere and comes up in at least some contexts

Adbot
ADBOT LOVES YOU

Tiny Bug Child
Sep 11, 2004

Avoid Symmetry, Allow Complexity, Introduce Terror
lol i'm a lowly php dev and i immediately knew what (*s++ = *t++) meant. lol at elitist c people who pretend pointers are this huge intractable mystery and not a simple but hacky concept that should rarely be used

Mr. Glass
May 1, 2009

Tiny Bug Child posted:

a simple but hacky concept that should rarely be used

haha what

Tiny Bug Child
Sep 11, 2004

Avoid Symmetry, Allow Complexity, Introduce Terror
pointers. they're not hard to understand, it's just that there's almost always a better way to do something than use pointers.

akadajet
Sep 14, 2003


c and pointers are garbage

vapid cutlery
Apr 17, 2007

php:
<?
"it's george costanza" ?>

Tiny Bug Child posted:

lol i'm a lowly php dev and i immediately knew what (*s++ = *t++) meant. lol at elitist c people who pretend pointers are this huge intractable mystery and not a simple but hacky concept that should rarely be used

you're really suggesting that people who are C experts actually thing pointers are an "intractable mystery"? ahahahahah

vapid cutlery
Apr 17, 2007

php:
<?
"it's george costanza" ?>
i'm a C expert but this concept of pointing.. at memory... eludes me

Mr. Glass
May 1, 2009
instead of copying this 500kb struct around i am going to take its address and "point" at it

ugh what a disgusting hack

Notorious b.s.d.
Jan 25, 2003

by Reene

Mr Dog posted:

treating arrays interchangeably with pointers to their first element is rather obtuse. i mean yeah it makes a lot of sense once you realise the array :2bongs: BOUNDARIES ONLY EXIST IN YOUR HEAD, MAAAAAAAAN :2bongs: but yeah it's really obtuse.

unfortunately arrays are not necessarily 100% interchangeable with pointers, they are a separate type

arrays are pointers except when they're not. and the exceptions change if you pass an array to a function

Tiny Bug Child
Sep 11, 2004

Avoid Symmetry, Allow Complexity, Introduce Terror

vapid cutlery posted:

you're really suggesting that people who are C experts actually thing pointers are an "intractable mystery"? ahahahahah

of course not you dingus. obviously they know there's nothing to it, they just treat it like a huge deal to scare off real devs

Tiny Bug Child
Sep 11, 2004

Avoid Symmetry, Allow Complexity, Introduce Terror

Mr. Glass posted:

instead of copying this 500kb struct around i am going to take its address and "point" at it

ugh what a disgusting hack

real languages automatically use pass by reference so programmers don't have to worry about it.

vapid cutlery
Apr 17, 2007

php:
<?
"it's george costanza" ?>

Tiny Bug Child posted:

of course not you dingus. obviously they know there's nothing to it, they just treat it like a huge deal to scare off real devs

that is completely false. it's uninformed morons like you who hype it up

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

the "exceptions" don't "change", rather an array passed as an argument to a function decays to a pointer to its first element. this simple topic is covered in the comp.lang.c faq clearly and accurately so it's distressing to see people repeating gibberish and hoodoo about it twenty years on

vapid cutlery
Apr 17, 2007

php:
<?
"it's george costanza" ?>

Tiny Bug Child posted:

real languages automatically use pass by reference so programmers don't have to worry about it.

nah, actually they pass references by value.

Mr. Glass
May 1, 2009

Tiny Bug Child posted:

real languages automatically use pass by reference so programmers don't have to worry about it.

ahahahaha i just can't with this

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

vapid cutlery posted:

nah, actually they pass references by value.

oh cool time to debate what "pass by reference" means

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
time to debate what goatse means.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
I think it means "frog golf"

Tiny Bug Child
Sep 11, 2004

Avoid Symmetry, Allow Complexity, Introduce Terror

Suspicious Dish posted:

oh cool time to debate what "pass by reference" means

pass by reference means if you give a function a thing it can change the thing and the change is visible outside the scope of that function.

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

Mr Dog posted:

So what you're saying is that pointers per se aren't hard, it's just that C's syntax for pointers is terrible (and it also permits wankery like the above).

I would say that if only the notion of pointers wasn't so prevalently related with how C deals with it

someone earlier in the thread said that assembly makes pointers easier to understand and I feel that she's right but I'm not sure if it's just because I'm used to C pointers now

pointer homeworks are nothing to diss

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Pointers aren't confusing, but the myriad of custom memory layouts are, with crazy arithmetic and dynamic allocation. And they don't get less and less confusing as time goes on. It's what makes an old C codebase feel like an old C codebase.

If your only pointers to the head of a struct, then that's a lot easier of a model to teach. And from there, you can expand how you can point to specific fields in the struct, and then go into the rest of the model.

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

Suspicious Dish posted:

Pointers aren't confusing, but the myriad of custom memory layouts are, with crazy arithmetic and dynamic allocation. And they don't get less and less confusing as time goes on. It's what makes an old C codebase feel like an old C codebase.

If your only pointers to the head of a struct, then that's a lot easier of a model to teach. And from there, you can expand how you can point to specific fields in the struct, and then go into the rest of the model.

if you cant handle indirection you are a bad computer scientist and programmer

the essence of cs is indirection via abstraction and vice versa

tractor fanatic
Sep 9, 2005

Pillbug

Suspicious Dish posted:

If your only pointers to the head of a struct, then that's a lot easier of a model to teach. And from there, you can expand how you can point to specific fields in the struct, and then go into the rest of the model.

I actually think C makes for a good beginners language, because it's one of the few that doesn't conflate the notion of pointer with the notion of struct although it conflates pointers and arrays.

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY
c looks like a good first language if you consider computation to be something that's done by computers

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Malcolm XML posted:

if you cant handle indirection you are a bad computer scientist and programmer

the essence of cs is indirection via abstraction and vice versa

I still find systems that are over-abstracted and have too much indirection. That's the issue with a lot of "enterprise" systems -- they're too scared of sitting down and writing if (business_condition) in the code that they come up with a crazy rules systems. Look at the many "configurable" FizzBuzz tests and rules engines and all that.

Too many macros is what kills Lisp. You build such a framework in your own language that it's hard to teach and hard to debug.

A bit of indirection is OK. But these are also new students. You need to ramp it up over time. Show them the basics first.

vapid cutlery
Apr 17, 2007

php:
<?
"it's george costanza" ?>

Suspicious Dish posted:

oh cool time to debate what "pass by reference" means

Is a debate where uninformed people give their opinions on a factual topic?

Sapozhnik
Jan 2, 2005

Nap Ghost
ppl getting tbc'ed pretty hard itt

tef
May 30, 2004

-> some l-system crap ->

Tiny Bug Child posted:

real languages automatically use pass by reference so programmers don't have to worry about it.

perl :q:

Notorious b.s.d.
Jan 25, 2003

by Reene

Otto Skorzeny posted:

the "exceptions" don't "change", rather an array passed as an argument to a function decays to a pointer to its first element. this simple topic is covered in the comp.lang.c faq clearly and accurately so it's distressing to see people repeating gibberish and hoodoo about it twenty years on

this means the exceptions to normal pointer behavior are different between an array i declare myself and an array passed to me as an argument

it's not gibberish or hoodoo, it's just a stupid and pointless inconsistency

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
the words you just said are gibberish and hoodoo; your fuzzy understanding of the subject is probably due to years of neglect from java

Notorious b.s.d.
Jan 25, 2003

by Reene

Otto Skorzeny posted:

the words you just said are gibberish and hoodoo; your fuzzy understanding of the subject is probably due to years of neglect from java

my understanding isn't fuzzy. I know exactly how this works because I have to remember these stupid details.

It's just loving stupid.

C code:
#include <stdio.h>

// -*- mode: c -*-
// 
// fucking_stupid.c
//

int main() {
  char a_real_array[12] = "C is stupid";
  printf( "Size of a real array: %d\n", sizeof( a_real_array ) );
  printf( "Size of a decayed array: %d\n", decay( a_real_array ) );
}

int decay( char dumb_array[] )
{
  return sizeof( dumb_array );
}
code:
Size of a real array: 12
Size of a decayed array: 8
When has this exception benefited anyone, anywhere? Given that an array decays to a pointer 99.9% of the time, when is the array type useful?

Notorious b.s.d.
Jan 25, 2003

by Reene
the fact that the difference between an array type and a normal pointer is in the comp.lang.c FAQ should be an indicator that people ask about it.

tractor fanatic
Sep 9, 2005

Pillbug
the only exception you need to remember is that [] indicates a pointer, and not an array when it appears in the parameter list. it's not an array that's decayed to a pointer, it's just a pointer.

FamDav
Mar 29, 2008
arrays wouldnt decay to pointers if bjarne had just shown them the light of references a little earlier

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
that's not an "exception" to anything - it's arguable that the deceptive function signature "int decay(char[])" shouldn't be legal, but the semantics are pretty clear and obvious. as for when the array type is useful, consider the case where you want to initialize a buffer with a string literal but have it be writeable later.

b0lt
Apr 29, 2005

Tiny Bug Child posted:

php: a simple but hacky concept that should rarely be used

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

I sit near the HHVM people who have been working on the PHP language specification we're about to publish. I don't know how they're ever sober enough to focus their eyes. They just radiate despair.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
lol

Tiny Bug Child
Sep 11, 2004

Avoid Symmetry, Allow Complexity, Introduce Terror

Subjunctive posted:

I sit near the HHVM people who have been working on the PHP language specification we're about to publish. I don't know how they're ever sober enough to focus their eyes. They just radiate despair.

i assume this is because PHPNG is going to render HHVM completely obsolete (and usher in a new era of widespread PHP usage now that its one downside, poor performance, is a thing of the past)

Adbot
ADBOT LOVES YOU

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
It's a PHP language specification. It has nothing to do with PHPNH nor HHVM.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply