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
Nude
Nov 16, 2014

I have no idea what I'm doing.

DONT THREAD ON ME posted:

I spent a day doing unity without a whole lot of game dev or c# experience and it was very clear to me that there are untold horrors hiding there.

I've posted it here before but it's one of my favs:
C# code:
UnityEngine.Object unityObject = new UnityEngine.Object();
Debug.Log(unityObject); // null
Debug.Log(null); // Null <- notice the capital N
Debug.Log(unityObject == null); // True
Debug.Log(System.Object.ReferenceEquals(unityObject, null)); // false
Watcha doing with that object Unity? What horrors lie?

Adbot
ADBOT LOVES YOU

Hughlander
May 11, 2005

Nude posted:

I've posted it here before but it's one of my favs:
C# code:
UnityEngine.Object unityObject = new UnityEngine.Object();
Debug.Log(unityObject); // null
Debug.Log(null); // Null <- notice the capital N
Debug.Log(unityObject == null); // True
Debug.Log(System.Object.ReferenceEquals(unityObject, null)); // false
Watcha doing with that object Unity? What horrors lie?

That's what I mean and if you do a
code:
Debug.Log(unityObject?.ToString());
It'll log null in the editor and throw NullReferenceException on iOS/Android.

Mooey Cow
Jan 27, 2018

by Jeffrey of YOSPOS
Pillbug

Hughlander posted:

Well I assume it’s for Unity3D which does questionable things with overriding.Equals for null checks that causes Elvis operator to work in the editor but fail on a device. They asked for a way to override ?. And were told to go gently caress themselves.

They are overriding equality comparisons for objects derived from their UnityEngine.Object (so basically every game resource and component), so they can add a lot of additional error checking. Serialized Object fields are never truly "null", they have various states, like "unassigned", or "destroyed" and so on, so they can give separate error messages for if that null-reference exception you got was due to the object never having been assigned a value in the first place, or if it used to have a value but was destroyed elsewhere, and possibly some other things. In release builds much of that additional stuff is stripped away and accessing a null might in some cases result in a null reference crash on some unmanaged devices, rather than just a friendly exception.

All this of course results in the ?? operator not working for UnityEngine.Objects, since that relies on reference equality to null, which you can't really override. ?. too relies on reference equality.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
That sounds like unity doesn’t trust its users.

I assume unreal is just a different kind of horrible?

CPColin
Sep 9, 2003

Big ol' smile.

DONT THREAD ON ME posted:

I will say this: if you need a dynamic language on the JVM, you could do a hell of a lot worse than Clojure.


Groovy

gently caress Groovy. It's my hell at work. I keep fishing around for a replacement and Spring Boot + Thymeleaf looks reasonable, but I don't want to write a bunch of useless getters and setters again, nor do I want to use a hack like Lombok. Ideally, I could use Ceylon with Spring Boot, but that's uncharted territory and Ceylon has one foot in the grave nowadays.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Ah, I didn’t realize Unity made such interesting decisions. Good to know in case I ever find myself in a position I use it.

Loezi
Dec 18, 2012

Never buy the cheap stuff

CPColin posted:

gently caress Groovy. It's my hell at work. I keep fishing around for a replacement and Spring Boot + Thymeleaf looks reasonable, but I don't want to write a bunch of useless getters and setters again, nor do I want to use a hack like Lombok. Ideally, I could use Ceylon with Spring Boot, but that's uncharted territory and Ceylon has one foot in the grave nowadays.

While it ain't the perfect solution, surely you can just press some combination of keys in your favored IDE to bring up a window where you click "select all" and press enter to generate all those getters and setters? I mean, even Netbeans of all things has support for that.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

CPColin posted:

gently caress Groovy. It's my hell at work. I keep fishing around for a replacement and Spring Boot + Thymeleaf looks reasonable, but I don't want to write a bunch of useless getters and setters again, nor do I want to use a hack like Lombok. Ideally, I could use Ceylon with Spring Boot, but that's uncharted territory and Ceylon has one foot in the grave nowadays.

Is Kotlin an option?

Hughlander
May 11, 2005

CPColin posted:

gently caress Groovy. It's my hell at work. I keep fishing around for a replacement and Spring Boot + Thymeleaf looks reasonable, but I don't want to write a bunch of useless getters and setters again, nor do I want to use a hack like Lombok. Ideally, I could use Ceylon with Spring Boot, but that's uncharted territory and Ceylon has one foot in the grave nowadays.

I honestly didn't realize anyone used groovy for anything other than gradle, and it was just poo poo because all build DSLs are poo poo.

Carbon dioxide
Oct 9, 2012

I haven't regretted my decision to apply to a Scala job for even one second.

I mean, I had to relearn most of what I knew because functional programming is a whole other can of worms, but Scala does a good job of not bothering you with Java internals unless you hook in Java libraries yourself.

And every update, the scala compiler gets a little bit less slow.

Mooey Cow
Jan 27, 2018

by Jeffrey of YOSPOS
Pillbug

DONT THREAD ON ME posted:

That sounds like unity doesn’t trust its users.

I assume unreal is just a different kind of horrible?

Well Unity's target users are beginners, or at least were when they decided on that thing, which I believe has always been there. Or perhaps they wrote it for themselves, as they too were pretty much beginners when they first made Unty... They have thought about changing it for some time now, but doing so would probably break a lot of existing code, since Object references are in effect weak references actually managed by the underlying native code engine.

Having had the pleasure of working with UE3 for the last year or so though, I'm extremely hesitant to touch anything Unreal ever again :yikes:

testsubject
Apr 18, 2006
Java code:
static int convertProductIdToIndex(final int productId) {
  int hexNumber = productId;
  int index = -1;
  for (int i = 0; i < 2; i++) {
    int lastDigit = hexNumber % 16;
    // Right shift one digit.
    hexNumber >>= 4;
    // Combine togther to get decimal value.
    index += lastDigit * Math.pow(16, i);
  }
  return index;
}
Does it count if it was during code review?

return productId & 0xFF;

Bonus:

Java code:
/**
 * The pattern for input devices.
 * 0x04xx. When convert to hex number, the first zero will lose. Match the rest three digits.
 */
private static final PATTERN = "4[0-9A-Fa-f][0-9A-Fa-f]";

static boolean isDevice(final int pid) {
  final String deviceCode = Integer.toHexString(pid);
  return Pattern.matches(PATTERN, deviceCode);
}

CPColin
Sep 9, 2003

Big ol' smile.

Loezi posted:

While it ain't the perfect solution, surely you can just press some combination of keys in your favored IDE to bring up a window where you click "select all" and press enter to generate all those getters and setters? I mean, even Netbeans of all things has support for that.

Oh, for sure. It's just nice not having the clutter.

DONT THREAD ON ME posted:

Is Kotlin an option?

I'm figuring Kotlin is what I'll eventually pick. Every now and then, I search for "kotlin + spring boot" or something similar, to see if anybody else is doing it. All I've found so far are the usual Hello World demos, but I haven't dug too deeply.

Hughlander posted:

I honestly didn't realize anyone used groovy for anything other than gradle, and it was just poo poo because all build DSLs are poo poo.

Yeah, I don't know how or why my predecessor picked it. All the code has the hallmarks of stuff that a one-person team barfed out, piece-by-piece, with no concern over maintainability or structure. They said they didn't even use an IDE while developing, which just boggles my mind.

eth0.n
Jun 1, 2012

Mooey Cow posted:

Having had the pleasure of working with UE3 for the last year or so though, I'm extremely hesitant to touch anything Unreal ever again :yikes:

Unreal has a function-like macro called "check". They know it's terrible and causes problems, but won't get rid of it due to backwards-compatibility.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

CPColin posted:

I'm figuring Kotlin is what I'll eventually pick. Every now and then, I search for "kotlin + spring boot" or something similar, to see if anybody else is doing it. All I've found so far are the usual Hello World demos, but I haven't dug too deeply.

If it helps, a colleague started a new thing using spring boot with Kotlin and gave up after a couple days, citing too much magic and not enough/inaccurate documentation.

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.
I'm happily using Kotlin and Spring Boot. It's your colleague who is not enough and/or inaccurate.

netcat
Apr 29, 2008

Hughlander posted:

I honestly didn't realize anyone used groovy for anything other than gradle, and it was just poo poo because all build DSLs are poo poo.

At my last job we used it for something related to coding Jenkins jobs for a while but abandonded it and just did the jobs manually

Hughlander
May 11, 2005

netcat posted:

At my last job we used it for something related to coding Jenkins jobs for a while but abandonded it and just did the jobs manually

Yes but that's still a build DSL. (We have a Jenkinsfile.groovy as well which shares code with Gradle files.)

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
maintaining jenkins jobs is such a loving pain in the rear end

Winter Stormer
Oct 17, 2012

testsubject posted:

Java code:
static int convertProductIdToIndex(final int productId) {
  int hexNumber = productId;
  int index = -1;
  for (int i = 0; i < 2; i++) {
    int lastDigit = hexNumber % 16;
    // Right shift one digit.
    hexNumber >>= 4;
    // Combine togther to get decimal value.
    index += lastDigit * Math.pow(16, i);
  }
  return index;
}
Does it count if it was during code review?

return productId & 0xFF;

I dunno Java but I can't see how the spoiler code isn't off by one

Ellie Crabcakes
Feb 1, 2008

Stop emailing my boyfriend Gay Crungus

Winter Stormer posted:

I dunno Java but I can't see how the spoiler code isn't off by one
That's why this is a horror: it's an overly complicated way of doing it wrong.

Thermopyle
Jul 1, 2003

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

Fatty Crabcakes posted:

That's why this is a horror: it's an overly complicated way of doing it wrong.

My preferred coding method.

Steve French
Sep 8, 2003

Fatty Crabcakes posted:

That's why this is a horror: it's an overly complicated way of doing it wrong.

It's lacking context, and a reasonable read of "convertProductIdToIndex" without context is that product IDs are 1-indexed and this is for accessing products in some array that is 0-indexed. Of course, it's still an overly complex implementation if that were the case.

Ellie Crabcakes
Feb 1, 2008

Stop emailing my boyfriend Gay Crungus

Steve French posted:

It's lacking context, and a reasonable read of "convertProductIdToIndex" without context is that product IDs are 1-indexed and this is for accessing products in some array that is 0-indexed. Of course, it's still an overly complex implementation if that were the case.
Yeah, but with this it'll end up with the third value instead of the second.

Steve French
Sep 8, 2003

Fatty Crabcakes posted:

Yeah, but with this it'll end up with the third value instead of the second.

I don't follow. It seems like you're saying it will return 2 (third value when zero indexed) when it should return 1. Is that right?

Ellie Crabcakes
Feb 1, 2008

Stop emailing my boyfriend Gay Crungus

Steve French posted:

I don't follow. It seems like you're saying it will return 2 (third value when zero indexed) when it should return 1. Is that right?
Well actually I'm an idiot because I somehow knocked off the - in vim and queered the results.

It's me! I'm the horror!

Votlook
Aug 20, 2005

ToxicFrog posted:

While I love Clojure and had the same experience with it, it is never far from my mind that its error reporting sucks endless fields of rotting rear end, and that's the main thing that prevents me from wholeheartedly recommending it to everyone.

A runtime error is just a plain old Java exception, so you get a gross mix of Clojure stack frames, Java stack frames in Java libraries you called deliberately, and Java stack frames in the internals of Clojure itself filling multiple pages of terminal. Coming from languages like Lua or Python (or even plain Java) where errors don't generally lay the guts of the interpreter out all over your terminal, this is pretty shocking.

The stacktraces are gross, but most tooling has an option to hide the java and internal stuff (at least Cider does), and there have been some improvements in version 1.10

boo_radley
Dec 30, 2005

Politeness costs nothing

Fatty Crabcakes posted:

That's why this is a horror: it's an overly complicated way of doing it wrong.

Ah, enterprise programming.

Ellie Crabcakes
Feb 1, 2008

Stop emailing my boyfriend Gay Crungus

boo_radley posted:

Ah, enterprise programming.
I'd have to see the rest of ProductIdConverterFactoryBuilderFactory to make that determination

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

CPColin posted:

gently caress Groovy. It's my hell at work. I keep fishing around for a replacement and Spring Boot + Thymeleaf looks reasonable, but I don't want to write a bunch of useless getters and setters again, nor do I want to use a hack like Lombok. Ideally, I could use Ceylon with Spring Boot, but that's uncharted territory and Ceylon has one foot in the grave nowadays.

Sounds like you hate Groovy on Grails and not Groovy the language?

I've used Groovy + Spring Boot + Thymeleaf for side projects and it's just fine. To be fair, I've only used Groovy to sidestep some of the verboseness of pure Java. I don't mess with the AST stuff.

Also Groovy and Spock Framework for testing is my favorite and it's literally the only way I can get people to write tests no matter what company I'm at. Truly the path of least resistance.

ToxicFrog
Apr 26, 2008


Votlook posted:

The stacktraces are gross, but most tooling has an option to hide the java and internal stuff (at least Cider does), and there have been some improvements in version 1.10

Most of my projects are still on 1.8 or 1.9, so that's good to know. I generally link in Pretty, which does the same thing, at least for runtime errors -- compile-time errors are still a total shitshow. None of this should be necessary, though.

CPColin
Sep 9, 2003

Big ol' smile.

poemdexter posted:

Sounds like you hate Groovy on Grails and not Groovy the language?

I've used Groovy + Spring Boot + Thymeleaf for side projects and it's just fine. To be fair, I've only used Groovy to sidestep some of the verboseness of pure Java. I don't mess with the AST stuff.

Also Groovy and Spock Framework for testing is my favorite and it's literally the only way I can get people to write tests no matter what company I'm at. Truly the path of least resistance.

I might hate Groovy less if my predecessor hadn't coded it so sloppily. Also if I weren't stuck on whatever Groovy version is supported by Grails 2.3. Spock is all right, though. Being able to put my test parameters in a big data table is pretty nice. This is not compatible with Grails 2.3, of course. Groovy's definitely got some surprises lurking under the hood, though, like how the == operator always tries calling compareTo() first, so you'd better make drat sure your implementation is compatible with equals()! (Guess if my predecessor's implementations were!)

Kuule hain nussivan
Nov 27, 2008

Are companies that don't have a clue a horror?

I work for a place that has basically bought licenses to an (industry standard) application and we now resell those licenes and offer support to our direct customers. In return, we get...."expert" support from the company (hereby referred to as Poop Ltd) that has made the application. This support includes server configuration etc.

So the application has been slow. Really slow, considering the amount of users and such. So we open up a ticket with Poop Ltd. We wait. And we wait some more. No action from Poop Ltd. This isn't unusual though, they're slow as gently caress. I get tired of waiting and go check out the server settings myself, despite knowing very little about it. There's quite a lot of settings that look suspicious, so I report these to Poop Ltd. They say they'll look into it. We wait again. By this time, the ticket has been open for the better part of 2 months.

But suddenly, I receive a reply to the ticket! Oh glorious joy! The reply...

"We cannot find the setting you mentioned. Could you please let our tech team know where this setting can be found?"

It's not an obscure setting. It is a very loving basic server setting. And that's not even what makes me angry. What makes me angry is that they literally didn't go through the effort of googling the server name and setting and clicking on the first result. That would have given them plenty of material to bullshit their way to a response. But no, even that is too much loving effort for Poop Ltd.

CPColin
Sep 9, 2003

Big ol' smile.
More like Poop Unlimited

Happy Thread
Jul 10, 2005

by Fluffdaddy
Plaster Town Cop
Here's quite the horror from the BitCoin thread. Solidity is the programming language used for Ethereum butt coins.

DominoKitten posted:

Not being able to correct bugs and errors in smart contract code in Ethereum is one of my favorite parts of the whole cryptocurrency boondoggle, expressed quite eloquently by someone in one of the bad with money threads:

VitalSigns posted:

Ethereum is utterly baffling to me on a fundamental level, it is an unsolvable riddle of the cosmos that it was even made.

Anyone with enough programming knowledge to actually implement it would also have enough programming knowledge to understand that while machines may be logically perfect your code will never be and thus why it's a terrible idea to design a system around code that is not allowed to be changed. Ethereum cannot exist, its conditions of creation contain the seeds of its own destruction, the knowledge necessary for one to make it demonstrates why one shouldn't. Its existence is impossible and yet, here it is.

And it gets even better when you find out that the programming language involved makes it easy to write incorrect code:

HackerNews [url posted:

https://news.ycombinator.com/item?id=14691212[/url]]
Solidity has far worse problems than not being an advanced research language. Just being a sanely designed normal language would be a big step up. Solidity is so riddled with bizarre design errors it makes PHP 4 look like a work of genius.

A small sampling of the issues:

Everything is 256 bits wide, including the "byte" type. This means that whilst byte[] is valid syntax, it will take up 32x more space than you expect. Storage space is extremely limited in Solidity programs. You should use "bytes" instead which is an actual byte array. The native 256-bit wide primitive type is called "bytes32" but the actual 8-bit wide byte type is called "int8".

Strings. What can we say about this. There is a string type. It is useless. There is no support for string manipulation at all. String concatenation must be done by hand after casting to a byte array. Basics like indexOf() must also be written by hand or implementations copied into your program. To even learn the length of a string you must cast it to a byte array, but see above. In some versions of the Solidity compiler passing an empty string to a function would cause all arguments after that string to be silently corrupted.

There is no garbage collector. Dead allocations are never reclaimed, despite the scarcity of available memory space. There is also no manual memory management.

Solidity looks superficially like an object oriented language. There is a "this" keyword. However there are actually security-critical differences between "this.setX()" and "setX()" that can cause wrong results: https://github.com/ethereum/solidity/issues/583

Numbers. Despite being intended for financial applications like insurance, floating point is not supported. Integer operations can overflow, despite the underlying operation being interpreted and not implemented in hardware. There is no way to do overflow-checked operations: you need constructs like "require((balanceOf[_to] + _value) >= balanceOf[_to]);"

You can return statically sized arrays from functions, but not variably sized arrays.

For loops are completely broken. Solidity is meant to look like JavaScript but the literal 0 type-infers to byte, not int. Therefore "for (var x = 0; x < a.length; x ++) { a[x] = x; }" will enter an infinite loop if a[] is longer than 255 elements, because it will wrap around back to zero. This is despite the underlying VM using 256 bits to store this byte. You are just supposed to know this and write "uint" instead of "var".

Arrays. Array access syntax looks like C or Java, but array declaration syntax is written backwards: int8[][5] creates 5 dynamic arrays of bytes. Dynamically sized arrays work, in theory, but you cannot create multi-dimensional dynamic arrays. Because "string" is a byte array, that means "string[]" does not work.

The compiler is riddled with mis-compilation bugs, many of them security critical. The documentation helpfully includes a list of these bugs .... in JSON. The actual contents of the JSON is of course just strings meant to be read by humans. Here are some summaries of miscompile bugs:

In some situations, the optimizer replaces certain numbers in the code with routines that compute different numbers

Types shorter than 32 bytes are packed together into the same 32 byte storage slot, but storage writes always write 32 bytes. For some types, the higher order bytes were not cleaned properly, which made it sometimes possible to overwrite a variable in storage when writing to another one.

Dynamic allocation of an empty memory array caused an infinite loop and thus an exception

Access to array elements for arrays of types with less than 32 bytes did not correctly clean the higher order bits, causing corruption in other array elements.


As you can see the decision to build a virtual machine with that is natively 256-bit wide led to a huge number of bugs whereby reads or writes randomly corrupt memory.

Solidity/EVM is by far the worst programming environment I have ever encountered. It would be impossible to write even toy programs correctly in this language, yet it is literally called "Solidity" and used to program a financial system that manages hundreds of millions of dollars.

Ola
Jul 19, 2004

It's almost enough to make you think someone just cobbled it together to scam people.

Soricidus
Oct 21, 2010
freedom-hating statist shill

Ola posted:

It's almost enough to make you think someone just cobbled it together to scam people.

nah, more likely it was cargo-culted together by some idiot who desperately wanted to design a pl/vm for a financial system despite not knowing anything about pl design, vms, or finance

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.

Soricidus posted:

nah, more likely it was cargo-culted together by some idiot who desperately wanted to design a pl/vm for a financial system despite not knowing anything about pl design, vms, or finance

i do think a language with no garbage collector which also doesn't support manual memory management is complete genius and i wish all languages were like that. "gently caress it, nothing we can do about that memory leak."

Soricidus
Oct 21, 2010
freedom-hating statist shill

Bruegels Fuckbooks posted:

i do think a language with no garbage collector which also doesn't support manual memory management is complete genius and i wish all languages were like that. "gently caress it, nothing we can do about that memory leak."

yet another reason why java is the best

Adbot
ADBOT LOVES YOU

Hughlander
May 11, 2005

Soricidus posted:

yet another reason why java is the best

For an extremely narrow set of problems that actually is really loving cool.

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