Python vs JavaScript language features

it would be nice if instead js decided to use like destructure syntax to get both at the same time.
I just figured out you can actually do something similar like this:

for (let [index, value] of ["A", "B", "C"].entries()) {
    console.log(index, value);
}
1 Like

The thing that make js liked (and in my case hated) is that its semantics is enriched by stealing constructs from whatever language with the only goal to make this the one-for-all language.

1 Like

BTW to make things more fun in python is now possible to also do:

i = 0
while (i := i + 1)<10:
  pass

That also works in many other languages including JS:

let i = 0;
while ((i = i + 1) < 10) {
  
}
1 Like

Sure, but in python this is only possible since ( think) 3.8 and most people are not aware of it or fail to understand how it works :slight_smile:

2 Likes

Or:

let i = 0;
while (++i < 10) {

}
4 Likes

NodeJS is considerably faster than Python, at least on Replit.

5 Likes

I wouldn’t necessarily say that; it seems that all languages on Replit run at similar speeds.

1 Like

now it’s time for the c-family enjoyers to say

ahcktually c is much faster than node :nerd_face: and you can technically run WSGI/UWSGI servers on it with 47 different files, 40k lines of code, and 400 gigs of memory

1 Like

No. I can prove that Python is slower. These both do the same thing and the Python one is unusable on Replit (note that I did not make the JS one; I found it on the internet).
https://replit.com/@CoderElijah/ASCII-Movie
https://replit.com/@CoderElijah/Star-Wars-1
Can someone move this to a topic about Python VS NodeJS?

5 Likes

JS is generally faster than Python, no matter where.

6 Likes

ahem you’re forgetting c

I compared C++ and Python and although most people say C++ is supposed to be faster, Python actually ended up being faster, with C++ being slow because of all the compile time.

6 Likes

Well yeah compilers are slower than interpreters

5 Likes

… of… course? c++ is about 10x faster than python since you can just compile the code before hand and spam run that – replit recompiles but you don’t need to if code doesn’t change

5 Likes

NextJS with RUI takes like 2mins to compile :noooooooooooooooooo:

2 Likes

Compile time does not count, speed matters only at execution time.

9 Likes

Adding onto this, compile time doesn’t matter from the users’ standpoint due to the fact your program’s files are generally precompiled before being provided to the user, so the user wouldn’t have to download a compiler themselves.

As far as simplicity though, if all you want to do is develop, testing C++ is usually slower than simply invoking the Python interpreter.

7 Likes

You do have to consider what were you doing, because most of Python’s libs are written in C++

2 Likes

CSS is the fastest, Painting is key.

1 Like