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
Optimus Prime Ribs
Jul 25, 2007

Looks like someone doesn't fully understand how to use booleans:
PHP code:
$acceptedDisclaimer = isset($_COOKIE['acceptedDisclaimer']) && $_COOKIE['acceptedDisclaimer'] == 'yes';
$declinedDisclaimer = isset($_COOKIE['acceptedDisclaimer']) && $_COOKIE['acceptedDisclaimer'] == 'no';

Adbot
ADBOT LOVES YOU

Xenogenesis
Nov 8, 2005

Gigantic Slut Man posted:

CoffeeScript is lexically scoped, but you don't have access to var, so you can't avoid changing the value of a variable from the outer scope other than by trying to make a unique variable name. If your function finds itself in a scope with foo, and you've named a variable foo, you're modifying the external foo.
Well, you can just use backticks to manually declare a variable with var if it's necessary. But again, it's only necessary if the foreign variable name you're worried about colliding with is in the global scope; CoffeeScript automatically declares var in the nearest function a variable first appears in, and if the variable is declared in a function, the variable's scope only exists for the file it's declared in. So, the scenario I think you're talking about :
code:
#file 1

outerFunction = (callback) ->
  poke = "buttz"
  callback()
  alert(poke)

#file 2

callback = ->
  poke = "putz"

outerFunction(callback)

# displays buttz
isn't a problem at all.

xtal
Jan 9, 2011

by Fluffdaddy
Sorry for the continued miscommunication, I know that JavaScript doesn't have those features. Let me explain like this: on the server side, you're using something like fs = require 'fs, which encapsulates that module. On the browser side, you're concatenating the files together, but they should all be enclosed in self-executing functions and assigned around one global variable. So you'll never encounter a library defining foo, only fs.foo, so to say. Unless I'm misunderstanding, the only time CoffeeScript's scoping behaves unexpectedly is if your library code isn't properly encapsulated, or if you're reusing a local variable name inside one module.

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.
I'm using Coffeescript. It encapsulates every .coffee file compiled into a function, so unless you specifically assign a variable to the window or global (for servers) object, it will not be a global variable. You have to manually export variables you want to be used by other files in your code base.

I personally haven't had any dramas getting it to do what I want it to do.

edit: all it's really doing is flipping around the default JavaScript behaviour so you imply locals rather than globals in assignment.

Maluco Marinero fucked around with this message at 23:20 on Sep 17, 2012

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

Optimus Prime Ribs posted:

Looks like someone doesn't fully understand how to use booleans:
PHP code:
$acceptedDisclaimer = isset($_COOKIE['acceptedDisclaimer']) && $_COOKIE['acceptedDisclaimer'] == 'yes';
$declinedDisclaimer = isset($_COOKIE['acceptedDisclaimer']) && $_COOKIE['acceptedDisclaimer'] == 'no';

Except, as silly as it is, that could actually serve a purpose.

If they're both false, then the user hasn't yet registered an opinion on the disclaimer. If the 'acceptedDisclaimer' is 'yes', then they've seen and accepted the disclaimer. If the 'acceptedDisclaimer' is 'no', then they've seen and rejected the disclaimer.

'yes' and 'no' are obviously, in this instance, strings that are set when the user either accepts or rejects the disclaimer.

Is it a great way to do it? Probably not, but it's not that much of a horror, really.

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
e

Blotto Skorzany fucked around with this message at 16:36 on Sep 19, 2012

UraniumAnchor
May 21, 2006

Not a walrus.

Otto Skorzeny posted:

Another department is trying to force my department to use Visual Source Safe for all new development (despite the fact that we don't and can't use visual studio for any of our projects). I know VSS is a piece of poo poo, can people spam me objective info to fight this with?

Zamujasa
Oct 27, 2010



Bread Liar

bobthecheese posted:

Except, as silly as it is, that could actually serve a purpose.

If they're both false, then the user hasn't yet registered an opinion on the disclaimer. If the 'acceptedDisclaimer' is 'yes', then they've seen and accepted the disclaimer. If the 'acceptedDisclaimer' is 'no', then they've seen and rejected the disclaimer.

'yes' and 'no' are obviously, in this instance, strings that are set when the user either accepts or rejects the disclaimer.

Is it a great way to do it? Probably not, but it's not that much of a horror, really.

That seems like something better represented by true, false, null for accept, decline, no response.

wwb
Aug 17, 2004

http://www.developsense.com/testing/VSSDefects.html is the classic anti-VSS rant.

If it makes you feel any better, I just had to extract our old VSS database and pull it into SVN to figure some things out. VSS2SVN.exe took the better part of the day but did work quite well. God I wished I had done things like comment commits back then.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

classic anti-VSS rant posted:

Create a project called A. To this project, add a file named 1.c. Optionally revise the file; then delete it from A. Add a different file called 1.c to A; you will be offered the choice to recover the file, or to purge it from the database. Choose not to recover the deleted file, but instead to add your new file. Display the history of the project, and attempt to Get a version of that project from before 1.c was deleted. You will find that the original version of 1.c is not available, and thus your project cannot be rebuilt.

Surely this on its own is cause for immediate rejection of VSS. You can trivially lose an entire file of data.

Plorkyeran
Mar 22, 2007

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

Zamujasa posted:

That seems like something better represented by true, false, null for accept, decline, no response.
You can only store strings in cookies, and using "true"/"false" is easier to confuse for an actual boolean value. No value set is equivalent to null.

Deus Rex
Mar 5, 2005

Gigantic Slut Man posted:

CoffeeScript is lexically scoped, but you don't have access to var, so you can't avoid changing the value of a variable from the outer scope other than by trying to make a unique variable name. If your function finds itself in a scope with foo, and you've named a variable foo, you're modifying the external foo. There's no declaration syntax available, only assignment with implicit declaration if the variable doesn't already exist.

you can get around this with coffeescript's do keyword, which makes an anonymous function wrapper and immediately invokes it. it's meant more for like inside a loop which generates functions to avoid closing over the same variable in each function (JS suffers the exact same scoping issue in this case, just with a more verbose workaround)

CoffeeScript code:
foo = 42
do (foo) ->
  foo = 43
  alert foo # alerts 43
alert foo # alerts 42
http://bit.ly/Qy91dt

that awful man
Feb 18, 2007

YOSPOS, bitch

Plorkyeran posted:

You can only store strings in cookies, and using "true"/"false" is easier to confuse for an actual boolean value. No value set is equivalent to null.

I think he was referring to the values and variables used within the program itself, not the value stored in the cookie. As it is, $acceptedDisclaimer is true if the disclaimer was
accepted, $declinedDisclaimer is true if the disclaimer was declined, and both are false if there was no response. It sounds like he was suggesting that $acceptedDisclaimer should be true if the disclaimer was accepted, false if it was declined, and null otherwise; and that $declinedDisclaimer should be done away with.

Bunny Cuddlin
Dec 12, 2004
My main problem with CoffeeScript, of which this argument is a symptom, is the mind-boggling belief (incorrect, in my opinion) that implicit is better than explicit. There are cases where it's useful to have implicit operations, but as a basic language design concept, I think it's horrible.

Bunny Cuddlin
Dec 12, 2004
To see what I mean:

Only registered members can see post attachments!

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.

Plorkyeran posted:

You can only store strings in cookies, and using "true"/"false" is easier to confuse for an actual boolean value. No value set is equivalent to null.

I am the horror. With this web app prototype I'm building I'm experimenting with IndexedDB, unfortunately it doesn't do indexes for booleans yet. Enter "true" and "false", although I should probably just change it in a function when they get applied to the object prototype I guess.


edit: Above, I see what you mean, although in the end of the day that IS the syntax, largely taken from Ruby's way of doing things. It's pretty clear to anyone who works with the language exactly what the problem is. For my mind the pros of working with Coffeescript outweigh the cons for me, although I guess I really haven't explored alternatives for languages that compile to javascript.

Maluco Marinero fucked around with this message at 09:11 on Sep 18, 2012

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Maluco Marinero posted:

edit: Above, I see what you mean, although in the end of the day that IS the syntax,

Shrugging your shoulders and going "well that's just the way it is" when it's entirely possible to change something is a bit of a horror.

Coffeescript is at the point where they should be identifying pain points and fixing them, not just settling for "marginally better than plain JavaScript"

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.
I guess by saying that that IS the syntax, I mean that it's pretty straightforward that a variable name directly followed by () is a function call with no arguments. This isn't some obscure rule here, it's the parentheses free style which is demonstrated throughout the language and it's documentation.

It's not something I entirely like working with myself, I ended up working with Python rather than Ruby for other stuff I've done, but it IS the syntax they've chosen, and it's an entirely consistent behaviour within that syntax.

Maluco Marinero fucked around with this message at 10:12 on Sep 18, 2012

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Jabor posted:

Shrugging your shoulders and going "well that's just the way it is" when it's entirely possible to change something is a bit of a horror.

Coffeescript is at the point where they should be identifying pain points and fixing them, not just settling for "marginally better than plain JavaScript"

They're far past that point. They've declared language stability: they cannot break existing code.

CoffeeScript makes certain tradeoffs. Sometimes design features are mutually exclusive. The designer has put his foot down re: shadowing. It won't change.

To be honest, I doubt the CoffeeScript designer thought about all these ambiguous edge cases; that really only comes with experience.

PrBacterio
Jul 19, 2000

Gigantic Slut Man posted:

To see what I mean:


Incidentally, this exact same issue is also something that has always bugged me about the C preprocessor:
C++ code:
#define FOO(X) ,X
#define BAR (X) ,X
int X=10,Y=10;
int main(){
  extern int printf();
  printf("%d\n" FOO(Y)); /*expands to printf("%d\n" ,Y);*/
  printf("%d,%d\n", BAR); /*expands to printf("%d,%d\n", (X) ,X);*/
  return 0;
}

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
e

Blotto Skorzany fucked around with this message at 16:36 on Sep 19, 2012

Sang-
Nov 2, 2007

Thermopyle posted:

Now I want to write an RTS in Python.

Scala has traits and would be quite interesting to do.

Is OpenGL for the jvm still horrible?

hobbesmaster
Jan 28, 2008

PrBacterio posted:

Incidentally, this exact same issue is also something that has always bugged me about the C preprocessor:
C++ code:
#define FOO(X) ,X
#define BAR (X) ,X
int X=10,Y=10;
int main(){
  extern int printf();
  printf("%d\n" FOO(Y)); /*expands to printf("%d\n" ,Y);*/
  printf("%d,%d\n", BAR); /*expands to printf("%d,%d\n", (X) ,X);*/
  return 0;
}

What would you expect it to do?

Optimus Prime Ribs
Jul 25, 2007

that awful man posted:

I think he was referring to the values and variables used within the program itself, not the value stored in the cookie.

Yeah that was my problem with it.
This would have made a lot more sense:
PHP code:
$acceptedDisclaimer = isset($_COOKIE['acceptedDisclaimer']) ? $_COOKIE['acceptedDisclaimer'] === 'yes' : null;
Still wouldn't be perfect, but would be better than playing around with two booleans that are basically opposites of each other.

e:


Yeesh. I'm glad I never have to work with CoffeeScript.

Optimus Prime Ribs fucked around with this message at 15:19 on Sep 18, 2012

That Turkey Story
Mar 30, 2003

hobbesmaster posted:

What would you expect it to do?

Yeah, I'm confused as to what the problem is here. If it didn't do this, how would you define non-function-style macros that start with parentheses? Would you make a new syntax? I think this is the most concise way to do it.

Strong Sauce
Jul 2, 2003

You know I am not really your father.





I'm not sure I've ever seen anyone run into that problem writing CoffeeScript. Mainly because having a function that returns a function which takes a function as input seems to be a coding horror in itself.

Deus Rex
Mar 5, 2005

Strong Sauce posted:

I'm not sure I've ever seen anyone run into that problem writing CoffeeScript. Mainly because having a function that returns a function which takes a function as input seems to be a coding horror in itself.

doesn't seem like a horror on its face, isn't that what a combinator does?

PrBacterio
Jul 19, 2000

Deus Rex posted:

doesn't seem like a horror on its face, isn't that what a combinator does?
In fact that is literally the definition of a combinator, and thinking that to be a horror is the real horror :eng99:

EDIT:

That Turkey Story posted:

Yeah, I'm confused as to what the problem is here. If it didn't do this, how would you define non-function-style macros that start with parentheses? Would you make a new syntax? I think this is the most concise way to do it.
I was only pointing out that this is the exact same syntactical issue as what was brought up with Coffeescript, and so if it bothers you in the one case it should also do so in the other and vice-versa.

PrBacterio fucked around with this message at 19:20 on Sep 18, 2012

Eliza
Feb 20, 2011

I've happened to stumble upon the worst soon-to-be production code I've ever seen in our server application at work the other day.

To give some context, our application gets something on the order of 40000 users a day stretched over 24 server nodes, and is written in Java backed by a database. Users access this through a proprietary client that's little more than a frontend for Internet Explorer.
All in all, it's running fine - actually very stable compared to what the users use otherwise.

The rights system is currently being overhauled completely, server-side. The old system was a database-backed list of roles with occasionally denied privileges depending on the role.
Users had accounts with group privileges noted down in a database table.
Those privileges were parsed during JSP compiling, and affected parts would simply not be generated on the page. The pages were in a hierarchical structure of static tags, so they could be referenced by the privileges table.

The new system first off does away with the database part.
Second, rights for certain parts of our business logic are defined through annotations in central classes now, about 50 classes in total. This wouldn't be so bad if not for
a) the privileges for specialised business objects being annotated in their general superclasses
b) the ratio of annotation-to-code being 8:1 or worse in affected classes. I've literally found a sub-300-line class (imports included) touting over 2200 lines of annotations.

It gets worse!
From these monolithic annotated classes, a batch (actually part of production code) will, on deployment, generate a massive XML containing the entire rights management. Should the user log on to our server application, a section of this xml will be cached in a server-side session attribute.
JSPs will be generated according the the read privileges, yada yada.

But the rights are now frozen in the code until the next version comes out, 4 months or so later. What if someone decides that some random role needs different rights after all?
Then they have to get someone to manipulate the XML that was generated earlier, by hand. And file a ticket to change it for the next version.
There is no graphical interface to do that, or a tool to do it more conveniently aside from general XML tools.
If they for some reason have to regenerate the XML and forget whatever changes they had made before the next version came out, they would have to figure them out all over again.

All this not only got past our architect, but he actually decided on it. He decided against a database-backed solution.

Every single person involved, except maybe him, gets angry very quickly if you so much as mention the topic. I am ever so glad I was too busy with other tasks to get suckered into this.

Eliza fucked around with this message at 20:25 on Sep 18, 2012

Doc Hawkins
Jun 15, 2010

Dashing? But I'm not even moving!


Strong Sauce posted:

I'm not sure I've ever seen anyone run into that problem writing CoffeeScript. Mainly because having a function that returns a function which takes a function as input seems to be a coding horror in itself.

Common LISP: the ultimate horror.

Pilsner
Nov 23, 2002

Eliza posted:

I've happened to stumble upon the worst soon-to-be production code I've ever seen in our server application at work the other day.

See, that kind of fundamentally flawed design is the real coding horror. All those little isolated snippets of code we see posted here and on The Daily WTF are really peanuts (although good for a laugh), because you can always just rewrite them as isolated methods/blocks of code with little to no impact.* This stuff though, is something that makes everyone's job miserable, causes bugs at every release, manual work, and constantly fights back when you try to work on other stuff. Poor architecture and data structure, lack of data integrity, misunderstanding of data flow, and similar are the coding horrors that can terrorise software for years. Someone doing an "if(b == true) return true else return false", or O(N^2) instead of O(N) or whatever the hell no one really cares much about today in modern programming is nothing.

Misused OO can also to an extent be horrible, but in my experience it's usually just that someone has simply implemented an OO structure that does almost nothing, so it's (mostly) just about refactoring code for a while and flattening the hierarchy. I don't doubt that there are examples of some seriously insane inheritance hierarchies out there, though, that make it a pain to do anything with.

* Of course, that kind of code can also indicate a poorly skilled developer overall, but can also just be a newbie.

Look Around You
Jan 19, 2009

Strong Sauce posted:

I'm not sure I've ever seen anyone run into that problem writing CoffeeScript. Mainly because having a function that returns a function which takes a function as input seems to be a coding horror in itself.

So I guess Haskell as a whole is just a horrible language and shouldn't exist. Huh.

Strong Sauce
Jul 2, 2003

You know I am not really your father.





Deus Rex posted:

doesn't seem like a horror on its face, isn't that what a combinator does?

I guess calling it a horror was pretty extreme, but stylistically to me a()(b) looks very ugly when for the most part a(b) will work.

Zombywuf
Mar 29, 2008

Look Around You posted:

So I guess Haskell as a whole is just a horrible language and shouldn't exist. Huh.

Yup.

Bunny Cuddlin
Dec 12, 2004

PrBacterio posted:

I was only pointing out that this is the exact same syntactical issue as what was brought up with Coffeescript, and so if it bothers you in the one case it should also do so in the other and vice-versa.

Uh. One's a high level language designed for writing production code and the other is a macro language. Nobody is advocating you write serious applications in C Preprocessor macros dude. It's not a fair comparison.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

That Turkey Story posted:

Yeah, I'm confused as to what the problem is here. If it didn't do this, how would you define non-function-style macros that start with parentheses? Would you make a new syntax? I think this is the most concise way to do it.

The preprocessor really should always insert parens for you automatically. I can't think of a single reason for it not to.

raminasi
Jan 25, 2005

a last drink with no ice

Gigantic Slut Man posted:

Uh. One's a high level language designed for writing production code and the other is a macro language. Nobody is advocating you write serious applications in C Preprocessor macros dude. It's not a fair comparison.

I think he's just saying that the wart is basically the same wart without making a judgment about whether that particular wart is more tolerable in one place than the other.

Amarkov
Jun 21, 2010

Suspicious Dish posted:

The preprocessor really should always insert parens for you automatically. I can't think of a single reason for it not to.

code:
#define ARGS X, Y, Z

some_function ARGS; // expands correctly
some_function(ARGS); // nope
In other words, do you trust C programmers to use preprocessor macros only where it makes sense to do so?

Amarkov fucked around with this message at 22:56 on Sep 18, 2012

KaneTW
Dec 2, 2011

Amarkov posted:

code:
#define ARGS X, Y, Z

some_function ARGS; // expands correctly
some_function(ARGS); // nope
In other words, do you trust C programmers to use preprocessor macros only where it makes sense to do so?

That doesn't parse

E: nmd, you fixed it.

Adbot
ADBOT LOVES YOU

That Turkey Story
Mar 30, 2003

Suspicious Dish posted:

The preprocessor really should always insert parens for you automatically. I can't think of a single reason for it not to.

You mean have macros always expand to something parenthesized? That wouldn't work -- the are lots of times where you don't want the expansion to result in something that's parenthesized I.E. almost anything that doesn't result in an expression.

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