/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous Thread:

Other urls found in this thread:

askubuntu.com/questions/989396/how-to-force-lubuntu-install-in-legacy-boot-mode-512-byte-mbr-when-installin
eloquentjavascript.net/
reddit.com/r/C_Programming/comments/7m1nfp/is_there_a_modern_terminal_emulator/
twitter.com/NSFWRedditGif

Current state of Linux fags:

askubuntu.com/questions/989396/how-to-force-lubuntu-install-in-legacy-boot-mode-512-byte-mbr-when-installin

That's not programming.

I know
whatchya gonna do now

I hate that curlylangs are dominant, Sup Forums.
>if and friends take only one argument like it's fucking Haskell or something, but you can use braces to group statements together
>dangling else "problem"
>stylistic holywars
>have to put the condition inside parens for some unexplained reason
>braces nonetheless mandatory for function and class definitions
Jesus we should've gassed all of them

UEFI is awful tho

>we
Dude, you're literally the only one, talking to yourself and your imaginary Hasklets in your NEET basement.

#include
#include
#include

struct sqVariables{
int number;
int answer;
}
void* sq(void* arg){
struct sqVariables *structSqVars = (struct sqVariables *)arg;
structSqVars->answer = structSqVars->number *;
structSqVars->number;
pthread_exit(0);
}

int main(int argc, char**argv){
int num_args = argc - 1;
struct sqVariables args[num_args];
for (int i = 0; i < num_args; i++){
args[i].number = atoi(argv[i + 1]);
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_create(&tids[i], &attr, sq, &args[i]);
}
for (int i = 0; i < num_args; i++){
pthread_join(tids[i], NULL);
printf("Squared number for thread %d is %lld\n",i, args[i].answer);
}
}


I keep getting errors for this code, can someone help me?

Let's say I made the mistake of writing a pretty big program in Python.

What's my best option for logging? Is it the logging module from the standard library, or is there something better out there I'm not aware of?

it's great actually
you get complete TCP/IP stack on boot
makes writing bootloaders much more fun
you don't even have to know assembly to write one anymore

who /pythonmasterrace/ here?

this is one place where the standard library reigns, i think

>watching anime while writing unit tests

why is it so hard to write unit tests senpai

>watching anime
Neck yourself. Immediately.

because you're brainlet that's why
kek

this

also
>firefox just crashed
sudo apt-get purge firefox && sudo apt-get install chromium-browser
that's how real world works baby

anime website

>trading botnets

>tids
?

>believing in botnet mem
>defending anime
I see you're a NEET.

I honestly don't have a clue mate.
Professor gave us this code, said it """worked""" and told us we needed it for 60% of our final module grade.

thread ids, i'm guessing

tiddies

>biting an obvious bait
I see you're NEW.

>botnet is a meme
>not watching anime
>not being NEET
You need to go back

>botnet is not a meme
>watching anime
>being a NEET
You have to kys

Ideally, it's supposed to be an array of pthread_t's. Also, you have a semicolon after the * in your sq function.

>tids
What the fuck?

You sure showed me !
Now you can leave, disgusting normie.

I've got this now
#include
#include
#include

struct sqVariables{
int number;
int answer;
}
void* sq(void* arg){
struct sqVariables *structSqVars = (struct sqVariables *)arg;
structSqVars->answer = structSqVars->number *
structSqVars->number;
pthread_exit(0);
}

int main(int argc, char**argv){
int num_args = argc - 1;
struct sqVariables args[num_args];
for (int i = 0; i < num_args; i++){
args[i].number = atoi(argv[i + 1]);
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_create(&tids[i], &attr, sq, &args[i]);
}
for (int i = 0; i < num_args; i++){
pthread_join(tids[i], NULL);
printf("Squared number for thread %d is %lld\n",i, args[i].answer);
}
}

Still don't know what the fuck my professor means by the whole "tids" thing, am I mean to add thread_id's in?

yeah, dude
we are not so keen on doing your homework
it doesn't seem like you are working hard enough

Didn't ask you to, was asking for help, pointers in the right direction.

eloquentjavascript.net/
Is this THE book for learning JS?

...

i just look stuff up on mdn

%lld on args[i].answer is probably still not right tho, but otherwise that seems correct IMHO.

If you can't even copypaste/type in your jewish professor's code rightly then poison will help you more than we ever could even if we wanted you fucking cretin

pretty much this
dude could've just googled what pthread_create was supposed to do.

>TCP/IP in your bootloader
that's neat indeed. From the geek boner machine standpoint it's a net positive, but from the real world point of view it's like killing a fly with a nuke. You don't need that, you can just load in an OS and it'll give you a TCP/IP stack and support for other languages easy. Hell, you could probably implement TCP/IP as a GRUB2, not even needing gay UEFI. You can also chainload OSes (yeah, kexec) and such, so I really don't see why BIOS->bootloader->OS is not good enough. And then you get all the unavoidable downsides of said oversized nuke like restricted boot, needing a fucking FAT32 partition oh god please no, all the weird bugs, duplication and all that good stuff. So that's my reason to hate UEFI. Really what am I missing that counters the simple fact that BIOS sucks less?

Not trying to start a flame war, but what are examples of actually useful things that can be done using dynamic typing, that are impossible in statically typed langs?

>useful things that can be done using dynamic typing, that are impossible in statically typed langs?
Nothing. You can emulate dynamic typing in a statically-typed language at the cost of additional steps and extra verbosity. This pretty much characterizes the entire debate.

>What are you working on, Sup Forums?
console app:
take user input string of letters
take another
convert alphabets to numerals
take user input string of numbers
take another
take another
convert each to int
manipulate and calculate
output results

works perfect with some alpha and numericals

hangs half way with others.

pouring of code not seeing the problem

racking my brain

+pissed off for lack of nicotine

argh!

I'm aware of that, but i would be satisfied with something, that is so verbose on the static side, that no one sane would use it. One thing that comes to mind right now is the eval function, but even dynamic typing fanboys tend to avoid using it.

dynamic typing is for script kiddies too retarded to understand the computers are dumb calculators and they think making types vague enough the compiler will magically understood.

you can literally add strings to integers in such languages.

utterly retarded and for niggers, pajeets and women.

learn C

>confusing dynamic typing with weak typing
go learn a lisp faggot

What did you get for Christmas /dpt/

Nothing, because I was a bad boy.
It's funny because it sounds like I'm joking.

>so verbose on the static side, that no one sane would use it
This is a pretty arbitrary criterion. I've made this point a thousand times already, but I guess I'll have to make it again: do you use a theorem prover to formally verify every program you write? Why? Is it "insane"? If you're writing embedded software for an aircraft, you'll probably want to do that. Do you feel the overhead doesn't pay off for your projects?

I wished for tea and I got tea.

Give it back, Tyrone.
i got nothing... seriously.
not a cent.
not a card.
i don't do xmas though.
or birthdays.
or any secular/pagan holidays.

never get gifts, any time.
even though i give gifts throughout the year.

maybe it will all add up and the universe will gift me with chloe (or similar model).

Well, i don't use theorem provers because i'm too brainlet for them. I've been meaning to learn about them, since i find this thing interesting as fuck, but i just couldn't find the time to do so.
I don't get from your response, on which side of the dynamic/static debate you are, but i feel that static type systems are very useful and well worth any overhead they may impose. I just want to hear some examples of why people think that dynamically typed langs are better.

i got paid
i don't celebrate consumerist trash

>I don't get from your response, on which side of the dynamic/static debate you are
Well, you kinda did. I'm on neither side of this "debate" (if you really want to call people screeching about their personal preferences a debate).

>i feel that static type systems are very useful and well worth any overhead they may impose
Then you should act in a way consistent with your feelings: learn Agda and start proving every aspect of every program you write.

I wish Santa could give us for-ranged loop with extra check for seppels.
So it's possible to write something like this:
std::string mr = "Merry Christmas and Happy New Year";
std::string nx;
for( auto i : mr; i != 't')
{
nx.push_back(i);
}

to inserting the sentence "Merry Chris" into variable nx without using ugly memcpy or iterator or std::string::at()

can't you just break?

this is a weird argument. it's fine to decide that being in-between offers the most benefit

to those who got nothing
i'll continue the pattern
you don't even get a (You) from me

How do arrays generally work in C++?
Is the template version the usual way to use them? The original C version seems pretty lacklustre.

most people don't use std::array, but it's there if you want it I guess

how does this autist find a way to steer every conversation towards his autistic hobby

So the only options are going all in on dependent typing and whatnot or abandoning all types whatsoever?
I guess i get your point, but very strong dependent types can be kind of hard to write (sometimes harder than the value conforming to that type), and that's where they may be more trouble than help.
For example i was trying to come up with the type for shift method in for lambda terms with de-bruijn's indices in idris, where each term depends on the size of context it requires, and even though i know how to write that function (it's quite straitforward) i could not for the life of me write a type signature for it.

tids

Could any of you help me out on this one?
Does programming take a lot of resources?

u r a dick

>it's fine to decide that being in-between offers the most benefit
What I'm trying to help you understand is that there is no "static typing vs. dynamic typing" debate. You can take a "dynamically typed" program, assign the static type "Any" to every expression and have a statically-typed program which doesn't prove anything useful. It's a "debate" about what completely arbitrary level of static verification is appropriate for everyone, in every situation, for every project (and you can see "static typing" fans fighting among themselves about this regularly).

Thanks.
Are templates generally the usual way to implement any sort of data structure then?

>So the only options are going all in on dependent typing and whatnot or abandoning all types whatsoever?
No, but only the ends of the spectrum can be "proven" to be universally valid choices if you accept the appropriate set of premises. Everything between them is down to personal judgment, subjective preferences and various circumstantial factors, so if you want to have a single language that addresses this problem, it'll have to be gradually typed.

Should I use mit-scheme for SICP?

if you're speaking against the implications of then sure, i have no argument with you

Not many areas of programming need a powerful computer. If you're compiling huge programs, a good PC will get the job done faster, but that's about it. You can do most things on a used laptop from 2010s you can get on Ebay for 200$.

But more importantly, 1000$ budget doesn't give you a powerful enough rig to do anything really interesting. You could probably do some alright neural network stuff with GPU, or edit 1080p video pretty comfortably, but nothing crazy.

gpu time on amazon is like $1/hr. not a big deal

Ok, i agree, that there's no one-solves-all silver bullet. I just don't think that dynamic typing is ever a better choice than inferred language with a reasonable type system, and want to be proven otherwise. I'm not claiming that my opinion is the right one, i just haven't yet seen any example where dynamic typing is clearly better.

Parsing JSON, or any format that doesn't have a schema you can perfectly predict at compile-time. On dynamic typing you can just get the object, look directly for what you want, and let exceptions tell you when you dun goofed EAFP-style. With static typing you have to do gay GetAsAnArrayIfItIsAnArray-tier stuff that's often going to be unwieldly as shit.

>apt

It depends what you're doing, but the answer is probably that you shouldn't use them as much as you think. The STL contains prefab datastructures for cases where performance isn't critical. It's very difficult for a generic data structure to be optimal in all cases so there might not be much point in using templates for the data structures you create yourself.

What languages are usually used for jobs to make money and how much do I need to know. I will in fact obsess over programming but first want get an idea of it first.

how do you know that about yourself

just use ADTs senpai

What do you mean?

Web dev, mostly. Progressive Web Apps are the shit right now, but web dev has always paid too much money for little effort.
Consult for more

But if it "doesn't have a schema you can perfectly predict at compile-time", then you can't really use it, because you don't know what fields to access. And i still think that some (even minimal) typescript structural definitions would help in a situation like that.

Wait actually yeah. I'm retarded.

int or float? JSON data don't care, but your language does

You'd probably choose int or float based on what makes sense in the context, or you could use some BigDecimal kind of datatype, which can fit any possible json number value.
Also, typescript doesn't care either (it only has number).

Is it that time of the month already?

>I just don't think that dynamic typing is ever a better choice than inferred language with a reasonable type system, and want to be proven otherwise
Nobody can "prove" anything to anyone on this matter because you're not setting any concrete criteria for what counts as "better". I can tell you that in my experience, prototyping gameplay is a lot nicer when you don't have to constantly create and/or modify classes or ADTs. Will that convince you of anything? Of course not. You'll just tell me how it's not a real problem, and how getting the occasional runtime error is the real problem.

Doesn't JSON use a double for all its numbers?

>But if it "doesn't have a schema you can perfectly predict at compile-time", then you can't really use it, because you don't know what fields to access.
Not him, but what he's getting at is that sometimes the "schema" has enough special cases and irregularities that your type system will give you hell trying to express them all.

Whoops, I forgot something. I prefer to be called a code magician.

JSON is supposed to be a portable format, so the spec just defines a "number" type, and mapping that to language-specific type(s) is left up to the decoder.

Maybe "prove" is a too strong word here. I just want to hear some arguments from the other side.
I can see how game scripting doesn't really need a type system, but i'm pretty sure i want at least a gradual type system for the library functions. Having type definitions (for me) makes it far easier to understand what they do, especially when things are poorly documented.

Why are Cfags downvoting me, Sup Forums?
reddit.com/r/C_Programming/comments/7m1nfp/is_there_a_modern_terminal_emulator/
Are they a bunch of old grumpy dudes, disconnected from reality, waiting to die?

>i'm pretty sure i want at least a gradual type system for the library functions
I agree with you: I want the utility library to be properly typed. I also want the engine core to be properly typed once it's stable. On the other hand, I don't want to have to define an ADT listing every kind of game entity while I'm still working that out. In fact, I like to use prototypal inheritance to create one-off variations on general-purpose entities. Where does that leave me? Static or dynamic typing?

come on faggots, I want to hear some honest opinions. This is Sup Forums after all.

>Why are people downvoting me
Because you're kind of an ass. People generally don't like dealing with difficult people.

That said, if you want something done right, do it yourself. If you make this terminal emulator, I'm sure some people will find use for it
iTerm is the terminal emulator I use regularly and, while nothing incredible, feels pretty comfy.

/dpt/ is lebbit - confirmed.

how do I embed my data files and dll into my executable on codeblocks?

Make an array of the bytes or somehting

I just found it surprising nobody has done it right for so many years.

Fine, I'll do it.