Surprise! Mozilla can produce near-native performance on the Web

Status
You're currently viewing only Voo42's posts. Click here to go back to viewing the entire thread.
Not open for further replies.

Voo42

Ars Praefectus
3,687
Subscriptor
[url=http://meincmagazine.com/civis/viewtopic.php?p=24556287#p24556287:2fghd6ms said:
web2nr[/url]":2fghd6ms]
[url=http://meincmagazine.com/civis/viewtopic.php?p=24546077#p24546077:2fghd6ms said:
abhi_beckert[/url]":2fghd6ms]For example, the way variable scope works in javascript is completely unacceptable.

It's easy to dislike what you don't understand. The variable scope is one of things I enjoy about JavaScript.
Really? I mean really? Someone is defending JS' scoping rules? Apparently it's also easy to like something if you're ignorant about the alternatives. Are you aware that even Brendan Eich considers the scoping rules in Javascript broken and tried to fix them in Harmony? ("Hey let's adopt C scoping syntax and then break it in a totally useless way that surprises everybody and needs a hack to fix, because we have a very limited timeframe to implement the language and it's easier!" - yep great idea)

Paraphrasing Peter Norvig: Design patterns are generally deficiencies in the language and having to write anonymous functions to get the scoping behavior that's not only expected but also in pretty much every situation conceivable preferred is just horrible.

And let's not even think about free variables, stupendous hoisting rules (quick are function definitions hoisted out of conditionals or not? Are variable definitions?), the four different versions of this, coercion rules for ==/!=, with statement, for..in statement problems, and.. can we stop here now?
 
Upvote
0 (1 / -1)

Voo42

Ars Praefectus
3,687
Subscriptor
[url=http://meincmagazine.com/civis/viewtopic.php?p=24560557#p24560557:3uj8bixo said:
quaint[/url]":3uj8bixo]
[url=http://meincmagazine.com/civis/viewtopic.php?p=24553757#p24553757:3uj8bixo said:
minifig404[/url]":3uj8bixo]Just a random side-note: C is the fastest language tested by The Computer Language Benchmarks Game. The second fastest langauge is C++, at < 3x slower than C. --

Food for thought.

Not that well-made. C++ is really better described as comparable to C in terms of speed in the Benchmarks Game (although, strictly speaking, what they do is compare the speed of implementations, not languages). In some tests it's faster, in some it's slower and they mostly cancel each other when looking at the big picture; although the C++ programs tend to use more memory (and asm.js even more so, I would guess).
Looking at most of the really fast running C++ code you don't see many classes or other stuff though, some stuff in C++ though allows it to actually be faster than standard c code. Or to be more exact: Getting the equivalent speed in C would need *lots* of extra code (well templates really, sorting stuff in c using qsort and a function pointer is generally horribly slow)
 
Upvote
0 (0 / 0)

Voo42

Ars Praefectus
3,687
Subscriptor
[url=http://meincmagazine.com/civis/viewtopic.php?p=24560681#p24560681:1imhgkb6 said:
Sobels[/url]":1imhgkb6]
There's nothing that intrinsically makes classes slower than plain functions. A method is really just a plain C function with an additional argument for the "this" pointer. And as you said, sometimes it can actually reduce the indirection you use. It just comes down to how much time you're really willing to spend optimizing something that takes microseconds anyway.
Absolutely true, but the thing is if you're going to use classes you'll most likely also use OOP principles and that in general does induce some runtime cost (exceptions are situations where you need a class because the language demands it), So yes should've been more specific there.
 
Upvote
-1 (0 / -1)

Voo42

Ars Praefectus
3,687
Subscriptor
[url=http://meincmagazine.com/civis/viewtopic.php?p=24561259#p24561259:3dshdkxo said:
DrPizza[/url]":3dshdkxo]
[url=http://meincmagazine.com/civis/viewtopic.php?p=24561237#p24561237:3dshdkxo said:
Voo42[/url]":3dshdkxo](exceptions are situations where you need a class because the language demands it)
No they aren't, and no it doesn't.
Huh? So you're saying actually writing OOP code in c++ does have absolutely no overhead and will give you generally just the same performance as vanilla c code? Unlikely that.

Yes if you use classes just to avoid passing a pointer to a struct to your methods you'll get the same performance, but as soon as you start using all the actual OOP stuff performance suffers to some degree or the other. From a glance at the well performing c++ code it generally looks pretty similar to the c code..
 
Upvote
-2 (0 / -2)

Voo42

Ars Praefectus
3,687
Subscriptor
[url=http://meincmagazine.com/civis/viewtopic.php?p=24561533#p24561533:1b6mbhpc said:
DrPizza[/url]":1b6mbhpc]
I'm saying that exceptions in C++ do not require you to use a class. The language does not demand it. Throw an int if you want.
I totally agree and neither did I say that, although I can see how my sentence could be misunderstood.

[url=http://meincmagazine.com/civis/viewtopic.php?p=24561533#p24561533:1b6mbhpc said:
DrPizza[/url]":1b6mbhpc]
C++ is not synonymous with "virtual dispatch". C++ features such as templates are arguably as important as virtual dispatch--perhaps even more important, in fact, if you're to judge by the design of the C++ Standard Library--and can often reduce runtime overhead, relative to comparable C implementations.
Umn yes, which is why I said that C++ templates give you advantages compared to C which you could otherwise only get by copious code duplication (the obvious example being qsort with function pointers being horribly slow compared to std::sort).
But templates have nothing to do with OOP and I still claim that the number of C++ programs that perform comparably to vanilla c programs and use OOP principles is vanishingly small (that obviously assumes that we don't go by "There's a class definition in the code, it's obviously object oriented!" there's more to it than that).


That's because there is no real alternative to, say, polymorphism in many cases.
I disagree, just because you pick polymorphism, etc. in say Java, doesn't mean that a corresponding C or LISP program would reinvent polymorphism to solve the same problem. Clearly the language influences the design process and decisions.
 
Upvote
-1 (0 / -1)
Status
You're currently viewing only Voo42's posts. Click here to go back to viewing the entire thread.
Not open for further replies.