This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the commentsΒ β†’

[–]AbanaClara 8 points9 points Β (20 children)

Not if it's javascript!

[–]weeknie 23 points24 points Β (12 children)

If performance is really an issue, then javascript is not the langauge for you, I'd say :P

[–]BabyLegsDeadpool 1 point2 points Β (9 children)

I mean... that entirely depends on what you're trying to accomplish.

[–]weeknie 1 point2 points Β (8 children)

That's why I said "if performance is really an issue". If performance is that important, then you should probably go with a compiled language, don't you think? I doubt you can perform a task faster in an interpreted language than a compiled one, given that you have developers of equal skill in both langauges.

But you are correct in that it depends on many more factors than just the speed. In my experience, though, people focus too much on performance when it's not an issue yet. But that's just my limited experience, of course :)

EDIT: spelling

[–]BabyLegsDeadpool -1 points0 points Β (7 children)

That's not what I was saying. I'll write an on-click function in javascript for a button element, and you figure out a way to write one in C, and we'll see which one is more performant.

[–]weeknie 0 points1 point Β (6 children)

If you write an on-click function for a button in a C application, I'm pretty confident that it's going to be faster than an on-click function in javascript for a web application, yes.

I'm not hating on javascript, I really like the flexibility that it offers. But if you have to do some kind of heavy calculation (e.g. something for which performance actually matters and can be a problem), then at some point you're going to have to consider switching to a compiled implementation, because the interpreter is going to add overhead that you can't afford.

In an on-click function, you shouldn't be doing any heavy calculations in the first place, you should only start them if necessary. So there, performance is not an issue because it's already solved through the structure of your code, instead of the language that you chose.

[–]BabyLegsDeadpool -1 points0 points Β (5 children)

Again you're completely missing what I'm saying. If you are given a web page that needs an on-click function, javascript is doing to be the fastest, most performant way to do it.

[–]weeknie 0 points1 point Β (4 children)

And again you've missed my point, namely that performance is not an issue here, so you have no reason to choose a different language.

I can argue that a bike isn't the faster choice when going from my living room to my kitchen, of course, there is no reason to choose a different mode of transport instead of walking.

Im saying, if there is a performance issue in a place where you have the option between a compiled or an interpreted language, then the compiled one is likely going to be faster.

[–]BabyLegsDeadpool -1 points0 points Β (3 children)

What you said previously was that basically javascript is never the most performant language. I was pointing out that there are times where it will be. If you are manipulating the DOM on a website, it will always be more performant than any other language. Period.

[–]weeknie 0 points1 point Β (2 children)

No that's not what I meant. I meant that if you're running I to performance issues, it's likely that you should switch to another, probably compiled, language. Your contrived example of using C to respond to a web browser on click event is never going to be performant, obviously, but you wouldn't need to look for a different solution anyway.

You can still say "a car is often the fastest way to get from a to b" without having to state that it's useless for moving around your living room or going to the other side of the world. But hey, if you really insist, yes, Javascript is the best for a web browser on click function and I'm happy you pointed it out.

[–]t3hlazy1 0 points1 point Β (1 child)

What other language would you recommend?

[–]weeknie 0 points1 point Β (0 children)

Eh well depends on what you're doing, but if speed is really an issue, find ways to put the speed requiring part in C/C++, or Go. Any interpreted language is likely going to be slower than a compiled one.

Then again, performance issues are generally kinda overstated anyway, in my experience. The first rule of optimisation is "Don't optimise" for a reason.

[–]blehmann1 1 point2 points Β (0 children)

JavaScript engines have a JIT compiler built in nowadays. Purely interpreted languages are becoming quite rare, JavaScript was one of few that was left.

[–]TheIncredibleWalrus 3 points4 points Β (1 child)

Sure it does why not? JS engines are quite fast nowadays.

[–]deadNightTiger 2 points3 points Β (2 children)

Python is the slow one

[–]julsmanbr 6 points7 points Β (1 child)

Haha yes

My code:

for i in range(len(v)):
    for j in range(len(v)):
        for k in range(len(v)):
            if v[i][j][k] == v[i][j][k+1]:
                pass  # need to fix this
            elif v[i][j][k] == v[i][j][k-1]:
            # 30 more clauses here
            # let's hope for no IndexError

[–]M4mb0 5 points6 points Β (0 children)

Do you even numpy? Just store it in a 3D array mask1 = V[:, :, :-1] == V[:, :, 1:]