{"id":34227,"date":"2021-11-22T16:35:55","date_gmt":"2021-11-22T21:35:55","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=34227"},"modified":"2021-11-26T14:55:11","modified_gmt":"2021-11-26T19:55:11","slug":"the-unexpected-return-of-javascript-for-automation","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2021\/11\/22\/the-unexpected-return-of-javascript-for-automation\/","title":{"rendered":"The Unexpected Return of JavaScript for Automation"},"content":{"rendered":"<p><a href=\"https:\/\/scriptingosx.com\/2021\/11\/the-unexpected-return-of-javascript-for-automation\/\">Armin Briegel<\/a>:<\/p>\n<blockquote cite=\"https:\/\/scriptingosx.com\/2021\/11\/the-unexpected-return-of-javascript-for-automation\/\">\n<p>One reason python became so popular with MacAdmins, was that the pre-installed python on Mac OS X, also came with PyObjC, the Objective-C bridge for python.<\/p>\n<p>[&#8230;]<\/p>\n<p>I&rsquo;ll be honest here and admit that working with JXA seems strange, inconsistent, and &mdash;&nbsp;in weird way &mdash; like a step backwards. Putting together <a href=\"https:\/\/scriptingosx.com\/2021\/11\/monterey-python-and-free-disk-space\/\">a Command Line Tool written in Swift<\/a> feels like a much more <em>solid<\/em> (for lack of a better word) way of solving a problem.<\/p>\n<p>However, the Swift binary command line tool has one huge downside: you have to install the binary on the client before you can use it in scripts and your management system.<\/p>\n<p>[&#8230;]<\/p>\n<p>However, as flawed as it is, JXA can be a simple replacement for the classic python &ldquo;one-liners&rdquo; to get data out of a macOS system framework. Other interesting use cases are being discovered, <a href=\"https:\/\/www.macblog.org\/posts\/how-to-parse-json-macos-command-line\/\">such as JSON parsing<\/a>.<\/p>\n<\/blockquote>\n<p>Python is no longer the favored choice because &ldquo;Monterey will now throw up dialogs warning the user.&rdquo;<\/p>\n<p>AppleScriptObjC is built-in, however.<\/p>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2021\/11\/05\/diskspace-tool-to-report-apfs-free-space\/\">diskspace Tool to Report APFS Free Space<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2021\/08\/26\/jsc\/\">jsc<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2019\/06\/04\/scripting-languages-to-be-removed\/\">Scripting Languages to Be Removed<\/a><\/li>\n<\/ul>\n\n<p id=\"the-unexpected-return-of-javascript-for-automation-update-2021-11-26\">Update (2021-11-26): See also: <a href=\"https:\/\/news.ycombinator.com\/item?id=29327349\">Hacker News<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>Armin Briegel: One reason python became so popular with MacAdmins, was that the pre-installed python on Mac OS X, also came with PyObjC, the Objective-C bridge for python. [&#8230;] I&rsquo;ll be honest here and admit that working with JXA seems strange, inconsistent, and &mdash;&nbsp;in weird way &mdash; like a step backwards. Putting together a Command [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2021-11-22T21:35:58Z","apple_news_api_id":"8bdca3a4-d276-433c-ba9c-dfd2298374e4","apple_news_api_modified_at":"2021-11-26T19:55:14Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAAQ==","apple_news_api_share_url":"https:\/\/apple.news\/Ai9yjpNJ2Qzy6nN_SKYN05A","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[2],"tags":[650,346,1072,30,2077,635,232],"class_list":["post-34227","post","type-post","status-publish","format-standard","hentry","category-technology","tag-applescriptobjc","tag-javascript","tag-javascript-for-automation","tag-mac","tag-macos-12","tag-pyobjc","tag-python"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/34227","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=34227"}],"version-history":[{"count":3,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/34227\/revisions"}],"predecessor-version":[{"id":34292,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/34227\/revisions\/34292"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=34227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=34227"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=34227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}