digitalmars.D.announce - Article: Why I use the D programming language for scripting
- aberba (2/2) Jan 31 2021 It's finally out!
- Steven Schveighoffer (5/8) Jan 31 2021 Hm... right off I see the shebang is not the first line in the example.
- Bastiaan Veelo (5/11) Feb 01 2021 Please fix, Aberba, right now the examples don't work because of
- aberba (5/17) Feb 01 2021 Yes, noted. I don't have direct access to edit it myself. I have
- Petar Kirov [ZombineDev] (4/25) Feb 01 2021 Perhaps we can create a channel on the dlang Slack for
- drug (2/26) Feb 01 2021 That's a really good idea!
- Petar Kirov [ZombineDev] (3/10) Feb 01 2021 I just created #article-proofreading - everyone is welcome to
- drug (2/4) Feb 01 2021 How can I join? I used slack once for a short period some time ago.
- Petar Kirov [ZombineDev] (4/10) Feb 01 2021 Any dlang slack member can invite new members by their email (I
- drug (2/13) Feb 01 2021 sent directly
- sighoya (3/6) Feb 01 2021 Is there any PM mechanism on board, no?
- Petar Kirov [ZombineDev] (2/8) Feb 01 2021 You mean does Slack have private messages? Yes it does.
- sighoya (8/11) Feb 02 2021 No I meant, if this board has such options, don't like to paste
- Walter Bright (2/5) Jan 31 2021 Very nice and informative article!
- Jon Degenhardt (4/6) Jan 31 2021 Very nice! Clearly I'm not taking enough advantage of scripting
- sighoya (3/5) Jan 31 2021 Thanks for your work, nice article, I wasn't even aware how easy
- Jacob Carlborg (6/8) Feb 01 2021 FYI, the code will compile faster if you use `dmd -run` instead
- Paul Backus (3/12) Feb 01 2021 Unfortunately, you can't pass more than one command-line argument
- Petar Kirov [ZombineDev] (19/34) Feb 01 2021 It is possible, using `/usr/bin/env -S command arg1 arg2` , as of
- Paul Backus (5/13) Feb 01 2021 This is great, thanks!
- Petar Kirov [ZombineDev] (8/22) Feb 01 2021 Yes, I think it's safe to use on Linux nowadays. In the worst
- Marcone (4/6) Feb 01 2021 D lang is life! I used Python for scripting, but D lang is
- =?UTF-8?B?0JLQuNGC0LDQu9C40Lkg0KTQsNC0?= =?UTF-8?B?0LXQtdCy?= (44/46) Feb 01 2021 If the article is about scripting, then the article will contain
- =?UTF-8?B?0JLQuNGC0LDQu9C40Lkg0KTQsNC0?= =?UTF-8?B?0LXQtdCy?= (30/37) Feb 01 2021 Remove dub cache in subsirectories:
- =?UTF-8?B?0JLQuNGC0LDQu9C40Lkg0KTQsNC0?= =?UTF-8?B?0LXQtdCy?= (18/29) Feb 01 2021 Perhaps the best version would be a high-level add-on over rdmd
- aberba (2/7) Feb 02 2021 Nice examples!
It's finally out! https://opensource.com/article/21/1/d-scripting
Jan 31 2021
On 1/31/21 3:36 PM, aberba wrote:It's finally out! https://opensource.com/article/21/1/d-scriptingHm... right off I see the shebang is not the first line in the example. It has to be. Nice writeup! -Steve
Jan 31 2021
On Sunday, 31 January 2021 at 20:47:13 UTC, Steven Schveighoffer wrote:On 1/31/21 3:36 PM, aberba wrote:Please fix, Aberba, right now the examples don't work because of this... -- Bastiaan.It's finally out! https://opensource.com/article/21/1/d-scriptingHm... right off I see the shebang is not the first line in the example. It has to be.
Feb 01 2021
On Monday, 1 February 2021 at 11:29:02 UTC, Bastiaan Veelo wrote:On Sunday, 31 January 2021 at 20:47:13 UTC, Steven Schveighoffer wrote:Yes, noted. I don't have direct access to edit it myself. I have to wait till the editors make the changes (depending on their TZ) I should really get someone here to proofread it next time 😅 Sorry about that.On 1/31/21 3:36 PM, aberba wrote:Please fix, Aberba, right now the examples don't work because of this... -- Bastiaan.It's finally out! https://opensource.com/article/21/1/d-scriptingHm... right off I see the shebang is not the first line in the example. It has to be.
Feb 01 2021
On Monday, 1 February 2021 at 11:52:18 UTC, aberba wrote:On Monday, 1 February 2021 at 11:29:02 UTC, Bastiaan Veelo wrote:Perhaps we can create a channel on the dlang Slack for proofreading articles and blog posts, so that more people can have a chance to review an article before publishing.On Sunday, 31 January 2021 at 20:47:13 UTC, Steven Schveighoffer wrote:Yes, noted. I don't have direct access to edit it myself. I have to wait till the editors make the changes (depending on their TZ) I should really get someone here to proofread it next time 😅 Sorry about that.On 1/31/21 3:36 PM, aberba wrote:Please fix, Aberba, right now the examples don't work because of this... -- Bastiaan.It's finally out! https://opensource.com/article/21/1/d-scriptingHm... right off I see the shebang is not the first line in the example. It has to be.
Feb 01 2021
On 2/1/21 3:14 PM, Petar Kirov [ZombineDev] wrote:On Monday, 1 February 2021 at 11:52:18 UTC, aberba wrote:That's a really good idea!On Monday, 1 February 2021 at 11:29:02 UTC, Bastiaan Veelo wrote:Perhaps we can create a channel on the dlang Slack for proofreading articles and blog posts, so that more people can have a chance to review an article before publishing.On Sunday, 31 January 2021 at 20:47:13 UTC, Steven Schveighoffer wrote:Yes, noted. I don't have direct access to edit it myself. I have to wait till the editors make the changes (depending on their TZ) I should really get someone here to proofread it next time 😅 Sorry about that.On 1/31/21 3:36 PM, aberba wrote:Please fix, Aberba, right now the examples don't work because of this... -- Bastiaan.It's finally out! https://opensource.com/article/21/1/d-scriptingHm... right off I see the shebang is not the first line in the example. It has to be.
Feb 01 2021
On Monday, 1 February 2021 at 12:26:02 UTC, drug wrote:On 2/1/21 3:14 PM, Petar Kirov [ZombineDev] wrote:join![..] Perhaps we can create a channel on the dlang Slack for proofreading articles and blog posts, so that more people can have a chance to review an article before publishing.That's a really good idea!
Feb 01 2021
On 2/1/21 3:28 PM, Petar Kirov [ZombineDev] wrote:How can I join? I used slack once for a short period some time ago.
Feb 01 2021
On Monday, 1 February 2021 at 12:49:28 UTC, drug wrote:On 2/1/21 3:28 PM, Petar Kirov [ZombineDev] wrote:Any dlang slack member can invite new members by their email (I think even temporary email addresses are fine). On which email shall I send you an invite?join!How can I join? I used slack once for a short period some time ago.
Feb 01 2021
On 2/1/21 4:37 PM, Petar Kirov [ZombineDev] wrote:On Monday, 1 February 2021 at 12:49:28 UTC, drug wrote:sent directlyOn 2/1/21 3:28 PM, Petar Kirov [ZombineDev] wrote:Any dlang slack member can invite new members by their email (I think even temporary email addresses are fine). On which email shall I send you an invite?How can I join? I used slack once for a short period some time ago.
Feb 01 2021
On Monday, 1 February 2021 at 13:37:38 UTC, Petar Kirov [ZombineDev] wrote:Any dlang slack member can invite new members by their email (I think even temporary email addresses are fine). On which email shall I send you an invite?Is there any PM mechanism on board, no?
Feb 01 2021
On Monday, 1 February 2021 at 18:11:43 UTC, sighoya wrote:On Monday, 1 February 2021 at 13:37:38 UTC, Petar Kirov [ZombineDev] wrote:You mean does Slack have private messages? Yes it does.Any dlang slack member can invite new members by their email (I think even temporary email addresses are fine). On which email shall I send you an invite?Is there any PM mechanism on board, no?
Feb 01 2021
On Tuesday, 2 February 2021 at 07:28:36 UTC, Petar Kirov [ZombineDev] wrote:On Monday, 1 February 2021 at 18:11:43 UTC, sighoya wrote:No I meant, if this board has such options, don't like to paste email data in their. Anyway, could you invite me over the following mail: <my forum username> gmail.com That would be nice. I'm interested in chat discussions.Is there any PM mechanism on board, no?You mean does Slack have private messages? Yes it does.
Feb 02 2021
On 1/31/2021 12:36 PM, aberba wrote:It's finally out! https://opensource.com/article/21/1/d-scriptingVery nice and informative article!
Jan 31 2021
On Sunday, 31 January 2021 at 20:36:43 UTC, aberba wrote:It's finally out! https://opensource.com/article/21/1/d-scriptingVery nice! Clearly I'm not taking enough advantage of scripting capabilities! --Jon
Jan 31 2021
On Sunday, 31 January 2021 at 20:36:43 UTC, aberba wrote:It's finally out! https://opensource.com/article/21/1/d-scriptingThanks for your work, nice article, I wasn't even aware how easy this is.
Jan 31 2021
On Sunday, 31 January 2021 at 20:36:43 UTC, aberba wrote:It's finally out! https://opensource.com/article/21/1/d-scriptingFYI, the code will compile faster if you use `dmd -run` instead of `rdmd`. If you have multiple files that need to be compiled you can use `dmd -i -run`. -- /Jacob Carlborg
Feb 01 2021
On Monday, 1 February 2021 at 09:36:15 UTC, Jacob Carlborg wrote:On Sunday, 31 January 2021 at 20:36:43 UTC, aberba wrote:Unfortunately, you can't pass more than one command-line argumentIt's finally out! https://opensource.com/article/21/1/d-scriptingFYI, the code will compile faster if you use `dmd -run` instead of `rdmd`. If you have multiple files that need to be compiled you can use `dmd -i -run`. -- /Jacob Carlborg
Feb 01 2021
On Monday, 1 February 2021 at 11:10:28 UTC, Paul Backus wrote:On Monday, 1 February 2021 at 09:36:15 UTC, Jacob Carlborg wrote:It is possible, using `/usr/bin/env -S command arg1 arg2` , as of coreutils 8.30. I have been using it at work and it's working perfectly. This functionality was already supported by FreeBSD [1] for ~15 years, but the coreutils developers implemented it just ~3 years ago [2]. The main disadvantage is that it's obviously not very portable, e.g. all users/developers need to use a modern linux distro, but for some teams this requirement already there for other reasons, so it's not a problem. Example: https://gist.github.com/PetarKirov/72168d8dc909c670444ca649ec28f80f This was extracted from a larger project, so it may not be useful on its own, but hopefully it should be enough to showcase the usage. Also, if you can use rund [3], it's likely a much cleaner option. [1]: https://www.freebsd.org/cgi/man.cgi?env [2]: https://lists.gnu.org/r/coreutils/2017-05/msg00020.html [3]: https://github.com/dragon-lang/rundOn Sunday, 31 January 2021 at 20:36:43 UTC, aberba wrote:Unfortunately, you can't pass more than one command-lineIt's finally out! https://opensource.com/article/21/1/d-scriptingFYI, the code will compile faster if you use `dmd -run` instead of `rdmd`. If you have multiple files that need to be compiled you can use `dmd -i -run`. -- /Jacob Carlborg
Feb 01 2021
On Monday, 1 February 2021 at 12:11:46 UTC, Petar Kirov [ZombineDev] wrote:On Monday, 1 February 2021 at 11:10:28 UTC, Paul Backus wrote:This is great, thanks! I just checked, and it's available in Debian stable, so most distros should have it by now.Unfortunately, you can't pass more than one command-lineIt is possible, using `/usr/bin/env -S command arg1 arg2` , as of coreutils 8.30. I have been using it at work and it's working perfectly. This functionality was already supported by FreeBSD [1] for ~15 years, but the coreutils developers implemented it just ~3 years ago [2].
Feb 01 2021
On Monday, 1 February 2021 at 12:41:19 UTC, Paul Backus wrote:On Monday, 1 February 2021 at 12:11:46 UTC, Petar Kirov [ZombineDev] wrote:I was missing this feature often, I'm glad I found it recently ;)On Monday, 1 February 2021 at 11:10:28 UTC, Paul Backus wrote:This is great, thanks!Unfortunately, you can't pass more than one command-lineIt is possible, using `/usr/bin/env -S command arg1 arg2` , as of coreutils 8.30. I have been using it at work and it's working perfectly. This functionality was already supported by FreeBSD [1] for ~15 years, but the coreutils developers implemented it just ~3 years ago [2].I just checked, and it's available in Debian stable, so most distros should have it by now.Yes, I think it's safe to use on Linux nowadays. In the worst case a user may need to upgrade their coreutils. I just mention this because a teammate was still on Ubuntu 16.04 or 18.04 so he had to upgrade [1]. [1]: https://packages.ubuntu.com/search?keywords=coreutils&searchon=names&suite=all§ion=all
Feb 01 2021
On Sunday, 31 January 2021 at 20:36:43 UTC, aberba wrote:It's finally out! https://opensource.com/article/21/1/d-scriptingD lang is life! I used Python for scripting, but D lang is better, I don't need install interpreter for execute it. I hope someay fobos have same support as Python library.
Feb 01 2021
On Sunday, 31 January 2021 at 20:36:43 UTC, aberba wrote:It's finally out! https://opensource.com/article/21/1/d-scriptingIf the article is about scripting, then the article will contain examples of scripts used in business. For example, to delete all dub caches in a directory: Version via Windows .bat: echo off FOR /D %%f IN ( .\* ) DO ( IF EXIST .\%%f\.dub ( echo .\%%f\.dub rmdir /q /s .\%%f\.dub ) ) Version via Dlang: module dubcache; import std.file; import std.path; import std.stdio; void main( string[] args ) { foreach( dir; dirEntries( args[0].dirName, SpanMode.shallow ) ) { if ( dir.baseName == ".dub" ) { writeln( "REMOVED: ", dir ); rmdirRecurse( dir.name ); } } } or module dubcache; import std; void main( string[] args ) { dirEntries( args[0].dirName, SpanMode.shallow ) .filter!( a => a.baseName == ".dub" ) .each!( ( a ) { writeln( a ); rmdirRecurse( a ); } ); }
Feb 01 2021
On Tuesday, 2 February 2021 at 03:53:43 UTC, Виталий Фадеев wrote:On Sunday, 31 January 2021 at 20:36:43 UTC, aberba wrote:Remove dub cache in subsirectories: module dubcache; // Reason: // each cache take 50 - 200 MB of disk space // Goal: // scan dirs and remove caches // // ./ // a/ // b/ // .dub/ <- target // c/ import std; void main( string[] args ) { dirEntries( args[0].dirName, SpanMode.shallow ) .filter!( a => a.isDir ) .map!( a => buildPath( a.name, ".dub" ) ) .filter!( a => a.exists ) .each!( ( a ) { writeln( a ); rmdirRecurse( a ); } ); } Source: https://run.dlang.io/is/ah1Vtp And we see what it not simple as windows .batIt's finally out! https://opensource.com/article/21/1/d-scriptingIf the article is about scripting, then the article will contain examples of scripts used in business. For example, to delete all dub caches in a directory:
Feb 01 2021
On Tuesday, 2 February 2021 at 04:24:48 UTC, Виталий Фадеев wrote:On Tuesday, 2 February 2021 at 03:53:43 UTC, Виталий Фадеев wrote:Perhaps the best version would be a high-level add-on over rdmd with Dlang syntax. . "main()" and "import std" will be hidden. For example, the final result will look like this: dirEntries( args[0].dirName, SpanMode.shallow ) .filter!( a => a.isDir ) .map!( a => buildPath( a.name, ".dub" ) ) .filter!( a => a.exists ) .each!( ( a ) { writeln( a ); rmdirRecurse( a ); } ); and the file will have the extension ".ds"On Sunday, 31 January 2021 at 20:36:43 UTC, aberba wrote:And we see what it not simple as windows .batIt's finally out! https://opensource.com/article/21/1/d-scriptingIf the article is about scripting, then the article will contain examples of scripts used in business.
Feb 01 2021
On Tuesday, 2 February 2021 at 03:53:43 UTC, Виталий Фадеев wrote:On Sunday, 31 January 2021 at 20:36:43 UTC, aberba wrote:Nice examples![...]If the article is about scripting, then the article will contain examples of scripts used in business. [...]
Feb 02 2021