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
fritz
Jul 26, 2003

sarehu posted:

So this article appeared on HN. You'd think functional programmer monoidsplaining was the horror, but actually it's this:



For normal pdfs, the mean, mode and median are all the same. I don't feel up to trying to argue for the variance bar right now but one could.

Adbot
ADBOT LOVES YOU

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

rjmccall posted:

You don't need types to default to not having mutable state for that; you just need them to not share their mutable state by default. That way, you pass an argument and the function gets its own copy.

The problem is that many, many languages do not give you the right tools for that.

Rivorous pretty much cracked his skull banging it against the wall trying to explain the benefits of pervasive value semantics to Russ Cox in blog comments (this was part of the initial 'discussion' about generics in Go). It was painful to watch.

TheresaJayne
Jul 1, 2011

nielsm posted:

This is an argument in favor of starting with C64 Basic, upgrading to Turbo Pascal, taking a little detour to Standard ML or Haskell, then go all C# (or Java if you absolutely must). Perhaps finish off with a trip to Pythonland, or Ruby or JavaScript to show off some more dynamic-ness.

I'm in favor of that argument.

Personally I would have gone for

ZX Basic
BBC Basic
Pascal
C
C++
Assembly
VB 6
Java
Everything else

oh wait - that was how i learnt to program

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
you should learn to program ActionScript 1, exactly how i learned to program

Linear Zoetrope
Nov 28, 2011

A hero must cook
Begin with a Babbage Difference Engine.

ErIog
Jul 11, 2001

:nsacloud:
The QCF Design DesktopDungeons.net password input system has different behavior on the web versus in the game itself. It appears to gently caress up on special characters. I did a password reset to a password like ='QCF1DES, and the web site happily accepted it while the game perpetually told me my password was incorrect.

The game has been in active development since at least 2011, and they just recently released an iOS/Android port along with a significant update to the PC version. The ability for a bug like this to persist is baffling.

comedyblissoption
Mar 15, 2006

Blotto Skorzany posted:

Rivorous pretty much cracked his skull banging it against the wall trying to explain the benefits of pervasive value semantics to Russ Cox in blog comments (this was part of the initial 'discussion' about generics in Go). It was painful to watch.
https://groups.google.com/forum/#!topic/golang-nuts/RKymTuSCHS0

Sean Talts posted:

Hi everyone,

I'm wondering if there are plans or it would be useful to implement map and filter on top of native Go collections, or maps and slices at least. Is there a reason that was not included? I've read a bit about why generics has not been included on a language level and instead they have been special cased on collections, but I don't see that precluding type-safe (i.e. not just translating everything to interface{} and back) implementations of map and filter. On the contrary, it seems to my admittedly Go-newbie self that they would, in fact, solve most of the use cases for generics. Thoughts? Does this violate some fundamental Go design decision I haven't yet encountered?

Thanks in advance,
Sean

PS I tried searching for this on the mailing list but my search-fu is weak and terms like "map" and "filter" are not particularly googleable. If I've missed a thread, feel free to link it! Thanks again.

Ian Lance Taylor posted:

I'm reluctant to add increasingly special purpose builtin functions.
There is no obvious endpoint as we head down that road.

Ian
...
Thinking about it a bit more, I'm not sure it makes sense even if we
ignore the slippery slope. The copy and append functions provide
facilites that are difficult to write in Go. The proposed map,
filter, and reduce functions presumably would call a function on each
element of a slice. That function would be provided by the caller,
and would have to have types that match the slice. But that means
that any use of these functions can be written as a trivial loop.

That is, copy and append get a significant advantage in working on
slices of any type. Map, filter and reduce do not get that advantage,
because they already require a function whose type must match the type
of the slice.

Ian

Rob Pike posted:

The modern programmer thinks a newline is a thousand times harder to
type than any other character. If instead you take a newline as only
one keystroke, which it is, the fact that your program might not fit
on one line is a bearable burden.

-rob

sarehu
Apr 20, 2007

(call/cc call/cc)
For loops are way better. You can just drop accumulator variables and debug statements without problem, it makes your code more editable and diffable and is better software engineering.

qntm
Jun 17, 2009

fritz posted:

For normal pdfs, the mean, mode and median are all the same. I don't feel up to trying to argue for the variance bar right now but one could.

It's pretty rare, though, that the mean is the height of the peak.

Amberskin
Dec 22, 2013

We come in peace! Legit!

qntm posted:

It's pretty rare, though, that the mean is the height of the peak.

Uh, I have interpreted the graph like the "mean" refers to the position of the vertical line in the horizontal (x) axis, and the "variance" as the width between -sigma +sigma. Of course that's incorrect (it is the SD, not the variance).

The graph is quite confusing, but I've seen worse things trying to ilustrate the normal distribution.

Hammerite
Mar 9, 2007

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

Amberskin posted:

Uh, I have interpreted the graph like the "mean" refers to the position of the vertical line in the horizontal (x) axis, and the "variance" as the width between -sigma +sigma. Of course that's incorrect (it is the SD, not the variance).

The graph is quite confusing, but I've seen worse things trying to ilustrate the normal distribution.

But then why is it that for one line the length is significant while for the other it's the position that's significant? Even accepting your charitable interpretation, the visual strategy is totally confused. And the most important thing you want to achieve in creating an explanatory diagram/aid to understanding is to be clear and not mislead people, so if it's confusing then the creator has certainly not done a good job.

Amberskin
Dec 22, 2013

We come in peace! Legit!

Hammerite posted:

But then why is it that for one line the length is significant while for the other it's the position that's significant? Even accepting your charitable interpretation, the visual strategy is totally confused. And the most important thing you want to achieve in creating an explanatory diagram/aid to understanding is to be clear and not mislead people, so if it's confusing then the creator has certainly not done a good job.

Agreed. One can make sense of that graph just if he has previous knowledge on the subject. As an attempt to show a neophyte how a normal distribution works, it is poo poo.

Tad Naff
Jul 8, 2004

I told you you'd be sorry buying an emoticon, but no, you were hung over. Well look at you now. It's not catching on at all!
:backtowork:
I inherited something. It's in Java, because of no reason I can tell.

This is a thing in it, which I have checked to see if it is actually called from anywhere in the code. It isn't:

code:
    public static String convertFormat(int i) {
        return String.format("%d", new Object[]{Integer.valueOf(i)});
    }
Does this make as much sense as I think it does? Java people?

another:

code:
    public int getMax(ArrayList al) {
        int max = 0;
        for (int i = 0; i < al.size(); i++) {
            if (Integer.parseInt(al.get(i).toString()) >= max) {
                max = Integer.parseInt(al.get(i).toString());
            }
        }
        return max;
    }

Contra Duck
Nov 4, 2004

#1 DAD
Is the thing you inherited is a first year CS assignment?

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

FeloniousDrunk posted:

I inherited something. It's in Java, because of no reason I can tell.

This is a thing in it, which I have checked to see if it is actually called from anywhere in the code. It isn't:

code:
    public static String convertFormat(int i) {
        return String.format("%d", new Object[]{Integer.valueOf(i)});
    }
Does this make as much sense as I think it does? Java people?

another:

code:
    public int getMax(ArrayList al) {
        int max = 0;
        for (int i = 0; i < al.size(); i++) {
            if (Integer.parseInt(al.get(i).toString()) >= max) {
                max = Integer.parseInt(al.get(i).toString());
            }
        }
        return max;
    }

And then the person who coded this went on to rant about Java being a poo poo language where nothing loving works.

b0lt
Apr 29, 2005

FeloniousDrunk posted:

I inherited something. It's in Java, because of no reason I can tell.

This is a thing in it, which I have checked to see if it is actually called from anywhere in the code. It isn't:

code:
    public static String convertFormat(int i) {
        return String.format("%d", new Object[]{Integer.valueOf(i)});
    }
Does this make as much sense as I think it does? Java people?

This is probably code that predates java having variadic functions/autoboxing, which were both added in java 2 standard edition 5.0 1.5.0.

edit: Huh, generics were java 5 also. I thought they were added earlier than that, but I guess not.

Soricidus
Oct 21, 2010
freedom-hating statist shill

b0lt posted:

This is probably code that predates java having variadic functions/autoboxing, which were both added in java 2 standard edition 5.0 1.5.0.

edit: Huh, generics were java 5 also. I thought they were added earlier than that, but I guess not.

Pretty sure String.format() was also only added in Java 5, so there was no point at which this code was acceptable.

I mean, even allowing for the fact that it's just a really inefficient reimplementation of Integer.toString().

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
I really want to know the thought process that went into converting an int primitive into an Integer object, encapsulating that into a 1-element Object array then using String.format to output it... as an integer string. Without any special formatting, like field widths or leading zeros or anything.

Spoiler alert, It's actually "loving Java is such a loving poo poo language gently caress why do I have to type all this loving boilerplate to convert an integer to a string goddamn"

TheresaJayne
Jul 1, 2011

Wheany posted:

I really want to know the thought process that went into converting an int primitive into an Integer object, encapsulating that into a 1-element Object array then using String.format to output it... as an integer string. Without any special formatting, like field widths or leading zeros or anything.

Spoiler alert, It's actually "loving Java is such a loving poo poo language gently caress why do I have to type all this loving boilerplate to convert an integer to a string goddamn"

I think i have seen a lot of this, Its where they get an error once, and find the solution there and apply that solution as boilerplate everywhere.

Like some code i saw in a minecraft mod source

String playername = (String)Server.getPlayerName();

When Server.getPlayerName() returns a string.

Contra Duck
Nov 4, 2004

#1 DAD
They read a thing about varargs that mentioned object arrays, so...

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

TheresaJayne posted:

I think i have seen a lot of this, Its where they get an error once, and find the solution there and apply that solution as boilerplate everywhere.

Or more likely, paste some codes they got from the internet.
Otherwise known as Cargo Cult programming.

canis minor
May 4, 2011

Zopotantor posted:

Or more likely, paste some codes they got from the internet.
Otherwise known as Cargo Cult programming.

I've had to deal with people pasting code between projects (without them really knowing why they are pasting this particular bit of code), and asking me why this thing doesn't work. Trying to understand the reasoning behind this took me a couple of minutes.

Hughlander
May 11, 2005

canis minor posted:

I've had to deal with people pasting code between projects (without them really knowing why they are pasting this particular bit of code), and asking me why this thing doesn't work. Trying to understand the reasoning behind this took me a couple of minutes.

Was the conclusion you reached was that it was faster for them to throw poo poo at the wall and get you to fix it than for them to reason through it on their own?

Dr. Stab
Sep 12, 2010
👨🏻‍⚕️🩺🔪🙀😱🙀

FeloniousDrunk posted:

I inherited something. It's in Java, because of no reason I can tell.

This is a thing in it, which I have checked to see if it is actually called from anywhere in the code. It isn't:

code:
    public static String convertFormat(int i) {
        return String.format("%d", new Object[]{Integer.valueOf(i)});
    }
Does this make as much sense as I think it does? Java people?

another:

code:
    public int getMax(ArrayList al) {
        int max = 0;
        for (int i = 0; i < al.size(); i++) {
            if (Integer.parseInt(al.get(i).toString()) >= max) {
                max = Integer.parseInt(al.get(i).toString());
            }
        }
        return max;
    }


First one is a bad implementation of Integer.toString() that doesn't make any sense. I have no idea how he ended up with that. Second one is, I think, done because he's declared the parameter as an ArrayList and not an ArrayList<Integer>, and then he just kept adding code until it worked. Also, as a bonus, it returns 0 if all the numbers are negative.

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?
I've noticed that inexperienced programmers dealing with strong typing have a tendency towards using strings as a sort of universal data type, either by using them as an intermediate in converting values, or by using them in place of better strongly typed options like enums, bools or even numbers. It's basically a way of embedding a weakly typed system into a strongly typed one.

HappyHippo fucked around with this message at 15:22 on Jun 4, 2015

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
This behavior is sometimes called "stringly-typed programming", although it is not restricted to supposedly strongly typed languages. Stubbornness... finds a way.

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.

HappyHippo posted:

I've noticed that inexperienced programmers dealing with strong typing have a tendency towards using strings as a sort of universal data type, either by using them as an intermediate in converting values, or by using them in place of better strongly typed options like enums, bools or even numbers. It's basically a way of embedding a weakly typed system into a strongly typed one.
http://c2.com/cgi/wiki?StringlyTyped

It's sadly common in a lot of APIs. :eng99:

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

It's easy to add ad hoc structure to strings, which points to a usability gap in most languages IMO.

SurgicalOntologist
Jun 17, 2004

Hammerite posted:

But then why is it that for one line the length is significant while for the other it's the position that's significant? Even accepting your charitable interpretation, the visual strategy is totally confused. And the most important thing you want to achieve in creating an explanatory diagram/aid to understanding is to be clear and not mislead people, so if it's confusing then the creator has certainly not done a good job.

Yeah, it's not the best depiction but it's not that far off. Put two small vertical lines on the edges of the "variance" line to indicate it's an extent, not a y location, and you have pretty much what you'd see in an intro stats textbook. You'd also want to extend the mean line to the edges of the figure so it's clear you're not measuring the height of the peak. (and yeah, it should be SD, not variance)

I teach stats and I try to use animations (or poor man's animations on the whiteboard) to avoid those kinds of misunderstandings. But go to any undergrad-level stats course and you'll see worse figures pretty much guaranteed.

canis minor
May 4, 2011

Hughlander posted:

Was the conclusion you reached was that it was faster for them to throw poo poo at the wall and get you to fix it than for them to reason through it on their own?

Oh, looking at some other code the person in question committed, it sometimes felt like it - but I had a long conversation regarding the thought process behind this - nothing malicious, bear in mind, he didn't want to bother me and as he copy/pasted some things on other project and it worked, he thought that he'll do it the same way here. But the thought of "why", or any sense of curiosity - no, this didn't occur to him. To be fair he wasn't a programmer, if that's an excuse - but yeah, just a cargo cult.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."

Subjunctive posted:

It's easy to add ad hoc structure to strings, which points to a usability gap in most languages IMO.

It's easy to add ad hoc structure to everything-is-a-hashmap scripting languages like JavaScript and that still doesn't stop anybody from using strings as a universal data structure. I think it's more accurately described as stubbornness or an education gap than a language usability problem. Everyone who reads this thread should be familiar with the phenomenon that many employed programmers have an anti-intellectual streak a mile wide and no interest in learning new concepts.

loinburger
Jul 10, 2004
Sweet Sauce Jones
On the subject of abuse of strings: the people who had written our back end prior to my being hired had decided to use "singular noun" to refer to row objects (e.g. Car) and "plural noun" to refer to the DAO (e.g. Cars). They then went and used a bunch of nouns with irregular plurals, e.g. Geography/Geographies or Ox/Oxen etc., along with a bunch of reflection-type stuff where Car had to be converted to Cars and vice versa. So, just refactor everything to something sensible, right? Like Car_Row and Car_DAO, Geography_Row and Geography_DAO, or whatever. Nope. Okay, use a lookup table of some sort, so key = Car and value = Cars (with an inverse key-value mapping). Nope. Instead, let's use Wordnet to do the singular-plural and plural-singular conversions for us! Brilliant! And do this lookup every single time, rather than caching the results.

So I killed the reflection crap. The singular/plural stuff stayed because after killing the reflection crap there was no reason to fix it. But still... goddamn.

piratepilates
Mar 28, 2004

So I will learn to live with it. Because I can live with it. I can live with it.



Wheany posted:

And then the person who coded this went on to rant about Java being a poo poo language where nothing loving works.

No matter how good or bad the language you use is, and no matter how powerful the IDE, the limiting factor to the quality of code is going to be that dumb rear end in a top hat sitting next to you (or more likely you).

I saw someone do 'new Function("whole bunch of code in here")' in a codebase the other day. No matter how bad of a language you think Javascript is I think there should at least be the assumption that that is not a good way of doing things ever and certainly not the only way to do it.

It wasn't even a short function, it was at least 7 lines all condensed in to one.

And all it did was appear to trigger some kind of animation on clicking a button, instead of just using a CSS selector or just not.

And it was also applied globally to all links on each page, and made it so that if it wasn't a postback URL (we're using Webforms, I know) and was just a regular <a href=fart> link then it wouldn't actually submit the link, it made it so that any external link just wouldn't do anything.

Did I mention that using 'new Function("fart")' is basically doing Eval() and will make it so that your developer tools won't show you were the handler is coming from? Instead (in Chrome) it shows it as coming from the VM so you have to search through your files for something that looks the same as the function.

Linear Zoetrope
Nov 28, 2011

A hero must cook

Internet Janitor posted:

It's easy to add ad hoc structure to everything-is-a-hashmap scripting languages like JavaScript and that still doesn't stop anybody from using strings as a universal data structure. I think it's more accurately described as stubbornness or an education gap than a language usability problem. Everyone who reads this thread should be familiar with the phenomenon that many employed programmers have an anti-intellectual streak a mile wide and no interest in learning new concepts.

To be fair, it's not like intellectuals are much better in this case. I've seen so much code that's just duct-taped together string-built shell calls in C++ at the universities I've attended. Sure, the code usually does something fascinating like a new method for human speech recognition or something, but there's a huge mess to get there. Granted a lot of this is because most academic code is made of throwaway scripts.

(Hell, right now I'm working on a Frankenstinian monstrosity that's stitched together Go/Java/Python due to time constraints and library availabilty).

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

loinburger posted:

On the subject of abuse of strings: the people who had written our back end prior to my being hired had decided to use "singular noun" to refer to row objects (e.g. Car) and "plural noun" to refer to the DAO (e.g. Cars). They then went and used a bunch of nouns with irregular plurals, e.g. Geography/Geographies or Ox/Oxen etc., along with a bunch of reflection-type stuff where Car had to be converted to Cars and vice versa. So, just refactor everything to something sensible, right? Like Car_Row and Car_DAO, Geography_Row and Geography_DAO, or whatever. Nope. Okay, use a lookup table of some sort, so key = Car and value = Cars (with an inverse key-value mapping). Nope. Instead, let's use Wordnet to do the singular-plural and plural-singular conversions for us! Brilliant! And do this lookup every single time, rather than caching the results.

So I killed the reflection crap. The singular/plural stuff stayed because after killing the reflection crap there was no reason to fix it. But still... goddamn.

:wtc:

So they were calling a third party system to figure out how to parse their data, and using reflection to do it? I'm not sure I can believe this.

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

Jsor posted:

To be fair, it's not like intellectuals are much better in this case. I've seen so much code that's just duct-taped together string-built shell calls in C++ at the universities I've attended. Sure, the code usually does something fascinating like a new method for human speech recognition or something, but there's a huge mess to get there. Granted a lot of this is because most academic code is made of throwaway scripts.

(Hell, right now I'm working on a Frankenstinian monstrosity that's stitched together Go/Java/Python due to time constraints and library availabilty).

I think you missed his point. The point is that an anti-intellectual attitude of refusing to learn/improve is what results in this "stringly typed code." Strings are capable of (poorly) representing all kinds of data, so after these people learn string manipulation they basically stop trying to improve their understanding of their language and just mangle every problem into strings.

Thermopyle
Jul 1, 2003

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

loinburger posted:

Instead, let's use Wordnet to do the singular-plural and plural-singular conversions for us! Brilliant!

It's amazing that this existed.

Harik
Sep 9, 2001

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


Plaster Town Cop

Blotto Skorzany posted:

That wasn't documentation from an expensive toolchain, just a lovely one. Expensive toolchains give you features like "is the only way to compile code for the chip your EEs have picked, and oftentimes does so correctly" and "refuses to work when the network is down because it can't contact its licensing server". So the value proposition is obvious :smith:

:smith::hf::smith: IAR buddy.

Other exciting features include error dialogs designed to fail if using VNC or other screensharing to work on a lab computer from your office, requiring you to walk over, badge into the lab, move the mouse to the dialog box and click 'OK'. Generally found in the unusual circumstance of the jtag debugger crashing when you do obscure things like "single step".

PIC is worse though, in every possible way. I don't think I've found a PIC compiler that's actually close to C compliant.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

loinburger posted:

On the subject of abuse of strings: the people who had written our back end prior to my being hired had decided to use "singular noun" to refer to row objects (e.g. Car) and "plural noun" to refer to the DAO (e.g. Cars). They then went and used a bunch of nouns with irregular plurals, e.g. Geography/Geographies or Ox/Oxen etc., along with a bunch of reflection-type stuff where Car had to be converted to Cars and vice versa. So, just refactor everything to something sensible, right? Like Car_Row and Car_DAO, Geography_Row and Geography_DAO, or whatever. Nope. Okay, use a lookup table of some sort, so key = Car and value = Cars (with an inverse key-value mapping). Nope. Instead, let's use Wordnet to do the singular-plural and plural-singular conversions for us! Brilliant! And do this lookup every single time, rather than caching the results.

So I killed the reflection crap. The singular/plural stuff stayed because after killing the reflection crap there was no reason to fix it. But still... goddamn.

Holy poo poo.

Adbot
ADBOT LOVES YOU

Tad Naff
Jul 8, 2004

I told you you'd be sorry buying an emoticon, but no, you were hung over. Well look at you now. It's not catching on at all!
:backtowork:
More! This is stuck on the end of every function that does a database call:

code:
catch (Exception e){
  e.printStackTrace();
  try{
     this.ct.close();
  }catch (SQLException e) {
     e.printStackTrace();
  }
}finally{
  try{
    this.ct.close();
  }catch (SQLException e) {
     e.printStackTrace();
  }
}
Yup, just dump stack (a bunch of times) and carry on, and finally, carry on. Also I've deleted a bunch of decompiler-generated comments, because this guy graciously shared this with no source. He's going on a cruise, because I guess he has to unwind after generating code like this.

Also naturally there is the mandatory C&P 25 times block of code with one parameter changed per paste.

So at my work, we have job classifications. They start at "A". He is a "C", which is pretty much entry level for a programmer. He's been here for about 12 years I guess. I am an "E", which is as close to management you can get without going over. I've been here for 7 years, started at "D". But I am still under a Manager (E) who told me to "enhance" this thing (with actual written requirements, which is a refreshing change) so, I dunno. The app was highly regarded when it launched, but holy poo poo it is a pig with not a lot of lipstick.

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