/dpt/ - Daily Programming Thread

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

Attached: 1561438160893.jpg (827x1200, 219K)

Other urls found in this thread:

cs.princeton.edu/courses/archive/spr09/cos333/beautiful.html
godbolt.org/z/FaQgyM
twitter.com/SFWRedditVideos

hows your game coming along?

Attached: freg.webm (1600x900, 1.05M)

metaprogramming :^)
class Benis
attr_accessor :size
end

i want to nakadashi sagiri

I abhor my existence.

Attached: 1561501893013.jpg (2313x1612, 846K)

I'm attempting to understand the iOS app signing process and logic which is so fucking complex compared to the Android one I'm having a hard time compiling notes.

c++

that is all.

I feel nervous and am autism posting everywhere. Should I code to calm down? What should I code?

Study to calm down. Get out a copy of SICP and take notes intensely.

same, any resource recs?

Well if you're really autistic, it comes with a strong obsession with something. What are you obsessed with?

Just code something related to that and you're golden!

Code me a waifu

I actually agree with this.
Studying is a great way to train your focus muscle in your brain. Being able to focus on one thing and one thing only is a crucial ability.

Meditation helps with that to.

>What are you obsessed with?
The paranormal because it scared me as a child.
I have pure ocd. My brain is permanently stuck in obsession and focus mode.

printed or in pdf? Which is best?

I'm working on a recommendation algorithm. Actually, I lied. I'm thinking about making a recommendation algorithm.

Are there any libraries that already have it handled? OR do I really need to bust out an adjacency matrix and do it myself?

Depends on the person. Physical reading and note taking materials can help people like with their ADHD, because they can turn off all the distracting devices and just focus on the text and taking notes.

For me I have good enough focus I can work for hours on the same laptop I use to chill and entertain myself.

I do well either or but some people swear by printed. Point is that you need to read SLOWLY and take notes on every part. If you don't understand something, look it up on google until you do and then write down your own explanation.

Lisp is the most powerful programming language.

Paranormal sightseeing app. Plenty of places have local legends that aren't well publicized. You can have community driven maps and ratings of places with paranormal activity all over the world. Enjoy your passive income, and possibly even summoning some demon by ramping up activity in these areas, you're welcome.

how long do you recommend learning a language before starting a project? I just started learning Java for about a month and I've done lots and lots of exercises. I program about 2-3hrs a day. I am still scared to start my own project I feel like i am extremely incompetent but at the same time doing the exercises is starting to bore me.

the best time to start was yesterday

You have a mindset that's going to lead you to what's known as "tutorial hell".

And in order to avoid that, you need to do stuff like personal projects and ideas, otherwise you are never going to actually program.

you learn the language BY doing projects

Lifetimes in Rust are so new to me. Lifetimes, borrowers, dereferencing, pointers, RAII, I shouldn't have learned Java as my first lang.

Learn C++ nigger

I don't want to deal with make files, headers, and all the other archaic bullshit that comes with C++. Though, seriously, I should learn C++. I think it'll do me good to write a few applications in old C++ (i.e. with raw pointers). Or, better yet, just learn C as the modern C++ library tends to abstract a lot of pointer logic away from you.

this. Rust is dead on arrival. C++ does it better and is supported everywhere

>humidity too high to sleep
>too hot to fap
>too tired to program

Attached: 1561413664364.jpg (738x341, 95K)

dude pointers are not arcane magic. Pointers are easy. Is just another feature of c++

>voluntarily infect yourself with AIDS
kek no thanks

Easy to comprehend but I should have some solid practice using them to really comprehend how they work. Pianos are simple too but practice makes perfect.

So should I spend 30 minutes on fizzbuzzes a day like I do with scales on piano?

Why learn C++ when C makes more sense conceptually and C++ is the retarded little brother though

this is bait

In every bait there is a bit of truth.

Not really? C++ has advertised itself to be an all purpose language when it literally asks you to handle every bit of memory management by yourself, which is contradictory by nature. C clearly advertises itself as a language that handles a handful of tasks really well and anything outside of that not so much, such as programs where you need to save every bit of space you can. But that's a good thing. I instinctively do not like languages like C++ and Java because they advertise themselves as "the only language that should exist because it does everything" when they clearly cannot handle tasks better than other languages.

C++ is something that tries to do everything when it shouldn't have. It was a conceptual mistake. The only people that will disagree are C++ evangelists that will create everything in C++ out of job necessity or because they buy into this idea that a language can perfectly do everything, which is a mistake that leads in a world where you have java schools. It's the truth and you cannot deny it.

Attached: tumblr_ped3n7WFdM1xxtxbqo4_250.png (250x250, 64K)

>C++ has advertised itself to be an all purpose language when it literally asks you to handle every bit of memory management by yourself, which is contradictory by nature. C clearly advertises itself as a language that handles a handful of tasks really well and anything outside of that not so much, such as programs where you need to save every bit of space you can.
Where is this advertising you speak off?

>C++ ... literally asks you to handle every bit of memory management by yourself
wrong
>C ..., such as programs where you need to save every bit of space you can
C++ is just as good if not better than C is for this

That's literally how the language is presented on Wikipedia and how it's been advertised by Bjarne Stroustrup as philosophy when he advertised his language and the decisions he made with the language. This is literally the reason he bolted on OOP into the language, it's because of that increasingly stupid belief that OOP can do everything, so including it with C philosophy can only be good!!! It's just how it lead to C++ even existing. I advise you to look through a bit of history, it can be eye opening as to why certain people came up with certain things, and why these things are harmful to all programmers at large.

When you have a motherfucker spamming his C++ garbage in every thread you can see the result of someone brainwashed by C++ philosophy.

You cannot embed C++ everywhere. C compilers are way easier to implement so they are inherently more handy when it comes to what it's good at. That's my point.

>it literally asks you to handle every bit of memory management by yourself
you can make programs without doing that
>contradictory
how?

How would I make it so that only [2..9] are part of the Number a in this type
data Rank a = Ace | Number a | Jack | Queen | King

>This is literally the reason he bolted on OOP into the language, it's because of that increasingly stupid belief that OOP can do everything, so including it with C philosophy can only be good!!!
Kek, you seriously haven't heard Bjarne speak about C++ at all then. He says only use the parts of the language you need, and that sometimes using OOP is good, other times you might need to use proceedural.
>You cannot embed C++ everywhere. C compilers are way easier to implement so they are inherently more handy when it comes to what it's good at. That's my point.
Name an architecture that doesn't have a C++ compiler?

Is this Haskell? I'm not an expert, but I think the only way is to manually create the type for each number like so.
data Rank = Ace | Number 2 | Number 3 | Number 4 | ... | Jack | Queen | King

Try to make a C++ program without memory management and come back when you realize the incredibly mistake you've made.

It's also contradictory because "all-purpose languages" should be designed to get things done rapidly, at the cost of speed. I realize it does not look contradictory at first glance but in a world where machines are really powerful, going C/C++ is inherently a mistake. They do a lot of things well but precise things terribly. That's why languages like Python get a lot of traction, by the way. It's because they're simple and get a lot of things done quickly, at the cost of being much slower than if you spent your time managing memory by yourself. THAT is a good all purpose language. You are actively harming yourself going for programming languages implicitly requiring you to take extra steps for the sake of avoiding memory usage, when it's perfectly fine to do so.

The compiler still has those possibilities to handle which makes for a compiler.
Also I'm not talking about architectures, I'm talking about embedded devices.

What if I needed from [2..9000]
There must be another way.

You can't because Haskell doesn't have dependent types yet.

Attached: programming.png (780x290, 94K)

how do you consider C# then?

>he fell for the haskell meme

So is there a language like Haskell that has "dependent types" whatever those are.
I know Haskell has language extensions, maybe I can there is one solving this problem?

C# is absolute garbage for being a microsoft product so that's an easy one, user.

Honestly my general thoughts for C-family languages is that I am not touching them unless I am absolutely required to do so. C makes more sense thematically and even then you're probably required to use Assembly if your platform is that small, C++ doesn't make sense unless in fringe scenarios like the gaming industry, and C# I would never use in any case ever. So yeah, that's my stance on C-like languages.

TL;DR Don't use C/C++ unless you need to.

I would like to program the tic80 but all its languages are garbage

you won't ever use github, then

Idris.

I don't get this post.

Github is a microsoft product. VS Code too.

C# inherently has a philosophy to design program for windows, on windows. That's basically why I will never use C#.

I have no problem using GitHub as it's the best networking platform to help people on projects and the best way to build a career out of doing what I love. I'm not a blind Microsoft hater, I can make the difference between things, but I do hate when Microsoft forces me to use Microsoft, yes.

Attached: shrug photostock.png (392x260, 72K)

c# is open source. It runs on linux, too.

nice try, microsoft shill, I'm not using your shit language!

>C# inherently has a philosophy to design program for windows, on windows.
Uh... no it doesn't. The reason C# is a rapidly growing language after years of decline is not because of Windows development; it's because of Dotnet Core. It pretty much does all the things Java does only without it being a god-awful language.

>.NET Framework (pronounced as "dot net") is a software framework developed by Microsoft that runs primarily on Microsoft Windows.

you niggas are not really smart are you

Attached: 1t0amw.jpg (600x399, 60K)

//C
int square(int num) {
return num * num;
}
square:
push rbp
mov rbp, rsp
mov DWORD PTR [rbp-4], edi
mov eax, DWORD PTR [rbp-4]
imul eax, eax
pop rbp
ret

//Rust
pub fn square(num: i32) -> i32 {
num * num
}

example::square:
push rax
imul edi, edi
seto al
test al, 1
mov dword ptr [rsp + 4], edi
jne .LBB0_2
mov eax, dword ptr [rsp + 4]
pop rcx
ret
.LBB0_2:
lea rdi, [rip + .L__unnamed_1]
mov rax, qword ptr [rip + core::panicking::panic@GOTPCREL]
call rax
ud2

str.0:
.ascii "./example.rs"

str.1:
.ascii "attempt to multiply with overflow"

.L__unnamed_1:
.quad str.1
.quad 33
.quad str.0
.quad 12
.long 3
.long 5

//Ada
function Square(num : Integer) return Integer is
begin
return num**2;
end Square;

.LC0:
.ascii "example.adb"
.zero 1
_ada_square:
push rbp #
mov rbp, rsp #,
sub rsp, 16 #,
mov DWORD PTR [rbp-4], edi # num, num
mov edx, 0 # _3,
mov eax, DWORD PTR [rbp-4] # tmp93, num
imul eax, DWORD PTR [rbp-4] # tmp92, num
jno .L2 #,
mov edx, 1 # _3,
.L2:
mov ecx, eax # _3, tmp92
mov eax, edx # _1, _3
test eax, eax # _1
je .L4 #,
mov esi, 9 #,
mov edi, OFFSET FLAT:.LC0 #,
call __gnat_rcheck_CE_Overflow_Check #
.L4:
mov eax, ecx # iftmp.2_6, _3
leave
ret


>these are the languages that are supposed to compete with C
lmao

.NET Framework != .NET Core

Stay behind the times, grandpa.

rate my regex implementation

/* match: search for regexp anywhere in text */
int match(char *regexp, char *text)
{
if (regexp[0] == '^')
return matchhere(regexp+1, text);
do { /* must look even if string is empty */
if (matchhere(regexp, text))
return 1;
} while (*text++ != '\0');
return 0;
}

/* matchhere: search for regexp at beginning of text */
int matchhere(char *regexp, char *text)
{
if (regexp[0] == '\0')
return 1;
if (regexp[1] == '*')
return matchstar(regexp[0], regexp+2, text);
if (regexp[0] == '$' && regexp[1] == '\0')
return *text == '\0';
if (*text!='\0' && (regexp[0]=='.' || regexp[0]==*text))
return matchhere(regexp+1, text+1);
return 0;
}

/* matchstar: search for c*regexp at beginning of text */
int matchstar(int c, char *regexp, char *text)
{
do { /* a * matches zero or more instances */
if (matchhere(regexp, text))
return 1;
} while (*text != '\0' && (*text++ == c || c == '.'));
return 0;
}

post compiler settings faggot

I'm going to be the one laughing when your language turns out to be a fad that doesn't stand the test of time lol

No flags, which is what the average programmer does.

//my shitlang
square num =: * num num
func_square:
imul rdi, rdi
mov rax, rdi
ret

SEETHING CNILE

//C -O2
square:
mov eax, edi
imul eax, edi
ret

//Rust -O
example::square:
mov eax, edi
imul eax, edi
ret

//Ada -O2
.LC0:
.ascii "example.adb"
.zero 1
_ada_square:
imul edi, edi # tmp92, num
jo .L10 #,
mov eax, edi #, tmp92
ret
.L10:
push rax #
mov esi, 9 #,
mov edi, OFFSET FLAT:.LC0 #,
call __gnat_rcheck_CE_Overflow_Check #

//Ada -O2 -gnatp (No runtime checks)
_ada_square:
imul edi, edi # tmp89, num
mov eax, edi #, tmp89
ret

"My language"? I know dozens of languages. I could switch to C++ in a week if it became my company's priority. Hell, if I had a pet language I'd probably say it's Kotlin, but I don't think it's a good idea to use that shit on a team. So you can hug that rotting corpse of a language and take pride that it's a little less than twice as old as C# (fun fact C# can now vote). Me, I'd prefer to ride whatever actual useful semi-modern language continues to get shit done and make me money.

Okay, so I have a ideas in mind but I feel way too underdeveloped to take them on. the easiest one I can think of currently is making some sort of algorithm that takes music playlists that i make and returns similar music found on the web/database. is that too out of scope for me?

Stop using that stupid word, you bacterium

You don't even know what languages I like. C# is still young compared to a lot of languages out there man.

Also I guessed there was a "my company uses C#!" argument hiding behind what you posted but didn't want to look dumb in case I was wrong, but I guess I was right lol. I find it to be unhealthy to defend a language like this because you happen to work in a company that uses it, but whatever, your choice. I guess I'm more passionate about some things that C# and C-like languages do very poorly.

>TRIGGERED

I think that is far out of reach if you've never done a real program before. With real I mean not an excercise

>Github is a microsoft product
github was already a product before m$ bought them.

they bought cause they dont want competition

>No flags, which is what the average programmer does.

Attached: 1558395280795.jpg (483x461, 31K)

I now exclusively use vscode when I need a GUI text editor. I never thought microshaft would ever make something this good.

>not using optimization flags
Room temperature IQ

Attached: 2rdkbw.png (205x246, 4K)

How do you deal with the crippling feelings of inadequacy when programming? When you know you'll never be a genius programmer and you're always going to be average?

Attached: 1524946348507.gif (400x225, 2.3M)

C created the software industry as you know it, and it can take it away again if you don't show it some respect.

int matchhere(char *regexp, char *text)
{
return (regexp[0] == '\0') ? 1
: (regexp[1] == '*') ? matchstar(regexp[0], regexp + 2, text)
: (regexp[0] == '$' && regexp[1] == '\0') ? *text == '\0'
: (*text && (regexp[0] == '.' || regexp[0] == *text)) ? matchhere(regexp + 1, text + 1)
: 0
}

Cope. C is getting replaced by sepples everywhere.

I want to learn to program solely to make something like this.

It's a program where you input cock weights (for cockfighting), and then you match them by weight with another cock from another entry.

What language do I learn?

Attached: matchsw.jpg (1021x776, 122K)

>/prog/
>inadequate
>average or below average
maybe you meant to go to one of /sci/s CS threads?

Attached: CjcQBE6_d.jpg (362x346, 13K)

Lol no

kek cs.princeton.edu/courses/archive/spr09/cos333/beautiful.html

Stop lying to yourself. Sepples is the industry standard now and is even slowly replacing C in microcontrollers which was once thought to be C's safespace.

reminder to always rely on tail call optimization

Attached: use_recursion.png (944x74, 14K)

>cope

Don't worry. Even if you were genius programmer, you'd have other inadequacies to fixate on.

you could make that with literally any language, user

forgot a semicolon there

Also, *text != NULL is the same as *text so you can omit that part.

int matchstar(int c, char *regexp, char *text)
{
do { /* a * matches zero or more instances */
if (matchhere(regexp, text))
return 1;
} while (*text && (*text++ == c || c == '.'));

return 0;
}

int match(char *regexp, char *text)
{
if (regexp[0] == '^')
return matchhere(regexp + 1, text);
do { /* must look even if string is empty */
if (matchhere(regexp, text))
return 1;
} while (*text++);
return 0;
}

Attached: use_recursion2.png (929x138, 22K)

>. I find it to be unhealthy to defend a language like this because you happen to work in a company that uses it,
Unhealthy? What does that even mean. Stop living in your own pathologist. Adopt to new technology. C# is good for the kind of rapid development that's super popular right now. I wouldn't recommend it for all applications. Frankly, I don't even know if I "like" the language. But defending it from the absolutely pathological and frankly, provably wrong bullshit you keep throwing at it? Yeah, that I'll defend. Just so I can call you a little armchair NEET.

spreadsheets

godbolt.org/z/FaQgyM

tried to declare chars as const chars but godbolt bitches

Please post the original version of this pic too. And if you'd like to keep posting sexy anime qts I promise they'll be appreciated.

Attached: 1561288530504.jpg (618x616, 200K)

Is this the fastest way to check if a number is even?
if (!(num&1))