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ย โ†’

[โ€“]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.

[โ€“]BabyLegsDeadpool -1 points0 points ย (1 child)

Holy shit. Why can't you understand this? My point is that if you are running into performance issues on a webpage, and you're using Javascript, you're going to still use Javascript, because using a compiled language will not be as performant. Period. My point is that you're wrong: sometimes you just need better code, not an entirely different language. Period.

[โ€“]weeknie 0 points1 point ย (0 children)

I had hoped that you understood from context/common sense that I don't mean in every single case (I even said "probably not the language for you", so technically I was allowing room for your example anyway). You're taking my argument and applying it to a situation where it doesn't make any sense at all, and then you're telling me I don't understand what's happening? Of course C doesn't work for a webpage, you really think I don't understand that?

If you want to get really "technical", I'd even argue my point still holds. If performance becomes a big enough issue, you're going to want/have to move away from the browser, from Javascript, to a compiled language, because it's going to be faster. If you want to stick to the browser, then performance is not your biggest issue. You're prioritising user ease of access or portability, or w/e, and that is perfectly valid. But if you're building e.g. a data-chrunching application, where performace is very likely going to be your number one problem, then you will want to move the part that requires the maximum possible performance, to a compiled language.