/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: DPT.png (934x1000, 389K)

Other urls found in this thread:

ruby-doc.org/core/Array.html#method-i-2D
tryshift.com/privacy/
tryshift.com/pricing/
hackage.haskell.org/package/postgresql-simple
twitter.com/SFWRedditImages

JavaScript rocks!

Attached: js-rocks.png (1000x494, 368K)

Don't use deprecated software. Update to Node 11.12.0 asap.

The only functional language that is actually functional.

dpt txt pls stop liking lewds

what kind of lewds are they

Isn't C technically functional if you use callbacks? Ugly, but technically possible.

ruby-doc.org/core/Array.html#method-i-2D

Array Difference

Returns a new array that is a copy of the original array, removing any items that also appear in other_ary. The order is preserved from the original array.

It compares elements using their hash and eql? methods for efficiency.

[ 1, 1, 2, 2, 3, 3, 4, 5 ] - [ 1, 2, 4 ] #=> [ 3, 3, 5 ]

If you need set-like behavior, see the library class Set.

See also #difference.

I wish I could come up with a project that would get 100 stars on github.

>web browsers inside web browser
it's a joke, right?

Attached: 1521851606135.png (1242x1167, 411K)

That's just something Ruby made up. It's not intuitive. The only sensible thing - should do for arrays, if anything, is vector subtraction.

What's your current project user?

This looks deceptive. It's a O(n^2) procedure without looking like one.

tryshift.com/privacy/

tryshift.com/pricing/

OH NO NO NO NO

is web development with .NET actually good? I know c# already (unity) and I can't stand one more second of javascript

Reminder that haskell has anime tiddie monsters

Attached: 1529643995629.png (850x1200, 938K)

what's the point? google already has an extremely simple way of switching accounts
>We collect information about you and how you use Shift.
lol

wtf? I love haskell now.
jk, F# is better

t. OOPsie

how are you enjoying no IDE, no debugging tools, no documentation and no libraries?

Attached: 1551399965641.jpg (960x960, 105K)

t. NEET

I tried JavaScript for the first time, at first I hated it, but after a while Im starting to love it, however you have to be very diciplined in not writing shit code. A subset of Js + better compile time checking would be amazing, I've tried Typescript, but thats to verbose, and does not add the checks I want. Are there any other languages very close to js to check out? Im thinking of writing a parser that can do the types of checks I want for it and strip out additional type annotations to transpose to js.

>does not add the checks I want.
what checks are those? you prolly don't need them

Or you could just use jslint, you know.

Things like when a member of a object is used in a function I want an implicit interface to be made for the parameters of the function that can be checked even outside the specific file.

Who needs an IDE when you can enjoy an OS.
I have all the rest though.

>3DPD posters are retards or lying shills
not really surprised desu

Attached: 1539165139643.jpg (886x1253, 384K)

kys mentally ill weeb

>"like a boss"
>"Get sh*t done"

Attached: disgusted anime girl yuck.jpg (912x1009, 522K)

>no IDE
He probably is enjoying it well.
>no debugging tools, no documentation and no libraries
For some godforsaken reason, Haskell is not lacking in these.

Is this why Haskell can be so comfy? It's like snuggling up in her lap with her hugging you from behind.

What about Lua?

>he needs an IDE

Attached: smug anime milf.png (397x354, 44K)

weeb website

I've tried looking for library for postgres but all I get is some links on hackage like this hackage.haskell.org/package/postgresql-simple
does haskellfags call this a documentation or I am just stupid and can't find it?

class A{
static int counter = 0;
A() { counter++; }
~A() { counter--; }
};

Can you even do this in Java?

There is no compile time in JS. It's all strictly runtime.
Like user said, you can write a plugin for ESLint to do whatever analysis you want to the AST.
What are the feature you want to get rid of in your subset?

You can use finalizers, but there's no guarantee they are executed.

>you misunderstand how encapsulation works
>a member function of one object can access the private variables of another object if they are of the same class
By the way, why the heck doesn't it work like this in java? Even a bloody copy constructor is a pain in the fucking ass to write?

try-with-resources sort of can mimick it as well

It does work like that in Java. Java methods can access the internals of other objects of the same class.
But copy ctors in Java usually copy an interface rather than the exact class.

Sorry then, I last time I used it was years ago. But I remember having trouble with it

Someone wanna rub me off

Good afternoon everyone I hope you have a great time programming today in your language of choice.

with acid maybe

Hello UK

>Good afternoon everyone I hope you have a great time programming today in your language of choice.

Attached: 1547583438205.png (249x387, 38K)

You can abuse continuation passing style to guarantee it happens.
class A
{
private A() { /* ... */ }
private static int counter = 0;
public static fix(Consumer f)
{
try
{
++counter;
f.accept(new A());
}
finally
{
--counter;
}
}
}

A.fix(a -> {
/* ... code that uses a goes here */
});

tfw no GNU+Gf

Wasted half an hour because I made a mistake in Python that should have and would have been caught by the most basic type system. I can't even fucking get the type hints working.

what mistake
you're just a noob at programming

Use OCaml instead of python.

don't listen to that happens a lot in python

Making a mistake does not make you a noob. Even professionals fuck up once in a while. The difference is that real languages call out blatant fuck ups as errors instead of trying to run with them. I shouldn't have to write everything perfect first time and install three fucking extensions to have a sane development cycle.

WHAT MISTAKE

Python does have types. I'm pretty sure the problem is in you and not the language.

For backend? Absolutely. Frontend? I've heard of blazor but don't expect much

I accidentally deleted too many parentheses and ended up overwriting a class method with a variable. Python decided that this was perfectly sensible and Pylint is either invisible or refusing to run.

did you use @classmethod ?
you're just dumb sorry

How the fuck did you manage to do that just by deleting parenthesis? And I fail to see how this is hard to spot, because you can't call a variable, and the interpreter would definitely tell you where you try to do that.

So just to be sure, once a static object is first initialized, all subsequent initializations will be completely ignored by the compiler, right?

string staticString_calls()
{
static string s = "";
return s += "Hello ";
}

int main()
{
for (size_t i = 0; i != 10; ++i)
cout

here

Solved my problem, I realized the segfault came from [probably] a stack overflow. I was using a matrix of AVX-512 vectors, changed it to chars, it works great now.

I did not use that no. It does not seem appropriate.
The ideal situation is that Python would have said "don't assign a variable to a method retard". The interpreter told me where I tried to call a variable, but not why I tried to call a variable.

>trying to add .d file generation to my makefile

my head fucking hurts holy shit

>staticString_calls()
why have you done this

Yes, static objects are intialized once. That can come in handy sometimes.
void foo()
{
static auto _= []{
/* arbitrary code here */
return nullptr;
}();
}
The contents of the lambda will run once, the first time foo() is called.

Static objects are stored in static (global) memory.

just collage homework but rn mainly math

Rewriting an old application of mine, following the rules applied by the books "Clean Code" and "Clean Architecture".

Whilst rewriting my user interface, I stumbled upon a probably easy problem which I can't find the right design pattern for.
Basically I'm creating a UI, and I had the idea of seperating the logic from several types of UI objects using abstractions.
Here a button can e.g. be clickable and changes color when hovered over. However a list should not be clickable but can change as well when hovered over.
How do I properly split up this functionality?
Currently put all the logic such as what to happen in classes thinking of using the decorator pattern, but then I realised that this forces me to make these classes concrete, while they're abstract by nature.
What's a way to solve this problem?

CFLAGS = -Wall $(DEPFLAGS)
DEPFLAGS = -MT $@ -MMD -MP -MF $*.d

src = main.c foo.c
deps = $(patsubst %.c,%.d,$(src))

%.d: ;
-include $(deps)

So the only difference between a static object and a global one is that the static one can only be accessed from within the function that created it?
But can't static objects be also declared in the global scope (outside a function)? I'm struggling to understand the usefulness of static variables when global ones exist.
The only instance I can think of where a global static object might be useful is when you declare it in the global scope of a class so it can be accessed across multiple instances of that object.

xD

>So the only difference between a static object and a global one is that the static one can only be accessed from within the function that created it?
Correct.
>But can't static objects be also declared in the global scope (outside a function)?
Static at file scope means a different thing to static at function scope.
>I'm struggling to understand the usefulness of static variables when global ones exist.
Better encapsulation.

My makefiles are a lot more complicated than that

It's still the same, you either add it to CFLAGS or in %o: %.c and -include them. The only time this would become difficult is if you use recursive make which you shouldn't.

>Static at file scope means a different thing to static at function scope.
If that's the case, then alright I guess. I was trying too hard to compare the two.

>Better encapsulation.
Now that I think about it this point does make sense. Global variables scattered all around can sometimes be troublesome to track and determine their behavior. I should start using global variables more wisely from now on.

Thanks for your time, user.

Attached: 1552032446328.jpg (800x662, 85K)

Reminder that silverlight is dead, and that you need to stop using it

My makefile supports multiple compilers, creates a nice organized build tree, has about 200 variables and 10 separate files and extensive metaprogramming to generate all the rules for all targets.

And I'm sure it's bugged as hell.

Sounds gay

yeah so does my dick

>you need to stop using it
Who started to use it to begin with?

Dear Jow Forumsentoomen, is there a proper way to learn this supreme programming language? A good book perhaps? Do we have a Perlmonk onboard?

Attached: group_482_3fb3b3_huge.jpg (250x250, 25K)

Programming perl aka the camel book is still good

Don't do this. it has mutex overhead.
Use a bool or integer flag so the compiler can use atomic instructions instead of a slow mutex.

Why would you learn a dead language?

Its still better than the cmake bullshit we had earlier, my friend actually understands how it works but I dont fully grok it

Why would it be buggy? It either generates the files we want or fails. Ive actually manually inspected the make database thing (god its horrible) and all my files and their deps look ok

Perl isn’t dead

Thank you.

It is used by some groups in the biggest known electronics company.

After a successful compilation what is the output of the command make (if you type it again)?

The main problem I face is everything is in its own dir. The .o files get one dir per build type (static/dynamic/debug/etc), the .d files get their own dir, and its making my head hurt wiring it all up.

Working with dirs is really fucking hard wow. No wonder most projects just dump literally everything in the current dir

mkdir -p buildfiles/ buildfiles/x86/ ...

It tries to make the build directories because there's a phony target that does that, and every single target has a order only dependency on it.

So your makefile is bugged.

Why? That's what I expected to happen. The directory thing always runs. It doesn't try to rebuild other stuff.

Look at what a correct makefile prints:
make: Nothing to be done for 'default'.

Then what is the bug?

Wait, it actually does both:

$ make
mkdir -p $(shitloads of directories)
make: Nothing to be done for 'bin'.

It's fine, don't worry.

Anyone here ever worked/currently works in games?
I want to try being a games programmer, but I don't know how hard it will be to change fields from general soft.dev to games dev.

Any advice? Starting my first grad job in summer.

What

Attached: sadted.jpg (534x712, 61K)

A good makefile should do NOTHING when the build run successfully.
No it's not.