/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: 1529388942671.jpg (500x375, 54K)

Other urls found in this thread:

phoenix35.js.org/
fsharp.org/guides/data-access/
ideone.com/SzV2xR
youtube.com/watch?v=hE52D-zbX3g
twitter.com/SFWRedditGifs

rolling for learning nim or setting up tensorflow in python to fuck around with ML
evens for the former

Hacking on my window manager. Making it possible to initiate a resize by dragging the edge of a window.
I was watching my wife play around with my system for a while and got lots of good ideas from it.

Attached: edge_resize.png (1920x1200, 1.05M)

JavaScript rocks!

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

Please put programming references in the OP next time

No. Fuck off.

>implying there are people who use them

Lads, should I learn JS and become a frontend dev?

Learning JS is never a disadvantage. It's a really simple scripting language afterall.
Best up-to-date resources all in one place for you: phoenix35.js.org/

Google code jam babes

I love you anons

Attached: 1492870106236.jpg (612x816, 211K)

I love you too user

you would rather to get brain cancer

Where can I get a physical copy of SICP

thanks for the fumo pics

Are you the osdev that was working on implementing networking? If you are then did a solution show up?

lmao just read the documentation

C-CUTE!

in the internet

MIT used to sell them for I think like $10 not that long ago(5-10 years), now they charge $50. You're probably better off somewhere else.

I was doing that a couple weeks back yeah.I have basic Ethernet, IP, ARP, TCP, UDP and ICMP working now. And I made an IRC client to prove it :)

Attached: ircping.png (1026x824, 357K)

I'm taking F# for a spin and so far the language itself is great. Setting up a REST API server with Giraffe was also very easy.
But database access has proven to be completely impossible. There are literally no examples to follow either.
I guess databases are too stateful for functional nerds?

fsharp.org/guides/data-access/

i want to learn OS dev. How should i go about it?

write a toy kernel

just do it. i did.

Just start hacking. OS development is learned by throwing yourself into OS development.

I'm not using MSSQL, so that leaves SQLProvider.
SQLProvider for dotnet core requires some retarded hack where you use the dotnet framework compiler to build for dotnet core.
I couldn't even be bothered trying to get it to work. Sounds really fragile.

EntityFrameworkCore was the closest I got, but the designer has no support for F# types, so I got stuck on trying to create db migrations from types.

How can I find all permutations of x characters using trees in java?

This is really cool.

h-hey everyone give me your brutally honest opinions on my undergrad c++ assignment if you could please
ideone.com/SzV2xR

Attached: 1536672128585.png (1052x1342, 769K)

You paid money to get taught basic c++?

>compilation error
>case sensitive
>only counts lower case
>rebuilds a dynamic array of characters each time the function is called?

Attached: 1436105427013.jpg (399x464, 52K)

Looks ok, I mean it's not very hard.
The assumption is that the string will not contain other characters, like digits? Otherwise the software is incorrect.
If they can only be letters you could write a isVowel(char c) function, then consonants are !isVowel(), would save a bit of code but doesn't really matter I guess.

Do you guys think that a game about programming would sell? and I don't mean autistic assembly programming like shenzhen io or tis-100; I mean a retard-proof game with a nice gui, a lot of tutorials and hand-holding and a retard-proof language like python

Rust is such a comfy language, why has it not been mass adopted yet?

>inb4 rust faggot
I program is C more, i just like how rust feels (plus the fact that it runs at almost the exact same speed as C).

yea, it's a transfer prereq
a lot of that shit was mandated by the prompt m8
similarly, i coulnd't just use anything I wanted.
that said, i do appreciate the awareness of more efficient shit to do than this

Attached: 1536665708633.jpg (540x652, 46K)

Basic Requirements
1. Strong fundamentals (Binary / Hexadecimal, Algorithms, know how things work at the bare metal level, working knowledge of assembly, version control, and documentation procedures)
2. An idea of what exactly you want to create a os for and what you're aiming for it to do.
3. Study the manual for whatever processor / processors you're targeting
4. Willingness to research memory management, compiler theory, threading, security, multiprocessing (Threads, Smp, etc), and different types of kernels.

Start by just being able to display hello world or something similar. Then after that start to develop a rudimentary command line and then from there you want to start on the actual system (Memory Manager, Interrupt handler, and some sort of threading mechanism). After you've got the basic systems running you should have enough of a idea to work out the rest (Perhaps unix compatibility and libc).

>case sensitive
He calls toLower() so should be ok.

If you care about performance there are a few things that can be done.
if(std::tolower(*(enteredString + count)) == consonantElement)
++consonantsFound;

Here you can break the inner loop after an element was found. Also I think not using braces for single life if statements is bad.

Instead of using an array for the vowels and consonants you can make it an std::unordered_set, you will get O(1) average case lookup.
You can make that map static, that way it will not be created each time the function is called.

in racket/scheme/lisp or whatever fuck it is, how do i print better output than the hot garbage that is "value:" 4
can't it just print "value: 4" instead
```(write "unit table:")
(writeln (getUnitTable costTable))
(write "current least value ==>")```

What should I call a function that takes in a collection of sets and two optional parameters N and M, and returns a set of all elements that appear in each of the input sets between N and M times?

Currently I just call it "intersection" (and describe it as an "arbitrary intersection" in a comment), but strictly speaking it's only an (arbitrary) intersection when N == M == length(collection_of_sets), which is the default. On the other extreme when N == 1 and M == length(collection_of_sets) the result is an (arbitrary) union. I'm not really sure what the call the cases for other values of N and M / the general operation represented by the function.

Is there any case where the type of main in a haskell program won't be main ::IO () ?

no i don't think so

oh i think it can be polymorphic, e.g.
-- forall a. IO a
main :: IO a
since that can be instantiated to IO () (by picking a = ())

applicatives compose
unlike monads
and java

what's the use case?

In racket
(printf "unit table: ~A~n" (getUnitTable costTable))

that's kinda neat
given the second case you mentioned, the behaviour should be the same, right?

*~s for write ~a is for display

I figured out what was going on. Most of the time when I malloc'd a string it just happened to be null-terminated but other times it wasn't. Stamping '\0' on the end of my mallocs stopped it.

Attached: 1464470940808.jpg (800x450, 47K)

yeah

how can I convince my manager that generics are a good thing and we should use them??

I'm working on an ML / NLP task of classifying an incoming IT ticket and assigning it a priority. I already have it working with Connectwise and it's about 80-85% accurate on average.

Probably best to go with keras for starting off. It takes a surprisingly low amount of time to become productive. If you're thinking of doing original research into ML then perhaps learn tensorflow and lower level APIs but honestly Keras can do 99% of what's required, even most state of the art stuff.

newtype Compose f g a = Compose { getCompose :: f (g a) }

instance (Applicative f, Applicative g) => Applicative (Compose f g) where
pure x = Compose (pure (pure x))
Compose f Compose x = Compose (() f x)

data Product f g a = Pair (f a) (g a)

instance (Applicative f, Applicative g) => Applicative (Product f g) where
pure x = Pair (pure x) (pure x)
Pair f g Pair x y = Pair (f x) (g y)


Haskell is beautiful

munge_sets(s,n,m)
intersections_within(sets,min,max)
my_fun_get_intersections_but_between_range_times(ss,lo,hi)

i recommend maximum spaghetti

It depends on the language.

>It depends on the language.
Java

Please do not use an anime image next time. Thank you.

Perhaps you could give a pitch based on type safety at compile time and the amount of time / money saved via reduction of repeated code.

I hope you have a good reason to inflict Java Generics on your colleagues.

It's so goddamn elegant

Attached: ae258beb13e65e76db70033dc83afeec5ea4813980f2fb6d115112c92fee72d6.png (1320x1005, 284K)

#include
#include
#include
#include

template
std::ostream& operator

Attached: Cover.png (1772x1772, 65K)

i took a handful of C++ programming classes at a community college and did reasonably well at them, I also learned some embedded c programming as well. where should I take it from here?

I have barely started programming properly and am already tired of listening people saying I'm not enough of a mathematician to program properly

Attached: 1553107170527.jpg (1920x1080, 223K)

e.g. "Find all elements that appear in only one of these sets", "Find all elements that appear in at least nine sets" and so on. You know, as opposed to the edge case of "Find all elements that appear in each of these sets" which is the normal (arbitrary) intersection.

Spaghetti is what I already have, the reason I'm thinking of renaming things now is because I'm refactoring the application ahead of its first proper 1.0.0 release and want things to make sense.

The alternative is Java without generics, which we're stuck with right now.

Unfortunately he has a warped view of the type safety aspect of it because he's heard of type erasure in Java, so he says things like "but that's not real type safety because it just gets turned into Object anyway". As for having to write less code, he claims it takes him even more time to read and understand generic code than was saved by writing it with generics.

Ignore them. Math is only really needed when you get into gamedev, anything else you can really figure it out yourself or read a book on algorithms then come up with your own

gods this irks me so much

What?

Attached: file.png (120x89, 1K)

Because it's a language that's designed to replace sepples, and where sepples is necessary to use, no one wants to bother to switch. For most tasks it's an awkward middle ground that's not as fast or portable as C or Fortran, and complete overkill for higher level userland software.
If you like C, Go is unironically decent for making simple Unixy programs. It's abysmal for complex software though.

Yes, and?

balancing my game AI

shouldn't it be 2?

It shouldn't.

x mod y = x+ky where 0

hey guys how can i paint a "path" of cells in a stringgrid? im using delphi

math is so fun

Attached: yes-and.jpg (620x872, 71K)

I have an app and a lib used by the app that I'm developing at the same time. Can I have a link from app repo to the lib repo?

lib/
src/
include/
makefile
app/
src/
lib/ # actually a symlink to lib
makefile # executes app/lib/makefile too

This way I can develop lib and app will automatically pick up the changes. Submodules need me to checkout a specific commit, I want it to always point to the latest like a symlink to the repo directory would.

Modulus isn't remainder.

You can imagine it like a clock.
17 mod 16 is 1,
16 is 0,
15 is 15 and so on.

0 mod 16 = 0
-1 mod 16 = 15
-2 mod 16 = 14

-16 mod 16 = 0
-15 mod 16 = 15
-14 mod 16 = 14

thanks user

>there are programmers of 20 years experience who do not understand the difference between functor, applicative, and monad

what is k?

whatever integer that makes the inequality true.

You do realize that this manager has a unreasonable already existing bias that is unlikely to change. I mean with just those two statements he literally denied the main use case of generics.

The only thing you can do is attempt to overcome his bias. Use concrete provable facts along with examples to support your argument. A power point presentation or something similar is usually helpful with management types. Make sure you've got outside references to support yourself such as examples of other successful projects using generics , data, more programmers on the team supporting you, etc. Go out of your way to tailor the whole argument towards the manager use experiences you know he has and connect the argument with things that he is comfortable with.

this is advanced math, are you preparing for fizzbuzz?

>A power point presentation or something similar is usually helpful with management types.
That still doesn't usually work. Look at the fast inverse square root function, and you know how boomer manager types see all advanced language features.

Mm. I'm trying to get the other programmers in the team to back me up but half of them are juniors who know the manager is wrong but are scared to tell him, and the rest either don't care and just want a paycheck or take his side. One of them has even been agitating for Go.

I think part of the problem is that he hasn't really written any production code in over a decade but still wants to control every single merge.

#include
#include
#include
#include

template
std::ostream& operator

who the fuck are you?
break anonimity right fucking now

Please help me anons I need to learn the absolute basics of programming and C#, I get confused about what are methods, objects etc. and how to use them and why they reject certain things that I type in.

Your facts should be concrete but the concept itself can be dumbed down or abstracted enough that you don't lose the manager. It is all a matter of presentation and making sure you target the correct level of ignorance and the right personal experiences to convince them.

Sadly the world is more about Persuasion and Manipulation rather than basing things on pure Truth.

Well. perhaps at this point you should probably be asking yourself if it is worth it to stay on this particular job or if you should be finding another. Your posts don't seem to be painting a good picture of the environment.

wow for a nice, intelligent, coherent response.
well done, Jow Forums, well done.

youtube.com/watch?v=hE52D-zbX3g

What does this do? Reverse the elements from index i to k?

You're missing yo

borrow checker is fucking shit

Let's face it: we should be teaching category theory in first year undergrad, not industry fads.

The video isn't that bad. You really need to work on confidence when speaking all the "uh" and "um" is distracting and makes it seem like you've no idea of what you're doing. Take some time and slow down what you're saying if it is necessary to avoid sounding lost and losing the audiance's attention.

where else would you learn haskell but with a useless university education

Rate my vector.
typedef struct {
int * buf;
int len;
int cap;
} vec;

vec vecnew() {
int init = 8;
vec v;
v.buf = malloc(sizeof(int) * init);
v.len = 0;
v.cap = init;
return v;
}

void vecpush(vec * v, int val) {
v->buf[v->len] = val;
v->len++;
if (v->len >= v->cap) {
v->cap *= 2;
int * newbuf = malloc(sizeof(int) * v->cap);
memcpy(newbuf, v->buf, sizeof(int) * v->len);
free(v->buf);
v->buf = newbuf;
}
}

void vecset(vec * v, size_t index, int val) {
v->buf[index] = val;
}

int vecget(vec * v, size_t index) {
return v->buf[index];
}

that's how normal people talk when they're giving a presentation
he's not pewdiepie