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
TheresaJayne
Jul 1, 2011
I think that the OS/IDE/Paren arguments are for hobbyists, I know what I prefer but if the company I work for says use Notepad then I use notepad.

Adbot
ADBOT LOVES YOU

Athas
Aug 6, 2007

fuck that joker

TheresaJayne posted:

I think that the OS/IDE/Paren arguments are for hobbyists, I know what I prefer but if the company I work for says use Notepad then I use notepad.

I think most programmers (in western nations anyway) are privileged enough to pick jobs where they achieve good job satisfaction. I would not work at a place where I was required to use painful tools. This does not mean that I'm going to quit over the mandated brace style or anything like that, but saying that only hobbyists care about tooling is not correct. (Also, the OS issue is somewhat more substantial - I had to do OpenCL development on Windows for an industrial course I was teaching, and it was quite painful. I never thought GPU programming would be nicer on Linux than on Windows, but here we are.)

sunaurus
Feb 13, 2012

Oh great, another bookah.

TheresaJayne posted:

I think that the OS/IDE/Paren arguments are for hobbyists, I know what I prefer but if the company I work for says use Notepad then I use notepad.

I've worked at two places where I haven't been allowed to install linux on my work computer. Both times I ended up just using the work computer as an extremely overspecced ssh tunnel hub so I could do most of my work my personal computer with linux. I guess if the company I work for says use Notepad then I find a workaround.

Beef
Jul 26, 2004

sunaurus posted:

I've worked at two places where I haven't been allowed to install linux on my work computer. Both times I ended up just using the work computer as an extremely overspecced ssh tunnel hub so I could do most of my work my personal computer with linux. I guess if the company I work for says use Notepad then I find a workaround.

Same, but through a linux VM. Editing ssh-remote files in emacs is more comfy if the other end of the tunnel is on a different continent.
I have colleagues that unironically use telnet+nano for their C++ coding. Ironically, because of that, we only get simple thinkpads instead of decent workstations.

Ola
Jul 19, 2004

Soricidus posted:

You’re talking like you think it’s possible for an automated process to make the correct aesthetic judgements to format code the right way

IDEs do auto-indentation already, it's not much more than that. One guy writes his {'s on the same line as the function declaration, you like them one line below so your IDE moves it. That's very easy. What sort of text style would you say is aesthetically beautiful formatting, but isn't easily quantifiable under syntax rules?

eth0.n
Jun 1, 2012

Ola posted:

IDEs do auto-indentation already, it's not much more than that. One guy writes his {'s on the same line as the function declaration, you like them one line below so your IDE moves it. That's very easy. What sort of text style would you say is aesthetically beautiful formatting, but isn't easily quantifiable under syntax rules?

Line continuations are problematic for auto formatters. Where to break, how much to indent isn't always clear, and can vary by context. A human eye often produces better aesthetics here.

CPColin
Sep 9, 2003

Big ol' smile.
Use \n for line breaks that the autoformatter is allowed to alter and \r for manual line breaks for breaking up long lines. Problem solved.

Thermopyle
Jul 1, 2003

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

TheresaJayne posted:

I think that the OS/IDE/Paren arguments are for hobbyists, I know what I prefer but if the company I work for says use Notepad then I use notepad.

There's nothing incompatible with working with what your company demands and saying "i wish we would use X".

In fact, there's nothing wrong with moving to a different job that lets you use tools that you're comfortable with.

"I'm a real programmer and roll over and use whatever my company demands no matter how uncomfortable" is a weird stance to take.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

eth0.n posted:

Line continuations are problematic for auto formatters. Where to break, how much to indent isn't always clear, and can vary by context. A human eye often produces better aesthetics here.

The autoformatter should follow simple and predictable rules here, and in cases where it looks like poo poo the human can fix it by breaking out subparts into separate expressions.

sunaurus
Feb 13, 2012

Oh great, another bookah.

CPColin posted:

Use \n for line breaks that the autoformatter is allowed to alter and \r for manual line breaks for breaking up long lines. Problem solved.

This makes me feel super anxious and I can't even tell you why

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

Ola posted:

Me too, but it shouldn't matter in a project either, that's why it should just get reformatted in each client. The running code doesn't care.

Is this a thing that's done? How does it work in practice? Does everyone's IDE just save the file in their preferred format? If so, doesn't that make diffs horrendous? How can I refer to a line number when talking to someone if they have to code formatted differently? If I'm looking at the code in a code review, is it going to be formatted differently depending on who's posted the review?

Ola
Jul 19, 2004

HappyHippo posted:

Is this a thing that's done? How does it work in practice? Does everyone's IDE just save the file in their preferred format? If so, doesn't that make diffs horrendous? How can I refer to a line number when talking to someone if they have to code formatted differently? If I'm looking at the code in a code review, is it going to be formatted differently depending on who's posted the review?

No, it's a fantasy suggestion that hasn't been properly thought through!

Beef
Jul 26, 2004
Not that fantastical. Smalltalk has had a semantic-based version management system for ages. A good deal of the research at our PL lab was essentially reproducing some of the Smalltalk functionality in other languages using Eclipse's AST API.

Soricidus
Oct 21, 2010
freedom-hating statist shill

Jabor posted:

The autoformatter should follow simple and predictable rules here, and in cases where it looks like poo poo the human can fix it by breaking out subparts into separate expressions.

Unfortunately what looks poo poo for one person’s set of preferences may look great for another’s, so now we’re back at the original problem where people are editing code just to change the formatting.

That Dang Lizard
Jul 13, 2016

what; an idiomt

HappyHippo posted:

Is this a thing that's done? How does it work in practice? Does everyone's IDE just save the file in their preferred format? If so, doesn't that make diffs horrendous? How can I refer to a line number when talking to someone if they have to code formatted differently? If I'm looking at the code in a code review, is it going to be formatted differently depending on who's posted the review?

I guess it could work, if your IDE formats code to your liking when you pull code but pushing up to CI has a pre-commit hook that calls a formatter?

I've never tried that so IDK how practical it would be.

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)
Not really a horror, but a pretty silly fuckup. I thought I'd be cute and add something like
code:
echo a random port into sshd_config ... cloudflare blocks the actual bash code from being posted ...
into a cloud-init script. Didn't really think that one through ...

HappyHippo posted:

Is this a thing that's done? How does it work in practice? Does everyone's IDE just save the file in their preferred format? If so, doesn't that make diffs horrendous? How can I refer to a line number when talking to someone if they have to code formatted differently? If I'm looking at the code in a code review, is it going to be formatted differently depending on who's posted the review?
I'd imagine you could do it by AST node like someone here or in the yospos language thread said, but that would require every shop's token greybeard to stop using diff and their pile of rotting emacs extensions and what not sooooo
E:

CPColin posted:

Source code should only ever save to disk as an AST and IDE's should just format them into readable text on load.

dougdrums fucked around with this message at 00:45 on Apr 24, 2019

CPColin
Sep 9, 2003

Big ol' smile.
I was only mostly joking, of course.

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)
It would be cool if you could get a list of AST changes for a given pull request or something. There's gotta be something out there that does this already.

EpicCodeMonkey
Feb 19, 2011
Is integrating open source code a valid horror? Let me introduce you to mDNSResponder.

Years ago, Apple decided they needed a way to announce devices and services onto a local network, so that applications can find and talk to other applications without manual setup. This became mDNS, also known by the marketing name "Bonjour". It's one way for your phone to detect your Apple TV, or your Mac to discover your WIFI speakers. There's others, but Apple uses it exclusively.

Except it's a lovecraftian horror show. Apple actually open sources their reference implementation, called mDNSResponder, to try to drive adoption. There's one one problem: it's crap. Utter, utter crap. Not only does it not actually build on most platforms (the platform layers shipped with the release don't match the actual core changes they've made over the years, so every vendor integrating it has to re-do it) it's a pile of dusty C code written by monkeys.

Don't believe me? Here's just one random file from it that I found on GitHub:
https://github.com/jevinskie/mDNSResponder/blob/master/mDNSCore/mDNS.c

Note the formatting, and the size. No, the guy that imported the code dump hasn't touched the formatting, that's all as-shipped. Yes, it's an old version, but the newer ones are almost identical barring some minor bug fixes.

Apple actually tried to replace this crap with a re-written C++ version a few years ago called discoveryd, which was quickly killed off due to apparently insurmountable bugs.

Volte
Oct 4, 2004

woosh woosh
I'll see your Bonjour implementation and raise you the TypeScript type checker:

https://github.com/Microsoft/TypeScript/blob/master/src/compiler/checker.ts

Absurd Alhazred
Mar 27, 2010

by Athanatos

Volte posted:

I'll see your Bonjour implementation and raise you the TypeScript type checker:

https://github.com/Microsoft/TypeScript/blob/master/src/compiler/checker.ts


:pervert:

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice
https://twitter.com/kherman/status/1120738998928977920

As a software developer in Texas, the thought of dealing with this gives me anxiety.

fishmech
Jul 16, 2006

by VideoGames
Salad Prong
Permanent dst would be the dumbest method to pick, so I'm sure they'll do it.

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

Volte posted:

I'll see your Bonjour implementation and raise you the TypeScript type checker:

https://github.com/Microsoft/TypeScript/blob/master/src/compiler/checker.ts

Other than the sheer size, this doesn't look at all bad to me? Functions and variables have clear names and types, there's little mutability or casts, no magic literals, comments aren't plentiful but aren't lacking either.

TypeScript has easily the most complicated type system of any widely-adopted language, so it can't really be helped that the type checker is a complicated class. Function names like getIsContextSensitiveAssignmentOrContextType are as good as you can get IMO.

Meanwhile, that Bonjour code has more magic numbers than a Martin Gardner book.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Volte posted:

I'll see your Bonjour implementation and raise you the TypeScript type checker:

https://github.com/Microsoft/TypeScript/blob/master/src/compiler/checker.ts

OH LAWD HE COMIN

No Safe Word
Feb 26, 2005

fishmech posted:

Permanent dst would be the dumbest method to pick, so I'm sure they'll do it.

I get why it's dumb but I'll still vote for it because I like it being light later in the day like it is right now and changing the clocks is dumb as gently caress

CPColin
Sep 9, 2003

Big ol' smile.

No Safe Word posted:

changing the clocks is dumb as gently caress

Same. California passed a proposition last year to allow the state to go to year-round DST, should the Feds open the door to that. I don't care if we're year-round UTC-08 or UTC-07; I just want to eliminate the two weeks per year that I'm all hosed up on clock bullshit. (My most recent period of unemployment coincided with the start of DST and it was wonderful not having to participate!)

Bonfire Lit
Jul 9, 2008

If you're one of the sinners who caused this please unfriend me now.

EpicCodeMonkey posted:

Don't believe me? Here's just one random file from it that I found on GitHub:
https://github.com/jevinskie/mDNSResponder/blob/master/mDNSCore/mDNS.c

Note the formatting, and the size. No, the guy that imported the code dump hasn't touched the formatting, that's all as-shipped. Yes, it's an old version, but the newer ones are almost identical barring some minor bug fixes.
It's always a good sign if your license statement is immediately followed by a 10 line paragraph about how you're an idiot if you have different style preferences than the author.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



No Safe Word posted:

I get why it's dumb but I'll still vote for it because I like it being light later in the day like it is right now and changing the clocks is dumb as gently caress

It'd probably be good to do some studies to figure out which one would make the biggest beneficial difference to night shift workers. Of course Texas will probably do it by coin flip because Texas.

Kazinsal
Dec 13, 2011


Bonfire Lit posted:

It's always a good sign if your license statement is immediately followed by a 10 line paragraph about how you're an idiot if you have different style preferences than the author.

I'm a big fan of the complaint about "type* varname" causing confusion and being verboten, followed by that rule being broken ten lines of code later.

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)

Bonfire Lit posted:

It's always a good sign if your license statement is immediately followed by a 10 line paragraph about how you're an idiot if you have different style preferences than the author.
Haha oh my god, I just read "apache" and skipped over it ...

quote:

so-called "standard" C functions

quote:

* Formatting notes:
* This code follows the "Whitesmiths style" C indentation rules. Plenty of discussion
* on C indentation can be found on the web, such as <http://www.kafejo.com/komp/1tbs.htm>,
* but for the sake of brevity here I will say just this: Curly braces are not syntactially
* part of an "if" statement; they are the beginning and ending markers of a compound statement;
* therefore common sense dictates that if they are part of a compound statement then they
* should be indented to the same level as everything else in that compound statement.

* Indenting curly braces at the same level as the "if" implies that curly braces are
* part of the "if", which is false. (This is as misleading as people who write "char* x,y;"
* thinking that variables x and y are both of type "char*" -- and anyone who doesn't
* understand why variable y is not of type "char*" just proves the point that poor code
* layout leads people to unfortunate misunderstandings about how the C language really works.)
I'm almost certain that the italics part doesn't hold up in the case of enum and struct declarations, but whatever.
code:
#if COMPILER_LIKES_PRAGMA_MARK
What if your compiler is indifferent? :shrug:
code:
	// 0x0E IPv6 header
	*ptr++ = 0x60; *ptr++ = 0x00; *ptr++ = 0x00; *ptr++ = 0x00;		// Version, Traffic Class, Flow Label
	*ptr++ = 0x00; *ptr++ = 0x20;									// Length
	*ptr++ = 0x3A;													// Protocol == ICMPv6
	*ptr++ = 0xFF; 
:barf: I guess that is what you'd have to do for lack of htonl()

dougdrums fucked around with this message at 18:53 on Apr 24, 2019

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?
Gotta love nerds that get extremely mad about cosmetic poo poo. When I started my current job I found an old style guide that declared "camel case is for wiki pages and idiots" among other things. Thankfully the guy who wrote it isn't around any more.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

I get mad when people don't post in 40 c
olumn mode

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

Scaramouche posted:

I get mad when people don't post in 40 c
olumn mode

Linus Torvalds account found.

LongSack
Jan 17, 2003

TBF, that “char *” example is clearer if written as char *x,y

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Love when people think it’s possible to write C without invoking undefined behaviour, if only they condescend hard enough.

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?
char* x,y; is one of the dumber parts of c.

LongSack
Jan 17, 2003

HappyHippo posted:

char* x,y; is one of the dumber parts of c.

IMO, if it were more strongly typed, then char * would be the type, and both x and y would be pointers. As it is, though, char is the type which leaves x as a pointer and y as a scalar. This kind of ambiguity is indeed a horror.

Edit: this makes me glad I’m using C# now

LongSack fucked around with this message at 04:47 on Apr 25, 2019

Happy Thread
Jul 10, 2005

by Fluffdaddy
Plaster Town Cop

Ola posted:

IDEs do auto-indentation already, it's not much more than that. One guy writes his {'s on the same line as the function declaration, you like them one line below so your IDE moves it. That's very easy. What sort of text style would you say is aesthetically beautiful formatting, but isn't easily quantifiable under syntax rules?

In JavaScript sometimes you make long lines with lambdas nested inside expressions. Sometimes you do a few of these in a row. Sometimes I have a few complex, but similar lines in a row* and that's when I like to add horizontal spacing to make sure the like tokens line up. That can't really be done automatically because it's a subjective choice of whether to do it or not.

*These are all the cases where the DRY principle did not give good enough savings

Adbot
ADBOT LOVES YOU

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)

LongSack posted:

This kind of ambiguity is indeed a horror.
It's not ambiguous, the pointer is part of the declarator. I mean this is well worn ground and I don't think I'm telling anyone anything new but:
code:
int x[4], y[8];
would not be sensible otherwise. Of course in C# arrays are reference types derived from Object with different semantics, and the [] is part of the type specifier. In that sense, T[] is just sugar for Array.CreateInstance, which ends up being an internal call which creates a struct with the type, rank, and lengths, and then the actual values. Pointer types in C# are neither value types or reference types, but they are all types, and the syntax for declarations treats them as such.

So the stronger typing is nice but it would make C arrays syntactically inconsistent or semantically inconvenient. It's just the matter of knowing why you're using C in the first place. That being said I love that I can use abstract stuff like BlockingCollections and also void* all the same in C# (more or less).

Also gently caress writing C declarations like that. Just don't do it aaaaaaaarrrrrrggg :rant:

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