4 ms·
Everything here is pretty easily accomplished using vanilla Python (numpy counts as vanilla at this point). I'm having trouble seeing what the advantage is of a
by vlmutolo 5y ago
Everything here is pretty easily accomplished using vanilla Python (numpy counts as vanilla at this point). I'm having trouble seeing what the advantage is of an "array-based" language over a well-designed array library like numpy.
import numpy as np
from collections import Counter
print(2+2)
print(np.array([4,2,3]) + np.array([8,5,7]))
print(np.arange(1,11))
print(np.arange(1,100001).sum())
print(np.arange(1,11).prod())
avg = lambda x: x.sum() / x.shape[0]
print(avg(np.array([1, 6, 3, 4])))
throws = np.random.randint(1, 7, size=(10000,))
print((throws == 1).sum())
print(Counter(throws))
print(Counter("Mississippi"))
- busterarm 5y agoTerseness and composability. Here: https://medium.com/@jansson.sebastian/apl-in-the-eyes-of-a-python-programmer-7b1b955f7134 https://medium.com/@jansson.sebastian/apl-in-the-eyes-of-a-p...
- bombcar 5y agoIt's interesting how many programming languages seem to have "accessible to those not trained in it" as a design goal (offhand I can think of SQL and COBOL, but also BASIC and you see it even in Python, etc). But there are trade-offs doing that, and "amount you can look at at once" is a huge one.
- busterarm 5y ago"amount you can look at at once" is severely underestimated.
- yiyus 5y agoThis. What I find really annoying is how many people confuse this property ("accessible to those not trained in it") with readability.
- bombcar 5y agoIt's a shame, too, as the most "dense" recent language we had was perl and that got universally made fun of as "line noise" - which I feel influences people more than they think.
- b2gills 5y agoI also wonder how many people understand that linenoise meant noise on a data cable of some description. i.e. the difference between `d` and `$` is a single bit. If your cable happened to glitch during that first `1` bit, you would get a `$` instead of the `d` you should have. The thing is that doesn't happen anymore. Or at least when it does happen it gets caught and retransmitted. --- Which means that some of the first people to say it might not have been making a value judgement, but a statement of fact. (I doubt there was very many in that camp.) Note that I say that as a person who's second favorite language is Perl. (First favorite is Raku, formally known as Perl6.) It is too bad that most of coolest features have come to Perl after I switched to Raku.
- Grustaf 5y agoThe point is not _what_ you can achieve, but _how_. You can achieve almost anything in any language, but I bet you can’t implement Game of Life in 20 characters of Python!
- skruger 5y agoWhat about 17? {≢⍸⍵}⌺3 3∊¨3+0,¨⊢
- tzs 5y agoPeople like it for the same reason we like modern chess notation over older more verbose notation. Consider a game that starts with white moving their king side knight to the square in front of the pawn on the bishop's file. Here is how that would have been written through the ages [1]. Early 1600s: The white king commands his owne knight into the third house before his owne bishop. Mid-1700s: K. knight to His Bishop's 3d. Early 1800s: K.Kt. to B.third sq. Around 1850: K.Kt to B's 3rd. Around 1860: K.Kt to B. 3d. Around 1870: K.Kt to B3. Around 1890: KKt-B3. Early 1900s: Kt-KB3. Mid 1900s: N-KB3. Last quarter of 1900s to present: Nf3 or ♘f3 if you want to avoid language-specific piece names. Reading that numpy code compared to reading APL is like reading a record of a chess game from around 1700. [1] https://www.knightschessclub.org/the_history_of_notation.html https://www.knightschessclub.org/the_history_of_notation.htm...
- mamcx 5y agoExist power in being fully immerse in a paradigm. You can do OO on C, but still you are on C, that is not OO. You can do arrays on python, but python is not an array language. In other words, the moment you mix 2 paradigms, them will mismatch in direction of the most dominant one.