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
KernelSlanders
May 27, 2013

Rogue operating systems on occasion spread lies and rumors about me.

Subjunctive posted:

Working from the C standard, or JS standard, or C# standard, or Java standard is...not much better.

programming languages should be intuitive like natural languages are. If you need to look at the reference standard and you're not writing a compiler or re-implementing the core library, something has seriously gone off the rails.

Adbot
ADBOT LOVES YOU

loinburger
Jul 10, 2004
Sweet Sauce Jones
In the case of Java the de jure standard was seriously broken until the 1.5 memory model revision, so the de facto standard (i.e. the thing implemented by compilers and virtual machines) ignored the broken bits

Kazinsal
Dec 13, 2011
The C standard pisses me off because in 2015 with the latest standard in use, it is still perfectly legal for sizeof(int) to be 2 bytes.

That is some serious early 70s poo poo and I do not appreciate it.

There are many stupid little gotchas in the standard like this. This is just the tip of the iceberg.

EpicCodeMonkey
Feb 19, 2011

Kazinsal posted:

The C standard pisses me off because in 2015 with the latest standard in use, it is still perfectly legal for sizeof(int) to be 2 bytes.

That is some serious early 70s poo poo and I do not appreciate it.

There are many stupid little gotchas in the standard like this. This is just the tip of the iceberg.

On an 8-bit micro, a 16-bit int makes sense. That said, it's difficult/impossible to write proper portable code that uses native types directly, due to the unknown widths. I guess that's why C99 added <stdint.h> which gives you know only fixed-width types, but other metatypes such as uint_least16_t to make portable code possible.

In my own code I use the <stdint.h> types exclusively, with the exception of float/double.

feedmegin
Jul 30, 2008

Kazinsal posted:

The C standard pisses me off because in 2015 with the latest standard in use, it is still perfectly legal for sizeof(int) to be 2 bytes.

That is some serious early 70s poo poo and I do not appreciate it.

There are many stupid little gotchas in the standard like this. This is just the tip of the iceberg.

Embedded platforms are still a thing and mostly you program them in C.

b0lt
Apr 29, 2005

Kazinsal posted:

The C standard pisses me off because in 2015 with the latest standard in use, it is still perfectly legal for sizeof(int) to be 2 bytes.

That is some serious early 70s poo poo and I do not appreciate it.

There are many stupid little gotchas in the standard like this. This is just the tip of the iceberg.

There are platforms that still exist today where ints are 1 byte long, and bytes are 16 bits long.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

KernelSlanders posted:

programming languages should be intuitive like natural languages are. If you need to look at the reference standard and you're not writing a compiler or re-implementing the core library, something has seriously gone off the rails.

So people should learn to use programming languages without reading anything other than source? What is the official documentation (as referenced in the post I was quoting) for those languages if not the standards?

feedmegin
Jul 30, 2008

Subjunctive posted:

So people should learn to use programming languages without reading anything other than source? What is the official documentation (as referenced in the post I was quoting) for those languages if not the standards?

The standard is a reference not a tutorial. You wouldnt learn French by just buying and reading a formal grammar.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

So what's the other official documentation?

feedmegin
Jul 30, 2008

Depends on the language. K&R for C, Stroustrops big tome for C++.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Interesting, what makes those official?

(Learning C++ from D&E would be a mess, I think.)

Subjunctive fucked around with this message at 15:40 on Jan 9, 2016

feedmegin
Jul 30, 2008

Subjunctive posted:

Interesting, what makes those official?

(Learning C++ from D&E would be a mess, I think.)

Why are you so hung up on the word 'official' here? Theyre written by the languages creator(s) so are most likely to reflect the intended use of the language by said creator. Theres no, like, certification authority or anything.

http://www.stroustrup.com/4th.html was what I meant for c++.

eth0.n
Jun 1, 2012

Subjunctive posted:

Interesting, what makes those official?

(Learning C++ from D&E would be a mess, I think.)

Why is "official" relevant to most coders of a language?

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

eth0.n posted:

Why is "official" relevant to most coders of a language?

I was replying specifically to that term in a post, if you read back in the chain.

eth0.n
Jun 1, 2012

Subjunctive posted:

I was replying specifically to that term in a post, if you read back in the chain.

Official documentation (the term originally used) is not the same as official standard (the word you started using in response). PHP (and a lot of other newer languages like Python and Java) have official documentation which is meant for all coders. They may also have standards that are not. C and C++ have official standards, but not official documentation.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

I'm surprised that you don't consider the language standards to be official documentation, I admit. They seem to be the epitome of both elements, and for some languages the only such.

But fair enough!

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

Kazinsal posted:

The C standard pisses me off because in 2015 with the latest standard in use, it is still perfectly legal for sizeof(int) to be 2 bytes.

That is some serious early 70s poo poo and I do not appreciate it.

There are many stupid little gotchas in the standard like this. This is just the tip of the iceberg.

The C standard pisses me off because it has so much undefined behavior, often needlessly so. It's hard to imagine that any significant c or c++ program doesn't have undefined behavior lurking in it somewhere.

Fun fact: "An unmatched ‘ or ” character is encountered on a logical source line during tokenization" isn't a syntax error, it's undefined behavior.

Suspicious Dish
Sep 24, 2011

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

eth0.n posted:

Official documentation (the term originally used) is not the same as official standard (the word you started using in response). PHP (and a lot of other newer languages like Python and Java) have official documentation which is meant for all coders. They may also have standards that are not. C and C++ have official standards, but not official documentation.

You kidding me? 90% of the C standard is documentation for the standard library. I use it all the time.

http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1539.pdf#page=364

KernelSlanders
May 27, 2013

Rogue operating systems on occasion spread lies and rumors about me.

Subjunctive posted:

I'm surprised that you don't consider the language standards to be official documentation, I admit. They seem to be the epitome of both elements, and for some languages the only such.

But fair enough!

I feel the same but in the opposite direction. Probably just a function of what languages we use the most.

eth0.n
Jun 1, 2012

Suspicious Dish posted:

You kidding me? 90% of the C standard is documentation for the standard library. I use it all the time.

http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1539.pdf#page=364

I didn't say a language standard cannot satisfy any of the purposes of documentation.

That other 10% is pretty darn important (perhaps more important than that 90%), but you already know it. For someone who doesn't already know the C language, reading the standard is a very poor way of learning it. Whereas that's a purpose that should be satisfied by proper documentation.

The point is, judging PHP by its poor documentation is sensible. It's judging it based on what it's purpose is supposed to be; to help users understand it. Judging C/C++/C#/Java by how well their language standards help a new coder learn is, in contrast, pointless. That's not what it's there for. Judging the official C#/Java documentation on the same basis as the PHP judgement would, instead, be reasonable. No similar comparison exists for C/C++ since no official documentation comparable to PHP, C#, and Java exists. Judgement of unofficial documentations like K&R and Stroustrup, on the other hand, on the basis of how they help new coders learn would be reasonable.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
nobody disagrees and i have no idea what we were arguing about in the first place

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
It must be early in the month, we're back to "the horrors are coming from inside the thread".

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Suspicious Dish posted:

nobody disagrees and i have no idea what we were arguing about in the first place

I think this is my fault, I woke up an idiot today or something.

FlapYoJacks
Feb 12, 2009

Suspicious Dish posted:

nobody disagrees and i have no idea what we were arguing about in the first place

Nested functions in PHP being bad, then php being bad, then all other languages being bad, then C being bad.

All bad language arguments turn into "C" is bad.

Soricidus
Oct 21, 2010
freedom-hating statist shill

Suspicious Dish posted:

nobody disagrees and i have no idea what we were arguing about in the first place

yospos bi--oh wait

brap
Aug 23, 2004

Grimey Drawer
Any C code written today should use the _t suffixed type definitions, not the built in types.

b0lt
Apr 29, 2005

fleshweasel posted:

Any C code written today should use the _t suffixed type definitions, not the built in types.

Also, pretty much any C code written today should be written in C++.

Pavlov
Oct 21, 2012

I've long been fascinated with how the alt-right develops elaborate and obscure dog whistles to try to communicate their meaning without having to say it out loud
Stepan Andreyevich Bandera being the most prominent example of that

b0lt posted:

Also, pretty much any C code written today should be written in C++.

Don't you go starting holy wars now.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Subjunctive posted:

I think this is my fault, I woke up an idiot today or something.

I'm glad this happens to other people as well.

FlapYoJacks
Feb 12, 2009

b0lt posted:

Also, pretty much any C code written today should be written in C++.

Yeah, when I am coding on a micropic with a few k of memory what I really need is a a huge increase to my footprint of the binary.

sarehu
Apr 20, 2007

(call/cc call/cc)

fleshweasel posted:

Any C code written today should use the _t suffixed type definitions, not the built in types.

If overflow's gonna be a problem it's still going to be a problem with _t types.

Edit: Here is a list of uses I've found for non-_t types in a recent 20k-line C project:

- argc is of type int,
- int was used all over as the boolean type for portability reasons -- _Bool doesn't have a _t either, you know :-)
- some values in the range 0-3 and 0-7 were made to be of type int,
- operator precedence levels, which are numbers in the 100-999 range, are ints,
- format string sizes have to be converted to int,
- a runtime limit whose value was 50 is an int,
- some stand-in values for representing interval boundaries (that had the same ordering as the real values) ranging from -11 to 12 were represented as int,
- some compile time assertions cast enum values to int in order to compare them (and pass warning flags),

- ftell returns a long (and the return value gets converted to a size_t beneath a compile-time assertion that LONG_MAX < SIZE_MAX),

- argv was of type char**,
- filepaths are of type char*, because they come from argv and are used in C library functions that take char,
- certain other functions take const char * so you can pass a string literal, or emit const char * in order to be used in printf functions,
- an arena allocator uses char * because you can do pointer arithmetic on it, unlike void *,
- some other buffers are char because they use ascii digits or other ascii characters, and they get cast to void* pretty soon,
- a few buffers use char when it would probably be better to use uint8_t -- not that you can have sizeof(uint8_t) > sizeof(char).

- nothing uses short, long long, or anything with "unsigned".

Generally speaking I used an int whenever I cared to do so. You should use whatever interoperates with your other functions correctly. If malloc took an int, I'd recommend using int for sizes of things -- but malloc takes a size_t, so you should use that instead. The protocol buffers APIs use int for lengths, so you should use int when indexing into those.

I used int32_t and uint32_t a lot more, in particular because the file format I was working with demanded it. It had nothing to do with C specifically or C safety concerns. The way I see it, all you're doing is deciding the limit at which some runtime overflow check can kick in.

sarehu fucked around with this message at 22:06 on Jan 9, 2016

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

feedmegin posted:

Depends on the language. K&R for C, Stroustrops big tome for C++.

k&r is ancient and it encourages dumb poo poo



sarehu posted:

No. If overflow's gonna be a problem it's still going to be a problem with _t types.

its about documentation more than anything

b0lt
Apr 29, 2005

ratbert90 posted:

Yeah, when I am coding on a micropic with a few k of memory what I really need is a a huge increase to my footprint of the binary.

So use -fno-exceptions -fno-rtti, and don't use the STL (or only the constexpr-y part)? Pretty much the core philosophy of C++ is that you only pay for the parts of the language that you use, so just turn that poo poo off. You end up with a language that is still better than C, but with identical output.

Malcolm XML posted:

its about documentation more than anything

size_t, ptrdiff_t, etc. are obviously better than long, if they're used correctly. int32_t is not obviously better at representing types that aren't explicitly defined as being 32 bit integers, like in file formats or network communication.

b0lt fucked around with this message at 22:12 on Jan 9, 2016

Sauer
Sep 13, 2005

Socialize Everything!

Malcolm XML posted:

k&r is ancient and it encourages dumb poo poo

Is there a better book that you know about that doesn't teach dumb poo poo? And maybe acknowledges that IDEs, auto-completion, identifiers with more than eight characters and the shift key exist?

b0lt posted:

So use -fno-exceptions -fno-rtti, and don't use the STL (or only the constexpr-y part)?

So you're saying he should just use C.

Sauer fucked around with this message at 05:07 on Jan 10, 2016

KernelSlanders
May 27, 2013

Rogue operating systems on occasion spread lies and rumors about me.

Malcolm XML posted:

k&r is ancient and it encourages dumb poo poo

its about documentation more than anything

There's tons of out of date programming tomes. Numerical Recipes assumes that cosine is calculated from a taylor expansion.

Carbon dioxide
Oct 9, 2012



No thanks.

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

b0lt posted:

So use -fno-exceptions -fno-rtti, and don't use the STL (or only the constexpr-y part)? Pretty much the core philosophy of C++ is that you only pay for the parts of the language that you use, so just turn that poo poo off. You end up with a language that is still better than C, but with identical output.


size_t, ptrdiff_t, etc. are obviously better than long, if they're used correctly. int32_t is not obviously better at representing types that aren't explicitly defined as being 32 bit integers, like in file formats or network communication.

unless you know the compilation triple's choice of data model it's better to explicitly say "I want this integer to be 32 bits exactly" rather than "it's 32 bits on windows and 64 on linux"

i guess if you don't care so much then it doesn't matter, but given that every major C project rolled its own sized types like u32, s32, s16 etc you might as well use the standard's



KernelSlanders posted:

There's tons of out of date programming tomes. Numerical Recipes assumes that cosine is calculated from a taylor expansion.

numerical recipes is also mostly garbage and i guarantee that you have broken the terms for its source code license at least a few times if you're like most people

Sauer posted:

Is there a better book that you know about that doesn't teach dumb poo poo? And maybe acknowledges that IDEs, auto-completion, identifiers with more than eight characters and the shift key exist?
Despite it being from zed shaw learn C the hard way is probably as good as you'll get

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

You would think the marketers who make these stupid ads would get an actual programmer to look over their poo poo so it doesn't insult the intelligence of the people they're trying to recruit. Not only is the "== true" redundant and the curly brace placement an atrocity, you're also forced to apply regardless of the conditional!

Edison was a dick
Apr 3, 2010

direct current :roboluv: only

TooMuchAbstraction posted:

You would think the marketers who make these stupid ads would get an actual programmer to look over their poo poo so it doesn't insult the intelligence of the people they're trying to recruit. Not only is the "== true" redundant and the curly brace placement an atrocity, you're also forced to apply regardless of the conditional!

Also, the missing semicolon.

Adbot
ADBOT LOVES YOU

xzzy
Mar 5, 2009

Maybe that's the point, they want everyone in the world to apply for a job, but front end developers get the special "for you" tag.

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