/dpt/ - Daily Programming Thread

Previous: What are you working on Sup Forums

Other urls found in this thread:

graphisoft.com/ftp/techsupport/documentation/developer_docs/AC15/GSRoot/GSRootHTMLLibrary/GS/UniString/UniString.html
graphisoft.com/ftp/techsupport/documentation/developer_docs/AC15/GSRoot/GSRootHTMLLibrary/GS/UniString/ToCStr.html
graphisoft.com/ftp/techsupport/documentation/developer_docs/AC15/GSRoot/GSRootHTMLLibrary/GS/UniString/Constructors.html
youtube.com/watch?v=PxdPj6vm1Pg
twitter.com/NSFWRedditImage

Thank you for not posting an anime image.

Thank you for posting an honorary anime image.

ay, how do i put a force on the x axis please ? rb2d.AddForce (new Vector2 (7, jumpForce), ForceMode2D.Impulse);

Ask your favorite programming literate anything (IAMA)

last time i verified, qemu was an interpreter.

>If a cacheline in the instruction cache gets dirtied, I could just re-decode them again.
yes

>Is it feasible to write an interpreted VM and expect some decent performance?
yes, the goal is to have the smallest ratio of native instructions per virtual instruction.

>I have it all in a big switch statement, is that bad?
Depends the compiler.

A faster instruction decoding than the if/else is

instructionsHandlers[] = {&ADD, &SUB, &JMP, ...};

INC_IP:
++ip;

NEXT:
goto instructionsHandlers[ program[IP] ]; // double fetches + direct jump

ADD:
...
goto INC_IP;
SUB:
...
goto INC_IP;
JMP:
ip = ...;
goto NEXT;

...

Is it a bad habit to use the same variable name when passing a function a parameter.
For example, using:
int myFunction(int var) { ... }

int main() {
int var;
myFunction(var);
... }

Compared to using two different names:
int myFunction(int someVariable) { ... }

int main() {
int var;
myFunction(var);
... }

>Ask your favorite programming literate anything (IAMA)

Many of your answers seem inane and use a lot of alternative terminology I've only seen used at shitty American unis

What is your degree?

He doesn't have a degree - he's a tripfag without the trip.

I don't really see anything wrong with it m8. Some people make a huge deal about it and add prefixes to all their variables to say where they're from though. l_ for local, m_ for member, p_ for parameter, r_ for reference parameter, etc etc

Yes. If it's global you also don't need to pass it in the first place.

what terminology are you referring to ?

No.
It's not a bad habit.
Don't listen to people who says it is for no reason.
Especially don't listen to who doesn't know how global variables are defined in in C/C++.

That's what I suspected because of the anime too

Lots of it. Just last thread you used a term that no one inside academia would use (and I have a BSc from EU did a year of my MSc in the US, so it is NOT a regional thing).

I'm not going to point it out because your arrogant attitude makes me hope you don't better yourself.

>class grenadeobject derived from a renderingobject class that has a tick added to the virtual render func to know when to explode
>class grenadeentity derived from a physicsobject that has a virtual oncollision func that checks if the collided with object was a bullet, if so it needs to delete both grenadeobject and physicsobject
>grenadeobject and grenadeentity are glued together to make it work

God this is fucking disgusting. Seriosly considering doing a class grenade deriving from both a rendering object and a physics object.

I didn't even notice that he posts anime because I've got the "werk tyme" option of my extension on. I just generally assume anyone who posts that line is a genuine retard trying to act smart.

>go to work
>already done within 30min
>7.5h to go
What should I Program?

Programming in python. I have two lists, expressionList and normalisedList. expressionList contains roughly a thousand sublists of the form [IDNUMMER,coor1,coor2,...coor8], each representing a vector. I want to normalise the vectors in expressionList by dividing every coordinate in each vector by the total length of the vector. For that, I'm using this function.

def normalisatieFunctie(expressionList):
normalisedList = expressionList[:]
for line in range(len(normalisedList)):
lengthVector = sqrt(sum(i*i for i in normalisedList[line][1:]))
normalisedList[line][1:] = [x/lengthVector for x in normalisedList[line][1:]]
return normalisedList

However, every time I use the function, both the expressionList and normalisedList turn into the same list. Shouldn't the copy at the start (normalisedList = expressionList[:]) make it so that only normalisedList gets changed? I am so fucking confused.

Do you guys think that Udacity courses are relevant enough to add them to my resume?

I think I got it m8.
I agree that a = b[:] does a copy. However, it's only a shallow copy, meaning that normalisedList and expressionList refer to the same set of lists. When you mutate those lists through normalisedList, the changes thus become visible also through expressionList.

c++ add-on upgrade for new software version but it sucks, they made a change i'm unable to bypass with the current version

I could be reading your code wrong because it's very late here, but with this line:
for line in range(len(normalisedList)):


Surely you haven't expressed a range there? You've expressed that you want it to go for the length of your list, but you haven't expressed where to start (eg. 0). I haven't used python in a while, but that doesn't look right to me.

>have biased generator
>xor it with 10101010
Would this make it unbiased or am I being retarded?

Actually, no. I'm a dickhead, you can do that in python.

It takes the length of the normalisedList, which is 1012, then makes a list which is [0,1,2...1011].

Depends what biais, here you're betting that this bias is even vs odd in a very specific way, no?

>xor it with 10101010
Just get it to stop consuming MSM and the bias will naturally dissipate if your generator has the power of critical thinking.

In Python3 it's not a list

Using python 2.

something something generator identifies as non-binary

See

I'm just talking about the very simple bias. I want the expected next bit to be 0.5. Obviously I don't want to just discard the random stream and replace it with 10101010 bytes though.

Independent study is usually always a plus on a resume because it means you can actually take the initiative and learn on your own but make sure that there's something accredited there. From a quick glance I don't see anything that points to a named school outside of their CS "Masters" with Georgia Tech.

I'd also be careful if you're really relying on that as your shining point because while it takes some sort of good looking give-a-fuck to study on your own, pajeets and ching chongs can take the same courses and do the same thing. It sounds counter-intuitive but try to have real extracurriculars or knowledge in the humanities.

How do I go about making something different then a shallow copy?

What's the opposite of 'shallow'?

Google the answer of that, plus 'copy'.

Namasté, I'm a fucking moron.

kanker

Or you could voluntarily copy the vector in the loop.

Also do
normalisedList = []
for vector in expressionList:
normalisedList.append(... vector ...)

It's simpler

You are all thanked.

help me out Sup Forums
strncpy_s(char * _Dst, rsize_t _SizeInBytes, const char * _Src, rsize_t _MaxCount);
this takes a pointer as a destination, right? it also has to point to a char, right? how do i make it eat a custom string variable for the destination?

>custom string variable
clarify.

non standard string variable

use the pointer to the internal buffer of "non standard string variable" then

>non standard string variable
clarify.

clarify what to clarify
its a GS::UniString class

>GS::UniString
Documentation for that class please.

graphisoft.com/ftp/techsupport/documentation/developer_docs/AC15/GSRoot/GSRootHTMLLibrary/GS/UniString/UniString.html

Alright. It seems that the class designer really doesn't want you to do that. There seems to be no way to access the private char array of that class, assuming there is actually one (maybe it's a wonky chunked linked list or god knows what, hell, that's the reason for encapsulation). The question is: why do you want to call strncpy_s? There must be another facility for transfering string content that's more appropriate for GS::UniString.

Why not GS::UniString::ToCStr( ... )?

oh nevermind me

That interface only has methods to get a pointer to a _constant_ characters array.

This is not an anime image, delete and redo please.

...

Sup Forums how do i actually git gud? There's only so many books I can read

You mean GS::UniString? (I'm ) Agreed.

Kill yourself
>please

yes

graphisoft.com/ftp/techsupport/documentation/developer_docs/AC15/GSRoot/GSRootHTMLLibrary/GS/UniString/ToCStr.html

>A private object which can be implicitly converted to const char*.

Practice. There's nothing that enhances your skills as much as developing software every day for hours and hours.

agreed.

>Note that maximum length of a Pascal string is 255 characters.
top kek

Well it was working before, when the data i have to modify was available directly(as char). They removed it and gave a function which returns this UniString. There might be another way to modify it, but I'm not sure. Will investigate next week and also ask in their dead forum. Thx user, at least I wont waste more time trying this method.

that didnt work, i get a cant convert gs::unistring::cstr to char or something like that. or i juat fucked it up

>Thx user, at least I wont waste more time trying this method.
You're welcome

>Will investigate next week and also ask in their dead forum.
way to go

No don't do that, user wasn't saying it would work anyway. But yes, according to the documentation, the CStr is only a read only copy of the UniString: It can be converted to const char*, but never to char*.

graphisoft.com/ftp/techsupport/documentation/developer_docs/AC15/GSRoot/GSRootHTMLLibrary/GS/UniString/Constructors.html
>Content is converted to the Unicode representation using the default user locale.
So yeah. Now everything depends on what output your code is meant to produce. UniString or char[]? In the second case: allocate your own char array, strcpy the ToCstr() result into it, and modify it.

What's an easy library or API I can practice with after I'm done with the standard library for C++?

Qt

win32

youtube.com/watch?v=PxdPj6vm1Pg

Hey /dpt/, guess what?

has anyone here gone from knowing c# to knowing java? did it take long? from what i've seen the languages are pretty much identical but i'd like to check before i apply for a job doing java thx lads

char c;
int i;
c == 'A' ? i++: ((void)0);


is this bad practice? i think its easier to read these ternaries but they need a nop to work

If you're sure it's going to stay as-is, then you might as well use a one-line if for readability.
char c;
int i;
if (c == 'A') i++;

Best practice would be to add brackets, so that in the future, if you want to do something in addition to incrementing i, it's easy to add:
char c;
int i;
if (c == 'A')
{
i++;
}

>writing 140 lines to draw a window with "hello world"

#define noop ((void)0)

c == 'A' ? ++i : noop;

>best practice would be to add brackets
stop

t. someone who doesn't work with other people on large projects

this isnt /gsg/

>first bracket on a new line
please kill yourself

what, mr trips?

I'm getting the habit to do

if(var)
{
do_something();
}


instead of

if(var)
do_something();

ffffffffffffffffffuck dynamic typing

Ignoring the fact that YOUD GET A COMPILER ERROR BECAUSE c HAS NO VALUE
you should generally use
char c = 'A';
i += 1 && (c == 'A');

>trips then dubs

inb4 singles

I literally don't know how to get singles.

3

And fuck duck typing.

>1 && (c=='A')
I like this user
How about
1 & ~(c - 'A')

visual studio doing its magic

You can change this behavior if you prefer.

>There are people who actually dislike Allman braces

It's 2017, folks.

>thinks saving lines and brackets is more important than readability/understandability

If you ever find yourself in a professional setting you'll realize that your code golf attempts do not impress, only annoy.

Allman braces a best

>python baby

>baby can't understand standard c
get out

>not using braces for a single statement
>code golf

Jesus Christ kill me now

Hindley-Milner type inference is based and lazy evaluation by default is for faggots

you're all fucking terrible at programming

:3

at least im cute

you're not cute you're delusional

>s.AuthentificationInfoValue = new IntermediaAccountService.AuthentificationInfo();
>Authentification

I FUCKING HATE MAINTAINING THIS PARTICULAR CODEBASE

I SAT HERE AND QUESTIONED MY CONCEPT OF ENGLISH FOR LIKE 4 MINUTES WHEN I READ THIS

FUCK

plz no bullying

pajeet

it's valid french lmao

this is C# right? is there no #DEFINE-like statement? I don't remember.