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
Soricidus
Oct 21, 2010
freedom-hating statist shill

Spatial posted:

"The Unstoppable Will of Code"

Sieg++

Adbot
ADBOT LOVES YOU

Spatial
Nov 15, 2007

Oops I got it wrong the actual quote was "The steadfast iron will of unstoppable code" lol

Munkeymon
Aug 14, 2003

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



Athas posted:

Really? I can come up with a ton of ideas for a pure functional language that I expect from the kind of mind that would create Solidity:

  • Dynamically typed, obviously.
  • All numbers are 512-bit integers.
  • Any value can be used as a function, which is string prefixing if it is string-like, or multiplication if it is number-like. So you can write 'x y'!
  • Implicit casting between strings and numbers, of course. Any string containing solely hexadecimal digits (ignoring whitespace) is interpreted as a hex number. Leading zeroes make it octal.
  • An expression using unbound names is implicitly considered a lambda taking parameters matching those unbound names. For example if 'x' and 'y' does not exist, the expression 'x+y' corresponds to Haskell's '\x y -> x + y'. The parameters are sorted alphabetically, so 'y+x' is also '\x y -> x + y'.
  • There is a record system, and any value can be extended with fields (Javascript-style) with the syntax 'object.fieldname = fieldvalue'. But it returns a copy of object, so purely functional, see?
  • If you try to read an unknown field, you get back numeric zero.
  • If you try to perform a mathematical operation on a function (e.g. 'f + 2'), then that creates an implicit lambda that applies the operation to the result of calling the function, i.e., this example becomes what you'd write in Haskell as '\x -> f x + 2'. This applies recursively if 'f x' returns a function, so be careful you don't blow the stack!
  • Speaking of the stack, the compiler does not perform tail-call optimisation, but recursion is still the only way to loop.

Are you saying that's what it was before they said gently caress it and went with an imperative structure?

Doom Mathematic
Sep 2, 2008

Athas posted:

Really? I can come up with a ton of ideas for a pure functional language that I expect from the kind of mind that would create Solidity:

  • Dynamically typed, obviously.
  • All numbers are 512-bit integers.
  • Any value can be used as a function, which is string prefixing if it is string-like, or multiplication if it is number-like. So you can write 'x y'!
  • Implicit casting between strings and numbers, of course. Any string containing solely hexadecimal digits (ignoring whitespace) is interpreted as a hex number. Leading zeroes make it octal.
  • An expression using unbound names is implicitly considered a lambda taking parameters matching those unbound names. For example if 'x' and 'y' does not exist, the expression 'x+y' corresponds to Haskell's '\x y -> x + y'. The parameters are sorted alphabetically, so 'y+x' is also '\x y -> x + y'.
  • There is a record system, and any value can be extended with fields (Javascript-style) with the syntax 'object.fieldname = fieldvalue'. But it returns a copy of object, so purely functional, see?
  • If you try to read an unknown field, you get back numeric zero.
  • If you try to perform a mathematical operation on a function (e.g. 'f + 2'), then that creates an implicit lambda that applies the operation to the result of calling the function, i.e., this example becomes what you'd write in Haskell as '\x -> f x + 2'. This applies recursively if 'f x' returns a function, so be careful you don't blow the stack!
  • Speaking of the stack, the compiler does not perform tail-call optimisation, but recursion is still the only way to loop.

Hey, I just had an idea for a new cryptocurrency.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Had a weird one. I'm looking over code that takes in IDs and returns search results for them. There can be a series of comma separated IDs, or a magic number built in, zero means "return all results". So the guy wrote this:

code:
private const string Zero = "0";

if (!string.IsNullOrWhiteSpace(IDs) && !IDs.Contains(Zero))
                {
                    return IDs;
                }

                return string.Join(",",IDs);
I'm still kinda floored.

megalodong
Mar 11, 2008

Scaramouche posted:

Had a weird one. I'm looking over code that takes in IDs and returns search results for them. There can be a series of comma separated IDs, or a magic number built in, zero means "return all results". So the guy wrote this:

code:
private const string Zero = "0";

if (!string.IsNullOrWhiteSpace(IDs) && !IDs.Contains(Zero))
                {
                    return IDs;
                }

                return string.Join(",",IDs);
I'm still kinda floored.

What is it even meant to do? Extract the individual ID values to query on?

GABA ghoul
Oct 29, 2011

Cuntpunch posted:

code:
//C#
public class Foo
{
    private string _text;
   
    public Foo(string text)
    {
        if(text != null)
        {
            _text = text;
        }
    }
}
This 'pattern' was *rampant* at work and every time I asked the people doing it *why* they did it, they cited some sense of 'because we have always done it this way'. Some of the more junior folks, when asked *what* it does spent a lot of time and effort talking themselves in circles about how it was preventing null references.

Someone who didn't know that strings have null as their default value wrote this ten years ago and then it cargoculted from there.

Also, I'm new to C# and serious coding so I'm really looking forward to see my code in here very soon.

zergstain
Dec 15, 2005

I assume there's no constructor that ensures _text has a value.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

megalodong posted:

What is it even meant to do? Extract the individual ID values to query on?

The IF is a pre flight check to see if the IDs are null or zero, of not split the string into comma separated list. However the way he checked for zero is particularly problematic

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Scaramouche posted:

The IF is a pre flight check to see if the IDs are null or zero, of not split the string into comma separated list. However the way he checked for zero is particularly problematic

oh i was so confused but all the other problems that i didn't even notice that.

redleader
Aug 18, 2005

Engage according to operational parameters

Spatial posted:

Oops I got it wrong the actual quote was "The steadfast iron will of unstoppable code" lol

mooooooods

repiv
Aug 13, 2009

https://twitter.com/sghctoma/status/1089906975167660032?s=19

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
i'm the signed byte. thanks sun microsystems

Soricidus
Oct 21, 2010
freedom-hating statist shill

Suspicious Dish posted:

i'm the signed byte. thanks sun microsystems

literally the worst thing about java. gently caress having to litter my code with "& 0xFF" everywhere whenever trying to do literally anything with binary data.

"we can't have any unsigned integer types, they'd confuse everyboyd" *makes char an unsigned integer that's too small to hold the full range of character values*

Cuntpunch
Oct 3, 2003

A monkey in a long line of kings

zergstain posted:

I assume there's no constructor that ensures _text has a value.

Oh of course not, this is the single constructor and - irrelevant to this little nibble of bad code - owing to the structure of things, that *specific* argument will always be non-null, since these are being created out of a factory that error-checks on null before calling this ctor.

zergstain
Dec 15, 2005

Oh, sorry, I had been thinking that was a method. Guess it didn't register with me that it had the same name has the class. Yeah, so that was my only idea as to how that little code snippet could accomplish anything.

Wouldn't you want the ctor to be private or something to ensure the class can only be instantiated via the factory?

Happy Thread
Jul 10, 2005

by Fluffdaddy
Plaster Town Cop
Not in Foo no, I think Foo is not the factory, but they're saying whatever creates the string argument is

Cuntpunch
Oct 3, 2003

A monkey in a long line of kings
The example is trimmed down, but there's a lot of things that look like Foo that are instantiated reflectively as part of a plugin style architecture. So we have a separate class for loading these that handles the creation of the string, and then passes it in as an argument to these ctors. But that also handles the default case, so no nulls will get passed anyway.

Trammel
Dec 31, 2007
.
Because this is how we self-implement permission systems in TYOOL 2019.

code:
import { Role, UserTag } from '../../../commons/Enum';
import ListingPermissionDto from './ListingPermissionDto';

export default class RolePermissionDto {
    public roleCodes: Role[];
    public tag: UserTag;
    public isAdministrator: boolean;
    public isInternalStaff: boolean;
    public accessCustomerApp: boolean;
    public viewOrganisationMenu: boolean;
    public viewMyTeamMenu: boolean;
    public viewAllOrganisation: boolean;
    public createOrganisation: boolean;
    public editOrganisation: boolean;
    public canCreateRoleCodes: Role[];
    public canUpdateRoleCodes: Role[];
    public canViewRoleCodes: Role[];
    public canViewTags: UserTag[];
    public canBatchUploadUsers: boolean;
}

itskage
Aug 26, 2003


That ts? Does run on the client???


Hammerite posted:

I'd never heard of the product this relates to, though it is apparently a .NET framework language. Do you really think it's probable that Cuntpunch's coworkers got it from there? At the risk of generalising from my own experience, I assume that most C# programmers also haven't heard of this thing. It has fewer than 300 questions on Stack Overflow, which surely is hardly anything.

I think Microsoft Dynamics has one if the larger market shares for ERPs but not sure if that's just AX or thier NAV and CRMs combined.

But you need to look for axapta on stackoverflow since thats what it's called before Microsoft bought it out. Much more results that way than searching X++ or xpp. Google makes it near impossible to search X++ anyway because of C++.

I don't think it is probable. Just pointing out the similarities. X++ doesn't have constructors anyway.

e: Well rather it does, they're just protected statics and you're not supposed to init anything in them. Instead they want you to write a static method that calls your new foo, then sets the params/properties and returns your class. Of course there's no standard naming and no overloading so you see poo poo like:

SalesLine::init();
SalesLine::initFromSalesTable();
SalesLine::initFromSalesLine();
SalesLine::initFromPurchLine();
SalesLine::initFromSalesQuotationLine();

And it wouldn't be uncommon to look inside SalesLine::initFromSalesLine() and see it call init, then query the salesTable and use it to call initFromSalesTable.

itskage fucked around with this message at 08:02 on Feb 25, 2019

Trammel
Dec 31, 2007
.

itskage posted:

That ts? Does run on the client???

No, it's a node app that connects to a db (credentials committed to the codebase) with all db instructions wrapped in async promises that immediately wait for completion.

Pollyanna
Mar 5, 2005

Milk's on them.


Trammel posted:

Because this is how we self-implement permission systems in TYOOL 2019.

code:
import { Role, UserTag } from '../../../commons/Enum';
import ListingPermissionDto from './ListingPermissionDto';

export default class RolePermissionDto {
    public roleCodes: Role[];
    public tag: UserTag;
    public isAdministrator: boolean;
    public isInternalStaff: boolean;
    public accessCustomerApp: boolean;
    public viewOrganisationMenu: boolean;
    public viewMyTeamMenu: boolean;
    public viewAllOrganisation: boolean;
    public createOrganisation: boolean;
    public editOrganisation: boolean;
    public canCreateRoleCodes: Role[];
    public canUpdateRoleCodes: Role[];
    public canViewRoleCodes: Role[];
    public canViewTags: UserTag[];
    public canBatchUploadUsers: boolean;
}

We do something like this at work. It sucks and we hate it. We need a better way, but we’re not sure what yet, nor do we have the time.

CPColin
Sep 9, 2003

Big ol' smile.
A place I worked had a nightmare of a permissions system, because it had to be ~~~totally dynamic~~~ so the frontend devs could modify it, without talking to the backend devs. (It never worked out that way, of course.) We finally started to make some headway on it when we forced ourselves to separate Roles from the Authorities they granted. Our code had been doing isAdmin() checks in some places and canEditWhatever() checks in others, with the end result being that nobody could remember what each Role was supposed to be able to do. On top of that, some of the Roles were progressive, in that they were supposed to grant every Authority that every Role below them had, while other Roles were stand-alone.

We finally had User objects with a single Role ID for which ranked Role they had, along with a many-to-many map of Users to Roles for the unranked Roles. Each Role had a many-to-many map to its granted Authorities. The Authorities were an enum in the code and all permission checks in the code were only allowed to check Authorities.

Took us years to figure that out, ugh.

xtal
Jan 9, 2011

by Fluffdaddy

Trammel posted:

Because this is how we self-implement permission systems in TYOOL 2019.

code:
import { Role, UserTag } from '../../../commons/Enum';
import ListingPermissionDto from './ListingPermissionDto';

export default class RolePermissionDto {
    public roleCodes: Role[];
    public tag: UserTag;
    public isAdministrator: boolean;
    public isInternalStaff: boolean;
    public accessCustomerApp: boolean;
    public viewOrganisationMenu: boolean;
    public viewMyTeamMenu: boolean;
    public viewAllOrganisation: boolean;
    public createOrganisation: boolean;
    public editOrganisation: boolean;
    public canCreateRoleCodes: Role[];
    public canUpdateRoleCodes: Role[];
    public canViewRoleCodes: Role[];
    public canViewTags: UserTag[];
    public canBatchUploadUsers: boolean;
}

As somebody who's worked on video games, this is giving me flashbacks. So many of them have a global struct of bools for things like userHasExploredForestTemple.

Kazinsal
Dec 13, 2011


xtal posted:

As somebody who's worked on video games, this is giving me flashbacks. So many of them have a global struct of bools for things like userHasExploredForestTemple.

My favourite was an engine that had std::list<int> visited; where the list entries were the CRC32 values of the internal nicknames for every selectable static world object.

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)
Blockchain scripts shouldn't be any more complex than what bitcoin has planned. Unbound loops in a blockchain script interpreter is a really really dumb idea. Even the scheme where scripts fail on time-out or count-out is terrible. Blockchain scripts don't need to be turing complete to be useful. They're really more useful with those boundaries in place.

Ellie Crabcakes
Feb 1, 2008

Stop emailing my boyfriend Gay Crungus

dougdrums posted:

Blockchain scripts shouldn't be
You really didn't need to go any further than this

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

dougdrums posted:

Blockchain shouldn't be

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

dougdrums posted:

Blockchain scripts ... a really really dumb idea.

NihilCredo
Jun 6, 2011

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

Look, guys, don't worry, no matter how dumb blockchain projects get, at worst they're going to be a money sink for gullibe VCs.

They're not going to affect normal people in their everyday life or their basic necessities.
















































































































Ola
Jul 19, 2004

Actually, replacing the current fiat money systems and the finance oligarchy with the blockchain will ensure unprecedented equality of wealth for humanity.

We'll all be poor.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.
The problem I can see is that since everyone is treating blockchain as a joke, within five years, you're not going to be able to compile anything without blockchain being involved, because anything that big a joke is going to have to become integral to your product's build tools.

Bruegels Fuckbooks fucked around with this message at 16:51 on Feb 27, 2019

Munkeymon
Aug 14, 2003

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



But I already use Git?

Absurd Alhazred
Mar 27, 2010

by Athanatos

Munkeymon posted:

But I already use Git?

G-g-g-g-g-gitchain!?!?!?

Jazerus
May 24, 2011


Bruegels Fuckbooks posted:

The problem I can see is that since everyone is treating blockchain as a joke, within five years, you're not going to be able to compile anything without blockchain being involved, because anything that big a joke is going to have to become integral to your product's build tools.

okay, look, hear me out

nodejs on the blockchain

darthbob88
Oct 13, 2011

YOSPOS

Jazerus posted:

okay, look, hear me out

nodejs on the blockchain
Stored in MongoDB. It's web scale!

QuarkJets
Sep 8, 2008

Hello I would like to purchase some gitcoins

Nude
Nov 16, 2014

I have no idea what I'm doing.
Is it too much to ask what's so horrific bout blockchain? Apologies in advance if so.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Nude posted:

Is it too much to ask what's so horrific bout blockchain? Apologies in advance if so.

it's a solution in search of a problem. the idea is like, say you don't have a secure place to store a transaction log. if you distribute that transaction log to a bunch of people online, and do a bunch of bullshit with digital signatures, people invest money in your company. of course, you still don't have a secure place to store your transaction log...

Adbot
ADBOT LOVES YOU

Cuntpunch
Oct 3, 2003

A monkey in a long line of kings

Bruegels Fuckbooks posted:

it's a solution in search of a problem. the idea is like, say you don't have a secure place to store a transaction log. if you distribute that transaction log to a bunch of people online, and do a bunch of bullshit with digital signatures, people invest money in your company. of course, you still don't have a secure place to store your transaction log...

Am I wrong to find that Blockchain is being split into two definitions these days?

The first is the 'original' meaning, which involves Work of Proof nonsense ala Bitcoin. This is basically just a roundabout way to feather the accelerator for rising sea levels.

The second is the 'free VC money' meaning, which is basically what git does.


When we talk about things like chain of custody solutions, I don't see any reason why we'd be talking about the original meaning, but the latter meaning seems like a 'of course you'd want to do something like this, but now if we say Blockchain, we get showered in cash' opportunistic thing.

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