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
OddObserver
Apr 3, 2009

ToxicFrog posted:

Oh. So "automatic semicolon insertion" is "a semicolon is inserted at each newline if one is not already present".

:gonk:

Nothing that logical. Some statements or expressions get it inserted only if not having it would produce a parse error, others have it inserted unconditionally.

Adbot
ADBOT LOVES YOU

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Plorkyeran posted:

The rules are actually significantly more complicated than that, but it pretty much comes down to that if a line doesn't end in a semicolon and it would syntactically valid to have a semicolon at end of the line, the interpreter tries its hardest to do the opposite of what you wanted it to.

Not going to even attempt to defend automatic semicolon insertion, but if anyone's genuinely curious about when it happens, here's a decent summary of the standard. It's not so insane that semicolon-free JavaScript is impossible to write, but I'd guess almost nobody bothers and just tosses in semicolons everywhere.

I really don't understand why someone would see two options, "require semicolons" and "don't require semicolons", and decide to go right down the middle. Sometimes it's ok to pick one!

nielsm
Jun 1, 2009



pokeyman posted:

I really don't understand why someone would see two options, "require semicolons" and "don't require semicolons", and decide to go right down the middle. Sometimes it's ok to pick one!

Someone had had enough of his compiler telling him that he probably forgot a semicolon somewhere and had a great idea: "If the compiler can tell me where they need to be, let it insert them for me!"

Pimblor
Sep 13, 2003
bob
Grimey Drawer

pokeyman posted:

Not going to even attempt to defend automatic semicolon insertion, but if anyone's genuinely curious about when it happens, here's a decent summary of the standard. It's not so insane that semicolon-free JavaScript is impossible to write, but I'd guess almost nobody bothers and just tosses in semicolons everywhere.

I really don't understand why someone would see two options, "require semicolons" and "don't require semicolons", and decide to go right down the middle. Sometimes it's ok to pick one!

I can see the merits of both sides of the argument, for and against semicolons as statement delimiters. But there's sort of a rule on Algol/C like languages that a statement termination is a semicolon and when you break that rule the compiler/interpreter tells you done hosed up. JavaScript is kinda like a junky who comes back and says, hey man that's cool. And it is cool, until you have to blow a elephant. I'm not sure if the analogy carries, but wow. Debugging that particular syntax error really sucks.

edit: changed analogy to be more friendly :gay:

Pimblor fucked around with this message at 14:35 on Oct 10, 2011

Opinion Haver
Apr 9, 2007

The correct answer is to use Coffeescript.

NotShadowStar
Sep 20, 2000
JS rather gets a pass because Brendan Eich had eight days to go from conception, implementation, to production or else 'something even more horrible would have been unleashed'. I don't think he ever really stated what it was, but it was probably some sort of Java derivative since Netscape and Sun were trying to team up around then. Once everything ever was using Javascript with all of its bugs and quirks, it became pretty much impossible to go back.

The real horror is nobody except MS even bothered to implement anything else. <script type="text/javascript"> is there for a reason. I'm surprised google hasn't embedded Python or Apple put Ruby into WebKit.

Opinion Haver
Apr 9, 2007

NotShadowStar posted:

The real horror is nobody except MS even bothered to implement anything else. <script type="text/javascript"> is there for a reason. I'm surprised google hasn't embedded Python or Apple put Ruby into WebKit.
Right, just what we need. More poo poo that only works on one specific browser. I think that if anything displaces JS, it'll be something that compiles down to it, not a whole new language.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Hu Fa Ted posted:

JavaScript is kinda like a junky who comes back and says, hey man that's cool. And it is cool, until you have to blow a tranny. I'm not sure if the analogy carries, but wow.

If the point of your analogy was "JavaScript is a bigoted joke", you did great.

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

yaoi prophet posted:

The correct answer is to use Coffeescript.

or clojurescript

Pimblor
Sep 13, 2003
bob
Grimey Drawer

pokeyman posted:

If the point of your analogy was "JavaScript is a bigoted joke", you did great.

I have no idea where I was going with that analogy, I think it sounded better in my head. The analogy that is.

I've been bitten by the automatic semicolon, and by extension returning a block.

i.e.:
code:
return
{
  // whatever, but it never gets returned
}

tef
May 30, 2004

-> some l-system crap ->
if you used the one true brace style that would never happen hth :can:

Sedro
Dec 31, 2008
Someone posted this a while back.

NotShadowStar
Sep 20, 2000
The Crockford book is 100% required reading for anybody doing any Javascript ever. It completely changes how you think about the language. The man has been around forever and has a keen sense of language history, really knows his stuff and can give a reasoned opinion on things.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
At least watch that video.

All Hat
Jul 11, 2008

He that is without int among you, let him first cast a long

Xenogenesis posted:

https://code.google.com/p/phpreboot/

Surely this is some brilliant troll?

It is nice that they aim to be "more in sync with the Web of 2010".

Munkeymon
Aug 14, 2003

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



NotShadowStar posted:

I'm surprised google hasn't embedded Python or Apple put Ruby into WebKit.

What a perfect day to have this discussion. I'm just sorry they didn't say gently caress it and actually use Python :\

Also,

https://code.google.com/p/phpreboot/ posted:

XML and SQL can be mixed together

:ughh:

Pardot
Jul 25, 2001




NotShadowStar posted:

I'm surprised google hasn't embedded Python or Apple put Ruby into WebKit.

They just did http://www.dartlang.org/

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.
code:
class Printer extends Isolate {
  main() {
    port.receive((message, replyTo) {
      if (message == null) port.close();
      else print(message);
    });
  }
}

main() {
  new Printer().spawn().then((port) {
    for (var message in ['Hello', 'from', 'other', 'isolate']) {
      port.send(message);  
    }
    port.send(null);
  });
} 
hang on that isn't python at all!

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
I am become death, destroyer of DOMs.

NotShadowStar
Sep 20, 2000
Oh goodie another class-based language with worse syntax than what's out there. I don't loving get google at all. I also get the impression google doesn't get google either. I mean Go was SO successful that they had to invent yet another thing. Or GWT, what a miraculous thing that was!

There's a really good reason why Brendan Eich busted his rear end to make sure a strongly typed Java style class based languages weren't driving the web and google goes all 'welp' over and over. Ah well another project from google to go 'hmm' and then ignore.

Brecht
Nov 7, 2009

NotShadowStar posted:

I mean Go was SO successful that they had to invent yet another thing.
Go is p. successful and gaining steam.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

NotShadowStar posted:

I mean Go was SO successful that they had to invent yet another thing.

Go looks like a miracle compared to this poo poo.

pseudorandom name
May 6, 2007

Go doesn't require every person on the planet to upgrade their web browser to as-yet-unwritten versions in order to be useful.

Zombywuf
Mar 29, 2008

pseudorandom name posted:

Go doesn't require every person on the planet to upgrade their web browser to as-yet-unwritten versions in order to be useful.

Are you implying that some future version of Chrome will make Javascript-with-optional-typing useful?

mjau
Aug 8, 2008
code:
main() {
  int x = 3;
  int y = x / 2;
  print('x: $x, y: $y');
}
code:
x: 3, y: 1.5

tef
May 30, 2004

-> some l-system crap ->

NotShadowStar posted:

Oh goodie another class-based language with worse syntax than what's out there. I don't loving get google at all. I also get the impression google doesn't get google either. I mean Go was SO successful that they had to invent yet another thing. Or GWT, what a miraculous thing that was!

There's a really good reason why Brendan Eich busted his rear end to make sure a strongly typed Java style class based languages weren't driving the web and google goes all 'welp' over and over. Ah well another project from google to go 'hmm' and then ignore.

it isn't strongly typed :confused: go and dart address wildly different problem spaces :confused:

this is actually close to gwt though in some respects

I do love all of the indignant rage from all the programmers who see the word 'java like' and start frothing without actually finding out the implementation of the language.

Zombywuf
Mar 29, 2008

Wait a minute, classes, interfaces, optional typing, server side support, sort of javascipty....

http://msdn.microsoft.com/en-us/library/ms974588.aspx

:colbert:

tef
May 30, 2004

-> some l-system crap ->
google wasabi

TasteMyHouse
Dec 21, 2006

mjau posted:

code:
main() {
  int x = 3;
  int y = x / 2;
  print('x: $x, y: $y');
}
code:
x: 3, y: 1.5

is this real


how can this be real

Zombywuf
Mar 29, 2008

TasteMyHouse posted:

how can this be real

Actually checking types is actually specified to not be an impediment to the program running in Dart.

EDIT: The type annotations are to make the refactoring tools in Eclipse work.

TasteMyHouse
Dec 21, 2006

Zombywuf posted:

Actually checking types is actually specified to not be an impediment to the program running in Dart.

EDIT: The type annotations are to make the refactoring tools in Eclipse work.

I'm just astounded that they made a language where you can call something an "int" which then behaves like a float. if those are just type "annotations" and not real type declarations, they should've chosen a different way of writing it.

TasteMyHouse fucked around with this message at 13:59 on Oct 11, 2011

Brain Candy
May 18, 2006

mjau posted:

code:
main() {
  int x = 3;
  int y = x / 2;
  print('x: $x, y: $y');
}
code:
x: 3, y: 1.5

Ah, a replacement for PHP.

TasteMyHouse
Dec 21, 2006
Apparently that code triggers a warning, "double is not assignable to int" http://try-dart-lang.appspot.com/s/_44V

but uh... so does this
http://try-dart-lang.appspot.com/s/D-cV

Mr.Radar
Nov 5, 2005

You guys aren't going to believe this, but that guy is our games teacher.

TasteMyHouse posted:

Apparently that code triggers a warning, "double is not assignable to int" http://try-dart-lang.appspot.com/s/_44V

but uh... so does this
http://try-dart-lang.appspot.com/s/D-cV

That's because / is the floating-point division operator. The integer division operator is ~/.

Munkeymon
Aug 14, 2003

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



Is it weird that I find the notion of an entry point for a browser scripting language kind of distasteful? It's not that you need it to represent the start/exit stack frame.




Also this is totally a solved problem http://projects.nikhilk.net/ScriptSharp :smug:

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Munkeymon posted:

Is it weird that I find the notion of an entry point for a browser scripting language kind of distasteful? It's not that you need it to represent the start/exit stack frame.

It seems kind of nice to me, actually. Presuming I can put a main in an included file, I can put it at the top of the file, instead of jamming it in at the bottom or using some weird DOM event hooks to trigger it to start.

Munkeymon
Aug 14, 2003

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



BonzoESC posted:

It seems kind of nice to me, actually. Presuming I can put a main in an included file, I can put it at the top of the file, instead of jamming it in at the bottom or using some weird DOM event hooks to trigger it to start.

There may be things you want to have done before the DOM is ready and things you will want to do after, so driving that with the regular event system just makes sense. I would agree that it's nice to have main(){} as a shorthand for the code to hook the DOM Ready event (if that's what it actually means - I haven't found that in the docs yet), but jQuery pretty well solved event management problems already.

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Munkeymon posted:

There may be things you want to have done before the DOM is ready and things you will want to do after, so driving that with the regular event system just makes sense. I would agree that it's nice to have main(){} as a shorthand for the code to hook the DOM Ready event (if that's what it actually means - I haven't found that in the docs yet), but jQuery pretty well solved event management problems already.

Now what about something you want run after the file is parsed but before the DOM loads? How does jQuery help you put that at the top of the file where you can find it quickly instead of at the bottom?

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
How does jQuery help wit a lot of things that I suddenly decided were a problem?

Adbot
ADBOT LOVES YOU

NotShadowStar
Sep 20, 2000

BonzoESC posted:

Now what about something you want run after the file is parsed but before the DOM loads? How does jQuery help you put that at the top of the file where you can find it quickly instead of at the bottom?

//do this poo poo now bro
( function () { console.log('dickbutt') } () )

Yeah somebody is gonna be a Dart apologist here. They are wrong.

https://gist.github.com/1277224

code:
/**
 * Extend the Boolean prototype with members expected in dart.
 *
 * TODO(jimhug): Add verification to ! and truth tests
 */
Boolean.$instanceOf = function(obj) {
  return typeof obj == 'boolean' || obj instanceof Boolean;
};

function native_BoolImplementation_EQ(other) {
  if (typeof other == 'boolean') {
    return this == other;
  } else if (other instanceof Boolean) {
    // Must convert other to a primitive for value equality to work
    return this == Boolean(other);
  } else {
    return false;
  }
}

function native_BoolImplementation_toString() {
  return (this == true) ? "true" : "false";
}

RunEntry(unnamedcac5e9$main$member, this.arguments ? (this.arguments.slice ? [].concat(this.arguments.slice()) : this.arguments) : new Boolean('false'););

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