Earlier quoted context omitted.
Another of my favorites -- this was fun in middle school (years 6-8) when I had a spare minute or two to sit down at a random computer (maybe in a computer lab). 10 SCREEN 9 20 CLS 30 COLOR 1, INT(RND*10) 40 SOUND 20+(RND*5000),.2 50 GOTO 30 The effect is rather striking, like someone must have really messed up the computer. My main gripe with Windows NT was that it would go back to the NT screen saver -- I couldn't…
How would you do this on macOS with just the built-in Python or Ruby?
macOS deprecating scripting language runtimes, including Python, Ruby, and Perl
441–450 of 450 posts
Re: macOS deprecating scripting language runtimes, including Python, Ruby, and Perl
#442Earlier quoted context omitted.
> What kind of cool things do you envision the curious beginner to write, using only the current preinstalled Python/Ruby/perl, that they can't do with the remaining interpreters that I mentioned? What about the iconic 4th grader "greetings and cool things" script? Here's something like what it looked like for me (on the IBM PC in my classroom): 5 CLS 7 RANDOMIZE TIMER 10 PRINT "Hello there. I'm a computer. What is y…
clear echo "Hello there. I'm a computer. What's your name?" read G echo "Hello $G. You are welcome to computer land." while true do echo "" echo "What would you like to do today?" echo "1) Say something random" echo "2) Make a maze" echo "3) Exit" echo "Enter your selection" read S if [ "$S" = "1" ]; then say $( head -n $((7*RANDOM)) /usr/share/dict/words | tail -n 1 ) elif [ "$S" = "2" ]; then for i in {1..3000}; do…
I still contend that Ruby and Python are far more accessible than shell scripting, because they are very popular, especially Python, cross-platform, and less arcane.
Re: macOS deprecating scripting language runtimes, including Python, Ruby, and Perl
#443Earlier quoted context omitted.
Yup but OSX has a tonne of C (and unfortunately C++) APIs. But yeah having most of the system apis being in a language that has built in dynamic resolution makes a world of difference in the difficulty of maintaining abi compat
Publicly exposed? Most of CoreFoundation and the other C APIs vend objects that are entirely opaque, and there are very few actual C++ APIs that I'm aware of–though many are written in (Objective-)C++ internally.
struct APIFoo { int a_field; }
void do_something(struct APIFoo* argument);
later on we add a new field, and that becomes:
struct APIFoo { int a_field; int new_field; }
For API compatibility you just need the source level field names to remain, and to remain the same type. But for ABI compatibility - e.g a existing compiled program - the fields must remain in the same location, so you can only add members to the end, and you can't change the alignment or padding rules.
What remains is how the API implementation knows if the argument is the size of the old api, or the new one.
The Microsoft API idiom is to have a size field that you initialize to sizeof(APIFoo). This means when you recompile you code against a more recent version of the API you'll get a modern sized struct. My feeling has always been that this approach is more fragile, as you can unintentionally increase the struct without initializing the new members. Apple APIs that need it tend to use an explicit version number, so you have to explicitly say that you know which fields you want to update - as an example you can look up JSClassDefinition (IIRC) in JavaScriptCore.
The other thing that Apple APIs will do is use a linked-on-or-after check: basically the macOS and iOS include metadata about the system version that a library or application was compiled to target. This is generally used to control legacy behaviour to handle cases where some internal logic leaked across an encapsulation boundary but the behaviour that was leaked is simply too awful to retain in general, and in the worst of worst cases code may include explicit tests for what the current application is (you can see a bunch of these in the WebKit codebase). Microsoft accomplishes similar tasks using (I think they're called) compatibility shims.
You are right however that the actual objects you get returned in macOS and iOS APIs are basically all opaque objects - looking at the JSC example, the actual API objects are opaque: so JSClassMake() takes a pointer to a JSClassDefinition, and returns an opaque JSClassRef that provides the actual API object you use to create objects.
As for C++: I would suggest you look at the nightmare that is IOKit. That's right, the kernel driver APIs are in C++. Because NEXT wrote that code in the 90s, when C++ was considered the perfect solution to all problems (e.g. before people really understood how hard C++ makes ABI compatibility)
Re: macOS deprecating scripting language runtimes, including Python, Ruby, and Perl
#444Earlier quoted context omitted.
It’s part of why companies like Apple and Microsoft care so much about backwards compat Compared to (former) Microsoft, I don't think Apple spends anywhere near the amount of effort MS does on backwards compatibility. You can create a single .exe that will work on any Windows starting from Windows 95 - nearly 25 years. In that timespan, Apple changed CPU architectures twice, and their OS architecture once. If you're…
32 bit Windows binaries will even run on the ARM version of Windows.
The difference is that after a while Apple is willing to deprecate things. Versus a lot of open source projects that don't guarantee any stability at all, even across minor version increments. That's the problem that makes them dangerous for platforms like macOS and iOS to expose them as public API (intentionally or unintentionally - my understanding is for instance that the system openSSL was accidentally exposed publicly - and that took most of a decade to remove from the OS, e.g. most of a decade of shipping an increasingly old Frankenstein branch of openSSL)
Re: macOS deprecating scripting language runtimes, including Python, Ruby, and Perl
#445Earlier quoted context omitted.
And rather than just accepting that was what you had and accepting that you occasionally had to deal with that (as JavaScript did), they decided to cause a decade of problems that aren’t going to go away just because they’ve now declared python 2.7 dead.
Because of that, Javascript is now a pile of accumulated technical debt and it one of the worst language you can dev in. Hell, it has no type and still 4 ways to declare a variable. In fact it's so terrible the most popular JS projects are actually project to avoid writing JS or emulate features that don't exist in one JS implementation or another (typescript, babel, JSX, webpack, polyfills, etc)
And yeah, JS has some old crufty things, but it also has the ability to do things nicely now. No one is forced to use old syntax, and most new code does not, but because those features have not been unilaterally removed there has not been anything like the problems python3 has produced.
Seriously: what new syntax in python three necessitated breaking python2 compatibility? Even your string example is weird because JS allows arbitrary invalid ucs2/utf16 strings despite adding actual unicode compatible APIs.
Re: macOS deprecating scripting language runtimes, including Python, Ruby, and Perl
#446Probably the right call - many of them don’t have abi or api stability guarantees, or in the case of python needlessly broke backwards compatibility that is still causing pain today. Apple used to ship an incredibly old version of OpenSSL because people used its API which was not ABI stable. Even getting rid of it was a nontrivial amount of work. The lack of care about API&ABI stability in developer facing open sourc…
I don't know if I completely buy into that argument. API's on the bleeding edge are often prone to breakage because the development frontier is in constant flux. However, software that neglects to update also tends to breakdown as libraries change to reflect new knowledge. If you're developing software based on someone else's library you are implicitly accepting the demand to modify your software to maintain currency…
You can make APIs that are ABI stable (literally that's the entirety of the Microsoft and Apple platform APIs, and plenty of open source libraries as well - Qt and GTK for instance). You can also explicitly choose not to (which I believe includes OpenSSL).
Basically if a library or application is not or cannot provide a stable ABI, it cannot be used be a platform where the default update model does not include the possibility of recompiling all software. Essentially such a model would require Apple and Microsoft to have the source for all apps, and be the primary/only distribution point for all of them as well - note that this is host most linux distributions operate: any given update can result in an arbitrarily large portion of all software for the system being recompiled.
Re: macOS deprecating scripting language runtimes, including Python, Ruby, and Perl
#447Earlier quoted context omitted.
clear echo "Hello there. I'm a computer. What's your name?" read G echo "Hello $G. You are welcome to computer land." while true do echo "" echo "What would you like to do today?" echo "1) Say something random" echo "2) Make a maze" echo "3) Exit" echo "Enter your selection" read S if [ "$S" = "1" ]; then say $( head -n $((7*RANDOM)) /usr/share/dict/words | tail -n 1 ) elif [ "$S" = "2" ]; then for i in {1..3000}; do…
You do have a point - that's not too bad, but to my eyes it's still more arcane than Python and Ruby (spoken as someone who has written less than 30 shell scripts in my life). I still contend that Ruby and Python are far more accessible than shell scripting, because they are very popular, especially Python, cross-platform, and less arcane.
import os
import random
import sys
os.system("clear")
print "Hello there. I'm a computer. What's your name?"
G = raw_input()
print "Hello " + G + ". You are welcome to computer land."
while True:
print ""
print "What would you like to do today?"
print "1) Say something random"
print "2) Make a maze"
print "3) Exit"
print "Enter your selection"
S = raw_input()
if S == "1":
F = open("/usr/share/dict/words").readlines()
W = random.choice(F)
os.system("say {}".format(W))
elif S == "2":
for i in range(1, 3000):
if random.random()>0.5:
sys.stdout.write("/")
else:
sys.stdout.write("\\")
elif S == "3":
print "Bye."
exit()
else:
print "Try again."
It looks like a tossup to me, all 3 versions have their own share of magic that will confuse the beginner. I say this as someone who reads and writes a lot more python than bash daily.Re: macOS deprecating scripting language runtimes, including Python, Ruby, and Perl
#448Only problem is security: with multiple applications including their own dependencies, some of those dependencies will lag behind in their security updates. You can't just get a single fix for your Python run-time and fix it in all applications at once.
Re: macOS deprecating scripting language runtimes, including Python, Ruby, and Perl
#449Earlier quoted context omitted.
Publicly exposed? Most of CoreFoundation and the other C APIs vend objects that are entirely opaque, and there are very few actual C++ APIs that I'm aware of–though many are written in (Objective-)C++ internally.
There are plenty of APIs that have structs in their interface, although they are always passed by reference so that the structs can increase in size, while still retaining compatibility with old software, e.g. struct APIFoo { int a_field; } void do_something(struct APIFoo* argument); later on we add a new field, and that becomes: struct APIFoo { int a_field; int new_field; } For API compatibility you just need the so…
Re: macOS deprecating scripting language runtimes, including Python, Ruby, and Perl
#450Earlier quoted context omitted.
It's not a good thing or a bad thing. I'm saying it's not a thing at all. If someone decides they want to run a custom ruby or python script the least difficult aspect of that decision is installing the interpreter. For example, I was dealing with someone yesterday who decided they wanted to learn how to write apps for Android. Without even seeing a single line of code (or even knowing which language they would have…
Lots of people on just this thread, who have far more than a glancing interest, have expressed their disagreement with this exact idea. The hardest part for lots of people in learning to program is getting over the idea that programming is for Special People, or possibly Wizards, who know lots of incantations which are beyond mere mortals. Please stop trying to convince them they're right. Source: I've taught lots of…
Installing the interpreter is nothing special. It should be taught as such.