/dpt/ - Daily Programming Thread

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

Other urls found in this thread:

youtube.com/watch?v=uiJycy6dFSQ
docs.oracle.com/javase/specs/#4.3.1
docs.spring.io/spring/docs/current/javadoc-api/
twitter.com/SFWRedditGifs

ruby is a trap

>OTOH, are you really saying that C++ should be given leeway on how late it added lambdas because LC was invented in the 1930s? How does that make sense?

I was only alluding to the lambda calculus because he specifically mentioned lambdas being around for 80 years, which is really the only way to make sense of that comment. C++ wasn't "late" in adding them. Like you said it's not a functional language and they didn't go mainstream in imperative languages until the mid 90's, and C++ has the additional burden of being a conservative and heavily standardized language with a long procedural lead time for being updated. All things considered it was fairly quick.

Trying to learn to Microcontroller. My program isn't working and idk why.


#include "SevSeg.h"
SevSeg sevseg; //Instantiate a seven segment controller object

void setup()
{
#include

//Define segment pins
#define SEG_A (LATBbits.LATB8) //LED pin 7 to MC pin 17
#define SEG_B (LATBbits.LATB7) //LED pin 6 to MC pin 16
#define SEG_C (LATBbits.LATB2) //LED pin 4 to MC pin 6
#define SEG_D (LATBbits.LATB1) //LED pin 2 to MC pin 5
#define SEG_E (LATBbits.LATB0) //LED pin 1 to MC pin 4
#define SEG_F (LATBbits.LATB9) //LED pin 9 to MC pin 18
#define SEG_G (LATBbits.LATB10) //LED pin 10 to MC pin 21
#define SEG_DP (LATBbits.LATB3) //LED pin 5 to MC pin 7

//Define control pins
#define CONT_1 (LATBbits.LATB11) //LED1 pin 8 to MC pin 22
#define CONT_2 (LATBbits.LATB13) //LED2 pin 8 to MC pin 24
#define CONT_3 (LATBbits.LATB14) //LED3 pin 8 to MC pin 25
#define CONT_4 (LATBbits.LATB15) //LED4 pin 8 to MC pin 26

byte numDigits = 4;
byte digitPins[] = {CONT_1, CONT_2, CONT_3, CONT_4};
byte segmentPins[] = {SEG_A, SEG_B, SEG_C, SEG_D, SEG_E, SEG_F, SEG_G, SEG_DP};

sevseg.begin(COMMON_CATHODE, numDigits, digitPins, segmentPins);
sevseg.setBrightness(90);

TRISBCLR = 0xFFFF; //RB0...RB13 and RB15 set to output
TRISASET = 0x0001; //RA0 set to input
LATBCLR = 0xFFFF; //RB0...RB13 and RB15 set to 0
}

void loop()
{
int sensePin = A0; //read analog voltage off RA0 (MC pin 2)
int analogVal = 0; //analog voltage value read from pin 2
int voltageVal = 0;
int dBVal = 0;

analogVal = analogRead(sensePin);
voltageVal = analogVal*(3.3/1024);
dBVal = 20*log10(voltageVal);

sevseg.setNumber(analogVal, 3);
delay(5000);
sevseg.setNumber(dBVal, 3);
delay(5000);
}

newtype is cool
GeneralizedNewtypeDeriving is cool

C

Can you explain to me what pass by value is?

The arguments passed to a function is copied? Then how are the arguments modified or changed by the functions?

I am struggling to understand this.

C# is slow as molasses. Why can't it be as fast as Assembly?

ever heard of pointers?

>Then how are the arguments modified or changed by the functions?
pass a pointer value
pass a value that contains pointers

>The arguments passed to a function is copied?

yes

>Then how are the arguments modified or changed by the functions?

The local copies are changed; the originals aren't.

The copy is changed.

Basically if you pass-by-reference, any changes that you make to the parameters will effect the variable that was sent. In pass-by-value, any changes that you make inside your function will be ignored by the outside.

Of course in C there is no such thing as pass-by-reference, but it can be emulated by passing the pointer.

>Microshit in charge of good software

rate my type deduction algorithm:

---------------
Array Byte

this is not true for every value passed by value

>Basically if you pass-by-reference, *any* changes that you make to the parameters will effect the variable that was sent.
wrong
see

C# doesn't get enough justice for being that slow.

Pass by value means that if the function mutates its parameter, it's not reflected back to the caller. That is to say, the value of a in f(a) is the same before and after the call.

I see it; it doesn't really clarify anything. I don't doubt that there are some subtleties to C[++]'s parameterization, but you're not exactly giving me much to work with here.

You all just confused me more

>That is to say, the value of a in f(a) is the same before and after the call.
So then how does a function change the value you pass to it?

>No one here codes in assembly
Terry Davis does

wrong
see there's a notable difference between these two definitions: java and c# are both pass by value (i.e. they have no references) but you can still modify parameters with changes that are reflected in the caller to some extent. every object is addressed by the pointer, so the pointer value is passed.
this does not mean that you cannot mutate passed state without it being mutated in the caller.

int main() {
int a = 0;
byValue(a);
// a is still 0
byReference(a);
// a has been changed to 1
}
void byValue( int n) {
n += 1;
}
void byReference( int* n) {
(*n) += 1;
}

Looks right to me off hand just reading it.
Check your MC and make sure the pins are correct. IIRC some MC only have RO pins or +5/-5 only pins. Shit like that.

int* is not a reference you faggot it's a pointer

wrong

Scala

I learn Unity and i try do an AI character what is do basic things. My currently problem is that, why go trough the plane my charcter (unity-chan) after i give her a rigidbody. I know the gravity but i dont understand why dont stop on the top of plane collider.

"pass by reference" is a language-agnostic term. Stop trying so hard to be pedantic, it just looks desperate.

youtube.com/watch?v=uiJycy6dFSQ

just write proper comments and code

How helpful. Or you could not be a jack-ass and tell him that I forgot a & and a return 0.

But, hey, you never tried so you never failed.

it isn't, user
you'll find that even in the c++ world "pass by references" refers to references, not pointers

this whole fucking bullshit confusion stems from the fact that some retard (i.e. the people that wrote the java spec) thought it was a good idea to use the word "reference" and "pointer" interchangably.

So a was passed as a pointer value and the pointer value was modified, correct?
So you can't tamper with a variable or address in a function, only the value itself?

i could also expect him to read one of the 20 other posts in this thread explaining what "pass by reference" means

No, it stems from the fact that the C specification uses the terms reference when they mean pass by pointer value aka pass by address.

I'm not the person who posted that.

Most of the rest of us can juggle in our head that terms have different shades of meaning in different domains and levels of discussion, it's not that confusing.

"pointer value" is ambigious in this context, but i'm pretty sure you used it correctly.
from what i can tell your understanding is correct.

Yes

Nice fairy tell you made up. Next time try using English instead of the language that only you speak.

you're still retarded

guys, let me clear this all up for you:

Typically, for references to data stored in memory on a given system, a reference is implemented as the physical address of where the data is stored in memory.

so basically, pointers are a subset of references!

He did and didn't understand. Then he read my post and did understand. Funny how writing things in terms of concepts and functionality is more effective than being pedantic about things that aren't even really true.

Assembly

What language will get me the highest paying jobs? And why is it Java.

A reference may also be a remote object reference, so it doesn't necessarily equate to an address.

I would argue that pointers are distinct from references. Referencing and dereferencing objects are usually implicit (although may be explicit when using stuff like CORBA). Pointers are simply variables that hold memory addresses, i.e. an int pointer holds the address to an int object.

wrong
the c standard is actually quite precise in that regard. the following is the only quote relating both "referencing" things and "pointers":
"A pointer type may be derived from a function type, an object type, or an incomplete
type, called the referenced type. A pointer type describes an object whose value
provides a reference to an entity of the referenced type. A pointer type derived from
the referenced type T is sometimes called ‘‘pointer to T’’. The construction of a
pointer type from a referenced type is called ‘‘pointer type derivation’’"
there's no mention of "references" or "pass by reference".

>What language will get me the highest paying jobs?
COBOL at expert level

>so it doesn't necessarily equate to an address.
this is what was written you fuckhead

wrong
"The reference values (often just references) are pointers to these objects, and a special null reference, which refers to no object"
docs.oracle.com/javase/specs/#4.3.1

that's great for you, user
i'm proud of you

Prove me wrong

posting it 2 times wasnt enough?

>2 more posts
where

1.
i haven't ever heard someone call a specific language *the* first programming language

2.
assuming that this is implying that most code is just glue code and most programming is just code monkeys glueing libraries together, this is correct
that being said, even when writing glue code there's a lot more to writing code than "knowing your libraries".

3.
i've never heard someone make that distinction before.
why is a specific choice of terminology an "unpopular opinion"?

>Hobby guitar players are guitar players, paid guitar players are "guitarist"

>A learner should be able to decide his "first programming language" by judging what the language offers and the goal of the language.
Hahaha. What fantasy world does this person live in? Expecting a beginner programmer to know what any of that even means, much less be able to judge such things.

Human beings are wired to learn spoken language developmentally as their brain develops (in fact if they don't they are never able to learn language at all; an unfortunately well-documented phenomenon thanks to the Nazis). Trying to create an analog between the way the language center of the brain develops and how various flavors of formal math are learned is pants-on-head retarded.

The use of buzz-phrases, the coddling language, and the sheer and utter ignorance of this image makes me legitimately believe it was written by an SJW.

f(&a)

Java and C# are pass by value because you cannot change what object is being pointed to. You can change the contents of said object, however. The "value" is the pointer, not the object.

>Want a job that writes libraries
>Realize writing libraries take knowledge and research above a bachelor's
>No money for Masters and Degrees
>Reduced to glueing libraries together for the rest of my life

Is this purgatory?

giving him the benefit of the doubt, i'm assuming the author was suggesting that others make that decision for him after asking for his focus instead of telling everyone to learn the same programming language.

>Start working as Java developer for company
>Get handed a fucking Macbook
>Clone the repository you'll be working in
>See this

WHAT DO /dpt/

Can someone explain to me how to refresh a Datagrid from a different thread, specifically for filtering.
It crashes every time something interrupts it but any form of locking or waiting i could think of and find online didn't work

>i haven't ever heard someone call a specific language *the* first programming language
Python/Javascript. Find one book that assumes you know any other language

If you want to play guitar, play it. Money should not make you play guitar

> Expecting a beginner programmer to know what any of that even means.
Your fault you are not explaining what you offer

So people who develop programs on the side for free or hobbies are not developers?

correct
i was specifically getting at
>Pass by value means that if the function mutates its parameter, it's not reflected back to the caller.
though, which is incorrect, because there exist parameter mutations which are reflected back to the caller

They are programmers, they are not mere developers

>Macbook
Quit and never go back.

Dictionary.com tells me you are wrong.

Well it isn't pointing to a different object, so I'm somewhat correct... just depends on how you interpret that statement.

But I'm fresh out of college and this is literally my first job

Got any others things besides your memes?

i'm not from the us, so i can't judge that.
from my experience in europe, a math oriented cs bachelor degree (i.e. not a cs degree that's just an se degree in disguise) already qualifies you to work on a bunch of interesting stuff.
sadly for people that already learned most in regards to se, cs degrees that focus less on maths and more on se are taking over.

Then suck it up for 1~2 years for muh working experience and then leave and never come back. That was what I did as well.

fyi, beginning every other post in a thread with 'wrong' when you're later willing to backtrack and concede hues of ambiguity in the subject you're discussing makes you look like a sperg.

be happy that it isn't spring
docs.spring.io/spring/docs/current/javadoc-api/
see "all classes", left hand side

>Start working for Wendy's as a Senior Chef
>Use CMake
>okay.jpg
>Need to generate VS2013 solution
>507 projects, 8Msloc, and 6 hour full rebuild

Get on my level.

>Then suck it up for 1~2 years for muh working experience
Another guy here. I did the same.
Learning to deal with sub-par code and messy projects is a worthwhile skill.

The thing is developing libraries require higher education above a degree. So either you rise high enough to be management or you go and have further studies. Being stuck in the lowest rung in a R&D is hell well.

Your code isn't working for me

You forgot the REAL way to pass variables

int main() {
int a = 0;
byValue(a);
// a is still 0
byMemes(a);
// a has been changed to 1
}
void byValue( int n) {
n += 1;
}
void byMemes( int& n) {
++n;
}

i agree, i did not see the other possible meaning of that statement

But user

IT IS

W R O N G !

>just stick your condomless dick in this std-infested whore
>promise me your dick won't fall off in a month or two
>if she gets pregnant you won't get blamed i promise

>C++
kys

>The thing is developing libraries require higher education above a degree.
i'm not so sure about that, definetly depends on the kind of libraries you end up writing.
i've got a few friends that now work in google research and spend part of their time writing libraries for related work with only a math focused bsc in cs, so it definetly isn't impossible.

See it as an exercise in patience.

i don't want to kiss you

>Your language which can literally natively include and compile my language is worse than my language!!!!

welcome to org.springframework.test.web.client.AbstractRequestExpectationManager.RequestExpectationGroupHell friend
enjoy your stay

It's not your language, it's Bjarne's language, you stupid frogfuck

>include and compile

Compile this motherfucker
int main(void)
{
int new = 2;
}

Suggest me a book/article on programming Windows Services (Daemons) in C.

he's referring to extern "C" { ... }
ya dingus

lewd

This is a blue board

typedef friend, class int;

freind namespace(class catch);

>call file anonisafucktard.c
>it compiles using a c++ compiler because it's got a .c extension

B T F O

Semen Daemon

I fucked that typedef up
typedef int friend, class;