/dpt/ - Daily Programming Thread

Old thread: What are you working on Sup Forums?

Other urls found in this thread:

youtube.com/watch?v=Am2is2QCvxY
youtube.com/watch?v=a0FliKwcwXE
youtube.com/watch?v=iVN3LLf4wMg
pastebin.com/NHAm780P
twitter.com/SFWRedditImages

Nice doubles dubs

int i;main(){for(;i["]

Please do not use an anime image next time., thank you.

Thank you for using the traditional Yuki image.

xD

>wants 7 year old tradition to die
kys

A macrokernel for ARM64 written is assembly user, thinking of making some 3d games for it that use purely the SIMD instructions

I'm learning C++ and i'm doing problems on Project Euler to motivate that. I've noticed that every problem will overflow int and most will also overflow long long int. I made my own class of ints as vectors of digits but its clunky and probably slow so now I just use a BigInt header. Do C++ devs often experience this problem or is my situation rather synthetic

scheme edition

its a common problem in project euler, less so in real life. its not confined to C++, other languages will overflow in similar situations

So my emulator still has a black screen. I created a WebView project on my desktop and it has a black screen too. I have 90 minutes to finish this. I am really pissed off.

Rewriting the Linux kernel in a mix of C and assembly

I hope thats not a script.

Just started to learn how to use wireshark and that shit is amazing.

Forget to say the rest, What are some good projects I can work on that involve wireshark? I am working in C++.

Any good opengl tutorials?

Try intercepting game packets, perhaps make a simple bot

Implement your own network protocol on top of UDP, play with sockets and write a Wireshark dissector to check the fields of your protocol packets.

Remember: you should not send POD structs through the sockets, since padding and order in the case of bitfields is implementation-defined. Only exchange array of bytes that you may mask then to get the value of each field.

Is =< slower than plain

On bad architectures? Yes.
On good architectures? No.

NeHe is super ancient retro antique opengl from the early '00s and '90s but it's still worth going through. You can learn the modern opengl shit afterwards though.

>its not confined to C++, other languages will overflow in similar situations


No, it's pretty much confined to shitty outdated languages like C and C++.

Never seen it. If you are worrying about the performance difference between ja and jae you are worrying about the wrong thing.

What's the rationale behind Python's PEP-8 E731?

> Always use a def statement instead of an assignment statement that binds a lambda expression directly to an identifier.

Using a lambda conveys that the function is pure, so I always prefer it over def, if possible.

i would figure that jae requires more logic and more processor cycles to evaluate than ja

f = lambda x: print(random.randint(0, x))

Nope. Being greater than and being equal to are computed in parallel by hardware.

Sure, it does not enforce it, but semantically, it conveys that is should be pure. So just don't use it for print & random.

In any case, even if you were to use it for impure functions, what's the argument for forbidding it? PEP-8 does not say?

what do you think about concepts, since gcc 6.1 now supports them.

More specifically, on x86, any comparison is made by subtracting the two arguments, that's where most cycles are spent. The difference between ja and jae is just that ja check the Zero Flag while jae does not. Shouldn't have an impact on performance.

>but semantically, it conveys that is should be pure
I'm still unconvinced of that, especially since this is Python we're talking about.

>what's the argument for forbidding it? PEP-8 does not say?
As written, the argument is just for a slightly better backtrace and "no need for it".

I don't think anyone would shoot you for just using a lambda, but I wouldn't bother with it myself.

Making Sup Forums moot.

Okay, I deployed the app and it works, but I still need to fix the emulator for future work.

What's a macrokernel? A monolitic kernel?

C++ or Java?

Definitely C++.

100% c++

Yes, it's a monolithic kernel.

Java jobs pay better if you're gonna do it for the money

whats a good persistent linux OS i can put on a flash drive and boot "anywhere".
as in i can go to some computer and plug in my flash drive and have it boot from it and have it -persist- so software and files I download or install STAY on the next time I boot up.

What language has the best impact on your sanity for the money.

Java is less nightmare to work with than C++

Puppy Linux

everything but tails.

Oh, sorry, I wasn't the Java, C++ guy. I meant in general.

Driver issues might be a pain. Why not carry portable programs on there? That's what I do.

Depends on you really. Some people hate brackets and love the white space in Python, other's vice versa. Some people like dynamic languages, others don't. It depends on what kind of development you like and what fits in with your 'flow' what will make you the happiest to work in.

I love working in Python but I have a job doing .NET with C# because there's just not a lot of Python jobs where I am.

For what purpose?

For being a programmer

By that criteria alone then both are suited to the task.

>assignment due in havent started yet
>estimated time to produce is 40-60 hours
>dont feel like doing fucking anything
help

What language should I learn if I want to make 300k/year starting?

Drop out.

Better order a waifu pillow, because you're gonna become neet soon enough.

You need to learn an entire stack, not just one language

i dont want to fail though, i want to be productive

Should have started being productive 40-60 hours ago

i didnt have the will power

What is /dpt/ consensus regarding template metaprogramming?

youtube.com/watch?v=Am2is2QCvxY
youtube.com/watch?v=a0FliKwcwXE

Pretty cool, even if it was never intended.

What's the assignment, I'm curious.

>He doesn't have the spark

just some C++ assignment meant to test our knowledge of data structures, testing, etc, fairly dull shit desu

this stuff doesnt excite me anymore, anything C# or C++ bores the shit out of me. the AI modules were fun as fuck, but this stuff is dull by comparison.

it's honestly pretty cool, but I think Jonathan Blow might've made something better: youtube.com/watch?v=iVN3LLf4wMg

What SO do you guys use in your work machine?

Tbh, I'm a little excited for Blowlang. I don't think it's revolutionary, but it does look nice to write in.

why are ML-like functional languages so based

>SO

I use Felicity Jones.

But really I run Windows on my office computer with Linux Mint in a VM and use OS X with Windows in Bootcamp at home.

desu i dont even know why i like ocaml as much as i do, it's just better than almost everything else
me too. it feels like it'll be sort of an in-between for Rust and C, so that when i dont want all the extra shit Rust adds i'm not limited to using C/C++. although im kinda doubtful about performance at this point

I have no idea why SDL still fucks me over here.
SDL seems to think I still have locked surfaces even after the surface unlocking loop in there.
Looking through the implimentation for SDL_UnlockSurface gives no clues.
pastebin.com/NHAm780P

The output goes
$ ./test
load BMP
blit
Surfaces must not be locked dusring blit
$

C++11/14

No data structures assignment could possibly take 40-60 hours unless it was a fucking term project that lasted the entire quarter/semester. Fuck what you've been told. Make yourself a pot of coffee, because you're going to do this entire fucking assignment in 6-8 hours.

Or at the very least, you'll have a product that can earn partial credit.

An excellent application of black magic.

>struct Window *win = &(struct Window){.win=tmp_win, .surf=tmp_surf};
this shouldnt compile

yeah, looks simple enough, ive just gotta knock up some simple node and relation data structure, a few simple query functions, and write a report on performance testing it

Too much fuckery with pointers and "obscure" assignment syntax?
Any sugestions? I'm still new to this.

you are taking the address of a temporary object, which should be an error.
you need to allocate some memory for that struct.

struct Window *win = malloc(sizeof(*win));
*win = (struct Window){.win=tmp_win, .surf=tmp_surf};
return win;


and in destroy_window function you need to free that memory once you are done with it.
free(win);

You sure it was 40-60 hours? Not 40-60 MINUTES?

Because mate, my symbol table took about 12 hours of work this weekend, and a portion of that was spent multitasking, and about a half hour to an hour of that was just spent reading YACC documentation.

I don't even know of an assignment that would take that long, unless he had the entire semester to do it.

im fairly new to C++, so i imagine its for the mistakes im likely to make on the way

well, kinda, im fucking awful for procrastinating

Honestly, is there anything python can't do besides be fast? It seems good at everything

You're a legend mate.
This has been plaguing me since last night.

So /dpt/,

When you start a new project, how much time do you spend prototyping things and identifying data relationships on paper before actually coding the stuff?

Or do you code into your text editor immediately like what most Open Source losers do?

pypy is fast

PyPy is still stuck in 2.7

Any of you nigs do swift and ios dev? I just got hired to work on an ios app and wtf man, xcode is gay as shit. How do people make apps on that shit? Fucking thing kept crashing and maxing out the 1 core it uses and giving me the spinning beachball of death when just doing some trivial auto layout tasks. I have and i7 in my macbook pro so it's not like I'm using a complete garbage system.

Lots of things are still stuck in 2.7, using 2.7 isn't much of a price to pay if you want excellent performance from python.

>implying any good code has been written in python 3
2.7 for lyfe nigga!

Can someone explain why in c++ switch statements with strings isnt allowed.

>how much time do you spend prototyping things and identifying data relationships on paper before actually coding the stuff?

No time, and that's why all my projects are half baked.

What fucking language allows strings in switch statements? Swift?

c# for one

Pretty much all of them designed sometime within the past millennium, thereby excluding C and C++.

D

How my professor teaches algorithms:

1. Go over formal rules of algorithm with abstract examples
2. Maybe give a concrete example in the end

How I learn:

1. See a concrete example of the algorithm being used
2. Figure out the formal rules based on what it appears to be doing
3. Check against the actual formal rules later to get a better understanding of what the fuck we're doing.

Depends on the nature of the project. I typically do a back and forth of jumping into code and reading documentation, and many times I do jump straight into a text editor, if nothing else to get a skeleton framework going.

As far as C++ not allowing strings in switch statements, the branch table is generated the same as in C, which does not have real strings.

Really unfortunate too, because switching on strings is very nifty.

I agree, I can never understand a complex algorithm until I see a worked example.

Same reason you also can't use a switch statement with a float. The intention is to make it easier to create a jump table, which requires integers. Otherwise, whatever you're writing is just going to be syntactic sugar for a bunch of if/else statements.

While we're on the topic of C, make sure you demonstrate to prospective employers that you are a 10X programmer via liberal application of longjmp.

How do I learn C++?

for you.
i was bored
#include
#include
#include

struct foo { const char *str; void *lbl; };
int foocmp(const void *lhs, const void *rhs) {
return strcmp(((foo*)lhs)->str, ((foo*)rhs)->str);
}

int main(int argc, char **argv) {
__label__ sfoo;
__label__ sbar;
__label__ sbaz;

if (argc != 2) return 1;
foo jmp[] = {
{"bar", &&sbar},
{"baz", &&sbaz},
{"foo", &&sfoo}
};

foo tmp = {argv[1], NULL};
if (foo *res = (foo*)bsearch(&tmp, jmp, 3, sizeof(*jmp), foocmp))
goto *res->lbl;
printf("no match\n"); return 1;
sfoo: printf("foo matched\n"); return 0;
sbar: printf("bar matched\n"); return 0;
sbaz: printf("baz matched\n"); return 0;
}