CTFE sort of tuples

2019-05-01 Thread Andrey via Digitalmars-d-learn

Hello, I have got this code:


alias Group = Tuple!(int[], "data", int, "key");

void main()
{
enum group = [
Group([1,2,3,4], 1),
Group([5,3], 1),
Group([4,5,4, 8, 9, 4], 1),
Group([2,3,4], 1),
];

enum result = group.sort!"a.data < b.data"().array(); }


I want to sort array of tuples using "data" element in CTFE. But 
this code give me errors:

/dlang/dmd/linux/bin64/../../src/phobos/std/algorithm/mutation.d(2782): Error: reinterpreting cast 
from Tuple!(int[], "data", int, "key")* to ubyte* is not supported in CTFE
/dlang/dmd/linux/bin64/../../src/phobos/std/algorithm/mutation.d(3014):
called from here: swap(r[i1], r[i2])
/dlang/dmd/linux/bin64/../../src/phobos/std/algorithm/sorting.d(1672):
called from here: swapAt(r, 2LU, 3LU)
/dlang/dmd/linux/bin64/../../src/phobos/std/algorithm/sorting.d(2112):
called from here: shortSort(r)
/dlang/dmd/linux/bin64/../../src/phobos/std/algorithm/sorting.d(1875):
called from here: quickSortImpl(r, r.length)
onlineapp.d(32):called from here: sort([Tuple([1, 2, 3, 
4], 1), Tuple([5, 3], 1), Tuple([4, 5, 4, 8, 9, 4], 1), 
Tuple([2, 3, 4], 1)])
onlineapp.d(32):called from here: array(sort([Tuple([1, 
2, 3, 4], 1), Tuple([5, 3], 1), Tuple([4, 5, 4, 8, 9, 4], 1), 
Tuple([2, 3, 4], 1)]))


As I understand the function "sort" sometimes can't be run at CT 
because of reinterpreting cast.

In this case how to sort?


Setting process name

2019-05-01 Thread Anonymouse via Digitalmars-d-learn
Is there a way of setting the process/thread name that's neater 
than this?


import core.sys.posix.pthread;

extern(C) int pthread_setname_np(pthread_t, const char*);

void main()
{
import std.string : toStringz;
pthread_setname_np(pthread_self(), toStringz("thread_name"));
// ...
}

It seems to work, but it also seems peculiar that 
pthread_setname_np isn't in core.sys.posix.pthread with the rest. 
Why is this? Is there an easier way? Thread.getThis().name 
doesn't seem to be it.



https://forum.dlang.org/thread/gudwwmmdcqrfhbdux...@forum.dlang.org


Re: Noob questions

2019-05-01 Thread 0x10001 via Digitalmars-d-learn

On Thursday, 25 April 2019 at 02:39:22 UTC, Andre Pany wrote:

On Wednesday, 24 April 2019 at 22:44:17 UTC, 0x10001 wrote:
Hello, i've hit some roadblocks while trying to learn D, i'll 
try to explain each of them below :


[...]


Regarding question 1, I had the same question some days ago
https://forum.dlang.org/thread/akootxwiopsltifwd...@forum.dlang.org

For question 2, can you show your complete coding? It should 
work, I assume there might be a subtitle issue in your logic.


Kind regards
Andre


Your workaround with " %s\n" worked perfectly, thank you! i 
wasn't able to reproduce the second issue however despite the 
source file not having changed since, if i encounter it again 
i'll try to do what Erinaceus said.(Well i already did but since 
i wasn't able to re-reproduce the problem it prints the same two 
ubyte arrays.)


On Friday, 26 April 2019 at 09:04:26 UTC, Erinaceus wrote:
In case you have not solved the 3rd problem yet (your code is 
almost there),

it can be fixed by replacing this line:
	rawfile.écrire(uncompress(efile_buf2)); // alias for 
std.file.write

with this one:
(filename ~ ".out").écrire(uncompress(efile_buf2));

The lines that open files using std.stdio.File are not needed 
and can be removed:

File efile = File(filename, "r");
File rawfile = File(filename ~ ".out", "w");

std.file.write works pretty much like this:
void write(string filename, void[] writeThis) {
import std.stdio;
File f = File(filename, "w");
f.rawWrite(writeThis);
f.close();
}

It expects a filename as an argument (not a std.stdio.File 
structure representing an open file). std.file.read also 
expects a filename, your code is calling that one correctly.
Using std.stdio.File is not necessary here because 
std.file.read/write open and close the files on their own.



About your 2nd problem: its hard to tell whats going on without 
more complete code. You may want to inspect the problematic 
string using something like this:

string correct = "test.txt";
string tricky = std.string.strip(readln());
writeln("c: ", cast(ubyte[]) correct);
writeln("t: ", cast(ubyte[]) tricky);

This is going to print numeric codes of all bytes in the string 
and reveal any potentially invisible characters (like spaces, 
line-ending markers, tabs etc.), like this:

c: [116, 101, 115, 116, 46, 116, 120, 116]
t: [116, 101, 115, 116, 46, 116, 120, 116, 13]


The changes you proposed worked, and thank you for your 
explanation, i can't reproduce my second problem anymore but here 
is the original code anyway :


import std.stdio;
import std.file;
void main() {
writeln();
string filename = strip(readln());
File file = File(filename, "r");
File ofile = File((filename ~ ".out"), "w");
if (exists(filename)) {
writeln("success : ","'", filename, "'");
} else writeln("bad");
}




Re: GtkD slows down visual D keyboard

2019-05-01 Thread Alex via Digitalmars-d-learn

On Friday, 26 April 2019 at 14:50:17 UTC, Mike Wey wrote:

On 26-04-2019 10:31, Amex wrote:
When debugging under visual D, the keyboard response is slowed 
down to the extreme. This is a Gtk issue I believe. It only 
has to do with the keyboard.


For example, if I hit F10 to step, it takes the ide about 10 
seconds to "respond" and move to the next line... yet the 
mouse can access stuff instantaneous.



I believe Gtk or GtkD is slowing down the keyboard input 
somehow and for some reason making debugging apps a nightmare 
since it literally takes about 100 times longer to debug than 
it should.


searching google reveals:

https://github.com/Microsoft/vcpkg/issues/4529

https://developercommunity.visualstudio.com/content/problem/42018/debugging-with-keyboard-very-slow.html


"You somehow break keyboard shortcuts during debugging in VS 
if the application you're debugging is registering a callback 
with "SetWindowsHookEx" from user32.dll with hook ID 
"WH_KEYBOARD_LL".


Don't call it in debug builds or add "if 
(!Debugger.IsAttached)" in front of the call to 
"SetWindowsHookEx" if the debugger is attached before the 
function is called.


This brings debugging with keyboard back to the same speed as 
with the UI buttons for our application."




This seems to be an issue with Gtk. I'm not sure if GtkD can 
do anything about it. Maybe somehow reroute the keyboard 
handler(first remove it from the hook then call it manually or 
reduce the number of calls to it).


I can confirm that gtk call  "SetWindowsHookEx" with the 
"WH_KEYBOARD_LL" ID upon initialization.


As far as i can tell it doesn't provide a way to skip this.


Any news about this? Do you think it can be fixed in some way?


Re: dmd -unittest -main -run: undefined reference to `_D1c12__ModuleInfoZ'

2019-05-01 Thread Seb via Digitalmars-d-learn

On Wednesday, 1 May 2019 at 22:46:34 UTC, kdevel wrote:

On Wednesday, 1 May 2019 at 22:35:12 UTC, ag0aep6g wrote:

On 02.05.19 00:25, kdevel wrote:

dmd -unittest -main -run package.d c/package.d


That doesn't compile c/package.d. Everything after `-run 
package.d` is interpreted as an argument to the compiled 
program.


Thanks for the information. Wouldn't it be better, if 
everything directly
after the `-run` would be taken as argument to the programm? In 
this case


   dmd -unittest -main -run package.d

would immediately fail due to missing source.


Would be, but would also be a breaking change.
In the past it has been discussed to use e.g. `--` as a 
separator, but that PR was rejected because it could only be done 
in a useful way with breaking changes :/


Re: dmd -unittest -main -run: undefined reference to `_D1c12__ModuleInfoZ'

2019-05-01 Thread kdevel via Digitalmars-d-learn

On Wednesday, 1 May 2019 at 22:35:12 UTC, ag0aep6g wrote:
[...]
Or use -i so that DMD compiles the imported module 
automatically:


dmd -unittest -main -i -run package.d


Now I have:

a/main.d
a/b/package.d
a/b/c/package.d

b/package.d and c/package.d as before. a/main.d is

```
import b;

void dummy ()
{
   string s = "test";
   mkdir (s);
}
```

In cwd a/ with

   $ dmd -unittest -main -i -run main.d

I get

   b/package.d(2): Error: module `c` is in file 'c.d' which 
cannot be read

   import path[0] = /.../dmd2/linux/bin64/../../src/phobos
   import path[1] = 
/.../dmd2/linux/bin64/../../src/druntime/import


Why does dmd not get it? I have to supply -I=b explicitly. Which 
leads me to

the actual problem I wanted to post:

   $ dmd -unittest -main -I=b -run main.d
   main.d(6): Error: undefined identifier mkdir

The problem I see here is that b passes the isolated unittest. 
But when it is used undefined symbols show up. I stumbled over 
this problem while using a project as submodule which uses 
msgpack-d as its submodule. Only if I restrict

the import like in

   import msgpack : unpack, pack;

my submodule's unittest fails right away. My submodule 
corresponds to b/package.d in this thread. I suppose the line


package import std.file, core.stdc.string;

in msgpack-d's file packer.d causes the export of mkdir. Right?


Re: dmd -unittest -main -run: undefined reference to `_D1c12__ModuleInfoZ'

2019-05-01 Thread kdevel via Digitalmars-d-learn

On Wednesday, 1 May 2019 at 22:35:12 UTC, ag0aep6g wrote:

On 02.05.19 00:25, kdevel wrote:

dmd -unittest -main -run package.d c/package.d


That doesn't compile c/package.d. Everything after `-run 
package.d` is interpreted as an argument to the compiled 
program.


Thanks for the information. Wouldn't it be better, if everything 
directly
after the `-run` would be taken as argument to the programm? In 
this case


   dmd -unittest -main -run package.d

would immediately fail due to missing source.

[...]


Or use -i so that DMD compiles the imported module 
automatically:


dmd -unittest -main -i -run package.d


That looks nice.


Re: dmd -unittest -main -run: undefined reference to `_D1c12__ModuleInfoZ'

2019-05-01 Thread ag0aep6g via Digitalmars-d-learn

On 02.05.19 00:25, kdevel wrote:

dmd -unittest -main -run package.d c/package.d


That doesn't compile c/package.d. Everything after `-run package.d` is 
interpreted as an argument to the compiled program.


I.e., that line effectively does this:

dmd -unittest -main package.d
./package c/package.d

You need to put c/package.d before -run:

dmd -unittest -main c/package.d -run package.d

Or use -i so that DMD compiles the imported module automatically:

dmd -unittest -main -i -run package.d


Re: OT - Git training Lon/HK and book recommendation on taste in programming

2019-05-01 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Wed, May 1, 2019 at 9:18 AM Arun Chandrasekaran  wrote:
>
> On Wed, May 1, 2019 at 8:15 AM Guillaume Piolat via
> Digitalmars-d-learn  wrote:
> >
> > On Wednesday, 1 May 2019 at 09:51:01 UTC, Laeeth Isharc wrote:
> > >
> > > Second question.  Lots of people these days start to program to
> > > solve their problems at work but they may never have been shown
> > > the basic principles of design, structuring and maintenance of
> > > their code.  If I could give them one book (and a few YouTube
> > > links) what should it be ?
> >
> > Pragmatic Programmer
>
> +1

In case interested, here is the summary of Pragmatic Programmer:
https://github.com/HugoMatilla/The-Pragmatic-Programmer


dmd -unittest -main -run: undefined reference to `_D1c12__ModuleInfoZ'

2019-05-01 Thread kdevel via Digitalmars-d-learn

In the current working directory b/ I have

package.d
```
module b;
import c;

void bar (string s)
{
   mkdir (s);
}
```

c/package.d
```
module c;
package import std.file;
```

   $ dmd -unittest -main package.d c/package.d

produces the binary "package" as expected, but

   $ dmd -unittest -main -run package.d c/package.d

fails with

   package.o:(.data.rel.ro+0x10): undefined reference to 
`_D1c12__ModuleInfoZ'

   collect2: ld returned 1 exit status
   Error: linker exited with status 1

Why this?


Re: Erasing passwords from ram?

2019-05-01 Thread Cym13 via Digitalmars-d-learn

On Tuesday, 30 April 2019 at 08:15:15 UTC, Dukc wrote:
I am currently programming a server. So I got the idea that 
after I've generated all the hashes I need from a password, I 
want to erase it from RAM before discarding it, just to be sure 
it won't float around if the server memory is exposed to 
spyware by some buffer overflow. Is this wise caution, or just 
being too paranoid?


And if it is worthwhile, do I have to do this:
```
foreach(ref part; cast(ubyte[]) rootPassword) 
volatileStore(, 0);

```

Or, can I rely on that the compiler won't optimize this out?
```
rootPassword[] = '\0'
```

`rootPassword` is allocated on the heap, but only locally 
referred to.


There are very few relevant threat models where removing a 
password from RAM is an adequate solution, I'm not sure it's 
worth the trouble.


For comparison one case where it's considered important is 
removing the master password from a password manager from RAM to 
prevent another person finding the computer unlocked to recover 
it by memory inspection (which it would have the rigth to do 
since the process would be from the same user).

That's quite specific and a server isn't nearly as exposed.

That said, if you want to remove it, make sure to audit all 
functions that use it from the moment it enters memory to check 
that they don't make a copy for some reason (or use a type that 
doesn't allow copies). It's no use removing it at one place if 
it's still at another. In particular a pattern I see often is 
that you have a function that reads the password from a 
file/stdin/whatever onto the stack and sets on the heap the 
object you'll use throughout the program then returns. You will 
think of checking the use of that object, but may forget to clear 
the setter's buffer before returning leaving it in a stack's 
frame. You should also make sure that your compiler isn't 
recognizing that this part of memory isn't used later and 
optimizing away the overwrite call.


This is lots of work for a vulnerability that should not be there 
and may not lead to memory disclosure even if it is present. I'd 
rather focus on mitigating that threat by keeping boundchecking 
on, writing @safe code etc.


Re: OT - Git training Lon/HK and book recommendation on taste in programming

2019-05-01 Thread Sebastiaan Koppe via Digitalmars-d-learn

On Wednesday, 1 May 2019 at 09:51:01 UTC, Laeeth Isharc wrote:

Hi.

First question - can anyone recommend git / Gitlab training 
providers in HK and London?  Two distinct audiences - highly 
intelligent people that may or may not really program, and 
experienced developers with a finance background that could 
benefit from knowing how to use git properly (finance is often 
in the dark ages).


Can't recommend anyone in particular, but I would recommend to do 
some interactive challenges at some point. Instruqt is a good 
one. It has a section on git. 
https://instruqt.com/public/topics/getting-started-with-git . It 
is fun and can give you insights who is picking up the material 
and who is lagging behind.


Second question.  Lots of people these days start to program to 
solve their problems at work but they may never have been shown 
the basic principles of design, structuring and maintenance of 
their code.  If I could give them one book (and a few YouTube 
links) what should it be ?


'Code Complete' is always good. And there are plenty of MIT 
courses online of course, like: 
https://www.youtube.com/watch?v=ytpJdnlu9ug=PLUl4u3cNGP63WbdFxL8giv4yhgdMGaZNA (6.0001 Introduction to Computer Science and Programming in Python. Fall 2016). Also, there are ones from the 80's, they have a certain quality, a certain rigor that I fail to find in more recent lectures.


Re: What's best practice to use compound literals with structs and C-APIs?

2019-05-01 Thread Alex via Digitalmars-d-learn

On Wednesday, 1 May 2019 at 14:59:48 UTC, Robert M. Münch wrote:

On 2019-05-01 14:23:37 +, Alex said:

However, to rebuild the same structure, auto ref parameters 
may be appropriate.

https://dlang.org/spec/template.html#auto-ref-parameters


That would need me to change myfunc which is not possible 
because the D binding is all generated from C code.



Ok, I see.


or you new A(...) in place


Doesn't work because this seems to kick in some D releated 
run-time stuff which lead to unresolved externals during 
linking:


error LNK2001: Nicht aufgelöstes externes Symbol "...__initZ".
error LNK2001: Nicht aufgelöstes externes Symbol 
"...__xtoHashFNbNeKxSQBtQBoQBfZm".
error LNK2001: Nicht aufgelöstes externes Symbol 
"...__xopEqualsFKxSQBsQBnQBeKxQmZb".


Not sure, why this happens.


Found this bug:
https://issues.dlang.org/show_bug.cgi?id=12374

It is closed now, because of inactivity, if you have a current 
case - a reopen is welcome.
However... Not sure, maybe someone else has more knowledge about 
this.





or you use the byRef-pattern as shown in d-idioms
https://p0nce.github.io/d-idioms/#Rvalue-references:-Understanding-auto-ref-and-then-not-using-it



This again would need my to change the C bindings, which are 
generated.


So, you generate D structs from C, right? If so, and if you need 
the byRef at any cost - you could tweak the generator, so byRef 
is generated for all structs.


Re: OT - Git training Lon/HK and book recommendation on taste in programming

2019-05-01 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Wed, May 1, 2019 at 8:15 AM Guillaume Piolat via
Digitalmars-d-learn  wrote:
>
> On Wednesday, 1 May 2019 at 09:51:01 UTC, Laeeth Isharc wrote:
> >
> > Second question.  Lots of people these days start to program to
> > solve their problems at work but they may never have been shown
> > the basic principles of design, structuring and maintenance of
> > their code.  If I could give them one book (and a few YouTube
> > links) what should it be ?
>
> Pragmatic Programmer

+1


Re: OT - Git training Lon/HK and book recommendation on taste in programming

2019-05-01 Thread Guillaume Piolat via Digitalmars-d-learn

On Wednesday, 1 May 2019 at 09:51:01 UTC, Laeeth Isharc wrote:


Second question.  Lots of people these days start to program to 
solve their problems at work but they may never have been shown 
the basic principles of design, structuring and maintenance of 
their code.  If I could give them one book (and a few YouTube 
links) what should it be ?


Pragmatic Programmer


Re: What's best practice to use compound literals with structs and C-APIs?

2019-05-01 Thread Robert M. Münch via Digitalmars-d-learn

On 2019-05-01 14:23:37 +, Alex said:


On Wednesday, 1 May 2019 at 12:47:22 UTC, Robert M. Münch wrote:
I use some C library that uses structs and many functions that use 
pointer to structs as arguments:


struct A {...};
myfunc(A *myA);

In C you can do this to get a lvalue:

myfunc(&(A){...});

In D this doesn't work and I get an "is not an lvalue and cannot be modified".

What's the correct D-ish way in such a case?


Look, even in C you have to workaround the case, where you want to pass 
a value instead of a pointer.


That's not a workaround in C, it's the way to do it.


However, to rebuild the same structure, auto ref parameters may be appropriate.
https://dlang.org/spec/template.html#auto-ref-parameters


That would need me to change myfunc which is not possible because the D 
binding is all generated from C code.



or you new A(...) in place


Doesn't work because this seems to kick in some D releated run-time 
stuff which lead to unresolved externals during linking:


error LNK2001: Nicht aufgelöstes externes Symbol "...__initZ".
error LNK2001: Nicht aufgelöstes externes Symbol 
"...__xtoHashFNbNeKxSQBtQBoQBfZm".
error LNK2001: Nicht aufgelöstes externes Symbol 
"...__xopEqualsFKxSQBsQBnQBeKxQmZb".


Not sure, why this happens.


or you use the byRef-pattern as shown in d-idioms
https://p0nce.github.io/d-idioms/#Rvalue-references:-Understanding-auto-ref-and-then-not-using-it 



This again would need my to change the C bindings, which are generated.

--
Robert M. Münch
http://www.saphirion.com
smarter | better | faster



Re: What's best practice to use compound literals with structs and C-APIs?

2019-05-01 Thread Alex via Digitalmars-d-learn

On Wednesday, 1 May 2019 at 12:47:22 UTC, Robert M. Münch wrote:
I use some C library that uses structs and many functions that 
use pointer to structs as arguments:


struct A {...};
myfunc(A *myA);

In C you can do this to get a lvalue:

myfunc(&(A){...});

In D this doesn't work and I get an "is not an lvalue and 
cannot be modified".


What's the correct D-ish way in such a case?


Look, even in C you have to workaround the case, where you want 
to pass a value instead of a pointer. So, the proper question 
would be, how to redesign, so that &(A){...} is not needed.


However, to rebuild the same structure, auto ref parameters may 
be appropriate.

https://dlang.org/spec/template.html#auto-ref-parameters

or you new A(...) in place

or you use the byRef-pattern as shown in d-idioms
https://p0nce.github.io/d-idioms/#Rvalue-references:-Understanding-auto-ref-and-then-not-using-it

Not sure, which part is under your control...


Re: Any full feature xml library available?

2019-05-01 Thread rikki cattermole via Digitalmars-d-learn

On 02/05/2019 2:04 AM, Domain wrote:

On Wednesday, 1 May 2019 at 13:57:04 UTC, bachmeier wrote:

On Wednesday, 1 May 2019 at 13:54:08 UTC, Domain wrote:

I need a xml library which support document entity or xinclude.
The xml may like this:




]>
http://www.w3.org/2001/XInclude;>
    
    



Have you looked at this?

https://github.com/jmdavis/dxml


Yes, but I don't think dxml support these features.


It does not. Those features come under the big bad guys feature list.

Gonna have to go to C for it.


Re: Any full feature xml library available?

2019-05-01 Thread Domain via Digitalmars-d-learn

On Wednesday, 1 May 2019 at 13:57:04 UTC, bachmeier wrote:

On Wednesday, 1 May 2019 at 13:54:08 UTC, Domain wrote:

I need a xml library which support document entity or xinclude.
The xml may like this:




]>
http://www.w3.org/2001/XInclude;>





Have you looked at this?

https://github.com/jmdavis/dxml


Yes, but I don't think dxml support these features.


Re: Any full feature xml library available?

2019-05-01 Thread bachmeier via Digitalmars-d-learn

On Wednesday, 1 May 2019 at 13:54:08 UTC, Domain wrote:

I need a xml library which support document entity or xinclude.
The xml may like this:




]>
http://www.w3.org/2001/XInclude;>





Have you looked at this?

https://github.com/jmdavis/dxml


Any full feature xml library available?

2019-05-01 Thread Domain via Digitalmars-d-learn

I need a xml library which support document entity or xinclude.
The xml may like this:




]>
http://www.w3.org/2001/XInclude;>







What's best practice to use compound literals with structs and C-APIs?

2019-05-01 Thread Robert M. Münch via Digitalmars-d-learn
I use some C library that uses structs and many functions that use 
pointer to structs as arguments:


struct A {...};
myfunc(A *myA);

In C you can do this to get a lvalue:

myfunc(&(A){...});

In D this doesn't work and I get an "is not an lvalue and cannot be modified".

What's the correct D-ish way in such a case?

--
Robert M. Münch
http://www.saphirion.com
smarter | better | faster



Re: druntime giving wrong line for copy assert?

2019-05-01 Thread Rudy Raab via Digitalmars-d-learn

On Tuesday, 30 April 2019 at 20:35:11 UTC, Bastiaan Veelo wrote:

On Tuesday, 30 April 2019 at 13:59:52 UTC, Rudy Raab wrote:
The error was on line 36, which is the format, not my bad 
slice. Is there a reason for this, or is it a bug


The message is correct when not using dub:
https://run.dlang.io/is/chFTOY

I suspect that if you remove the dub related lines and put it 
in an empty dub project, it will produce a correct message. So 
it looks like a bug in dub from where I am sitting. Maybe dub 
adds lines behind the scene?


Bastiaan.


I had it as a single file dub project because it was a distilled 
version of an example from a larger dub project I was working on, 
and I wanted to keep everything as similar as possible. But you 
are correct, the incorrect error line only appears when it's 
built with dub.


I'll go looking at dub bugs and see if it hasn't been reported 
yet.


Re: OT - Git training Lon/HK and book recommendation on taste in programming

2019-05-01 Thread evilrat via Digitalmars-d-learn

On Wednesday, 1 May 2019 at 09:51:01 UTC, Laeeth Isharc wrote:


Second question.  Lots of people these days start to program to 
solve their problems at work but they may never have been shown 
the basic principles of design, structuring and maintenance of 
their code.  If I could give them one book (and a few YouTube 
links) what should it be ?




If I understand correctly you basically need something for those 
who already doing some basic scripting but doesn't get any real 
programming skills yet.


In that case "Code Complete" by Steve McConnel probably will be 
the best one for starters, it covers broad range of programming 
aspects.
And my personal recommendations for that one probably to read the 
last (or previous?) chapter first before starting from beginning, 
this is where the whole book is described in 10-20 pages or so, 
this should give the reader short overview of what to expect, 
because reading a lot of stuff will get you anxious to know if 
this is going to be explained later or not, and the book isn't 
short.


But even despite such simplicity, learning programming from zero 
will never be easy.


OT - Git training Lon/HK and book recommendation on taste in programming

2019-05-01 Thread Laeeth Isharc via Digitalmars-d-learn

Hi.

First question - can anyone recommend git / Gitlab training 
providers in HK and London?  Two distinct audiences - highly 
intelligent people that may or may not really program, and 
experienced developers with a finance background that could 
benefit from knowing how to use git properly (finance is often in 
the dark ages).


On the former we are even getting HR, legal and compliance to 
start to use git for documents.  So some handholding will be 
required.


I would like a combination of classroom, small group on-premise 
training and somebody being in the office a few hours a week to 
help show people.


No experience is necessarily required for the latter provided you 
know git well and can patiently explain things in a way less 
advanced people will understand.  It could even be a nice 
part-time job for a student and we could pay well.  Not that we 
wouldn't look at a professional either - I just mean that I am 
open minded.


Second question.  Lots of people these days start to program to 
solve their problems at work but they may never have been shown 
the basic principles of design, structuring and maintenance of 
their code.  If I could give them one book (and a few YouTube 
links) what should it be ?


Simple things like it's okay to write functions, start with 
getting the data structures right, quality is fractal (Walter 
making little improvements to DMD for example), value of 
simplicity and things that are harder to explain like the proper 
composition of a system.


I would appreciate any suggestions on either one.


Laeeth