/dpt/ - Daily Programming Thread

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

Attached: 1562633247343.jpg (600x725, 65K)

Other urls found in this thread:

stackoverflow.com/questions/4830900/how-do-i-find-the-index-of-an-item-in-a-vector
en.wikipedia.org/wiki/Include_guard
youtube.com/watch?v=4jh94gowim0
twitter.com/SFWRedditImages

i want to nakadashi koma-chan

I'll paypal someone $20 if they can help me figure this error out.

Cant tell without being able to see the lines the errors are referring to. Start at the first error and work from them.

I want to create desktop GUI for personal usage (on linux), what should I learn? Java? C++? Python? or what?

the picture shows the 4 lines of code that the errors are referring to. the code code block otherwise in the /code/ /code/ block ive copied and pasted all the relevent code from the two header files

randomChoice is uniform

Classic mistake my dude.
queue.h includes queuennode.h
queuenode.h includes queue.h
Circular reference prevents type from being fully defined so it defaults to int
Look up forward declarations.
Keep your money.

do you ever use for loops with an empty increment expression?
i do this all the time in C and feel badass

picrel

Attached: 1029373801.jpg (1194x1324, 644K)

writing loops makes me feel ill.
map and filter all day

i tried eliminating the queue.h call in queuennode.h. that didnt do anything

Tried the reverse, that just quadrupled the errors (as expected since queue.h has to get the QueueNode class declaration from queuennode.h. ).

What's the deal with Flutter? Is it any good?

oh wait. that fixed it. Even though data.h had no code that interacted with those ptrs, it also had:
#include "queue.h"
#include "queuenode.h" it broke the code and gave me those errors.

Thanks my dude!! Never would have guessed that error.

));
},
);
}))));
}
}

your future

structured programming was a mistake

all people need to do is stop being so butthurt over python and embrace whitespace again.

please do not put p*thon faggotry in the same category as haskell

could be worse
how does it run though?

Attached: DHdJbx6VwAAxUfd.jpg (1068x1200, 139K)

exactly my point.
There's plenty of good langs (idris, not haskell) that excel because of whitespace. But Python have brainwashed people into instantly discarding it, because god forbid we go against the curly gods
no idea, i don't do mobile shit

>idris
>good

>idris
>bad
doubt you've even used it beyond a hello world

On Monday I start first semester of software development - specifically programming fundamentals.

Anything I can do to prepare?

it's not bad it's just not good, a totally mediocre existence

Then you don't understand dep types and totality, and how useful they can be.

Stop being a brainlet and learn everything in one week.

>you just don't understand
ok retard

So how far did you get in actually using it?
Can you explain dep types and totality to me, and how they are "mediocre" then?

cute pic

Make a bulk purchase of cheap liquor.

I'm so tired. The code works until the while loop, it sends 'x' indefinitely, but if I send anything over USART, the controller just freezes. The ISR is not executed.
God damn Jow Forums, the temptation to leave this bullshit behind, and go back to programming using registers is strong but I want to be civilized, and not remain a savage.

#include

//ISR for USART
void USART1_IRQHandler(void)
{
USART_SendData(USART1, 'a');
GPIO_SetBits(GPIOC, GPIO_Pin_13);
//clearing flags and shit, doesn't work
USART_ClearFlag(USART1, USART_FLAG_RXNE);
USART_ClearITPendingBit(USART1, USART_IT_RXNE);
}

void main()
{
//setting clocks
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOC | RCC_APB2Periph_USART1 | RCC_APB2Periph_AFIO, ENABLE);

//NVIC setup
NVIC_InitTypeDef nv;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
nv.NVIC_IRQChannel = USART1_IRQn;
nv.NVIC_IRQChannelCmd = ENABLE;
nv.NVIC_IRQChannelPreemptionPriority = 0;
nv.NVIC_IRQChannelSubPriority = 0;
NVIC_Init(&nv);

GPIO_InitTypeDef g;

//setting led off
g.GPIO_Mode = GPIO_Mode_Out_PP;
g.GPIO_Pin = GPIO_Pin_13;
g.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &g);
GPIO_SetBits(GPIOC, GPIO_Pin_13);

//making PA9 as AF output
g.GPIO_Mode = GPIO_Mode_AF_PP;
g.GPIO_Pin = GPIO_Pin_9;
GPIO_Init(GPIOA, &g);

//making PA10 as input floating
g.GPIO_Mode = GPIO_Mode_IN_FLOATING;
g.GPIO_Pin = GPIO_Pin_10;
GPIO_Init(GPIOA, &g);

//setting up the usart
USART_InitTypeDef us;
us.USART_BaudRate = 9600;
us.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
us.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
us.USART_Parity = USART_Parity_No;
us.USART_StopBits = USART_StopBits_1;
us.USART_WordLength = USART_WordLength_8b;
USART_Init(USART1, &us);
USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
USART_Cmd(USART1, ENABLE);

//turning on LED
GPIO_ResetBits(GPIOC, GPIO_Pin_13);

while(1)
{
USART_SendData(USART1, 'x');
}
}

dependent types are not a saving grace for a mediocre language

He was making a joke about Lain you fucking idiot.

i actually wasn't but i don't want to make you look bad, i haven't watched lain

So you don't understand them?
It's okay to admit it user. Just refrain from shit talking things from atop mt. stupid in the future.

>Just refrain from shit talking things from atop mt. stupid in the future.
t. a total fucking retard
I bet you wouldn't be able to make reasonable use of any type system that lacked dependent types.

>I bet you wouldn't be able to make reasonable use of any type system that lacked dependent types.
No, i explore lots of languages, Idris is just one of many.
Why do you try actually learning things, instead of being miserable in mediocrity.

I already looked at the quoted post and realized it had absolutely nothing do do with Lain but I hate Lain and also don't care for programming generals, having been here since /prog/ was a board and programming threads were banned here.

So basically fuck you and your pedoshit thumbnails anyway lol.

>I read the tutorials for lots of languages I never use
That explains why you think Idris is amazing

Trying to Start Learning both Python and also AWS, What are some good books or beginner tutorials to get me going the right way?

Learning assembly little by little to write a comnpiler that will shove everything in _start!

Attached: 511635da94dd83f645ed88e34b7d3834.gif (400x400, 61K)

I'm surprised that you haven't killed yourself yet

How can you just "pause" a program and then restart it later (Ctrl-Z/closing lid)?
Like does the OS dump the entire CPU state in memory and forces all the caches to write back? What about side effects such as (network/other processes)connections or GUI and multi-threading?

Sounds crazy

have you ever heard of context switching? It does all the shit you're talking about anyway

I never did, thanks I guess

Automate the boring stuff with python.

Why is my Clojure code full of warnings

(.indexOf [1 2 3] 1)

Gives

>Reflection warning ... call to method indexOf can't be resolved (target class is unknown).

Every time I use a Java method...

Don't do this. You need your wits about you.

Learning programming for the first time.

Somebody told that you should start from the "bottom" and work your way "up" (in complexity?).

He recommended that I learn first "ASSEMBLER LANGUAGE" then "The C programming language" then "Java" then "Python".

Is this good advice? "ASSEMBLER LANGUAGE" looks complicated.

Check what flags have been set in your interrupt routine. Also don't send shit from an interrupt context, put your incoming data in a buffer.

he's retarded
90% of programmers won't have to write a line of assembly in their lives
pick something easy and useful like java or python then learn whatever else you need to accomplish what you actually want to do

'no'

it's not, it's really shit advice
start with C or python once you have a better grasp of what programming is you can choose what to learn next yourself.

I presume you used
(set! *warn-on-reflection* true)

You have two choices:
1. Turn off the *warn-on-reflection* flag.
2. Add a type hint to the vector, probably ^List.

Incidentally, I don't believe I've ever seen .indexOf used in Clojure before.
I'm not saying you can't, but you might be doing something weird.

but going straight to high level langs means you don't learn prog fundamentals like types and memory management. not saying that it's necessary - you can go your whole life without knwing what malloc is, but if you're learning programming you're missing half the topic by doing python

>got advice to learn assembler first
You got trolled hard.

stackoverflow.com/questions/4830900/how-do-i-find-the-index-of-an-item-in-a-vector
Top answer over 100 votes

program with a goal in mind. If you don't need to know malloc to accomplish your goals you don't need to learn it. if it becomes important to you, you'll learn about it at that time.

that's good advice in theory but a large proprortion of big problems i encountered as a beginner were because i didn't know the fundamentals and tried to use my high level knowledge to solve deeper problems

honestly it takes maybe 6 months to get familiar with basic programming principles. why jump straight to python and miss out on all that?

Just learn how assembly works without getting deep into it.

It's worthwhile to learn enough C to understand what's going on, but for someone just starting out, it may be more important for them to see they can do something significant. That's easier if they don't have to worry about the low-level stuff.

Someone please fork /dpt/.txt, I can't stand those fakku likes on my TL

Attached: 1532549572432.png (1280x720, 1.04M)

use at the top of each header file:
#define FILE_NAME_H
#ifndef FILE_NAME_H

and at the end
#endif

That will stop you from accidentally including the same file twice: en.wikipedia.org/wiki/Include_guard

I may start using .indexOf myself if the need arises but if you scroll down that page, you'll see cgrand (a well-known member of the Clojure community) give a different perspective.

To be honest I only started using Clojure about a week ago and that answer is pretty confusing, although I've now used it instead of indexOf since you've vouched for it. Still I don't see why such a ubiquitous operation isn't part of the standard library.

Thanks for the help though.

Attached: BohemianSharpsody.jpg (640x818, 56K)

Did you find that on r/programmerhumor or whatever the fuck it is?
That's pretty pathetic.

Attached: 1369446960901.png (256x310, 20K)

It's mildly witty but also very reddit and thus lame as fuck.

C# uses this. and not self. though?

I have the ultimate argument against test driven development...

It's FUCKING BORING.

haha xD

I'm guessing the reason it isn't in the standard library is because doing O(n) lookups is not performant.
Clojure tries to steer you toward performant operations.
Depending on your use case, that steering may be wrong, e.g. if you're searching very short lists.

But if you started a week ago then I wouldn't care about performance at this point. Just make things work.

self could be an instance of a class
var self = ....

I think TDD applications having bugs along with their admitted 50% of their code being tests is argument enough.
What if they spent that time just writing their application and actually doing proper testing?
It would be way worse.
If you fall for a meme like that you're either coping with a horrible management situation so your in-progress work has to be release ready. Meaning they'd release the instant they see the features that were requried.
Or you're just so garbage that you fall for memes like TDD.

type of testing has nothing to do with tdd. tdd is a software development methodology.

Yes you drive your development with tests. For instance they tell you to write your tests first and then implement to fit the test space you've established.
I'm well aware of it. Tell me what in the post contradicts that.

I just remembered: to get the index of a key in a performant way, you can use clojure.data.avl and its `rank-of` function.

This part
>What if they spent that time just writing their application and actually doing proper testing?
You can do proper testing on TDD. You're probably thinking of "write your tests first" in terms of writing a failing test for a new feature, then implmeneting the feature. But the tests can be functional too. Plus TDD doesn't prohibit you from writing additional tests too.

The time spent writing tests is actually recovered because without tests programmers tend to spend longer implementing things.

(zipmap xs (range))

Pssh, hey kid, I heard you like to write code heh? How about you drop those washed out software artisan wannabe languages and learn a real language? Yeah, that's right, I'm talking about Scala. Yeah you heard correct, the C boomers pray to us, the Rust trannys throw themselves at us, the Java kids cry about us, you think you got what it takes huh? Hmm, you better prove yourself, show me what you can do, you've got 200 characters, go on, prove you're ready to learn the language this universe was written in.

Attached: 1472719146965.webm (1280x720, 330K)

>you can do proper testing on TDD
Yes of course. I guess I wasn't clear. Any team divides their efforts in some way. If you write your stuff very carefully you're likely to have a lower expectation on the amount of work you'll spend doing finalizing testing.
Certain environments are excluded. For instance NASA does not do TDD as seriously as I would expect TDD people expect they would. They have countless other methods that are more robust in bug proofing code. They still also do TDD of course.
I but I don't think anyone there is insane enough to hold any expectation of less testing. You certainly don't get the impression that other places are like that when their bugs surface to you all the time.

the concept of high level languages and types/memory management are orthogonal to each other.
Please stop embarrassing yourself

scala is a horrific clusterfuck, it's worse than sepples in terms of incomprehensibility

wrong. there's strong correlation. orthogonal is a word used by pseuds btw.

>scala
youtube.com/watch?v=4jh94gowim0

t. pseud

You're onto something but it's not about features like memory management. It's about working with lower levels of expression. It's a different set of problems than gluing together existing libraries to something that sort of works.

I fucked up and confused Scala with Fortran ;_;

yet another proof everyone in this threads shills languages they never used.
I, for example, never wrote a single line of sepples

Bump for

Attached: 714F5GrOpdL._SY717_.jpg (477x717, 98K)

Says a lot about other languages when he still prefers to use Scala over other languages. Besides, that isn't necessarily a critique of the language than a critique of the standard library. And Scala 3 adds a lot of things which fixes some of the weaker parts of the language.
Yeah, you can write some shit which is difficult to understand, but which language doesn't have that shit? Scala is actually a pretty simple language syntactically, the grammar is around the same size as vanilla Haskell, and much smaller than C++ and C#.

hey i recognize that picture from a movie

>he still prefers to use Scala over other languages.
what are you talking about, he says at the end he hasn't really explored many other langs because he's been wrapped up in scala. And it's a critique of the community who have shaped the language and std.

"Oh I like this one... One dog goes one way, the other dog goes the other way, and this guy's sayin', "Whadda ya want from me?'"

Are libraries generally expected to work with optimizations enabled? I'm having a nightmarish time getting my assembly working because the compiler arbitrarily breaks up asm blocks or changes how things are inlined with -O2 and -O3.

all you need to restore your program back to its state is the current state of the registers and the address of the last instruction executed.

there's a bit more to the dynamic memory you allocated tho

Lisp is the most powerful programming language.

In what kinds of programming would you have the most use of mathematics? I have learnt enough about programming to know that I like it but I only do simple exercises like project euler so far.
I'm studying mathematics, is there anyone here with a degree in that? What kind of programming do you do then?

machine learning