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
TasteMyHouse
Dec 21, 2006
I'm an ECE major, and I was talking to one of the few programming-oriented fellow ECE guys I know. His focus is embedded systems and bare-metal C, however. He's always talking about how he hates operating systems. He told me the coding philosophy of the place he worked at for his last co-op:
1. All functions take void and return void.
2. All variables are global.

He said this made things easier to verify. I wasn't able to express how horrifying that was to hear.

Adbot
ADBOT LOVES YOU

nielsm
Jun 1, 2009



Well, since it prevents you from writing any kind of re-entrant code, it also effectively prevents you from writing any kind of recursive code. It should be reasonably easy to reason about functions never entering a kind of call loop. When you know that never happens, you can then determine the maximum stack size that can possibly occur, and design memory layout for that. Since everything else is global you should then be able to do some kind of reasoning about total memory consumption.

Opinion Haver
Apr 9, 2007

nielsm posted:

Well, since it prevents you from writing any kind of re-entrant code, it also effectively prevents you from writing any kind of recursive code. It should be reasonably easy to reason about functions never entering a kind of call loop. When you know that never happens, you can then determine the maximum stack size that can possibly occur, and design memory layout for that. Since everything else is global you should then be able to do some kind of reasoning about total memory consumption.

How does it do that? You can easily write a recursive function if you use a global variable as an accumulator and one to keep track of whatever your exit condition is.

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"
from a while back, but:

Incoherence posted:

I don't think that was quite what that post meant, but the obvious example of an empty catch statement is unit testing a method that's supposed to throw an exception.
code:
try {
  doSomething(...);
  fail("Did not throw BogusInputException");
} catch (BogusInputException e) {
  // this is supposed to happen
}
It's when you swallow EVERY exception for the whole program that you start having problems.
This is a coding horror, because you're not verifying the contents of the exception. How do you know the correct BogusInputException was thrown, and that it was constructed with the correct values?

zeekner
Jul 14, 2007

Janin posted:

from a while back, but:

This is a coding horror, because you're not verifying the contents of the exception. How do you know the correct BogusInputException was thrown, and that it was constructed with the correct values?

An exception type can be really specific or really general. Yea, you need to check the exception contents for an SQLException, but what can you really do with a NullPointerException? Even then, his code could easily have checked for the mis-constructed state inside the catch block and thrown a fail() there as well.

GROVER CURES HOUSE
Aug 26, 2007

Go on...

Geekner posted:

An exception type can be really specific or really general. Yea, you need to check the exception contents for an SQLException, but what can you really do with a NullPointerException? Even then, his code could easily have checked for the mis-constructed state inside the catch block and thrown a fail() there as well.

I'll cut the first rent-a-coder to specifically swallow NPEs. :ese:

Incoherence
May 22, 2004

POYO AND TEAR

Janin posted:

from a while back, but:

This is a coding horror, because you're not verifying the contents of the exception. How do you know the correct BogusInputException was thrown, and that it was constructed with the correct values?
This seems like a great way to make brittle and overly coupled tests, personally. It's one thing if you're catching Exception and not looking at it, but if I'm testing something with a contract that it will throw a specific exception type when the input is bogus, all the unit test should care about is that when the input is bogus it does in fact throw that exception, not that the exception message says exactly "foo must be odd in doSomething; was 42".

underage at the vape shop
May 11, 2011

by Cyrano4747
It's not actual code but rather a language and the fact I have to use it to pass this class

For my programming class we have to spend most of a year doing gml (Game Maker Language) because 90% of the dickwits in my class have never done any programming before and get bored with other languages such as delphi "coz you can't make games with them"

shrughes
Oct 11, 2008

(call/cc call/cc)
Babby didn't like milliseconds so he created a library that parses strings instead.

https://github.com/avk/jQuery-Chrono

code:
    $.after(100, function() { ... });           // 100 milliseconds
    $.after("9.7", function() { ... });         // 9.7 milliseconds
    $.after("50sec", function() { ... });       // 50 seconds
    $.after(7, "mins", function() { ... });     // 7 minutes
    $.after("33", "hours", function() { ... }); // 33 hours

shrughes fucked around with this message at 07:27 on May 15, 2011

PalmTreeFun
Apr 25, 2010

*toot*
Wait, who actually uses Delphi? Wouldn't you want to use Java or C# or something at least?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

shrughes posted:

Babby didn't like milliseconds so he created a library that parses strings instead.

Alright, I'll be that guy. What makes this a horror? OK, it's not implemented how I would have implemented it, adding 1.7KB of someone else's code to your page doesn't seem worth it for what little is gained, and the parsing of strings isn't even done very well:
code:
$.after("10 minutes", function(){ console.log('hi');}); // throws an exception
But keep in mind that, for a lot of people, "jQuery" and "JavaScript" are synonymous, and are also synonymous with "this lovely code I have to write so this stupid website works the way I want it to and I hate coding I'm a designer oh god kill me".

I guess I'm saying I have zero desire to use this guy's code but what's horror-worthy about it?

Also setTimeout's arguments are backwards, so at least this guy got that right.

Axel Rhodes Scholar
May 12, 2001

Courage Reactor

Mostly it's just poorly implemented, I mean your example where having a space in the string causes it to throw an exception is _exactly_ the kind of crap that's going to gently caress with "I'm a designer oh god kill me" crowd.

Not to mention the whole point of the thing is that milliseconds are un-natural to set timeouts with, but this 1.7kB of external code isn't enough to let you say "1 minute 45 seconds", though you can use "1.75minutes".

Additionally - the problem of turning some string into milliseconds should be separated from the timeout setting and made available to the rest of the environment. jQuery animation durations are specified in milliseconds, for example, if I'm having trouble with setTimeout then surely I'm having trouble with those too.

Finally, he clearly hasn't thought about internationalisation :colbert: $.après("2heures", function(){...});

Dicky B
Mar 23, 2004

Why you would choose string parsing over something like
code:
$.after(seconds(50), function() { ... }); // 50 seconds
$.after(minutes(7), function() { ... });  // 7 minutes
$.after(hours(33), function() { ... });   // 33 hours
is mind boggling.

Doc Hawkins
Jun 15, 2010

Dashing? But I'm not even moving!


e: ^^^ Bored programmer looking for busy work, I suspect. Your solution is too simple to practice TDD with.

dazjw posted:

Finally, he clearly hasn't thought about internationalisation :colbert: $.après("2heures", function(){...});

No need, English is the one true programming language.

Doc Hawkins fucked around with this message at 18:36 on May 15, 2011

GROVER CURES HOUSE
Aug 26, 2007

Go on...

shrughes posted:

Babby didn't like milliseconds so he created a library that parses strings instead.

https://github.com/avk/jQuery-Chrono

code:
    $.after(100, function() { ... });           // 100 milliseconds
    $.after("9.7", function() { ... });         // 9.7 milliseconds
    $.after("50sec", function() { ... });       // 50 seconds
    $.after(7, "mins", function() { ... });     // 7 minutes
    $.after("33", "hours", function() { ... }); // 33 hours

Using milliseconds to specify anything larger than a few minutes is the real coding horror.

Let me tell you about the time someone did this exact thing, but with days and weeks,

ToxicFrog
Apr 26, 2008


GreatKesh posted:

It's not actual code but rather a language and the fact I have to use it to pass this class

For my programming class we have to spend most of a year doing gml (Game Maker Language) because 90% of the dickwits in my class have never done any programming before and get bored with other languages such as delphi "coz you can't make games with them"

Someone should educate them.

(Comedy option: start them on Inform 7 so that they can complain it's not real programming because it doesn't use {} to delimit code blocks.)

(Cruelty option: start them on C++ with OpenGL so that they no longer want to make games, learn how to program, or live.)

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
ToxicFrog: I was very disappointed that none of those links involved Delphi. Apparently you can write games with it: http://delphigamedev.com/ :v:

bobthecheese
Jun 7, 2006
Although I've never met Martha Stewart, I'll probably never birth her child.

Doc Hawkins posted:

No need, English is the one true programming language.

American English, that is :(

gently caress you CSS, the word is "colour"!

qntm
Jun 17, 2009

bobthecheese posted:

American English, that is :(

gently caress you CSS, the word is "colour"!

And it's text-align "centre" too while we're at it

I think we're stuck with the "Referer" HTTP header, though.

No Safe Word
Feb 26, 2005

qntm posted:

And it's text-align "centre" too while we're at it

I think we're stuck with the "Referer" HTTP header, though.

Which isn't because American English spells it that way, it's just because the RFC had it that way

ToxicFrog
Apr 26, 2008


Internet Janitor posted:

ToxicFrog: I was very disappointed that none of those links involved Delphi. Apparently you can write games with it: http://delphigamedev.com/ :v:

I figured you probably could, but I don't know Delphi or any of its libraries, so I stuck to what I know.

Melted_Igloo
Nov 26, 2007

TasteMyHouse posted:

His focus is embedded systems and bare-metal C

Embedded system code is the most horrible code you will see
Sometimes variables are named after the registers in memory

It is poorly documented, the only thing you have to work with is only the technical manual of the system that some hardware guy wrote 3 years before the software was made

The code is litterred with #DEFINE and #IFDEF, so it works on different platforms
(literally an embedded system might have 3 kinds of chipsets it needs to work with)

Compilers might be terribly written for the chip, they take 5 hours to compile, even running a simple test takes 10 minutes just to start..

I could go on but you get the idea

Melted_Igloo fucked around with this message at 12:29 on May 16, 2011

Dr Monkeysee
Oct 11, 2002

just a fox like a hundred thousand others
Nap Ghost

No Safe Word posted:

Which isn't because American English spells it that way, it's just because the RFC had it that way

It's poetic that a typo is literally built into the HTTP standard. I'm sure that says something profound about the Internet, though I'm not sure what.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Monkeyseesaw posted:

It's poetic that a typo is literally built into the HTTP standard. I'm sure that says something profound about the Internet, though I'm not sure what.

It says something profound about software in general. APIs, once written, are forever. No, really forever. No, you won't get everyone to update their code. You better be happy with that spec now, because you're going to be living with it for the rest of your life.

wwb
Aug 17, 2004

Melted_Igloo posted:

Embedded system code is the most horrible code you will see
Sometimes variables are named after the registers in memory

It is poorly documented, the only thing you have to work with is only the technical manual of the system that some hardware guy wrote 3 years before the software was made

The code is litterred with #DEFINE and #IFDEF, so it works on different platforms
(literally an embedded system might have 3 kinds of chipsets it needs to work with)

Compilers might be terribly written for the chip, they take 5 hours to compile, even running a simple test takes 10 minutes just to start..

I could go on but you get the idea

That's it, I'll never hate on the "old" .NET 2.0 apps I see occasionally.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

Ryouga Inverse posted:

It says something profound about software in general. APIs, once written, are forever. No, really forever. No, you won't get everyone to update their code. You better be happy with that spec now, because you're going to be living with it for the rest of your life.

@deprecated since Java 1.1

e: Actually, this is one of the things that I liked about Qt when I first used it. Trolltech wasn't afraid to break backward compatibility. At least between Qt 3 and 4. I noticed it when I googled their API documentation and as hard as I tried, the IDE wouldn't autocomplete the methods that the objects supposedly had. Then I noticed I was browsing the the documentation for 3 when I was using 4. Well that's my story.

Wheany fucked around with this message at 21:21 on May 16, 2011

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Wheany posted:

@deprecated since Java 1.1

e: Actually, this is one of the things that I liked about Qt when I first used it. Trolltech wasn't afraid to break backward compatibility. At least between Qt 3 and 4. I noticed it when I googled their API documentation and as hard as I tried, the IDE wouldn't autocomplete the methods that the objects supposedly had. Then I noticed I was browsing the the documentation for 3 when I was using 4. Well that's my story.

This sounds great until you realize that it means you have to install Qt 3 and 4 side by side on any machine that you want to run Qt apps for an arbitrary amount of time, because there's always that one rear end in a top hat who wrote his poo poo for Qt 3 and then had the audacity to die or something.

I mean, there are arguments to be made for both, but you certainly can't change your API every time you have a whim, and in some cases (like the Internet) you can't ever break backward compatibility. And the problem is that those cases look exactly like the best-case success story that you only dream of.

Dessert Rose fucked around with this message at 22:28 on May 16, 2011

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

Ryouga Inverse posted:

This sounds great until you realize that it means you have to install Qt 3 and 4 side by side on any machine that you want to run Qt apps for an arbitrary amount of time, because there's always that one rear end in a top hat who wrote his poo poo for Qt 3 and then had the audacity to die or something.

Better to have multiple versioned, depreciable, isolated APIs side-by-side than some organically grown poo poo that can never die.

decarboxylated
May 4, 2006
cells!
code:
#DEFINE ZERO 0
#DEFINE ONE 1
#DEFINE TWO 2
#DEFINE THREE 3
#DEFINE FOUR 4
Scientific modeling code that's been under development by a multitude of developers for a decade. Reading it is like looking at the ark of the covenant.

zeekner
Jul 14, 2007

decarboxylated posted:

code:
#DEFINE ZERO 0
#DEFINE ONE 1
#DEFINE TWO 2
#DEFINE THREE 3
#DEFINE FOUR 4
Scientific modeling code that's been under development by a multitude of developers for a decade. Reading it is like looking at the ark of the covenant.

It's handy to have that, remember back in '79 when "Two" was legally 3 for a week? Just plannin' ahead. :smug:

Also, off-by-one errors can be fixed en-mass.

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!

wwb posted:

That's it, I'll never hate on the "old" .NET 2.0 apps I see occasionally.

Our enterprise .NET app is still 1.1

aViR
Aug 6, 2004

Melted_Igloo posted:

Embedded system code is the most horrible code you will see
Sometimes variables are named after the registers in memory

It is poorly documented, the only thing you have to work with is only the technical manual of the system that some hardware guy wrote 3 years before the software was made

The code is litterred with #DEFINE and #IFDEF, so it works on different platforms
(literally an embedded system might have 3 kinds of chipsets it needs to work with)

Compilers might be terribly written for the chip, they take 5 hours to compile, even running a simple test takes 10 minutes just to start..

I could go on but you get the idea
This.

The tools for embedded processors are amazingly bad. If you want to program for a processor from Texas Instruments, and use a debugger, they will sell you their full-featured IDE, "Code Composer Studio" for $1000-3000 depending on licensing details. It comes with a program called "Code Composer Studio Monitor" which runs in the system tray, and when Code Composer locks up, the monitor icon turns gray, and gives you a menu option to kill all Code Composer processes. They decided it was better to make it easy to kill Code Composer when it crashes, than to fix their lovely IDE. Oh, and even when it works and you exit cleanly, it leaves a process running that prevents Windows from shutting down until you go shoot it manually from the task manager.

When you use it to transfer a file to a processor via the J-Tag debug interface, the progress dialog has buttons for "stop", "pause", "rewind", and "fast-forward". I have yet to figure out what the last two do.

The new release uses Eclipse as a front-end, but still only runs on Windows because it uses the same code for the debugger and such, but they now draw their UIs inside Eclipse panels.

Some of the people using these tools are not too hot either. One engineer who works for a customer has been an embedded software engineer working primarily in C for over a decade. He declares strings like this...
code:
char *c = "Hello World!\0";
...because he "knows that C strings need to be null terminated."

And he was writing flight software for a U.S. government satellite.

edit: Was missing a semicolon.

aViR fucked around with this message at 07:10 on May 17, 2011

Thermopyle
Jul 1, 2003

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

I can't stop lauging about the Code Composer Studio Monitor. That's fantastic engineering!

underage at the vape shop
May 11, 2011

by Cyrano4747

PalmTreeFun posted:

Wait, who actually uses Delphi? Wouldn't you want to use Java or C# or something at least?

I'm the only one in 26 including the teacher who agrees but anything is better than gml

e: Delphi is the only alternative to game maker that's installed.
Year 11 and I'm learning fancy drag and drop.

underage at the vape shop fucked around with this message at 07:31 on May 17, 2011

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
this.opera5=this.agent.indexOf("Opera 5")>-1

Opera 5 was released December 6, 2000.
Opera 6 was released November 29, 2001.

Way to test for a 10-year-old version of a marginal browser. :waycool:

Jonnty
Aug 2, 2007

The enemy has become a flaming star!

Wheany posted:

this.opera5=this.agent.indexOf("Opera 5")>-1

Opera 5 was released December 6, 2000.
Opera 6 was released November 29, 2001.

Way to test for a 10-year-old version of a marginal browser. :waycool:

So...the horror is that your app is too portable?

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

Jonnty posted:

So...the horror is that your app is too portable?
Yes, our app is too portable for checking for Opera 5, and not, say, any opera released after the year 2000 :ramsay:

And browser sniffing is bad as-is.

dis astranagant
Dec 14, 2006

GreatKesh posted:

I'm the only one in 26 including the teacher who agrees but anything is better than gml

e: Delphi is the only alternative to game maker that's installed.
Year 11 and I'm learning fancy drag and drop.

No one sane actually uses the drag and drop interface for GML other than occasionally showing it to the art guys. It mostly exists so get the noncoders to buy a license before they discover that they actually have to code or get someone to code for them. For one thing, the visual interface exposes but a tiny fraction of the features of the language so anything non-trivial will involve large segments of fairly generic C-like code. Maybe you should learn a few things about your tools before you throw fits about them. I'm not saying it's the greatest thing ever or anything, but it's alright for what it does and has a lot more to it then you're letting yourself know. At least they aren't making you use ALICE.

Jonnty
Aug 2, 2007

The enemy has become a flaming star!

Wheany posted:

Yes, our app is too portable for checking for Opera 5, and not, say, any opera released after the year 2000 :ramsay:

And browser sniffing is bad as-is.

At the very worst, it's just old code that hasn't been taken out (I assume), but it doesn't sound like it's causing any active harm? I'd hardly call that a horror, just a bit overcautious. Unless it's checking for something that needn't be checked the first place.

Adbot
ADBOT LOVES YOU

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

Wheany posted:

And browser sniffing is bad as-is.

And why did I even stumble across that gem. Because I tested our app with IE 9 and it throws an exception "THIS BROWSER IS NOT SUPPORTED". :catstare:

I guess I'm adding the line
code:
this.ie9=(this.ver.indexOf("MSIE 9")>-1 && this.dom && !this.opera5)?1:0;
into the shitheap.




NOT! :c00l:

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