/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?
Old thread:

Other urls found in this thread:

doc.rust-lang.org/std/sync/struct.Mutex.html#poisoning
github.com/BrianWill/pigeon/blob/master/README.MD
nsubstitute.github.io/help/received-calls/)
lmgtfy.com/?s=d&iie=1&q=cmake add_executable
twitter.com/AnonBabble

>when you accidentally pull in a package by ekmett in your project

First for C++ is a loveable language.

Second for Rust is the best serious programming language.

Started leaning Lua last night, ended up rethinking my life and rather I even need that meme lang. And people say Go's error handling is annoying.

Alright niggers, Im thoroughly confused.
What is the difference between dependency INVERSION and dependency INJECTION - the former just seems to be theory while the latter implementation.

If there are any differences can someone provide me an example (C#, C, Java or C++ preferred).

C++ and Rust are both shitlangs, crippled by bad design.

wtf is with all this python shilling in the op pic?

fact: unsafe C# is the greatest language ever devised by man (not counting holy C since it's technically made by god)

No better alternatives exist.

t. GC-let

This guide is fucking retarded.

I want to elaborate an uf8 encoded text file in chunks, in C. What's the approach? I could end up having a chunk with incomplete utf8 char.

C is nice but you are correct.

what is that. is it some kind of object-oriented assembly.

How to I start getting into OpenCL/OpenGL?

Depends: what do you want to do?

this is unironically a good graphic, kudos to the dude for putting in the effort and saving the time/frustration of so many ppl
>inb4 stop shilling
nah, just think shit like this should be encouraged (by eg bjs from the resident rust radfems/girls (male))

Short answer: Git gud.
Longer answer: I am interested in computer graphics and I want to expand my c++ and general programming knowledge.
Regarding anything concrete, I saw some dude make a minecraft clone in it, and I think that would be a fun project.

Anybody have experience with NSubstitute?

What does poison mean in the context of a mutex?

C# is Microsoft's take on Java, with a C++-like obsession with constantly adding new misfeatures.
Unsafe extends it with C-like semantics for unmanged pointers and shit.

it's C# with pointers

unfortunately the e-book is dead but if you can find an archive of arcsynthesis opengl tutorial that's a pretty good primer on gl3/4 in c++.

doc.rust-lang.org/std/sync/struct.Mutex.html#poisoning

Start with open.gl (site) and then go pick up a good OpenGL book. After you've made a few rendering projects, go read pic.

Cool, thanks.

What does Sup Forums think of special purpose teaching languages for beginners? You start with something intentionally minimalistic unroll you grok the basic concepts, then you move to a more powerful but more complex dialect until you reach real world shitlangs.

A guy I'm subscribed to on YouTube just dropped 3 hours worth of tutorial on his minilangs
github.com/BrianWill/pigeon/blob/master/README.MD

Posted after new thread

Oh i made a minecraft clone, but with c and lisp. i used the opengl superbible.

C is that language. fake languages are harmful to learn with.

I don't think there's a need for specialist languages of the sort. Languages like C and Scheme fill this niche.

Reposting:
I've installed CMake and it seems to have fucked up MinGW. I now need the libstd dll in every project I make and compile with g++ for it to run. I'm guessing CMake caused this as that's the only real change I've made recently.

How do I fix this?

Just teach them a verbose language like C# or Java, why bother with fakes?

>What does Sup Forums think of special purpose teaching languages for beginners?
Waste of time, most real-world languages have a subset that can be used to teach programming without any problems.

Install Linux or use VS.

it doesn't sound like an anomaly. you could link with -static, no dlls needed then

Any good Udemy courses for Python besides Automate The Boring Stuff?

or you put your mingw's bin/ in the windows PATH

Isn't that language just scheme? You can build up the language with only macros and lambdas. I guess defines too to make it less autistic. e.g.
(define (cons a b)
(lambda (f) (f a b)))
(define (car pair)
(pair (lambda (a b) a)))
(define (cdr pair)
(pair (lambda (a b) b)))
(define (proc-if p a b)
((p (cons a b))))
(define-syntax if
(syntax-rules ()
((if p a b) (proc-if p (lambda () a) (lambda () b)))))
(define true car)
(define false cdr)

A little more work is obviously needed to get if to match scheme's if properties, but that's a learning experience about tagged data.

Why doesnt this work?

Will do. Thanks!

Read the text on the bottom left of the screen.

I checked the documentation (nsubstitute.github.io/help/received-calls/) but it it matches.

//Mock object of IPersonRepository
personRepoMock = Substitute.For();

> tells you exactly why it's wrong
> why doesn't this work

The chart intentionally shills for Java and Python, to further drive down the salaries of these coders. That makes companies employing them have better balance, and makes actual expert programmers (C, Assembly, Fortran, etc) worth more.

Check

Why did you comment out the expectAndReturn stuff?

I was using NUnit Mocks but I cant get it to work with NUnit anymore, so I've switched to NSubstitute.

any suggestions for a http client for testing that doesn't suck ass on mac? when i started at my current place a lot of people were using soapUI which lags like shit and is generally awful. I started using postman which was much better at first but now it's also starting to lag like shit and is generally buggy

The received was supposed to go before the method call, I was mistaken but now it doesnt get the call even though it IS called:

Person.cs
namespace NUnitMocks
{
public interface IPersonRepository
{
List GetPeople();
Person GetPersonByID(string ID);
}

public class Person
{
public string ID;
public string FirstName;
public string LastName;

public Person(string newID, string fn, string ln)
{
ID = newID;
FirstName = fn;
LastName = ln;
}
}

public class PersonService
{
private IPersonRepository personRepo;

public PersonService(IPersonRepository repo)
{
personRepo = repo;
}

public List GetAllPeople()
{
return personRepo.GetPeople();
}

public List GetAllPeopleSorted()
{
List people = personRepo.GetPeople();
people.Sort(delegate (Person lhp, Person rhp)
{
return lhp.LastName.CompareTo(rhp.LastName);
});
return people;
}

public Person GetPerson(string ID)
{
try
{
return personRepo.GetPersonByID(ID);
}
catch(ArgumentException)
{
return null; // No person found
}
}
}
}

>http client
You mean web browser?

I know next to nothing about they frameworks but it seems to me that you would have to pass them a bit of information about the test run. Specifically the second method in your chain (Received) doesn't want to run since the first one returned a meaningless value for lack of a meaningful one. Am I right?

I would love some ideas on what kind of things to do with Python and Excel /dpt/...

The call order was wrong it should have been:
personRepoMock.Received().GetPeople().Returns(peopleList);

Where as it was:
personRepoMock.GetPeople().Received().Returns(peopleList);

You're not supposed to have any errors in Lua. It's a language for game scripting, the kind of application where everything is presumed to be correct to skip on error handling.

...

sorry i meant a rest client for running unit tests on my code

Don't shit on Lua.

memes aside, what are the reasons you can't use Linux (e.g. in a VM) or VS?

Ignore invalid characters. Try to carry over last bytes from last chunk to first bytes of next chunk.

I learned racket early on in my professional career; I wish I had learned that, scheme, or some other lisp dialect because even though they are rarely used for practical applications, they require good programming habits. I'd imagine that for someone that's never programmed before it would be extremely beneficial because it would pull them away from shitty practices early on.

What does getAllPeople() return then? Check what it return using a debugger, maybe that'll clue us...

I wanna die

>unit tests
Fucking why? They're completely unusable for anything non trivial, and anything trivial doesn't needs unit testing. Complete waste of time.

In general, when having big files, it's better to divide them in chunks or using mmap?

It definitely returns the correct and it appears to be the mock I set

It's better to stream them.

Kind reminder that type theory is a worthless cult.

Would you include the .h files in the add_executable list for cmake? Or just .cpp files?

Common Lisp is the best language there is, too bad there is no good compiler for it.
C is really bad language, too bad it's the best usable language there is.

...

What does stream mean, in this context?

Yes, I think it's called Complete Python Masterclass. The dude is fat and has a white Python shirt, haven't finished it but it seemed pretty good.

See lmgtfy.com/?s=d&iie=1&q=cmake add_executable

>Imperative lisps
Just kys yourself.

fuck off with this chart it's utterly degenerate

>Common Lisp is the best language there is
Amen.

I have been using Haskell exclusively for the past 2 years. What kind of job can I get with this experience?

Homeless

Pretty sure Facebook uses PHP, and Python would be of no help.

data TAL p a b where
Null :: TAL p a a
Cons :: p a b -> TAL p b c -> TAL p a c


[p int float, p float string, p string (int, int), p (int, int) ...]

Finding monads in the dumpster behind Chipotle.

you can write
compose :: Category c => TAL c a b -> c a b
compose Null = id
compose (Cons x xs) = compose xs . x

It means use a small circular buffer. Remove the data that you had processed, feed it new data.

Depandancy injection is effectively where the module has the other modules it needs to run provided in its constructor.

An inversion of control container it a system that figure out what the interdependancies are between modules in a codebase (ie module c needs modules a and b already instanciated to start up). It then starts them all up in the correct order

as parameters to the constructor that is

I don't understand dependency injection meme
like at all

That's because you are not programmer.

just use higher order functions

I don't think its a meme, its just good practise.

>An inversion of control container it a system that figure out what the interdependancies are between modules in a codebase (ie module c needs modules a and b already instanciated to start up). It then starts them all up in the correct order
This doesnt match what I've read online. Care to elaborate?

learn to spell, faggots

>pic
I mainly write C and I don't think this is accurate.
Is this just the novice programmer perspective? Because I can see that.

Or you could just, you know, do it manually in controlled fashion. As far as I'm concerned, injection is, like with most things like that, just one extra way to fuck up your code without noticing.

I am writing a game in monogame and am so fucking tired of passing a reference to my implementation of Game absolutely everywhere. Which of these is the least retarded, most OO solution for getting an on-demand handle to PrettyFunGame? Current goal is making a quit button, but I'm not joking when I say I need this thing everywhere.

public static class Program{
///
/// The main entry point for the application.
///
public static PrettyFunGame Game { get; } = new PrettyFunGame();
[STAThread]
static void Main(){
Game.Run();
}
}

vs
public class PrettyFunGame : Game{
public static PrettyFunGameTheFuckingGame { get; }
//...
public PrettyFunGame(){
TheFuckingGame = this;
//...
}
}

vs
putting a reference to PrettyFunGame inside my Button class just in case this button needs to close the game

>chart doesn't contain agda
It's shit. All the Python items should be Agda.

s/Agda/Idris/ig

What do you think is not true? That it's not obedient? That it's not dumb? That instructions are not very specific? Clearly all three are correct.

Its true that computers are all three of those things but in your environment if your computer looks dumb all the time that's probably just the programmer being dumb. Not always but mostly.

I agree with the first poster, I think its stupid to call computers dumb or smart - they are neither. They just do.

What are you talking about?