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
Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.

tef posted:

I think you're confusing "similar things should look the same" as "every other language should work like the one I learned to use".

Yeah, it really seems to me that it's a bit of a no-brainer how much simpler it can be to read and understand a language that requires you to explicitly call 'this' or 'self' or '@' or whatever the hell the current object is. Unnecessarily complex variable scoping rules don't help anyone in the long run, it's just obfuscation. Read the docs of the language you use and lo and behold, you can understand how things work. The horror is only really there if a language finds ways to be internally inconsistent.

Adbot
ADBOT LOVES YOU

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde

Contra Duck posted:

code:
boolean aTrueValue = true;
boolean aFalseValue = false;
My guess is that someone overheard that this is recommended for Boolean to improve performance, and has gone cargo-cult with it using booleans instead.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

Stoph posted:

code:
"use strict";

Definitely.

But also: use jshint or jslint.

Cocoa Crispies posted:

Use a language that gives you different syntax for instance variables and local/global variables, syntax for classes and objects, and better syntax for function binding.

With web browsers you really don't have a choice. (Or is the joke that CoffeeScript is such a language and I'm dumb?)

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Wheany posted:


With web browsers you really don't have a choice. (Or is the joke that CoffeeScript is such a language and I'm dumb?)

It's the latter.

Plorkyeran
Mar 22, 2007

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

tef posted:

This is generally what I think of languages where 'this' or 'self' is implicit.
Implicit this is not quite as weird in statically typed languages (and unsurprisingly enough every language I've used with it has been statically typed), but I am gradually coming around to the viewpoint that it's not a net gain.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

Cocoa Crispies posted:

It's the latter.

Well, I don't know CoffeeScript so it's a bad language that you should not use.

Zombywuf
Mar 29, 2008

Wheany posted:

Well, I don't know CoffeeScript so it's a bad language that you should not use.

Obligatory: https://github.com/satyr/coco/wiki/wtfcs

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Wheany posted:

Well, I don't know CoffeeScript so it's a bad language that you should not use.

I like CoffeeScript a lot -- it hides a lot of JavaScript's warts and gives it a cleaner syntax. The problem is debugging CoffeeScript. Since it emits regular old JS, you still need to have a good knowledge of JS in order to effectively debug. Of course, you should be unit testing, but there are going to be times you'll need to dive into the code in a debugger no matter what.

jiggerypokery
Feb 1, 2012

...But I could hardly wait six months with a red hot jape like that under me belt.

It really makes nice code to look at though. http://coffeescript.org/

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.
Found this today in work stuff:
code:
//was I on drugs when I picked these variable names?
gently caress

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
code:
#			Problem & Solution							Cypress ID
8			ARM GCC 4.4.1 can Generate some Bad Code				78083
------------------------------------------------------------------------------------------------------------------------

There is a known issue with GCC 4.4.1 that can cause a warning similar to the following:
/cc1up7N2.s:41: Warning: register range not in ascending order /

Code with this warning is prone to failure and most likely will not work in your system.
This issue is resolved in the Fall release of GCC; however, that release has not yet been integrated into PSoC Creator. 
It will be integrated in a future PSoC Creator release.

In order to work around this issue, open the listing file created for the C file that generated the warning. 
There, look for the assembly line number indicated by the warning (in our case line 41). 
Then map that back to the offending line of C code. 
Change the code around that line, either reordering independent operations or some other mechanism.

Munkeymon
Aug 14, 2003

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




I don't know why, but I find Unexpected 'MATH' hilarious no matter how many times I see it. Unexpected ('Surprise') math: math you did not expect to see today.

Edit:

Basically, I picture CoffeeScript as an accounting student when faced with their first certification exam saying

CoffeeScript posted:

Oh, god! Oh, gently caress! I didn't think there'd be math in this thing! :cry:

Munkeymon fucked around with this message at 23:41 on Jan 21, 2013

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

Munkeymon posted:

I don't know why, but I find Unexpected 'MATH' hilarious no matter how many times I see it. Unexpected ('Surprise') math: math you did not expect to see today.

https://www.youtube.com/watch?v=6_Ye0HfX41Q&t=10s

Braaam
Oct 10, 2004

Sleep peacefully, people. There will not be a war.

Ithaqua posted:

I like CoffeeScript a lot -- it hides a lot of JavaScript's warts and gives it a cleaner syntax. The problem is debugging CoffeeScript. Since it emits regular old JS, you still need to have a good knowledge of JS in order to effectively debug. Of course, you should be unit testing, but there are going to be times you'll need to dive into the code in a debugger no matter what.

Source Maps make this a lot easier: http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Ithaqua posted:

I like CoffeeScript a lot -- it hides a lot of JavaScript's warts and gives it a cleaner syntax. The problem is debugging CoffeeScript. Since it emits regular old JS, you still need to have a good knowledge of JS in order to effectively debug.


I've found that writing CoffeeScript that compiles to relatively simple JavaScript helps with development, debugging, and maintenance. Generating an additional file to map source to compiled code sounds similar to the regex aphorism: "Some people, when confronted with a problem, think, I know, I'll use regular expressions. Now they have two problems."

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.

Cocoa Crispies posted:

I've found that writing CoffeeScript that compiles to relatively simple JavaScript helps with development, debugging, and maintenance. Generating an additional file to map source to compiled code sounds similar to the regex aphorism: "Some people, when confronted with a problem, think, I know, I'll use regular expressions. Now they have two problems."

Yeah, I've never really had trouble relating the compiled code to it's source with Coffeescript. As long as your dev environment is preserving white space with the compiled code, it's not like the structure becomes wildly different. It's not like it's a Haskell to Javascript compiler or anything. :)

No Safe Word
Feb 26, 2005

This probably belongs here but not because the code is bad, really: http://swanson.github.com/blog/2013/01/20/worst-bug-ever.html

quote:

After about of week of stepping through the code line by line (even verifying some of the calculations by hand), I finally isolated the section of code where the results diverged.

code:
for i=1:length(LensLayers)
  d[i] = compute_diffraction_at_wavelength(LensLayers[i], WAVELENGTH)
end
It seemed pretty innocuous; loop over an array, perform a calculation on each element, store the result in another array.

Do you see the bug?

Remember when I said there were some PhD-level computations being done? Most of them dealt with complex numbers, which are natively support in MATLAB like so:

code:
x = 2 + 3*i
Figure it out yet?

I was using i as my loop index, but as a side-effect the imaginary constant i in MATLAB was getting overwritten! So 2 + 3*i was evaluating to 5 for the first iteration, 8 for the second, etc. Sigh.
I guess MATLAB is the horror. Not sure why you'd allow reassignment of a fairly crucial constant which also happens to be a super-commonly used throwaway variable.

KaneTW
Dec 2, 2011

Maple and Matlab both are huge horrors. Probably the only good math software I saw is Mathematica, and even that has some quirks.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
Maple uses I for the imaginary unit, rather than i. It can be jarring when you forget you have to capitalise it, but I guess it does mean you can use i as a dummy variable or loop variable without issue.

My licence on this computer has expired or I'd check, but I think Maple would complain if you tried to reassign I.

That said, Maple is very clunky in a lot of different ways and I have posted about it in this thread in the past.

KaneTW
Dec 2, 2011

Yeah, Maple was so awful that I bought a Mathematica license despite it being like 6 times the cost of Maple (I think 40 or 50 euro). Definitely worth it, though.

Thern
Aug 12, 2006

Say Hello To My Little Friend
I thought Matlab was always a big thing. I've only used it a bit myself, but I never heard anything bad about it compared to Maple.

Leave it up to the Something Awful forums to make me hate everything I thought was good.

fritz
Jul 26, 2003

Matlab's got problems (http://abandonmatlab.wordpress.com/) but it's got itself wedged so solidly into its particular niche that it's not going to get displaced for a long long time.

YanniRotten
Apr 3, 2010

We're so pretty,
oh so pretty
Sort of off topic, but using a for loop in MATLAB is often not what you want to do.
Unless there's some obscured complexity here, d = compute_diffraction_at_wavelength(LensLayers, WAVELENGTH) would do the same thing, but faster.

Nickopops
Jan 8, 2006
You must be this funky to ride.
.

Nickopops fucked around with this message at 09:38 on Nov 1, 2019

hepatizon
Oct 27, 2010

Nickopops posted:

not a great MATLAB coder

Nice tautology you got there.

hobbesmaster
Jan 28, 2008

No Safe Word posted:

This probably belongs here but not because the code is bad, really: http://swanson.github.com/blog/2013/01/20/worst-bug-ever.html

I guess MATLAB is the horror. Not sure why you'd allow reassignment of a fairly crucial constant which also happens to be a super-commonly used throwaway variable.

IIRC j is also set to sqrt(-1) by default. Probably why I've never run into that one as an EE.

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"
I don't have the code for this, but it's definitely a horror. I was working in Sublime Text 2 today and went to rename a file by right-clicking it in the sidebar. When I typed the new name, I accidentally typed the name of a file that was already in that directory. (They're just a bunch of files in numbered sequence and I fat-fingered it.)

Sublime happily did the rename, destroying the file with the same name instead of telling me that it already existed.

Thank god I have a backup.

:suicide:

ToxicFrog
Apr 26, 2008


No Safe Word posted:

This probably belongs here but not because the code is bad, really: http://swanson.github.com/blog/2013/01/20/worst-bug-ever.html

I guess MATLAB is the horror. Not sure why you'd allow reassignment of a fairly crucial constant which also happens to be a super-commonly used throwaway variable.

The implication here is that in matlab, for loop variables have global scope rather than being loop local. :gonk:

Thern posted:

I thought Matlab was always a big thing. I've only used it a bit myself, but I never heard anything bad about it compared to Maple.

Leave it up to the Something Awful forums to make me hate everything I thought was good.

Matlab is hugely popular. It's just not very good, and most of the people I know who have to use it regularly hate it. (It's better than Maple, but that really isn't saying much.)

quiggy
Aug 7, 2010

[in Russian] Oof.


Not strictly a coding horror, but on my walk from my car to my lab today in the freezing cold I round the last corner leading up to the entrance and what's waiting or me? A giant truck that's part of a LabView campus tour :gonk:

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

quiggy posted:

Not strictly a coding horror, but on my walk from my car to my lab today in the freezing cold I round the last corner leading up to the entrance and what's waiting or me? A giant truck that's part of a LabView campus tour :gonk:
I was going to start bitching about LabView in proxy. I never used it, but I work with an army of electrical engineers, so it had come up before. I think the $$$ was a big issue. But then I read somewhere in CoC--probably here--about all the problems with the drat thing. IIRC one big thing was that if you reset the whole flow, it didn't reset all the variables. That and due to it trying to run everything in parallel, it could put your system into a crawl.

But this reminded me that maybe there has been an open-source alternative since I last checked. I am still looking, so I ran into this discussion thread, which I think is a horror in its own right:

quote:

I chimed in as well. The problem is that LV does make it "too easy" to do REAL programming and not have a CS background. That generates jealousy and anger esp from those who've invested years in learning the arcana of overloading functions from some obscure lib somewhere. The buggy whip manufacturers got really upset by automobiles...

I'll take suggestions for EE data collection tools and experiment automation if anybody has them.

quiggy
Aug 7, 2010

[in Russian] Oof.


Rocko Bonaparte posted:

I was going to start bitching about LabView in proxy. I never used it, but I work with an army of electrical engineers, so it had come up before. I think the $$$ was a big issue. But then I read somewhere in CoC--probably here--about all the problems with the drat thing. IIRC one big thing was that if you reset the whole flow, it didn't reset all the variables. That and due to it trying to run everything in parallel, it could put your system into a crawl.

But this reminded me that maybe there has been an open-source alternative since I last checked. I am still looking, so I ran into this discussion thread, which I think is a horror in its own right:


I'll take suggestions for EE data collection tools and experiment automation if anybody has them.

I had the assignment of porting some old LabView programs over to C# last year. They were pretty simple stuff, primarily controllers for different devices. I cannot tell you how frustrating it was that there is literally no way to have LabView release a port that a device is on if the program itself doesn't have that ability. Even nuking LabView from the processes menu doesn't free up the ports it was using :psyduck:

PrBacterio
Jul 19, 2000

ToxicFrog posted:

The implication here is that in matlab, for loop variables have global scope rather than being loop local. :gonk:
Or that it uses dynamic scoping as opposed to lexical :twisted: But more likely, it's probably what you said.

EDIT: While I'm on the topic of scoping rules:

Plorkyeran posted:

Implicit this is not quite as weird in statically typed languages (and unsurprisingly enough every language I've used with it has been statically typed), but I am gradually coming around to the viewpoint that it's not a net gain.
I'd say a better criterion would be languages where method definitions are lexically contained in the class definition. Statically vs. dynamically typed shouldn't really matter for this issue, but when you've got the method definition lexically separated and potentially in an entirely different source file from where the class, together with its member variables, is declared is where you start running into trouble. On the other hand, as long as the method definition is contained entirely within the class definition clause and occurs after whichever member variable you're referring to, e.g. something that looks like: class SoAndSo { int aMember; void SomeMethod () { ++aMember; return aMember } } is perfectly fine, imho, because its readily apparent from the nested structure of the code where each variable is in scope and which variable or method a name refers to.

PrBacterio fucked around with this message at 19:11 on Jan 22, 2013

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde
Crossposted from YOSPOS: The ancient bug that woke up me and other devs in the middle of the night for weeks because none of us knew what valgrind was.

C++ code:
shared_ptr<FILE> fp = fdopen(sock, "r");
The real horror is that the code wasn't doing anything that it couldn't do with file descriptors anyway.

Gazpacho fucked around with this message at 03:29 on Jan 23, 2013

SwimNurd
Oct 28, 2007

mememememe


My only experience with LabView is as a FIRST Robotics Mentor, gently caress LabView. I am very glad we got the team off of it.

Nickopops
Jan 8, 2006
You must be this funky to ride.
.

Nickopops fucked around with this message at 09:38 on Nov 1, 2019

astr0man
Feb 21, 2007

hollyeo deuroga
C++ code:
#define SOCKET_ERROR = -1

/* Note that this demonstration code does not have very robust error handling */
if (send(...) == SOCKET_ERROR)
  return success;
Well thanks for including that comment I guess?

hobbesmaster
Jan 28, 2008

Rocko Bonaparte posted:

I was going to start bitching about LabView in proxy. I never used it, but I work with an army of electrical engineers, so it had come up before. I think the $$$ was a big issue. But then I read somewhere in CoC--probably here--about all the problems with the drat thing. IIRC one big thing was that if you reset the whole flow, it didn't reset all the variables. That and due to it trying to run everything in parallel, it could put your system into a crawl.

But this reminded me that maybe there has been an open-source alternative since I last checked. I am still looking, so I ran into this discussion thread, which I think is a horror in its own right:


I'll take suggestions for EE data collection tools and experiment automation if anybody has them.

You can write reasonable software in Labview and connecting some instruments together with some filters and spitting out a csv or whatever is a good use of it.

Just take the time to learn the language and best practices and for the love of god don't go beyond data collection and initial processing with it.

Too bad about the entire not hiring people that understand software to write software so all Labview code is a complete disaster thing.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
So why is Matlab so big? Does everyone just use it because everyone uses it?

quiggy
Aug 7, 2010

[in Russian] Oof.


Wheany posted:

So why is Matlab so big? Does everyone just use it because everyone uses it?

Matlab is very good for computational purposes. You don't need to worry about data types or float precision or whatever, just let it do its thing. Also it has a lot of really useful and obscure built-in functions that you can do pretty much whatever with. If you're working in a science or engineering field and say "Oh, I need a program to do <thing> and have some amount of programming ability myself", 9 times out of 10 Matlab is probably your best bet.

Adbot
ADBOT LOVES YOU

ivantod
Mar 27, 2010

Mahalo, fuckers.
Nice bit of (literal) crap that I came across today in the app that I need to take over after a colleague's departure. Simplified example to show just the relevant parts (this is C#/.net, but it should be obvious even if you haven't used it):

code:
try {
  for (int i=0; i<dataTable.Rows.Count; i++) {
     // .....
     for (int j=0; j<20; j++) {
        try {
	   s+=" "+dataTable.Rows[i][j]
        } catch {
        }
        // .....
     }
     // .....
   }
   // .....
} catch {
   return "poo poo!!!";
}
Two things here:

1. In case it's not obvious, the inner try/catch is there only to catch an array index out of range exception (because this is some kind of generic querying code and data table may not always have the same number of columns). Oh, if only there were a property you could read to find out the number of columns beforehand and use that in the for loop... (there is, of course)

2. In the outer catch: it's cool no need to log the exception, that's pretty standard in this app. What's far more egregious is that this "poo poo!!!" text actually propagates all the way back to the GUI and is in fact displayed to the user when there is an exception in this code. This actually happened, that's how I found this code.

I realise that is (almost) nothing compared to some of the stuff seen here, but it really annoyed me today.

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