Poll

Do you like Python?

Yes, I love it.
22 (24.2%)
Yes, I like it.
24 (26.4%)
No, I don't like it
17 (18.7%)
No, I hate it.
14 (15.4%)
No opinion, indiferent
11 (12.1%)
I refuse to answer
3 (3.3%)

Total Members Voted: 90

Author Topic: Python becomes the most popular language  (Read 116060 times)

0 Members and 1 Guest are viewing this topic.

Offline PicuinoTopic starter

  • Super Contributor
  • ***
  • Posts: 1033
  • Country: es
    • Picuino web
Re: Python becomes the most popular language
« Reply #600 on: May 06, 2022, 07:45:46 am »
There is a general opinion that speed of execution is a fundamental parameter.
I believe that the increase in the use of Python is due precisely to the lesser importance of execution speed and the greater importance of the speed of development of both new programs and modifications of already created programs. This is where Python stands out by far.
Its ease of programming is not only something that neophytes take advantage of. It is a feature that professionals also take advantage of.
 

Online brucehoult

  • Super Contributor
  • ***
  • Posts: 4489
  • Country: nz
Re: Python becomes the most popular language
« Reply #601 on: May 06, 2022, 07:51:43 am »
Given equal speed of development, speed of execution matters.

Ruby and JavaScript are about as productive as Python.
 

Offline PKTKS

  • Super Contributor
  • ***
  • Posts: 1766
  • Country: br
Re: Python becomes the most popular language
« Reply #602 on: May 06, 2022, 08:04:26 am »
Ruby is better.. elegant  and with closures..  java sucks.. dog slow

Java was meant as a browser sort of engine


Btw. Python lack of closures sucks..
Paul
 

Online jfiresto

  • Frequent Contributor
  • **
  • Posts: 875
  • Country: de
Re: Python becomes the most popular language
« Reply #603 on: May 06, 2022, 08:08:49 am »
... Btw. Python lack of closures sucks..
Did you mean to write anonymous code blocks?

Python has had (late-binding) closures for many, many years, and since Python 3, generalized setting of up values.
-John
 

Offline Cerebus

  • Super Contributor
  • ***
  • Posts: 10576
  • Country: gb
Re: Python becomes the most popular language
« Reply #604 on: May 06, 2022, 10:00:09 am »
If we compare like-for-like, Python has mostly displaced languages like Perl (which I would say was the closest competitor, with the CPAN libraries and ubiquity), PHP and bash. It is a vast improvement on any of those, and I will fight anyone that tries to argue otherwise. The concept of scripting languages isn't going anywhere.

I like Ruby much more than Python. Unfortunately it hasn't gotten the same mindshare outside of a couple of web frameworks.

Modern Javascript is also better than Python, especially TypeScript. With v8 it also runs far far more quickly. It's for general scripting, not only in the browser. There are a huge number of libraries available in npm.

Ruby was very fashionable for a few years, you couldn't move for newly written things in Ruby, especially Ruby on Rails. It got mindshare, but it was transitory. There's no good reason for this, Ruby, as you suggest, was a much better general purpose language than several that have displaced it.

People who haven't kicked about for a good few years tend to discount the effect of fashions in computing. Anybody remember when 4GLs were the next big thing, the first time around that AI was going to be in everything, or more recently, blockchain (which is just another fancy name for a Merkle tree).
Anybody got a syringe I can use to squeeze the magic smoke back into this?
 

Offline Cerebus

  • Super Contributor
  • ***
  • Posts: 10576
  • Country: gb
Re: Python becomes the most popular language
« Reply #605 on: May 06, 2022, 10:04:42 am »
If we compare like-for-like, Python has mostly displaced languages like Perl (which I would say was the closest competitor, with the CPAN libraries and ubiquity), PHP and bash.

 :-DD

"displaced ... bash" - I don't think so. You put /usr/bin/python in place of /bin/bash in your /etc/passwd entry and let us know how you get on, if you ever recover from doing so.
Anybody got a syringe I can use to squeeze the magic smoke back into this?
 

Offline PicuinoTopic starter

  • Super Contributor
  • ***
  • Posts: 1033
  • Country: es
    • Picuino web
Re: Python becomes the most popular language
« Reply #606 on: May 06, 2022, 11:36:02 am »
Given equal speed of development, speed of execution matters.

Ruby and JavaScript are about as productive as Python.

I think Python is more productive because of the large number of libraries it has. There is no comparison.
Also the code is more maintainable in Python.
 

Online brucehoult

  • Super Contributor
  • ***
  • Posts: 4489
  • Country: nz
Re: Python becomes the most popular language
« Reply #607 on: May 06, 2022, 12:01:02 pm »
Given equal speed of development, speed of execution matters.

Ruby and JavaScript are about as productive as Python.

I think Python is more productive because of the large number of libraries it has. There is no comparison.

Python's PyPI has about 350,000 packages.

JavaScript's npm has about 1.3 MILLION packages.

I think you don't know what you're talking about when it comes to non-Python languages.

Quote
Also the code is more maintainable in Python.

Very much a matter of opinion.
 

Online voltsandjolts

  • Supporter
  • ****
  • Posts: 2423
  • Country: gb
Re: Python becomes the most popular language
« Reply #608 on: May 06, 2022, 12:11:45 pm »
JavaScript's npm has about 1.3 MILLION packages.

0.3 MILLION useful packages
1.0 MILLION rewrites of the above in someones 'favourite incompatible api strategy of the month'
 ;D
 
The following users thanked this post: newbrain, bd139

Offline PicuinoTopic starter

  • Super Contributor
  • ***
  • Posts: 1033
  • Country: es
    • Picuino web
Re: Python becomes the most popular language
« Reply #609 on: May 06, 2022, 12:28:13 pm »
As far as I can see JavaScript has libraries like Tensorflow for AI, libraries for web development, etc.
I didn't know JavaScript had such a lot of possibilities. I had always kept the language in the web page environment.

How to run JavaScript in command line?
 

Online brucehoult

  • Super Contributor
  • ***
  • Posts: 4489
  • Country: nz
Re: Python becomes the most popular language
« Reply #610 on: May 06, 2022, 12:45:40 pm »
How to run JavaScript in command line?

Install node.

Code: [Select]
Mac-mini:~ bruce$ echo 't=0;for (i=0; i<100000000; ++i) t+=i; console.log(t)' | time node
4999999950000000
        0.86 real         0.76 user         0.03 sys
Mac-mini:~ bruce$ (echo 't=0'; echo 'for i in range(100000000): t+=i'; echo 'print t') | time python
4999999950000000
       10.97 real         5.62 user         2.69 sys

Javascript doesn't have a nice range() function like Python, so I tried building one:

Code: [Select]
const range = (x,y) => (function*(){
  while (x < y) yield x++;
})();

let t = 0;
for (let i of range(1,100000000)) t += i;
console.log(t);

As you'd expect, it's a bit slower because of building an abstraction in the scripting language itself, not in the C implementation ...

Code: [Select]
Mac-mini:programs bruce$ time node speed.js
4999999950000000

real 0m2.503s
user 0m2.231s
sys 0m0.069s

But still four times faster than Python.
« Last Edit: May 06, 2022, 01:26:04 pm by brucehoult »
 
The following users thanked this post: emece67

Offline bpiphany

  • Regular Contributor
  • *
  • Posts: 133
  • Country: se
Re: Python becomes the most popular language
« Reply #611 on: May 06, 2022, 03:40:15 pm »
But the "correct" way to do it would be
Code: [Select]
~$ echo 't=0;for (i=0; i<100000000; ++i) t+=i; console.log(t)' | time node
4999999950000000
2.01user 0.14system 0:01.70elapsed 126%CPU (0avgtext+0avgdata 40276maxresident)k
1968inputs+0outputs (15major+3370minor)pagefaults 0swaps

~$ (echo 'print(sum(range(100000000)))') | time python3
4999999950000000
1.89user 0.00system 0:01.90elapsed 99%CPU (0avgtext+0avgdata 9408maxresident)k
0inputs+0outputs (0major+1137minor)pagefaults 0swaps

Edit: Or a bit faster
Code: [Select]
~$ echo 'import numpy as np; print(np.sum(np.arange(100000000)))' | time python3
4999999950000000
0.27user 0.59system 0:00.87elapsed 99%CPU (0avgtext+0avgdata 807240maxresident)k
0inputs+0outputs (0major+102682minor)pagefaults 0swaps
« Last Edit: May 06, 2022, 03:44:28 pm by bpiphany »
 

Offline emece67

  • Frequent Contributor
  • **
  • !
  • Posts: 614
  • Country: 00
Re: Python becomes the most popular language
« Reply #612 on: May 06, 2022, 03:58:04 pm »
.
« Last Edit: August 19, 2022, 05:27:37 pm by emece67 »
 

Online bd139

  • Super Contributor
  • ***
  • Posts: 23096
  • Country: gb
Re: Python becomes the most popular language
« Reply #613 on: May 06, 2022, 04:03:08 pm »
Oooh been away too long. I love these threads. Popcorn at the ready  :popcorn:

Python is absolutely fine for most things. If what you're doing is slow then you either should have written it in another language or screwed up the implementation.

Personally I mostly write Go now, which has certain advantages to it in the doing lots of things at the same department, but the time to market on Python, which is usually the marker of ROI, is by far the lowest of any platform I've had to work with.
 

Offline PicuinoTopic starter

  • Super Contributor
  • ***
  • Posts: 1033
  • Country: es
    • Picuino web
Re: Python becomes the most popular language
« Reply #614 on: May 06, 2022, 04:28:05 pm »
What a relief!  One more Python fan.  ;D
« Last Edit: May 06, 2022, 04:34:34 pm by Picuino »
 
The following users thanked this post: bd139

Offline PicuinoTopic starter

  • Super Contributor
  • ***
  • Posts: 1033
  • Country: es
    • Picuino web
Re: Python becomes the most popular language
« Reply #615 on: May 06, 2022, 04:34:06 pm »
Edit: Or a bit faster
Code: [Select]
~$ echo 'import numpy as np; print(np.sum(np.arange(100000000)))' | time python3
4999999950000000
0.27user 0.59system 0:00.87elapsed 99%CPU (0avgtext+0avgdata 807240maxresident)k
0inputs+0outputs (0major+102682minor)pagefaults 0swaps
Let's see if JavaScript has the same libraries for parsing and manipulating large amounts of data ...

Perhaps this?  https://github.com/nicolaspanel/numjs
« Last Edit: May 06, 2022, 04:35:50 pm by Picuino »
 

Online bd139

  • Super Contributor
  • ***
  • Posts: 23096
  • Country: gb
Re: Python becomes the most popular language
« Reply #616 on: May 06, 2022, 04:35:58 pm »
Let's see if JavaScript has the same libraries for parsing and manipulating large amounts of data ...

It does, but it'll take 500 hours to resolve the npm dependency chart and install several pieces of malware in the process...
 

Online brucehoult

  • Super Contributor
  • ***
  • Posts: 4489
  • Country: nz
Re: Python becomes the most popular language
« Reply #617 on: May 07, 2022, 03:07:19 am »
But the "correct" way to do it would be
Code: [Select]
~$ echo 't=0;for (i=0; i<100000000; ++i) t+=i; console.log(t)' | time node
4999999950000000
2.01user 0.14system 0:01.70elapsed 126%CPU (0avgtext+0avgdata 40276maxresident)k
1968inputs+0outputs (15major+3370minor)pagefaults 0swaps

~$ (echo 'print(sum(range(100000000)))') | time python3
4999999950000000
1.89user 0.00system 0:01.90elapsed 99%CPU (0avgtext+0avgdata 9408maxresident)k
0inputs+0outputs (0major+1137minor)pagefaults 0swaps

Edit: Or a bit faster
Code: [Select]
~$ echo 'import numpy as np; print(np.sum(np.arange(100000000)))' | time python3
4999999950000000
0.27user 0.59system 0:00.87elapsed 99%CPU (0avgtext+0avgdata 807240maxresident)k
0inputs+0outputs (0major+102682minor)pagefaults 0swaps

You could argue that you should always know what is "the Pythonic way" and always do that.

But I like languages where even if you do things the wrong way, the long-winded way, build up everything yourself from first principles rather than knowing the right library or function to use ... it's still damned fast.

Interestingly, if I use Python more like the JavaScript then it's actually a bit faster:

Code: [Select]
Mac-mini:programs bruce$ (echo 't=0;i=0'; echo 'while i<100000000: t+=i;i+=1'; echo 'print t') | time python
4999999950000000
        6.75 real         6.30 user         0.09 sys

Suggesting that the Python range() is not a generator like the one I built in JavaScript, but actually creates an array.

I also find it annoying that (as far as I know) there is absolutely no way to put the Python on a single line.

Well, ok, turns out you can tell echo (at least some versions) to allow embedding newlines:

Code: [Select]
$ echo -e 't=0;i=0\nwhile i<100000000: t+=i;i+=1\nprint t' | time python
4999999950000000
        7.31 real         6.55 user         0.11 sys
 

Online brucehoult

  • Super Contributor
  • ***
  • Posts: 4489
  • Country: nz
Re: Python becomes the most popular language
« Reply #618 on: May 07, 2022, 04:02:55 am »
Edit: Or a bit faster
Code: [Select]
~$ echo 'import numpy as np; print(np.sum(np.arange(100000000)))' | time python3
4999999950000000
0.27user 0.59system 0:00.87elapsed 99%CPU (0avgtext+0avgdata 807240maxresident)k
0inputs+0outputs (0major+102682minor)pagefaults 0swaps

numpy is cool and all, but I feel like I've seen it somewhere before, but more concisely...

Code: [Select]
# numpy
 a = np.array( [[1,1], [0,1]] )
 b = np.array( [[2,0], [3,4]] )
 # elementwise product
 a * b
 
 NB. J
 a =. 1 1 ,: 0 1
 b =. 2 0 ,: 3 4
 a * b
 
 # numpy - matrix product
 np.dot(a, b)
 
 NB. J - matrix product
 a +/ . * b 
 
 # numpy - uniform pseudo random
 a = np.random.random( (2,3) )
 
 NB. J - uniform pseudo random
 a =. ? 2 3 $ 0
 
 # numpy - sum all array elements - implicit ravel
 a.sum(a)
 
 NB. J - sum all array elements - explicit ravel
 +/ , a
 
 # numpy
 b = np.arange(12).reshape(3,4)
 # sum of each column
 b.sum(axis=0)
 # min of each row
 b.min(axis=1)
 # cumulative sum along each row
 b.cumsum(axis=1)
 # transpose
 b.T     
 
 NB. J
 b =. 3 4 $ i. 12
 NB. sum of each column
 +/ b
 NB. min of each row
 <./"1 b
 NB. cumulative sum along each row
 +/\"0 1 b
 NB. transpose
 |: b

Not to mention the 60 year old version of this that used hieroglyphics on a special keyboard.
 
The following users thanked this post: bd139

Online jfiresto

  • Frequent Contributor
  • **
  • Posts: 875
  • Country: de
Re: Python becomes the most popular language
« Reply #619 on: May 07, 2022, 06:43:59 am »
... Suggesting that the Python range() is not a generator like the one I built in JavaScript, but actually creates an array....
In Python 2, range() returns a list and xrange() returns an iterable [object].

In Python 3, range() returns an iterable as that is what most usually want.
« Last Edit: May 07, 2022, 06:46:37 am by jfiresto »
-John
 

Offline kjpye

  • Contributor
  • Posts: 36
  • Country: au
Re: Python becomes the most popular language
« Reply #620 on: May 07, 2022, 07:51:59 am »
Edit: Or a bit faster
Code: [Select]
~$ echo 'import numpy as np; print(np.sum(np.arange(100000000)))' | time python3
4999999950000000
0.27user 0.59system 0:00.87elapsed 99%CPU (0avgtext+0avgdata 807240maxresident)k
0inputs+0outputs (0major+102682minor)pagefaults 0swaps
Or you could use the language everybody complains about being slow:

Code: [Select]
> /usr/bin/time raku -e "say [+] ^100000000"
4999999950000000
0.14user 0.02system 0:00.13elapsed 123%CPU (0avgtext+0avgdata 115768maxresident)k
0inputs+0outputs (0major+6745minor)pagefaults 0swaps
and most of that time is raku startup (one of the places where it is slow):
Code: [Select]
> /usr/bin/time raku -e ""
0.13user 0.00system 0:00.11elapsed 121%CPU (0avgtext+0avgdata 112340maxresident)k
0inputs+0outputs (0major+6023minor)pagefaults 0swaps
(and cpu usage greater than 100% is perfectly normal)
 

Offline emece67

  • Frequent Contributor
  • **
  • !
  • Posts: 614
  • Country: 00
Re: Python becomes the most popular language
« Reply #621 on: May 07, 2022, 09:24:02 am »
.
« Last Edit: August 19, 2022, 05:27:31 pm by emece67 »
 

Online bd139

  • Super Contributor
  • ***
  • Posts: 23096
  • Country: gb
Re: Python becomes the most popular language
« Reply #622 on: May 07, 2022, 09:36:07 am »
Throw some proper language in...

Code: [Select]
package main

import (
"fmt"
)

func main() {
n := 0
for i := 0; i < 100000000; i++ {
n += i
}
fmt.Println(n)
}

Compile to native arm64 / run cycle

Code: [Select]
scratch % time go run loop.go
4999999950000000
go run loop.go  0.15s user 0.12s system 94% cpu 0.284 total

Compile to native arm64 then run again

Code: [Select]
scratch % go build loop.go
scratch % time ./loop     
4999999950000000
./loop  0.06s user 0.00s system 47% cpu 0.130 total

Target

Code: [Select]
scratch % uname -a
Darwin anubis 21.4.0 Darwin Kernel Version 21.4.0: Fri Mar 18 00:46:32 PDT 2022; root:xnu-8020.101.4~15/RELEASE_ARM64_T6000 arm64

This is actually easier to write (thanks to VScode), typed so far far far easier to rationalise bits, fast compile, fast execution, builds zero dependency native binaries for any platform from any platform. Everything else can bugger off  :-DD
« Last Edit: May 07, 2022, 09:41:48 am by bd139 »
 

Offline madires

  • Super Contributor
  • ***
  • Posts: 8144
  • Country: de
  • A qualified hobbyist ;)
Re: Python becomes the most popular language
« Reply #623 on: May 07, 2022, 10:20:47 am »
Edit: Or a bit faster
Code: [Select]
~$ echo 'import numpy as np; print(np.sum(np.arange(100000000)))' | time python3
4999999950000000
0.27user 0.59system 0:00.87elapsed 99%CPU (0avgtext+0avgdata 807240maxresident)k
0inputs+0outputs (0major+102682minor)pagefaults 0swaps

Fun fact: NumPy is mosty C. >:D
 

Online bd139

  • Super Contributor
  • ***
  • Posts: 23096
  • Country: gb
Re: Python becomes the most popular language
« Reply #624 on: May 07, 2022, 10:33:13 am »
Well python is basically a way to cheaply glue bits of C together so yeah.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf