Re: Verbosity in D

2022-08-07 Thread TTK Ciar via Digitalmars-d-learn

On Monday, 8 August 2022 at 00:11:33 UTC, pascal111 wrote:
I don't have specific code but it was a general notice. Take 
Python as in example, the same program in Python doesn't cost 
much code as D code, and of course by putting in accounts that 
that I assume that there are some special tasks D can do, while 
Python can't do.


There is definitely a spectrum of programming language practical 
expressiveness (the opposite of verbosity), with the dynamic 
languages (python, perl, ruby) on the "most expressive" end, and 
static languages (C, C++, Java) on the "most verbose" end.


D is somewhere in the middle of that spectrum, much more 
expressive than C but not as expressive as python.


The trade-off is much better run-time performance and lower 
memory overhead compared to the dynamic languages.


I've been writing C, Perl and Python for a living for a while, 
following the common practice of writing a solution in Perl or 
Python first, for shortest possible development time, and then 
rewriting performance-intensive bits in C when more performance 
is needed.


The appeal of D, to me, is that it gives me something akin to the 
same approach with just one language.  I can write very concise, 
expressive D when performance doesn't matter, and then write more 
verbose C-like D when I need C-like performance, all in the same 
source file, with the same language.


Having a sane and useful threading model is an added bonus.  
Neither python nor perl nor nodejs have useful threads, whereas D 
gives us real, concurrent threads with a fraction of the 
boilerplate -- 
https://tour.dlang.org/tour/en/multithreading/synchronization-sharing


On the other hand, I've noticed that D's idiomatic brevity can be 
diluted by the extremely verbose function names used in the 
standard library.  Sure, foreach loops can be just as concise as 
python's -- foreach(i; arr) -- but then you end up getting carpal 
tunnel syndrome anyway from typing out  
"AllImplicitConversionTargets" or "filterBidirectional" or 
"levenshteinDistanceAndPath".


My impression is that brevity is more important to the language 
developers than it is to the phobos developers.


Re: Is there such concept of a list in D?

2022-12-12 Thread TTK Ciar via Digitalmars-d-learn

On Sunday, 11 December 2022 at 17:45:20 UTC, ryuukk_ wrote:


Why is it called ``DList`` and not just ``List``, i have no clue


Probably because it is a *D*ouble-linked List :-)


Re: How to create a API server?

2022-12-16 Thread TTK Ciar via Digitalmars-d-learn

On Friday, 16 December 2022 at 20:57:30 UTC, Dariu Drew wrote:
Hi! i need help in can i create a serve API, what library i 
should use? what documentation i should read?


The arsd package includes arsd.http2 which makes it easy to 
implement API servers with very little code.


https://code.dlang.org/packages/arsd-official


Re: How to create a API server?

2022-12-18 Thread TTK Ciar via Digitalmars-d-learn

On Friday, 16 December 2022 at 22:10:37 UTC, TTK Ciar wrote:

On Friday, 16 December 2022 at 20:57:30 UTC, Dariu Drew wrote:
Hi! i need help in can i create a serve API, what library i 
should use? what documentation i should read?


The arsd package includes arsd.http2 which makes it easy to 
implement API servers with very little code.


https://code.dlang.org/packages/arsd-official


Oops, wrong module!! I meant arsd.cgi, very sorry!


Re: How to unpack a tuple into multiple variables?

2024-02-05 Thread TTK Ciar via Digitalmars-d-learn
I've been using AliasSeq for that (and aliasing it to "put" for 
easier use):



```d
import std.meta;
alias put = AliasSeq;

auto foo() { return tuple(1, 2, 3); }

int main(string[] args) {
  int x, y, z;
  put!(x, y, z) = foo();
  writeln(x, y, z);
  return 0;
}
```

My mnemonic: "put" is "tup" backwards, and undoes what tuple does.