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)[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.
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)[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).
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.[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.
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.[url=http://meincmagazine.com/civis/viewtopic.php?p=24561259#p24561259:3dshdkxo said:DrPizza[/url]":3dshdkxo]No they aren't, and no it doesn't.[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)
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]
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.
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).[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.
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.That's because there is no real alternative to, say, polymorphism in many cases.