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
rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Hammerite posted:

Yes, a logical consequence of the arrangement I advocate for is that the order at declaration would have to be the opposite of the order when indexing. It doesn't matter.

I mean, you're wrong. The bad consequence of doing it this way is that someone who gets the rule backwards encounters a compile-time failure when allocating a jagged nested array. The bad consequence of doing it the other way is that someone who gets the rule backwards has their code blow up dynamically when allocating a rectangular nested array. The rectangular array case is more common, and the failure mode is worse.

Adbot
ADBOT LOVES YOU

SupSuper
Apr 8, 2009

At the Heart of the city is an Alien horror, so vile and so powerful that not even death can claim it.

Hammerite posted:

Just found out that if you want to declare a jagged array in C#, and you want to explicitly size the outer dimension of the array, you have to do it the wrong way around. I don't know what's going on there.

i.e. you have to write "var myArray = new Thing[10][];" instead of "var myArray = new Thing[][10];"
If I had to guess, it's probably because in C# you can only new the outer dimension. You can't do new Thing[10][10] or new Thing[][10][] or etc. So for simplicity they defined the new[] operator as "new X[...]" so the size expression is always in the first bracket. See https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/expressions#array-creation-expressions

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
Oh, does C# not directly support rectangular allocation? I guess I'd forgotten that it has multi-dimensional arrays for that case.

Putting the bounds in the right position is still a good idea to reserve room to extend the language to do rectangular allocation.

CPColin
Sep 9, 2003

Big ol' smile.
Another array horror is in Java when you try to annotate them @NonNull and you have to vet it exactly backwards in order to say you want a non-null array of elements vs. an array of non-null elements.

Volguus
Mar 3, 2009

CPColin posted:

Another array horror is in Java when you try to annotate them @NonNull and you have to vet it exactly backwards in order to say you want a non-null array of elements vs. an array of non-null elements.

Last time i checked @NonNull was not part of the standard. Is it now a part of the java specifications? I'm asking that because if @NonNull is not part of the standard, any complains you may have about its behavior cannot be brought against the language itself, but against the idiot IDE that you're using to program in said language.

CPColin
Sep 9, 2003

Big ol' smile.
Java decides where annotations have to go in order to apply to things, so my complaint is still against Java, no matter the exact annotation.

dwazegek
Feb 11, 2005

WE CAN USE THIS :byodood:

rjmccall posted:

Oh, does C# not directly support rectangular allocation? I guess I'd forgotten that it has multi-dimensional arrays for that case.

Putting the bounds in the right position is still a good idea to reserve room to extend the language to do rectangular allocation.

It does, new int[3, 5] is perfectly valid.

Edit: that said, rectangular allocation of jagged arrays is not supported.

return0
Apr 11, 2007

Volguus posted:

Last time i checked @NonNull was not part of the standard. Is it now a part of the java specifications? I'm asking that because if @NonNull is not part of the standard, any complains you may have about its behavior cannot be brought against the language itself, but against the idiot IDE that you're using to program in said language.

It’s Lombok, which non-insane people use.

Volguus
Mar 3, 2009

return0 posted:

It’s Lombok, which non-insane people use.

Oh yes, Lombok. You're in the right thread then. Carry on.

CPColin
Sep 9, 2003

Big ol' smile.
Eclipse also provides @NonNull and @Nullable. Or you can provide your own and tell Eclipse to use it, if you don't want to throw Eclipse's JAR into your project's dependency graph. But, again, what I said would have worked with any annotation:

Java code:
// This annotates each element with @Foo
@Foo Object[] objects;

// This annotates the array itself with @Foo
Object @Foo [] objects;

// This annotates the array and each element
@Foo Object @Foo [] objects;
Backwards, right?

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
If you declared arrays like []Foo instead of Foo[] everything would make much more sense.

return0
Apr 11, 2007

Volguus posted:

Oh yes, Lombok. You're in the right thread then. Carry on.

Haha nice. Do go on, I’m interested in Lombok horrors if you have any stories?

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.

CPColin posted:

Eclipse also provides @NonNull and @Nullable. Or you can provide your own and tell Eclipse to use it, if you don't want to throw Eclipse's JAR into your project's dependency graph. But, again, what I said would have worked with any annotation:

Java code:
// This annotates each element with @Foo
@Foo Object[] objects;

// This annotates the array itself with @Foo
Object @Foo [] objects;

// This annotates the array and each element
@Foo Object @Foo [] objects;
Backwards, right?

Let me tell you about generic collections

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Sagacity posted:

Let me tell you about generic collections

Generic collections are totally fine.

code:
@Nullable List<Foo> foos; // The list can be null

List<@Nullable Foo> foos; // The things inside the list can be null
It's just arrays that are backwards.

Athas
Aug 6, 2007

fuck that joker

rjmccall posted:

[M x [N x int]].

I spent quite a lot of time bikeshedding this for my own array plang, and we came to the conclusion that this is the right choice. It also means that for any time t, []t is an array with row type t. With C-style dimension notation, you have to jam the new dimension in the middle.

Absurd Alhazred
Mar 27, 2010

by Athanatos

Jabor posted:

Generic collections are totally fine.

code:
@Nullable List<Foo> foos; // The list can be null

List<@Nullable Foo> foos; // The things inside the list can be null
It's just arrays that are backwards.

Same thing goes for pointers and references in C++. Let's say we could express a raw pointer for type T as std::raw_ptr<T>. What's the difference between these two lines, and why?
C++ code:
std::raw_ptr<int> a, b;
int* a, b;

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av
One makes sense, the other sucks

Absurd Alhazred
Mar 27, 2010

by Athanatos

hackbunny posted:

One makes sense, the other sucks

Exactly. Heck, this is a valid line in C++:
C++ code:
char holy, *poo poo(&holy), &piss(holy); 

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


C++ is a coding horror.

Absurd Alhazred
Mar 27, 2010

by Athanatos

ultrafilter posted:

C++ is a coding horror.

Yeah. And I get to use it every weekday! :v:

Harik
Sep 9, 2001

From the hard streets of Moscow
First dog to touch the stars


Plaster Town Cop

Absurd Alhazred posted:

Exactly. Heck, this is a valid line in C++:
C++ code:
char holy, *poo poo(&holy), &piss(holy); 

That particular bit of syntax is really annoying, especially since:
pre:
tt.cc:2:18: error: ‘baz’ has not been declared
 int foo(int bar, baz, f) {return f;}
                  ^~~
is not also legal, where an obnoxiously long type name being elided might actually be useful. I also consider binding pointer/reference to the variable and not the type a mistake, but it's really just a subset of multiple-definition being a thing.
C++ code:
int* a, b, c; // whoops, only one pointer here.
At least in C++ you can't just dump addresses into ints without a cast and wonder why things explode so spectacularly later.

Contributing:
C++ code:
struct plant_uml {
auto operator()() const noexcept {
    using namespace sml;
    return make_transition_table(
       *"idle"_s + event<e1> = "s1"_s
      , "s1"_s + event<e2> [ guard ] / action = "s2"_s
      , "s2"_s + event<e3> [ guard ] = "s1"_s
      , "s2"_s + event<e4> / action = X
    );
  }
};
I can't tell if boost::SML is brilliant or insane, but I know that that the operator overloading is both a horror and the only way to express this properly without a pre-compilation step. Going to find out when I make use of it to formalize some state machines and see how well it works.

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
Y'all sound like you want Go's type declarations. map[int]map[string][]float64 is a map of ints to maps of strings to arrays of float64s.

Similarly, Go will let you leave off the type declaration if you have multiple declared symbols in a row with the same type. E.g. func foo(a, b int, c string, d, e, f float64)

Absurd Alhazred
Mar 27, 2010

by Athanatos

TooMuchAbstraction posted:

Y'all sound like you want Go's type declarations. map[int]map[string][]float64 is a map of ints to maps of strings to arrays of float64s.

Similarly, Go will let you leave off the type declaration if you have multiple declared symbols in a row with the same type. E.g. func foo(a, b int, c string, d, e, f float64)

You do have that in templated code. As in, I've written declarations like this:

C++ code:
std::unordered_map<std::string, std::vector<int>> m_complicatedVariable;

Coffee Mugshot
Jun 26, 2010

by Lowtax
All the C++ I see nowadays mostly elides real type names and initializes each variable closest to when it's used with auto. Which is frustrating in one way, but an improvement from the last time I looked and there were still quite a lot of globals and multiple variable declarations per line, like the mentioned code snippet.

Goreld
May 8, 2002

"Identity Crisis" MurdererWild Guess Bizarro #1Bizarro"Me am first one I suspect!"

ultrafilter posted:

C++ is a coding horror.

I’ve found that declaring multiple variables simultaneously is just asking for trouble in any language.
Someone will always find a way to screw things up, and it messes with search patterns when you’re looking for variables of specific types.

Also one of the most common usages is when someone’s iterating over multiple dimensions, and half of the time THAT is someone using some awful O(n^4) heuristic.

If it takes deep knowledge of the language to figure out if it’s dangerous, why should you ever use it when simply splitting it into 2 lines makes it safe and easy to understand? Especially when the CPU doesn’t care at all since the compiled code is the same.

UraniumAnchor
May 21, 2006

Not a walrus.

Goreld posted:

I’ve found that declaring multiple variables simultaneously is just asking for trouble in any language.

On my team at work we actually added a linter rule to fail builds when people did this. Depending on what language you're talking about it prevents all sorts of silly problems at the cost of a bit of vertical space.

raminasi
Jan 25, 2005

a last drink with no ice

Goreld posted:

I’ve found that declaring multiple variables simultaneously is just asking for trouble in any language.
Someone will always find a way to screw things up, and it messes with search patterns when you’re looking for variables of specific types.

Also one of the most common usages is when someone’s iterating over multiple dimensions, and half of the time THAT is someone using some awful O(n^4) heuristic.

If it takes deep knowledge of the language to figure out if it’s dangerous, why should you ever use it when simply splitting it into 2 lines makes it safe and easy to understand? Especially when the CPU doesn’t care at all since the compiled code is the same.

The last time I had to deal with this was when I was trying to do some Roslyn thing and there was a weird abstraction in a syntax tree and I couldn't figure out why it was there until I realized it was to support this. It causes problems even if you avoid it like the plague yourself :argh:

SeXTcube
Jan 1, 2009

In .NET land if you use reflection on jagged arrays the dimensions are swapped. So if you declare an int[10][] and then reflect on the type you will get back System.Int32[][10]. I encountered a lot of headache inducing stuff like that while building a multi-language API from C# source.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Been catching up on this thread from mid 2017 or so when I last posted. I don't I've ever read as many posts in a single thread as this. Had my own horror to impart

We had this import process that creates Customers for a shared tenant ecommerce app, and the tools to do it just didn't scale, like at all. Basically if you had more than 1,000 rows you were rolling the dice if any of them get in, with bizarre errors that bubble up from the lowest point of the MSSQL stack. It took one front end staff close to 4 hours to import 8,000 customers into the system, and most of that was retrying/splitting the import into smaller and smaller files. Turns out, for some reason every Customer entry the application is also creating entries in AspNetUsers, NetUserRoles, etc etc. And doing a bunch of hashes. And doing them in individual order, not in batches. And doing them outside of the transaction scope. We unhooked the proc from AspNet stuff and inserted 200,000 rows in about 90 seconds.

Absurd Alhazred
Mar 27, 2010

by Athanatos
https://twitter.com/SwiftOnSecurity/status/1043003592188223489

Carbon dioxide
Oct 9, 2012


Deleted, what did it say?

Absurd Alhazred
Mar 27, 2010

by Athanatos

Carbon dioxide posted:

Deleted, what did it say?

Tay Tay has failed me again.

Two images: one stating that Windows 10 Enterprise users will now have Linux-like support; the other one was one of Linus Trovalds` rants from LKML.

Munkeymon
Aug 14, 2003

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



Absurd Alhazred posted:

Tay Tay has failed me again.

Two images: one stating that Windows 10 Enterprise users will now have Linux-like support; the other one was one of Linus Trovalds` rants from LKML.

What is 'Linux-like support'? Microsoft will have interns idling in an obscure IRC channel to answer support questions hours later? They already have forums full of barely-coherent Q&A posts.

Absurd Alhazred
Mar 27, 2010

by Athanatos

Munkeymon posted:

What is 'Linux-like support'? Microsoft will have interns idling in an obscure IRC channel to answer support questions hours later? They already have forums full of barely-coherent Q&A posts.

That was their speculation on this. Anyway, I wish I'd screencapped it. :smith:

ulmont
Sep 15, 2010

IF I EVER MISS VOTING IN AN ELECTION (EVEN AMERICAN IDOL) ,OR HAVE UNPAID PARKING TICKETS, PLEASE TAKE AWAY MY FRANCHISE

Munkeymon posted:

What is 'Linux-like support'?

Support is a bad word on this one - release schedule is probably clearer.

quote:

For future releases, Microsoft is moving to separate support lifecycles for its twice-yearly releases. The March updates will have an 18-month support cycle for all editions, whereas the September release will get the longer, 30-month support cycle for Enterprise and Education editions. (All Windows 10 Pro installations will be supported for 18 months, and Windows 10 Home has no ability to defer updates.)

Also: Windows 10: A cheat sheet TechRepublic

For all intents and purposes, Microsoft is adopting a release cadence that is strikingly similar to what Linux users are already familiar with. Ubuntu Linux, for example, has a nearly identical twice-yearly release schedule, offering Long Term Support (LTS) versions in the spring and interim releases in the fall.
https://www.zdnet.com/article/microsoft-extends-support-cycle-for-windows-10-enterprise-customers/

Hughlander
May 11, 2005

ulmont posted:

Support is a bad word on this one - release schedule is probably clearer.

https://www.zdnet.com/article/microsoft-extends-support-cycle-for-windows-10-enterprise-customers/

But that isn’t true right? Lts is every other spring. The even years April release. IE 16.04 and 18.04 are lts but 17.04 wasn’t and is already unsupported.

ulmont
Sep 15, 2010

IF I EVER MISS VOTING IN AN ELECTION (EVEN AMERICAN IDOL) ,OR HAVE UNPAID PARKING TICKETS, PLEASE TAKE AWAY MY FRANCHISE

Hughlander posted:

But that isn’t true right? Lts is every other spring. The even years April release. IE 16.04 and 18.04 are lts but 17.04 wasn’t and is already unsupported.

Yes, the article is wrong.

streetlamp
May 7, 2007

Danny likes his party hat
He does not like his banana hat
could probably format this time better right team?

Falcorum
Oct 21, 2010
Our terrible internal HR system (SelectHR) has holiday time requests down to the microsecond of precision.

Adbot
ADBOT LOVES YOU

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Scaramouche posted:

Been catching up on this thread from mid 2017 or so when I last posted. I don't I've ever read as many posts in a single thread as this. Had my own horror to impart

We had this import process that creates Customers for a shared tenant ecommerce app, and the tools to do it just didn't scale, like at all. Basically if you had more than 1,000 rows you were rolling the dice if any of them get in, with bizarre errors that bubble up from the lowest point of the MSSQL stack. It took one front end staff close to 4 hours to import 8,000 customers into the system, and most of that was retrying/splitting the import into smaller and smaller files. Turns out, for some reason every Customer entry the application is also creating entries in AspNetUsers, NetUserRoles, etc etc. And doing a bunch of hashes. And doing them in individual order, not in batches. And doing them outside of the transaction scope. We unhooked the proc from AspNet stuff and inserted 200,000 rows in about 90 seconds.

Found what for some reason was. Someone went through an added these calls to make everything compatible with Entity Framework. When it's not being used.

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