/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread: 57667266

Other urls found in this thread:

youtube.com/user/nallamothu
youtube.com/watch?v=4hnnqgx_tjk
a.pomf.cat/xpfqzv.ogg
twitter.com/NSFWRedditImage

>no anime op
sage this

>maxresdefault.jpg
Whats the video user?

About time for a new thread.

Got it from google images searching for C++ wallpaper.

>Pajeet in the shell

will telling my interviewers that I have a speech impediment excuse my bumbling, or will it screw me over by making them realize I'm not just nervous, I'm like this all the time

What are the core elements of Pajeet-style coding?

Where can I hire cringy weebs to enact this for me?

Found the channel from the sticky in the top right.
youtube.com/user/nallamothu

youtube.com/watch?v=4hnnqgx_tjk

Found the video too!!

It will definitely help. It gains you sympathy, they realize you are not retarded, and if it's a large business they might worry about a discrimination suit. I have no idea how important the last one is but you should be up front with them.

Be prepared to answer questions about how you cope with the speech impediment in the workplace.

Goddammit lol

youtube.com/watch?v=4hnnqgx_tjk

>windows 7
>Turbo C++

I wanna get into programming. Which make more money, front end developers, or back end? Which has more fun languages to learn?

Probably back end but far more important are the skills you have, both technical and soft.

Front end is predominately JavaScript, which most people seem to dislike, myself included. Backend gives you greater flexibility.

you're more likely to be able to make money on front end given no formal background.

Is this better than a wall of if statements?

h-how do i into soft skills

>that feel when parents fighting again and dad's blaming mom for getting me into programming instead of pushing me to go do medicine

Remember to also ask universities student councillors if they're open to you. They have their agendas but they can offer genuine advice. And you can be sure it's good info if they put you in contact with someone they think knows more.

Asian?
Tell them that medicine is hard. If things aren't working out now it'd be worse with medicine.

>he went to school to learn programming

your dad was right, you wasted your time

tfw college unironically uses Turbo C++ in XP

big league, big pepper.

>current year
>not accepting pajeetwaifu.exe as your lord and cuckster

Why the fuck street shitter still using borland

holy shit that editing

//const reference to a std::vector holding reference pointers to Gio::Files

void on_open(const std::vector< Glib::RefPtr >& files, const Glib::ustring& data)

Fuck fuck fuck
> void main
> TurboC++.exe
> DOS Box
> stdio.h in C++

Pretty sure I heard Windows Vista somewhere

Delete your Sup Forums account and go

Maybe just a little bit, but honestly, not by much. Do you _really_ need to hold your return value in a variable, user? Hint: No, you don't.

Hello Sup Forums. DU you have a minute to talk about your Lord and Saviour, Ada?

How did your mom get you into programming?

I finally got my VOIP client working and the audio output is good: a.pomf.cat/xpfqzv.ogg
For anyone interested, audio is opus 48kb mono.

How can I use bufferSubData in WebGL to add new data, rather than change data?
I keep getting errors saying I'm exceeding the allocated bytes.

Is your mom a cute progslut, or are you from the shitting-continent?

first use bufferData to allocate a buffer of an adequate size

I'm working on a personal C++ project (taking the Cryptopals challenge, if anyone's interested).
There are a lot of problems which require some common functions, so I thought it would be good time to learn some software engineering principles like Don't Repeat Yourself and such.

So, I was thinking of putting all the common functions somewhere else and making a library.

/
|----Lib/
|----src/
|----obj/
|----inc/

----Set1/
|----Challenge1/
|----src/
----bin/
----obj/
----inc/

|----Challenge2/
|----src/
----bin/
----obj/
----inc/

----Set2/
|----Challenge1/
|----src/
----bin/
----obj/
----inc/


Is this directory structure ok? Also, I've never made a library before, so should I use static or dynamic libraries?

Read up on reasons to use dynamic vs static liberties.
Honestly nowadays it makes far more sense to just statically link everything. The other considerations are just insignificant compared to the issues dynamic linking can introduce on some platforms.
>is the directory structure ok
The library is separated into its own folder. So yes it's fine. Doesn't particularly matter where it lies beyond that.

That kind of defeats the purpose of bufferSubData though.

no it doesn't

bufferSubData updates a subset of the buffer while keeping the rest as it is instead of throwing it all away with another bufferData call

Thanks.
Also, earlier when I didn't have any Lib/, I simply compiled a challenge from the Challenge directory itself (I had a makefile)
But now, should I compile from the root directory, since I have to use the Lib/ directory too.

But then I'll have a single big makefile in the root directory for all the challenges, so is there any good solution for this?

I could do -L../../Lib/ in the original makefile, but that doesn't look quite nice.

But I have to throw it all away each time I expand with a bufferData call.
I could use the classic method of doubling capacity whenever capacity is reached, but I don't know how to get the vertex data back out of a buffer; something which I'd need to do if I wanted to do another bufferData call for expansion.

>mfw Turbo C++

allocate everything you need in advance. "resizing" by allocating a new buffer is expensive, it's not something you want to happen at random times in a real-time rendering environment

I definitely need live resizing for what I'm doing: The case I'm dealing with could, in an unpredictable and everchanging manner, have many small objects or a few large objects.

Not him, but premature returns are equivalent to goto's. They disrupt program flow.

Why don't you just make some macros?

>many small objects or a few large objects
those can be in the same buffer

surely you have a known upper bound of the size, but if not, enjoy your out of memory crashes, and just reupload with bufferData then because bufferSubData doesn't magically append data like whatever webshit faggotry you're used to

Please explain how I could do that. I'm always looking for ways to improve.

Having seen and dealt with code that dogmatically sticks to the "single return" policy, I'd rather have the alternative!!

I'd do ../../lib
I don't see why it wouldn't be 'nice'. You can have it be a conf variable

I have a known combined maximum for the data of all objects.
But that data could be divided between hundreds of objects, and it'd be annoying to have to make hundreds of objects share a buffer.
Problem is I can't find a WebGL function that will allow me to pull vertex data out of a buffer so I can recreate the buffer with a larger cap.

Ok, what I thought of won't work. I think yours is a good solution.

By the way, when you're calling this function, are you passing in integer literals like 1,2,3 or have you enum'd the names somewhere?

>But that data could be divided between hundreds of objects, and it'd be annoying to have to make hundreds of objects share a buffer.
annoying maybe but it'd probably be the sensible solution

>Problem is I can't find a WebGL function that will allow me to pull vertex data out of a buffer so I can recreate the buffer with a larger cap.
you got the vertex data from somewhere (assuming no transform feedback) so just get the data from where you got it before

They're #define'd in the assembly.h header.
I probably should use enums over that, but I mindlessly wrote the defines before I thought of that.

put NULL in the table and return table[type]

I suppose you're right.

I'm a bit confused about the dependencies though. So suppose my binary is challenge1.out, what would be the dependencies?
It would obviously depend on the .o files of the current challenge, but would it depend on the library as well?
Technically it should, but how should I write that in the Makefile? Also, should each challenge's Makefile contain code to compile the libraries as well?

Will this matter? I still have to do bounds checks in case of negative numbers.

...

you could return table[type%34]

saves you one DEC operation m8

Y'all are probably fucking with me at this point.

still doesnt handle negative numbers

Why dont you make that table static?

Good idea, but I'm 90% sure the compiler will optimize that for me.

>rude
sure, it was rude
>abusive
what? literally what the fuck? who is being abused by a troll question on a programming board?

That's interesting. I didn't know compilers could change the storage classes.

it's cleaner code. and i don't see why you should need a bounds check, but if you do, then an early return on a ternary for the bounds check would make sense, you don't need a disgusting mutable return variable, it makes the code less readable

>firefox
gtf>>/out/

>on a ternary
or a ternary return expression

I'm working on a little python project with selenium and firefox. but firefox doesn't find the geckodriver even though its in the path. did anyone get this problem?

*selenium not firefox

Now that I'm looking into it, I'm not so sure.

I've been taught that it's "cleaner" to return only once, and never return early. Idk man, idk. Also, as much as ternary statements shorten code, they make it less readable. I think this is a matter of preference.

Here's the latest version. You guys sure are picky.

hey guys i need help, how do i make a visualization of sorting algorithms?, i already have the code for the algorithms but i dont know how to program the visualitzation, what framework should i use? library?, qt looks complicated, maybe i should use a 2d game framework?
im using C++, Java or Python

>I've been taught that it's "cleaner" to return only once

I personally like the returning NULL early paradigm better, because it sort of looks like an 'assertion'. And PLEASE remove that NULL from table[] for god's sake. Why are you mixing NULL and valid strings in the same table?

char *
func(int type) {
// Sort of like assert(type > 0)
if (type

> And PLEASE remove that NULL from table[] for god's sake. Why are you mixing NULL and valid strings in the same table?
You know what, I think I'll just keep it the way it was. There are as many opinons as there are people.

My assembler defaults to an instruction that takes no parameters and keeps on going. It made my logic very clean in my opinion.

>I've been taught that it's "cleaner" to return only once, and never return early
That's an extremely old-fashioned and quite honestly stupid way of doing things.
It doesn't make your code cleaner. All it does is complicate your logic by needlessly having to pass all of these errors around.

why not use enum?

He has to map integers to string literals. How will he use enums? I'm not saying you can't, but if there is one, it's gonna be very convoluted.

I'll learn from my mistakes, but I'm done staring at the same 10 lines of code. Thanks for your help, though.

I could use enums, as AFAIK you can give them integer values, at least for the purpose of mapping. But I can't print out an enum name so it's pretty much equivalent to #defining.

>visualization
You're going to need to be more specific about what kind of visualisation you're talking about. You could create a visualisation by printing to the terminal if you wanted to.

>Enums in C
Trash "feature"

>table not constant
>type isn't being sanitized
REEEEEE

it would be nice if each value's type was not unsigned int but instead of type 'enum'

that way I don't have to name them like
namespace_apple
namespace_orange
namespace_banana

They get the job done. They also interact nicely with other features:
enum my_enum {
A,
B,
C,
};

const char my_enum_str[] = {
[A] = "Alfa",
[B] = "Bravo",
[C] = "Charlie",
};

you know like the visualizations you see on youtube that has the vertical lines from small to big, or an array of numbers in a canvas that shows comparisions and stuff

this

they have their uses

why won't they put namespaces in C like holy shit how autistic do you have to be

Wait, hold on a second. You can initialise an array like that? What if my A=1, B=3, C=10. what will my table look like? I'm seeing this for the first time.

I'm intrigured but this doesn't compile.
What am I doing wrong?

enum fruits {
APPLE,
ORANGE,
TOMATO
};

unsigned int APPLE;
/*'APPLE' redeclared as a different kind of symbol*/

It'll be 11 elements large

C99

>unsigned int
enums underlying type default to int.
>but instead of type 'enum'
It's a shame they're not strongly typed, but that's never been too big of a concern to me.
There is actually a proposal for the next C2X to add more strongly types enums where you can specify the underlying type.
>that way I don't have to name them like
I don't get how that has anything to do with name spacing.

>why won't they put namespaces in C
C does have namespaces. Structs/unions have their own namespace.
This probably isn't what you're talking about though.
They won't add namespaces for functions because it would break C's simple ABI.

>You can initialise an array like that?
C99 Designated initialisers. A feature notable for being absent from C++.
>What if my A=1, B=3, C=10. what will my table look like?
The array will be 11 elements big.
The unmentioned elements will be initialised to zero.

const char *my_enum_string[]
You forgot the *

>I don't get how that has anything to do with name spacing.
name collisions trigger me

see that