/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Previous thread:

Attached: they_learned_to_code.jpg (2400x1348, 333K)

Is F* a practical general purpose language or just a meme?

Attached: Jinzo.png (689x1009, 1.31M)

Trannies with colourful hair make the best programmers.

>mfw it's pronounced "engine-x"

Attached: 7550f9841e0abaa07c9681402a2ad417.jpg (736x712, 42K)

Protip: If you haven't actually done significant work in a language, try not to lecture somebody else about that a simple google search would prove you know nothing about.

Got changing element through keyboard presses working with this GUI and now I'm just smashing buttons like a retard and giggling as everything moves.

Attached: 2b88a0fd176cc7c84d1ab6d3accaec4a696d35d2a3fee7e55ef6ff230c79526d.png (180x212, 51K)

real /dpt/ posters cite the C standard

For the C-illiterate, the retard quoted mixed up a 'declaration' and a 'definition' and proceeded to continue with his stupidity

No because real /dpt/ posters were born after Bill was elected president.

C is a boomerlang.

>tfw incomplete struct declaration is a thing
C and their circular dependencies...

Boomerang*. It comes back and hits you with a buffer overflow.

Imagine programming in a language created before memory protection was even a thing.

This exists in Java, you just don't see it

I thought I wanted to do backend stuff, but so far, my experiences with internships have all been terrible: Boring CRUD and/or maintaining some awful tangled mess.
What have your experiences been like?

General purpose language for formal methods, but impractical for software developer like CRUD or webservers.

That's how you pronounce nginx. A buddy of mine calls it "nigga next."

The same, don't fall for the STEM meme. Programming is not a profession for white men, because it is a boring, menial job that can be performed even by Indians. You can keep programming as your hobby as you focus in higher level white collar jobs that will get you further, like accounting or law.

How come? And does it generate good code?

ferror()
>Description
>The ferror function tests the error indicator for the stream pointed to by stream .
>Returns
>The ferror function returns nonzero if and only if the error indicator is set for stream .
fread()
>Description
>The fread function reads, into the array pointed to by ptr , up to nmemb members whose size is specified by size , from the stream pointed to by stream . The file position indicator for the stream (if defined) is advanced by the number of characters successfully read. If an error occurs, the resulting value of the file position indicator for the stream is indeterminate. If a partial member is read, its value is indeterminate.
>Returns
>The fread function returns the number of members successfully read, which may be less than nmemb if a read error or end-of-file is encountered. If size or nmemb is zero, fread returns zero and the contents of the array and the state of the stream remain unchanged.
fwrite()
>Description
>The fwrite function writes, from the array pointed to by ptr , up to nmemb members whose size is specified by size , to the stream pointed to by stream . The file position indicator for the stream (if defined) is advanced by the number of characters successfully written. If an error occurs, the resulting value of the file position indicator for the stream is indeterminate.
>Returns
>The fwrite function returns the number of members successfully written, which will be less than nmemb only if a write error is encountered.
errno does not seem to indicate the error for fread() and fwrite(), so how do I handle the error for those (like done with perror() and puts(strerror(errno)))?

Dynamic memory allocator for embedded. After some brief research, I've opted for TLSF (two-layer segmented fit).
>O(1) operations, ok speed
>small fragmentations, no growing creep
>works well over static memory, no requirements on virtual paging and MMU
>can manage multiple memory ares, e.g. additional RAMs
>tunable to not consume too much space, under 1 KB
The algo seems pretty simple, there was some headache to ensure that everything is aligned, but will have to rework it a little to support 8-byte alignment for amd64 as well.
Beside multiple allocations strategies I've also learned how can I export info from linker to code (e.g. end of .data segment and thus start of heap region), how to access simply access pointer register on runtime, some bit tricks used in the algo for optimizations, and how to implement mutex and how to use memory barriers on ARM.
I have not learned how to tell maximal stack size except fill memory with pattern and let it run, but that's shitty method since its supposed to be reusable (or use MPU and put some unaccessible region before the heap). So some diagnostics and debug checks are yet to go. Probably canary at the beginning of the heap region and check it on every alloc/free/whatever.

You mean automatically resolve it with multiple passes? I don't claim that circular dependencies are not an issue, just that C sucks at them.

Every degree or field is fucking garbage nowadays because we are a lost generation.
>STEM is a lie
>law school is a lie
>haven't seen much about accounting but I will assume it's a lie as well

what's a profession for white men then?

>accounting DEGREE
it's a joke in and of itself user

Is this allocator single-threaded? I'd imagine writing a multi-threaded allocator would be a pain (unless you just close everything with a global mutex).

Agriculture
Imperialism
Private Military Contracting

Terry A Davis would say it's writing compilers, but there's no where near enough jobs in things like that to support the legions of white men. That's why most of the white men here tried to become Asian women.

pornstar

Did you read my entire post?
I agree, but superior fields like business and finance will at least get you somewhere.
Not if you get your CPA.

Programming related only, retards.

C doesn't suck at them, all good style/syntax standards tell you explicitly how to use them, people ae just lazy.

Yes. It will probably run on single-core without threads as well, so locking will be usually with disabling interrupts and not with mutex (since interrupt routine would always either block or fail on reentrant, which is bad).

So clerical work that will be automated in a few decades instead of something creative? Are white people worker drones then?

>needing a license to do excel spreadsheets
absolute joke what 3rd world country are you from

>diggin potatoes

>imperialism
>profession

>being a glorified bodyguard or die in a ditch with your guts out in some shithole

Programming sucks. Don't do programming.
t. /dpt/ regular for at least a few years

Attached: 1551551943878.png (288x218, 121K)

Whatever faggot, nobody gives a shit; discuss your random digressions elsewhere.

don't say nobody warned you

Attached: 1550785432028.png (553x493, 50K)

>What are you working on, Jow Forums?
Practicing dynamic programming.
I've been wanting to learn it for a very long time, I've been stuck on project euler problem 11 way too long, and I think this might help.

>divide and conquer
>cache results
that's it
thank me later

>cache results
Yeah I was hoping this dynamic stuff would help with that. I could of course be totally wrong.

>what are guilds?
>CPAs
>ever being automated
Not in your wildest dreams, faggot.

>mechanically connecting databases to forms
>creating work
Mainstream programming is as far from "creative" as it gets, user.

that's called being a code monkey, that's not programming

Which is my original point here

Accounting is ultimately mechanical so it will ultimately be automated

Your point is that only hobbyist programmers do anything creative which couldn't be further from the truth

Maybe bookkeeping, but auditing never.

Certainly some professional programmers do anything creative, but how many? Like 1% tops!

The absolute overwhelming majority of programmers are just code monkeys though, user.

this was my naive solution
package main

import "fmt"

const SIZE = 20

var grid = [][]int{}

func row(y, x int) int {
if x > len(grid[y])-4 {
return 0
}
prod := 1
for i := 0; i < 4; i++ {
prod *= grid[y][x+i]
}
return prod
}

func col(y, x int) int {
if y > len(grid)-4 {
return 0
}
prod := 1
for i := 0; i < 4; i++ {
prod *= grid[y+i][x]
}
return prod
}

func diagR(y, x int) int {
if y > len(grid)-4 || x > len(grid[y])-4 {
return 0
}
prod := 1
for i := 0; i < 4; i++ {
prod *= grid[y+i][x+i]
}
return prod
}

func diagL(y, x int) int {
if y > len(grid)-4 || x < 3 {
return 0
}
prod := 1
for i := 0; i < 4; i++ {
prod *= grid[y+i][x-i]
}
return prod
}

func main() {
var n int
for i := 0; i < SIZE; i++ {
line := []int{}
for j := 0; j < SIZE; j++ {
if n, err := fmt.Scanf("%2d", &n); n != 1 || err != nil {
j--
continue
}
line = append(line, n)
}
grid = append(grid, line)
}

// test
fmt.Println(diagR(6, 8))

max := 0
for i := 0; i < len(grid)-4; i++ {
for j := 0; j < len(grid[i]); j++ {
if n := row(i, j); n > max {
max = n
}
if n := col(i, j); n > max {
max = n
}
if n := diagL(i, j); n > max {
max = n
}
if n := diagR(i, j); n > max {
max = n
}
}
}
fmt.Println(max)
}

finishes in 50 ms

Why do Python programmers make more than C++ programmers on average. How is this possible? You'd think the far higher barrier to entry would mean more money

It's a graduation and subject to opinion, but definitely nowhere near that low
maybe 40%
hard for me to say because I don't know an equal amount of people in every field

demand

Because C++ is comfy and Python is awkward. Programmers want to work with C++ and will accept lesser pay to work with a comfier lang. Conversely, they'll demand more money to work with a shitlang like Python.

n-notice me senpai, just the last line, the rest is pasted from the c draft.

This isn't God's design.
We were made for better things than this.
Go outside. There is a world out there.

Attached: fixed.png (2400x1348, 3.86M)

F# is the future.

Attached: 1368689001015.jpg (252x221, 9K)

Yeah when I started working on it the first time I did something along those lines, but I quit because my code quality was giving me aids. Since then I've just kind of been looking at it every few months, thinking about ways to do it more elegantly.
Your solution is nicer than mine though, we'll see what happens.

>You'd think the far higher barrier to entry would mean more money
This is not really how wages are set. Yes, the higher barrier decreases supply but the demand is still lower, seemingly.

What are Python programmers doing that is so in-demand compared to C++?

I'd wager there are significantly more people who prefer to work with Python, specifically because it's easier.

You're using that image wrong. Watch this:
>Ph.D. in F#
>any job I want
>$300k starting

Attached: counting money.jpg (640x427, 65K)

>up $100k
F# > Math

>she sees your github anime avi and haskell repos

Attached: C4oE9EBWYAAQ-R9.jpg (1200x675, 119K)

You say that, but the generation before us secluded themselves in their garages, working on "projects" instead.
Today I got my machinists square in the mail. Sometime in the next week I'll be getting a hand plane and a few pieces of wood.
You can't stop me from being a recluse no matter how much poetic you wax

This looks awful. people are so closely crammed together.

Now just imagine what you could accomplish if you devoted as much time to better yourself as you devote to judge others.

I like you user.

Holy shit whose idea was the C++ stream design?

This shit is fucking disgusting.

Attached: 1551642202897.jpg (590x768, 81K)

going to write a matrix client in java

>Holy shit whose idea was the C++ design?
>This shit is fucking disgusting.

there's a reason c++20 is introducing fmt style print functions

I like C++ otherwise, but streams are disgusting.

>Divide and conquer
Not all dp problems are divide and conquer

What about string interpolation?
I should be able to format expressions that return a string

such as?

What is the best application to create a professional CV in?
>inb4 vim
>inb4 emacs
>inb4 freetard shit

I'm pulling this out of my ass but perhaps because even though barrier to entry is lower for Python devs than it is for C++ devs, it's outweighed by the fact that there are more codebases (and thus more jobs) using Python, meaning higher demand. Or maybe just more open positions requiring python.

I don't understand the Jow Forums hateboner for Python, it's a decent scripting language for a lot of things although there's a lot of use cases where it's too slow.

LaTeX

LaTeX using vim. Not even kidding.

Sure, the function returns a std::string.

can someone explain how to solve this?

I know I must distribute the parenthesis, however this nigger online test gives me wrong this question.

Attached: math.png (259x46, 3K)

>hurrdurrr fuk freetard shit xD
Go look at your average computer science professor's CV, guaranteed it will be done in Latex

Ones with inter-subproblem dependencies

class MyWindow(QWidget):
def __init__(self):
self.lbl1 = QLabel("", self);
self.lbl2 = QLabel("", self);
self.lbl3 = QLabel("", self);

(...)

def unitUI(self):
self.lbl1.setText("Test1");
self.lbl2.setText("Test2");
self.lbl3.setText("Test3");
(....)


Not really a QT specific question... I'm creating multiple instances of QLabel in my init, but when I use them in my code they all all work as I had defined them to be all the same object, ej: if I set ext for lbl3 it gets outputted in lbl1. What could be happening here? I think python or the C++ QT5 underpinnings might be assigning the same pointer to all of them.

Python 3.7.2 btw

when you add caching it becomes a non-dependency and is the same thing as divide and conquer

LaTeX (not Latex you pervert) is a typesetting system, not a program you fucking brainlet.
>Hey guys what IDE should I use
>Rust xDDD

What did you answer?

let me try again, I'm taking the coursera algebra course.

So you already know the answer (a text editor of your choosing editing a .tex file) so why did you ask a retarded vague question (hurr durr what app i use?)

Looks like you're defining them all to point to self, what're you expecting?

-2t - (-3(2t-r)+6(t-3r))
-2t -(-6t + 3r + 6t - 18r )
-2t +6t -3r -6t +18r

In what way does it become divide and conquer? You're just not recalculating the same sub problem over and over. Other sub problems still depend on the result, you just already have it.

what is the time complexity of a calculation stored in a hash table?

>what is the time complexity of a calculation stored in a hash table?
You mean the lookup? O(n) where n is the # of collissions. Some people will claim it is O(1) but it is not technically true, unless you can guarantee the absense of collissions (perfect hash table).

1. original: -2T - (-3(2T-r) + 6(T-3r))
2. expanded paranthesis: -2T - (-6T+ 3r + 6T - 18r)
3. simplified: -2T - (-15r)
4. double negative: -2T + 15r


let me know if you need more help

-4t+30r

this is what a calculator gives me.

What does this have to do with divide and conquer?


This is if you're using linear probing, or not growing your table. Pretty much everyone uses double hashing.

ur calculator is wrong,

mines and the other anons answer are the same, its correct.