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
evensevenone
May 12, 2001
Glass is a solid.

PDP-1 posted:

4) LabView's motor controllers can operate in two regimes of stability: (1) If you want a motor to turn clockwise, power up the coils that turn it clockwise. This is the sane mode. (2) Power up both the coils that turn the motor clockwise and counter-clockwise to 100% so the opposing torques hold the shaft in place. If you want to turn clockwise, power down the counter-clockwise coils to 90% so the clockwise coils begin to win. This is the "Hey do you smell that hot electronics smell? *touches motor and burns off outer skin layer*" mode.

They actually do that intentionally for some applications, kind of forgot what though. You get better position control at low speeds. So probably CNC machines or something. That wouldn't be a Labview thing though, that would depend on the motor controller hardware.

that said, labview is loving horrible in so many goddamn ways.

Adbot
ADBOT LOVES YOU

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"
I'm digging through the code to a simple game, in the hopes of cleaning it up and using it as an example of writing games in Haskell. Some of the code is incredible.
code:
drawWinFail :: Cat -> IO ()
drawWinFail cat = do
    sequence_ $ if catItemName cat == "Hurt"
                   then [drawRect (Rect 380.0 390.0 100.0 30.0) (Color4 0.95 0.95 0.95 1.0),
                         drawString 395.0 400.0 "Nooooooo :'(" (Color4 0.20 0.20 0.60 1.0)]
                   else [return ()] 
    sequence_ $ if catItemName cat == "Win"
                   then [drawRect (Rect 380.0 390.0 120.0 30.0) (Color4 0.95 0.95 0.95 1.0),
                         drawString 395.0 400.0 "Stage Complete!" (Color4 0.20 0.20 0.60 1.0)]
                   else [return ()] 
For reference, a normal person would have written that like:
code:
drawWinFail :: Cat -> IO ()
drawWinFail cat = do
    let drawMessage msg = do
            drawRect (Rect 380.0 390.0 100.0 30.0) (Color4 0.95 0.95 0.95 1.0)
            drawString 395.0 400.0 msg (Color4 0.20 0.20 0.60 1.0)

    when (catItemName cat == "Hurt") (drawMessage "Nooooooo :'(")
    when (catItemName cat == "Win") (drawMessage "Stage Complete!")

The Gripper
Sep 14, 2004
i am winner

HappyHippo posted:

The idea of controlling industrial machinery on anything but a PLC sounds insane.

PLC programming is a horror of it's own, but not in a "this is dangerous" sort of way.
What sucks most about it is the way LabView tends to draw new users in because generally the payrate for LabView programmers is higher than PLC programmers.

People on the fence about it assume that it's because LabView is the newer, better product and worth more to businesses, when in reality the only reason for the divide is that there isn't a skilled pool of LabView programmers with decades of experience like there is with PLC. Unfortunately the replaceability factor favors LabView users to the extreme; if you have a production line that incorporates LabView, you are honest-to-god hosed if your programmer leaves and you don't already have a new one lined up. If you have a production line using PLC and your programmer leaves, there is a market consisting of users with decades of experience out there that can fill the position.

I know people that have picked LabView to learn and focus on because "It's better money and PLC is old, all the PLC programmers are like 50". They're probably right, and it's a good decision as far as working to make the most money you can goes, but that doesn't make LabView good in the slightest.

Also apparently a lot of LabView programmers have experience that is purely academic - a place I contracted for needed a LabView programmer and the only people available were 1st year apprentices, no experience outside the classroom. Would love to have been a fly on the wall at a company forced to replace a long-term employee with one of these guys.

Opinion Haver
Apr 9, 2007

Janin posted:

I'm digging through the code to a simple game, in the hopes of cleaning it up and using it as an example of writing games in Haskell. Some of the code is incredible.
code:
drawWinFail :: Cat -> IO ()
drawWinFail cat = do
    sequence_ $ if catItemName cat == "Hurt"
                   then [drawRect (Rect 380.0 390.0 100.0 30.0) (Color4 0.95 0.95 0.95 1.0),
                         drawString 395.0 400.0 "Nooooooo :'(" (Color4 0.20 0.20 0.60 1.0)]
                   else [return ()] 
    sequence_ $ if catItemName cat == "Win"
                   then [drawRect (Rect 380.0 390.0 120.0 30.0) (Color4 0.95 0.95 0.95 1.0),
                         drawString 395.0 400.0 "Stage Complete!" (Color4 0.20 0.20 0.60 1.0)]
                   else [return ()] 
For reference, a normal person would have written that like:
code:
drawWinFail :: Cat -> IO ()
drawWinFail cat = do
    let drawMessage msg = do
            drawRect (Rect 380.0 390.0 100.0 30.0) (Color4 0.95 0.95 0.95 1.0)
            drawString 395.0 400.0 msg (Color4 0.20 0.20 0.60 1.0)

    when (catItemName cat == "Hurt") (drawMessage "Nooooooo :'(")
    when (catItemName cat == "Win") (drawMessage "Stage Complete!")

At least they didn't write something like
code:
drawWinFail = ap ((>>) . flip when (drawMessage "Nooooooo :'(") . ("Hurt" ==) . catItemName) (flip when (drawMessage "Stage Complete!") . ("Win" ==) . catItemName)

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"
My favorite discovery so far is the "get-put pattern"
code:
-- update cat item effects
preEffect = execState (do 
        e <- get 
        put (if catBouncePogostick
                then pogostickEffect2
                else e)
                       
        e <- get 
        put (if catFallUmbrella
                then fallUmbrellaEffect
                else e)
                       
        e <- get 
        put (if catUpsUmbrella
                then upsUmbrellaEffect2
                else e)
                       
        e <- get 
        put (if catIsWet
                then hurtEffect
                else e)
            
        e <- get 
        put (if catWin
                then winEffect
                else e)
            
        return ()) noEffect
:eng99:

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.

The Gripper posted:

What sucks most about it is the way LabView tends to draw new users in because generally the payrate for LabView programmers is higher than PLC programmers.

People on the fence about it assume that it's because LabView is the newer, better product and worth more to businesses, when in reality the only reason for the divide is that there isn't a skilled pool of LabView programmers with decades of experience like there is with PLC. Unfortunately the replaceability factor favors LabView users to the extreme; if you have a production line that incorporates LabView, you are honest-to-god hosed if your programmer leaves and you don't already have a new one lined up. If you have a production line using PLC and your programmer leaves, there is a market consisting of users with decades of experience out there that can fill the position.

Strange, my experience had led me to the opposite view.

To me, LabView is a low-skill language that lets non-programmers plug things into a computer and make them work without having to know much about formal coding practice. Just connect a voltmeter to your PC with a GPIB cable, wait for VISA to detect it, and you're off. Draw a for-loop block, wire the output of the voltmeter to a graph node and you got a datalogger baby! No drivers, no win32, just plug-n-go. Also, LabView came out in 1986 and there's tons of people who know how to use it. I'm an electrical engineer and I'd guess 10-20% of my colleagues have at least some level of skill with it. I personally have been using it since the late 90's and only switched over to (mostly) C# in the last 2-3 years.

The PLC crowd on the other hand are usually lifers in the hardware control field and the ones I've met straddle the line between hardware and low-level software engineering. They build million dollar systems that will run for 20 years in conditions just shy of a meteor strike and go apoplectic when someone plugs their poo poo into a UPS from Best Buy instead of a true UPS. It's much more of a hardcore engineering field and I'd expect that they got paid better than some random LabView hack.

I'm not saying you're wrong, maybe it's just that our fields of work are very different, but to me if PLC work is LEGO Mindstorms then LabView is Duplo blocks.

The Gripper
Sep 14, 2004
i am winner

PDP-1 posted:

I'm not saying you're wrong, maybe it's just that our fields of work are very different, but to me if PLC work is LEGO Mindstorms then LabView is Duplo blocks.
The fields I've come across it in are mostly not-too-technical manufacturing, sheet steel and tube-cutting the two main ones. It's probably a different landscape in Australia than the US as well.

I agree with LabView being the less technical of the two though, PLC takes a lot of experience to really get the ball rolling whereas LabView is designed outright to cut a lot of that out.

In the companies I worked with PLC programmers weren't treated as extremely-skilled-professionals as much as they were blue collar laborers that know how to deal with PLC. This probably has a lot to do with the kind of people looking for PLC work in this area, generally as you said lifers in the hardware control field however they're looking to get back into the workplace rather than move to a better position, after their old workplace closed down or were made redundant. Not a whole lot of people with PLC skill were leaving jobs voluntarily to take new positions elsewhere.

LabView users tended to be younger - less blue collar and more white collar - and were shopping around for the best possible position they could find, so that entire side of the market tended to treat them as if their skills were worth more than PLC skills.

Opinion Haver
Apr 9, 2007

Janin posted:

My favorite discovery so far is the "get-put pattern"
code:
-- update cat item effects
preEffect = execState (do 
        e <- get 
        put (if catBouncePogostick
                then pogostickEffect2
                else e)
                       
        e <- get 
        put (if catFallUmbrella
                then fallUmbrellaEffect
                else e)
                       
        e <- get 
        put (if catUpsUmbrella
                then upsUmbrellaEffect2
                else e)
                       
        e <- get 
        put (if catIsWet
                then hurtEffect
                else e)
            
        e <- get 
        put (if catWin
                then winEffect
                else e)
            
        return ()) noEffect
:eng99:

How do you write basically the same four lines of code out five times and not think 'hey maybe I should abstract this into a function'?

Also this is probably just style but seeing do-blocks inside parentheses always weirds me out for some reason.

wwb
Aug 17, 2004

GrumpyDoctor posted:

I took an electronic arts class in college in which in which I did my final project in Max/MSP and I blew my instructor's mind by actually skeleton-ing out the program before diving in and stringing connections around willy-nilly the way musicians using Max always do.

The funny part is our audio engineer types love this sort of drag and drop things approach. They get scared by seeing actual code.

FamDav
Mar 29, 2008

ymgve posted:

Braces are good, even for single statements.

Isn't the correct answer to put it all on the same line?

baquerd
Jul 2, 2007

by FactsAreUseless

FamDav posted:

Isn't the correct answer to put it all on the same line?

Any of these are fine:

code:
if (thing) doStuff();

if (thing) {
  doStuff();
}

if (thing) 
{
  doStuff();
}

if (thing) { doStuff(); }
This is terrible:
code:
if (thing)
  doStuff();

Sneaking Mission
Nov 11, 2008

What you don't realise is if you use the right language you don't have to put braces around any if statements.

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

baquerd posted:

Any of these are fine:

code:
if (thing) doStuff();

if (thing) {
  doStuff();
}

if (thing) 
{
  doStuff();
}

if (thing) { doStuff(); }
This is terrible:
code:
if (thing)
  doStuff();

I like the terrible one. It has visual indication it's affected by the line above it and isn't polluted by braces. It's clean and compact and I have literally never been burnt by the obvious argument against it.

Now this, on the other hand, is terrible:
code:
if (thing)

doStuff();

evensevenone
May 12, 2001
Glass is a solid.

The Gripper posted:

LabView users tended to be younger - less blue collar and more white collar - and were shopping around for the best possible position they could find, so that entire side of the market tended to treat them as if their skills were worth more than PLC skills.

I think it's more of a management thing where they think they can just buy a computer and get a kid to drag blocks around on a screen, as opposed to some old dude who will want to buy a whole bunch of boxes with blinky lights and ask annoying questions about redundancy and fail-safes.

baquerd
Jul 2, 2007

by FactsAreUseless

Panic! At The cisco posted:

What you don't realise is if you use the right language you don't have to put braces around any if statements.

That's really a different matter altogether. In Python, Lisp, et al. there are other conventions that organize code. In a language featuring braces for organization, use them or go single-line.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug
I always use curly braces, even if it could reasonably be fit onto a single line, for the sake of consistency. Obviously, I am horribly wrong.

lamentable dustman
Apr 13, 2007

🏆🏆🏆

I use brackets because it looks dumb as hell. If you want to save those two key strokes just make a one liner out of it

McGlockenshire
Dec 16, 2005

GOLLOCKS!
Perl doesn't let you do one-line no-curly if statements... unless the statement precedes the if.

do_something() if($condition);
do_something() unless($condition);


I miss this syntax so much...

Strong Sauce
Jul 2, 2003

You know I am not really your father.





McGlockenshire posted:

Perl doesn't let you do one-line no-curly if statements... unless the statement precedes the if.

do_something() if($condition);
do_something() unless($condition);


I miss this syntax so much...

Ruby allows this too.

Dicky B
Mar 23, 2004

Ithaqua posted:

I always use curly braces, even if it could reasonably be fit onto a single line, for the sake of consistency. Obviously, I am horribly wrong.
It's perfectly consistent to always omit curly brackets when it's only one line.

Zamujasa
Oct 27, 2010



Bread Liar
But then you run into the issue stated before where a global search-and-destroy on "doSomething(z)" (which doesn't return a value, we'll say) will end up causing unforeseen effects.


Using braces turns the if-statement into a no-op. No braces means the next statement is executed next (or a syntax error if you're lucky).




On the subject of PHP and concatenated variables I'm pretty sure other languages have something similar. I know TI-BASIC on the TI-92+ allowed you to use variable variables by using "#variable" (useful when choosing a variable to store things in).

No Safe Word
Feb 26, 2005

TRex EaterofCars posted:

I like the terrible one. It has visual indication it's affected by the line above it and isn't polluted by braces. It's clean and compact and I have literally never been burnt by the obvious argument against it.

Now this, on the other hand, is terrible:
code:
if (thing)

doStuff();

Except if you have multiple people on your team mangling files with crazy formatters, then the "terrible" one that you like can potentially become the terrible one that in your mind is the truly terrible one.

With braces it can get mangled and look stupid but at least it'll never become what you posted above even with lovely reformatters around.

FLEXBONER
Apr 27, 2009

Esto es un infierno. Estoy en el infierno.

Dicky B posted:

It's perfectly consistent to always omit curly brackets when it's only one line.

Consistent with being a bad coder :colbert: I bet you don't use semi-colons to end all your lines in JavaScript.

I always use braces but don't actually care either way

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Let's just write parse trees. Man, what a weird language that would be.

Plorkyeran
Mar 22, 2007

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

Zamujasa posted:

But then you run into the issue stated before where a global search-and-destroy on "doSomething(z)" (which doesn't return a value, we'll say) will end up causing unforeseen effects.


Using braces turns the if-statement into a no-op. No braces means the next statement is executed next (or a syntax error if you're lucky).
"if you do this highly destructive thing without checking the results things might break" is not a very compelling argument

JewKiller 3000
Nov 28, 2006

by Lowtax

pokeyman posted:

Let's just write parse trees. Man, what a weird language that would be.

In case you're serious, there is a language like that, it's called Lisp. ;)

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
You know what? I think I actually preferred Stallman chat to brace chat.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Yeah that was an attempted Lisp joke.

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

Wheany posted:

You know what? I think I actually preferred Stallman chat to brace chat.
Can we all agree that Stallman's preferred style is terrible?
code:
static char *
concat (char *s1, char *s2)
{
  while (x == y)
    {
      something ();
      somethingelse ();
    }
  finalthing ();
}

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
"At age 59, every programmer has the indentation style he deserves."

edit: Stallman is still perhaps outclassed by "Eastern Polish Christmas Tree Notation"

Internet Janitor fucked around with this message at 20:43 on Mar 27, 2012

Contero
Mar 28, 2004

Internet Janitor posted:

"At age 59, every programmer has the indentation style he deserves."

edit: Stallman is still perhaps outclassed by "Eastern Polish Christmas Tree Notation"

Thats... Kind of awesome actually.

code:
                                      }
                                 catch(Exception e)
                                      {
                               logger . debug("!!! "+e.toString()+" "+key);
                                      }
                               finally
                                      {
                                  try {
Why do finally and catch have their braces on the following line, but try doesn't? Why does if() go completely on the left side, but catch() doesn't? Why does this bother me more than the style itself?

Zamujasa
Oct 27, 2010



Bread Liar

Plorkyeran posted:

"if you do this highly destructive thing without checking the results things might break" is not a very compelling argument

It's just an example of something that could happen, is all. You can get the same result if you just comment out the line normally, easily done especially if the code is like

code:
if (x == y) {
   doStuff(x)
   doThing(y)
} else
   doNothing()
I'm just saying that it's one of those consistency things.

TheChemist
Mar 26, 2012

For science!

Internet Janitor posted:

"At age 59, every programmer has the indentation style he deserves."

edit: Stallman is still perhaps outclassed by "Eastern Polish Christmas Tree Notation"

Those two architects deserve awards for being some of the greatest trolls of all time. "Hehe, they think they will maintain this after we are gone."

pigdog
Apr 23, 2004

by Smythe

Internet Janitor posted:

"At age 59, every programmer has the indentation style he deserves."

edit: Stallman is still perhaps outclassed by "Eastern Polish Christmas Tree Notation"

I don't know about braces, but I can dig the assignment operators being lined up. Looks kinda neat. :)

Hammerite
Mar 9, 2007

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

Zamujasa posted:

On the subject of PHP and concatenated variables I'm pretty sure other languages have something similar. I know TI-BASIC on the TI-92+ allowed you to use variable variables by using "#variable" (useful when choosing a variable to store things in).

Yeah but in PHP it is a terrible abomination because PHP already has a feature that lets you do this in a much more sensible and controlled way, i.e. associative arrays.

tef
May 30, 2004

-> some l-system crap ->
braces :rolleyes:

tef
May 30, 2004

-> some l-system crap ->
brb manually typesetting my code

gonadic io
Feb 16, 2011

>>=
From the same page as the christmas tree notation:
code:
// ensure string is null terminated
strcat(string, "\0");

Ari
Jun 18, 2002

Ask me about who Jewish girls should not marry!

Hammerite posted:

Yeah but in PHP it is a terrible abomination because PHP already has a feature that lets you do this in a much more sensible and controlled way, i.e. associative arrays.

http://php.net/manual/en/language.variables.variable.php

Adbot
ADBOT LOVES YOU

FamDav
Mar 29, 2008

Aleksei Vasiliev posted:

Can we all agree that Stallman's preferred style is terrible?
code:
static char *
concat (char *s1, char *s2)
{
  while (x == y)
    {
      something ();
      somethingelse ();
    }
  finalthing ();
}

Are those spaces between function name and args really a thing? :drat:.

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