/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

en.wikipedia.org/wiki/Dependent_type
youtube.com/watch?v=V49i_LM8B0E&list=PLPH7f_7ZlzxTi6kS4vCmv4ZKm9u8g5yic
github.com/Arefu/Wolf
twitter.com/NSFWRedditGif

First for D

Rust Or Bust

Reposting.

rust is a meme

>ree why won't more people use rust?!
>*sounds of rust devs not making it work well with VS*

doing some ML on tensorflow-python for my dissertation for school. pretty much babby ML but good enough to graduate with

rust is a joke

Working on my idea web app in Elixir
it's a surprise

Just state your project next time. Someone one is going to come along and say
>Python

>mfw visual studio adds botnet to my binaries
what's your excuse to use this shit instead of Clion in 2017?

>what's your excuse to use this shit
name a better C++ IDE for windows

Working on a WPF app for my dad's business.
I'm trying to make it so TextBox's are generated dynamically based on an ObservableCollection of categories, but I'm stuck on how to populate the TextBox Text with the information in the object selected from a ListBox. It's trivial to do it in the codebehind of the view but I'm trying to stick to MVVM as much as possible.

Rust is the future of software development

the telemetry is only present when you compile it for debugging

the telemetry keeps stats of crashes, errors and other shit from running binaries. These stats can be viewed under the Application Insights tab

Only if you're a tranny

>Le Rust is for SJWs meme

real functionals will, rust is a phase.

>telemetry is only present
>telemetry
>only
>IN MY FUCKING BINARIES
just kys

Explain dependent types and provide an example

>Explain dependent types
en.wikipedia.org/wiki/Dependent_type
>provide an example
Of what?

it is for debugging. your running binaries can let you know what is going on without the burden of running inside a debugger

>telemetry is bad cuz that is what nsa uses for keyloggers n snit
>keyboards are bad cuz that is what nsa uses for keyloggers n shit

a type made from a value

>"I'm not a SJW, just a progressive liberal feminist"

who "makes" the type?

_ Nat -> Prop
Array : Type -> Nat -> Type
index : Array A n -> (i : Nat) -> (i < n) -> A

You can read this as:
< is a predicate on two non-negative integers
Array is a type family (type constructor) taking an element type and a non-negative integer length
index is a function taking an Array of As of length n, a non-negative integer i that is less than n, and returning an element of type A.

When you see (x : A) -> in a function type (there is similar syntax for pair types), it's a dependent function since the next type can DEPEND on x.

you define it.

Yes, "define", not "make".

but I want to genocide all feminists and sjws.
Doesn't stop rust from being a good language.

The future of software development is speed and ease of use for the developer. Till Rust develops a good standard library it will not be the future.

are you the 1/0 = 1 guy?
define and make are synonymous in this context.

Haskell will never take over anything, and nor will any pure FP Lang.
They are just too slow.

you also want to wear knee socks and sit on a mans lap tho

Rusts stdlib is already better than C++'s

Tell me why you think pure FP means slow.

>Implications

There's the simple test for a programming language. If you can make a search engine, a driverless car AI, a mobile OS and a browser using the language, the language and its paradigm are not worthless. If you can't, the language is a /dpt/-tier useless shit.

>are you the 1/0 = 1 guy?
Not that I'm aware of.
>define and make are synonymous in this context.
Make is a retarded word to use in this context. Types don't get "made".

No I don't.
I despise traps and trapfags.

>Uninformed opinions

>Implications of uninformed opinions

>Haskell

Pure FP is much more than Haskell.

Well Haskell wont because its already ded from not starting with dependent types and not enforcing a real standard. Or it will just become the new C with a million flavors.

The future looks brighter for FP though. Its only just gotten a resurgence, but already well on the way to superiority. The fact that pure FP gets rid of exceptions and the imperative mentality of debugging errors.

hey, man
someone made a sorta useful user interface layout thingamajig for Linux using Haskell
it basically meets all your criteria right there!

>tiling wm
>useful

This

>spent hours on a sudoku solver
>4 nested for loops
>2nd loop keeps randomly incrementing by 1 and fucking up my algorithm
WHY WHY WHY

Remove the extra y++ you have somewhere that isn't in the for loop declaration.

>y++
I think you mean ++y.

Any well made soduku solver will use recursive functions anyway

Check if variables named in for loops are as expected.
Any sane person uses y++ in for

Recursion is an inefficient meme

What is everyone's thoughts on Ada?

I compiled with -O2 and suddenly the random incrementing is gone.
I don't know where it could be coming from.

Here's the whole function, there's no way l could be incremented randomly.
unsigned i, j, k, l;
for (k = 0; k < pz->size; k += 3) /* 3x3 box */
{
for (l = 0; l < pz->size; l += 3)
{
int lut[9] = { 0 };
for (i = 0; i < 3; i++)
for (j = 0; j < 3; j++)
lut[pz->arr[k+i][l+j]]++;
for (i = 0; i < 9; i++)
if (lut[i] != 1) break;
if (i == 9)
box++;
}
}

She was pimped out by Babbage and didn't actually write anything on her own.

Not if you are using it for a Sudoku solver.

What does sudoku involve that would make recursion a suitable solution?
I can understand that there are some situations where recursion would be the best solution, but it's still a massively overused and masturbated over meme.

Tail recursion is elegant and as efficient as loops.
Bad recursion means stack overflow.

Thanks, very helpful. I'm slowly learning. Would haskell be fine for playing with this or should I jump to Idris?

Because the idea of sudoku is many small puzzles coming together to form a huge puzzle. (no repeating numbers in a row, no repeating numbers in a column, solving a number results in other puzzles having another piece). The point of recursive is breaking down a large problem into smaller problems solving them and then putting it all together again. That is soduku

Tail recursion is just an ugly and inelegant way of looping.
Go back to writing your recursive fizzbuzz

>recursive fizzbuzz
it's funny because you'll never see output unless you restrict the domain

use a language with vectorized operations and free yourself from that madness

Ok, I understand that
I just hate it when people use recursion as a substitution for loops.

>lut[pz->arr[k+i][l+j]]++;
If I had to guess it would be from this.

Does it make sense to use libraries in the STL for basic usage? For instance, using std::vector and std::strings because they are safer and more convenient than using array pointers.

It feels weird using those stuff when using a language for runtime efficiency.

Have you guys noticed you can actually tell from a distance, someone who primarily codes using OOPs principles?

Unless you really need the runtime efficiency i.e. working in/with big data, just do whatever is easiest.

how the fuck do i understand tensorflow or machine learning at all?

ive been hitting my head against a wall for weeks and i just wanna make ai that can play video games

I can also actually smell an unhirable NEET over the internet.

i'm trying to get into that stuff too but no luck

I'm working on dealing with the debilitating alcoholism that comes with living at home, working two jobs, and making under 50k a year.

I thank my lucky stars I have a math background, and this exciting topic is fairly difficult to just "black box" (at least with any kind of consistent results). Suck it, losers, review your maths.

i'm i am starting college soon after years of neetdom, going into mathematics for the purpose of AI - is this something you would reccommend?

get your priorities straight my man
I work 10 hours a week and earn about $40k
but even if I only made $20k, I'd still only work 10 hours a week
having free time is more important to me than money, and I don't care where I live

this whole
>LOL He still lives with his parents!
meme is literally 'the man keeping you down'
only sheep fall for that

Is what something I'd recommend? I'll suggest, don't have the outlook of studying math for the purpose of AI, or some specific purpose, because you might get bogged down by feelings of "why do I care about generating functions (for instance), it's not related to my interests"

The mathematics involved in most AI/ML in common use you will have in your 2nd or 3rd year. You can get very far with basic linear algebra and multivariable calculus. Don't fall for the meme of lin alg coming "after" calc, there's no explicit dependency on calc and it's great to start lin alg as early as you can if you're doing anything CS related. That's my advice. Oh also don't be a sperg, and take some "soft" classes, they will surprise you, even in how they inform your main interest (for instance, maybe linguistics)

pure dchar switchCase(dchar c)
{
import std.ascii;
return !c.isAlpha ? c : c.isLower ? c.toUpper : c.toLower;
}

void main(string[] args)
{
import std.file : write, read;
import std.algorithm.iteration : map;
import std.functional : partial;
import std.array : array;
(cast(char[]) "test.txt".read).map!switchCase.array.partial!(write, "out.txt");
}


Reads a file, switch the cases of all letters, and write to an output file

Haskell doesn't have dependent types, Idris does.

>this whole
>>LOL He still lives with his parents!
>meme is literally 'the man keeping you down'
>only sheep fall for that
This. It's a core component of guaranteeing wage-slavery.

Source: I live on my own. And my attempts to pay the bills, with the assistance of food stamps of course (a means to more rapidly drain the upper and mid middle class), dictates the entirety of my everyday. You don't feel the leash, but you can be sure it's there.

thanks, sorry about such an open-ended question. i guess it was just about math as an academic pursuit. i also want to take some classes on psych, linguistics or even philosophy.

i fucked off in high school so i have been re-learning math through khan academy. right now im working on trig but its all stuff i vaguely remember up to now so i dunno where I really wanna go from here.

ok im starting to blog now, sorry

> no explicit type declaration
> inconsistent naming
> redundant & stupid keywords
> le future of le software development

Top 2 are blatantly incorrect.
Third is subjective and I don't think so at all.
Fourth is correct

>Mixing implicit and explicit type declarations
Positively haram

>Moving the goalposts

yeah? So then don't do it. Stick to 1 style.
Implicit is prefered though unless explicitly is required.

>Look at this shitty feature
>Well actually user, it's much worse
Whatever

It's cool things are pretty slow here right now. I came to math late, and out of pure love, rather than any like "oh I'm good at this, I'll pursue it" or "big money here". So I'd of course say it's very worthwhile as an academic pursuit. It underlies everything, it's the language of patterns. Definitely check out philosophy, yeah.

This gets advanced quickly, is probably meant for physics graduate students, but I absolutely love his treatment of the fundamentals in the first couple videos. He's very good at presenting, even though his audience is more advanced, I felt like sharing it anyhow youtube.com/watch?v=V49i_LM8B0E&list=PLPH7f_7ZlzxTi6kS4vCmv4ZKm9u8g5yic

Good luck man, it's a great time to be into both math and CS. A lot of things are moving quickly.

>Implicit is preferred
Sure it is

>A lot of things are moving quickly.
Too bad the human species doesn't have much time left. Waste of potential.

code::blocks

How can I create two vectors in c# and finde their dot prodcut, the vectors needs to have about 1000 dimensions.

>24:00
>going over some basics that everyone knows already as an introduction to new material
>that one nerd who raises one finger and asks an advanced question just to prove he knows more than everyone else
>>Yeah, we could do that, but it's fucking pointless now shut the fuck up ok?
lmao this guy is awesome

github.com/Arefu/Wolf

Hey guys, I'm creating a basic interpreter in c++, the idea at first is to let me calculate basic stuff such as an area, volume, etc but with a little of natural spanish language, the project involves searching for words in strings, then deciding what functions to call and then get the data from that same string or ask the user to specify it.

I just started minutes ago, this very first version just prints whatever I write, the problem is when using strings with more than a word because it prints n times (one per word), I want it to print just one time with the whole string in it. Any ideas?

#include
#include
#include
#include
#include
#include

using namespace std;

float calcula(void);
float genera(void);
float cambia(void);
int ayuda(void);


int main(void)
{
string comando;
SetConsoleOutputCP(65001);
system("CLS");
cout

Are you using Visual Studio?

Yes, I think I could use arrays? But I would need to dedicate certain places in the array to certain genres.

Cyka

English, faggot

>>cyka bylat

Assuming you are coding from scratch

public Vector(
double x,
double y
)

This 2 dimension vector can be multiplied with other vector (by using dot product) with the following instruction

public static double CrossProduct(
Vector vector1,
Vector vector2
)

Example

private Double crossProductExample()
{
Vector vector1 = new Vector(20, 30);
Vector vector2 = new Vector(45, 70);
Double crossProduct;

// crossProduct is equal to 50
crossProduct = Vector.CrossProduct(vector1, vector2);

return crossProduct;

}

The problem is creating an n-dimensional vector, maybe you need a dynamic array that stores the dimensions of your vector.

Welp, there's a bunch of libraries and stuff I'm planning to use.