|
Post by Tomaaz on Aug 6, 2019 15:17:47 GMT -6
Why should I not use Python standard library that's been written to be used with Python??? These are not some "external libraries written in C". There are external modules written by Python developpers and dedicated to be used with Python - docs.python.org/3/library/index.html . As you can see, no one is hiding the fact that some of these modules are written in C. Who cares, as long as they get the job done? And here is Python in a simple loop. Still faster than majority (all?) of BASIC interpreters (try AllegroBasic, ha ha ha!): Primes: import math for x in range(3, 1000000, 2): isprime = 1 for y in range(3, int(math.sqrt(x)), 2): if x % y == 0: isprime = 0 break if isprime == 1: print(x)
Pi: import sys n, a, b, e = 35001, 10000, 0, 0 f = [] for x in range(n): f.append(2000) for c in range(n - 1, 14, -14): d = 0 for b in range(c, 0, -1): d = d * b g = b * 2 - 1 d = d + f[b] * a f[b] = d % g d = d // g k = e + d // a print(k, end="") e = d % a sys.stdout.flush()
|
|
|
Post by Tomaaz on Aug 6, 2019 15:51:31 GMT -6
In Ruby or Perl, to use regular expressions, you don't have to import anything. Does it make a difference? In all BASIC dialects sqr() is a part of the core language. In Python it isn't - you need to import a module to use it. In both cases there is a pre-compiled C code behind sqr/sqrt, so what are you talking about Aurel?
|
|
|
Post by n00b on Aug 6, 2019 19:11:14 GMT -6
Hey Tomaaz. You bring up some valid points on python. But you also inadvertently made a case for BASIC.
If speed was the only factor in choosing a programming language then everyone would be using C/C++. And while python is mostly a simple language, its use of external libs can add unnecessary complexity for writing simple programs. Python programs can also be difficult to distribute due to needing to reference those external libs.
Like you said, BASIC's standard library is built-in which is its biggest strength over other languages in my opinion. And it also makes distributing your programs much easier as well.
This is not an argument for which one is better. I actually use both python and BASIC alot at work. They are both tools and sometimes one is just better for the job.
|
|
|
Post by Tomaaz on Aug 7, 2019 10:23:30 GMT -6
Well, I don't know. In BASIC standard library is usually very compact. You can't do much with it without reinventing the wheel. And is distributing BASIC programs really that easy? If I'm not mistaken (forgive me, if I am) you still need to include all required SDL libraries (written in C) with RCBasic programs. NaaLaa is a different story, because Marcus has written everything from scratch and it has almost no ependencies at all. For Tcl/Tk programs you can use Freewrap. It will bind your code with Tcl, Tk and Tcllib and create a single executable. There is also Appimage format, but again it's all about including all external dependencies in a single executable, not about creating interpreter that comes with everything built-in. LOVE (a game engine for Lua) has an Appimage ready to download and it comes with everything - Luajit and all libraries required for a 2d game engine, but, of course, with not all libraries available for Lua/Luajit.
|
|
|
Post by n00b on Aug 7, 2019 12:05:58 GMT -6
I am not referring to Dlls. I am talking more about package dependencies. For instance if you have a Qt app you would need to bundle Qt plus all the dependancy libs Qt has with it. There are tools like py2exe that attempt to solve that problem but in my experience it doesn't work that well. But when it does work you could end up with a much smaller application so there is definitely a lot more flexibility with python on that.
I mentioned that I use python regularly at work so I do appreciate what its capable of. But I also use Visual Basic alot as well. I never found 1 to be definitively better.
If you are just looking at speed, python can do a number of things pretty fast but so can most BASIC interpreters today. If you are looking at modern features then python has BASIC beat. If you look at whats just the best then that is always going to be a matter of personal taste.
|
|
|
Post by Tomaaz on Aug 7, 2019 12:57:20 GMT -6
I have zero experience with Qt, so forgive my ignorance, but I fail to understand what has Python to do with your example. Would it be different with Ruby, Perl or even BASIC if someone managed to use it with Qt? I'm not a Pythonista. I don't even like Python that much, but all this "Python is slow and crap..." is really annoying. It isn't. It gets the job done, millions use it everyday and sorry Aurel - there is no conspiracy behind it.
|
|
|
Post by eyfenna on Aug 8, 2019 8:44:43 GMT -6
Okay I'm suprised as reading some postings made me think "here a Pythonangelist appeared"
Overall I tend to agree with n00b programming languages are tools, and their use depends on various factors one being taste of the programmer.
Second I think sooner or later we see the visual coding paradigma wash over the land, replacing the "pure typing in words"with "drawing symbols and naming or filling them with alphanumerical or numerical characters" ... afterall we humans are visual oriented beings. When that will be I honestly don't realy care, it is going to be a lot of decades in the future.
|
|
|
Post by Tomaaz on Aug 8, 2019 9:58:30 GMT -6
Me? Pythonista? Ha ha ha! I was just replaying to the "Python is slow" nonsense (because I know it isn't and the fact that I don't like Python that much doesn't change anything here). And speed of languages is not really a matter of taste. Everybody can run those two simple examples I posted a couple of posts before, convert them to BASIC and then compare the results. Shouldn't take more than 15 min.
|
|
|
Post by n00b on Aug 9, 2019 13:04:40 GMT -6
Hey Tomaaz, Your example will technically run faster in python than RCBasic but it is not necessarily python is faster. If you run the examples you gave with floating point numbers you will discover that RC is actually faster.
|
|
|
Post by Tomaaz on Aug 9, 2019 15:13:14 GMT -6
If you run this example with floats RCBasic will run faster, but it doesn't mean that RCBasic is faster. If you run this example with ints, Python will run faster. Can we finally agree that Python is not the slowest language around? BTW I like fractals, but I couldn't use Python to calculate them, because guess what - it's to slow. But all BASIC interpreters are either. Go, FreeBASIC, Luajit and JavaScript are much better choice.
|
|
|
Post by n00b on Aug 9, 2019 15:59:24 GMT -6
I have said a few times that I don't actually have a problem with python. I think its a great language.
I just wanted to point out why your example was faster in python the way you wrote it. RCBasic does not have integers. Every number is stored as a double. RCBasic is specifically designed for simplicity so it was a trade off that I made when building the parser.
I know several languages and while I do personal like some more than others, I can't tell someone that what they choose to use is bad if it does what they need it to.
|
|
|
Post by tbird on Aug 9, 2019 19:08:04 GMT -6
If you run this example with floats RCBasic will run faster, but it doesn't mean that RCBasic is faster. If you run this example with ints, Python will run faster. Can we finally agree that Python is not the slowest language around? BTW I like fractals, but I couldn't use Python to calculate them, because guess what - it's to slow. But all BASIC interpreters are either. Go, FreeBASIC, Luajit and JavaScript are much better choice. Funny thing is your making an argument that no one is arguing lol. Your having an argument with aurel, everyone is talking about personal preference.....your on a BASIC forum....surprise. No one else has an issue with Python speed, even the op asked "Is Python Slow" not stated "Python is slow". Python may be a poor choice for some devs here, but speed wasn't brought up, well except for one user 😜
|
|
|
Post by johnno56 on Aug 9, 2019 20:11:31 GMT -6
Reginald Maudling has a hedgehog called Frank.
|
|
|
Post by tbird on Aug 9, 2019 20:21:35 GMT -6
Reginald Maudling has a hedgehog called Frank. The perfect way to end a thread...oops I ruined it 😔
|
|
|
Post by Python on Aug 10, 2019 3:16:22 GMT -6
Since tbird has already destroyed johno's perfect ending, here is another post from me. Tbird, I posted my opinion first and everything after that was my answer to people arguing with me. For some reason, my defence of Python did make you well... upset. I wasn't talking to myself, you know...
|
|