If you're looking for magnitutes faster scripting alternative to Python like once me, take a peek!
If you're looking for magnitutes faster scripting alternative to Python like once me, take a peek!
Array slicing, ranges, compile-time execution. Probably the most succinct and easy-to-read syntax out of many compiled languages. It's an investment (as with any other language) but the learning curve is not steep if you get scared away by C++ or Rust for that matter. Julia comes to mind too in terms of syntax but no UFCS and its interoperability with C++/C looks like a lot of work compared to D.
[1] https://riptutorial.com/scala/example/7538/implicit-classes
For example, seqOfChars.map!(a => a.toLower).filterIfNotDigitChar.sort.uniq; is simply not possible in Scala.
Here is a great presentation about fp in D: http://beza1e1.tuxen.de/stuff/FunctionalD.pdf
(Unless you mean something different).
Unfortunately it looks more like a kludge tbo. Sort and uniq get also hidden in a class which can be tucked away from your eyes and this is never good.
The official tour has a short page about FP as well: https://tour.dlang.org/tour/en/gems/functional-programming
Anyways, since Walter is probably reading this: Any new insights around this quote five years later?
> I know a lot of the programming community is sold on exclusive constraints (C++ concepts, Rust traits) rather than inclusive ones (D constraints). What I don't see is a lot of experience actually using them long term. They may not turn out so well. –Walter Bright
https://nim-lang.org/docs/manual.html#pragmas
And Active Oberon as well (here called flags),
http://cas.inf.ethz.ch/projects/a2/repository/raw/trunk/Lang...
However, you can write scripts which pull in packages from the internet called "single-file packages": https://dub.pm/advanced_usage
Just tried it myself for the first time:
#!/usr/bin/env dub
/+ dub.sdl:
name "hello"
dependency "requests" version="1.1.5"
+/
import std.stdio : writeln;
import requests : postContent;
void main() {
auto content = postContent("http://httpbin.org/post",
["name": "any name", "age": "42"]);
writeln(content);
}
On Linux, put this into a file, chmod +x it, and execute. The first time it will take a while (downloading and compiling packages). After that on my crappy laptop it takes: 0.66user 0.06system 0:01.25elapsed 57%CPU
That is a lot more convenient than venv in Python.I do not follow D closely, but i get the impression that the language breaks backwards compatibility every now and then - i remember some posts here or Reddit some months ago by someone complaining that Walter Bright introduced some changes to the language that broke existing code.
IMO a mature language is a language that you can depend on for your existing code to keep working in a timespan of decades - like C and C++ for example. A language that willingly breaks backwards compatibility is a toy, not something to be taken seriously for long term work.
> The release of Andrei Alexandrescu's book The D Programming Language on June 12, 2010, marked the stabilization of D2, which today is commonly referred to as just "D".
In other words, D is backwards compatible for 10 years now. At least, I don't know any breaks and the little code I have in D never broke.
The transition from D1 to D2 did break backwards compatibility in 2007. The change is comparable to the Python2 to Python3 transition but in a much smaller community. Outdated news from that time still pop up sometimes. Maybe you heard something related to that?
[0] https://en.wikipedia.org/wiki/D_(programming_language)#Histo...
I wonder what that complain was about then.
K&R C, gets, Annex K, VLA, gone by now in C17.
gets, exception specifications, external templates, std::auto_ptr now gone, RVO semantics changed, and a couple of other minor semantic changes by C++20.
TBH i'm not sure about modern C++20 since that has been a shitshow anyway.
Hint, there are more C compilers out there than clang and GCC.