/dpt/ - Daily Programming Thread

Old thread: Have you done anything productive today?

Other urls found in this thread:

collin.moe/post.php?i=8
github.com/aligrudi/fbpdf
nongnu.org/fbi-improved/fimgs.man.html
github.com/jichu4n/JFBView
twitter.com/SFWRedditImages

currently designing a cache index format that I can easily dump to and from disk (serialisation is key)

Trying to learn how to read assembly. It's interesting because it is both extremely simple and yet at the same time really hard. Every instruction is easy to understand because it does something really small like just add one number to another but when you put a thousand of them together it suddenly becomes a complex program with hopes and dreams.

Is Common Lisp a meme language?

It's a word added to another language so it is by definition a meme language.

e.g.

>C#
>Javascript

Rust will dominate the world.

Be scared C-cucks.

What to do when you are bored and tired of programming /dpt/?

Rust can't even stabilize its standard library. In 20 years C will still be around and Rust will be long forgotten.

Rust is a young language that is not ready for production.

If it's not ready by now, it never will be.

Watch anime.

Nah screw that, I'm not a child. Think I'll jump into learning Python.

>I'm not a child.
>learning python
???

Python is comfy as fuck.

t. child &/brainlet

but animu is for fags

what is the straight alternative?

Don't do it for a while except if it's your job then you probably need to do some of it

It's comfy because it's easy but you can't actually use it for real world things because of how slow it is. If they just made it a compiled language like Java then fair enough. I mean why not, they force you to install the interpreter to be able to use the program so they might as well compile and make the language usable.

typedef int matrix[COLUMN] [ROW];

mat = malloc(sizeof(matrix));

srand(time(NULL));

for(int i = 0; i < ROW; i++)
for(int j = 0; j < COLUMN; j++)
*mat[i] [j] = rand()%10;

Why this works if COLUMN and ROW are 5 but it gives a segfault if they are 500 instead?
Why is C such a piece of shit language?

I don't understand this code.
#define ZOPFLI_APPEND_DATA(/* T */ value, /* T** */ data, /* size_t* */ size) {\
if (!((*size) & ((*size) - 1))) {\
/*realloc size if it's a power of two*/\
(*data) = (*size) == 0 ? malloc(sizeof(**data))\
: realloc((*data), (*size) * 2 * sizeof(**data));\
}\
(*data)[(*size)] = (value);\
(*size)++;\
}


Most of the writes to this particular storage are unsigned chars, but a few are shorts with the upper bound being 258. Even if size is incremented properly according to the type, which I don't think it is, it would mess up the offset calculation, and wouldn't increment properly. Don't know if it's just been truncating the shorts, but nonetheless generating a valid output.

Also is there a better way to get template-like functionality out of C other than overloads? The only other option is to treat the type as an array of bytes and have to pass a size.

how do I improve my attention span

how do i flush input buffer from a file?

im using fgets in a while loop to read 9 characters from a file. my buffer array is 11 characters to account for the newline character and null terminator.

if i read in 10 (or more) characters instead of 9, the newline character is left in an input buffer (i think?), and my program gets stuck in an infinite loop because the next call to fgets just results in the string being unmodified.

how 2 fix

take adderall

set goals and reward yourself.
Implement X -> an hour of vidya/animu/whanever you like.

banned

eh, will try

Avoid exposure to wireless devices and cell towers. They damage the hippocampus, especially the dentate gyrus, which is involved with working memory and integration of present context with long term behavioral change. They also damage serotonergic systems (motivation, sensory, and memory processing), and alter neurotransmitter release elsewhere. This was well known 2 decades ago, and suspected as early as the 60's.

Get proper sleep, improve diet, exercise.

Optionally supplement with celastrus paniculatus seeds, phenibut (calcium channel blocker), or kava. Kava is good for focus, upregulates norepinephrine synthesis and release in the frontal lobes.

The psychological stuff is your own deal. Just learn to focus, have interest, and develop some drive.

>Rust can't even stabilize its standard library
What did she mean by this?

A reward cannot end you in the same place you started
If you pretend you can't do those things, letting yourself do them is not a reward.

>Avoid exposure to wireless devices and cell towers.
How?

You don't need to, he's talking out of his ass.

I have to learn C programming as part of my degree. they teach this in visual studio, but I would rather use linux and not have to dual boot, so what IDE would you recommend for a complete beginner?

netbeans/eclipse cdt

The Rust standard library is completely anemic. No async I/O, no JSON or XML parsers, not even an HTTP server. It lost to Go the instant it entered the race.

This is kinda a weird way to write this user.
Try
(*mat)[i][j] = rand()%10;

monodevelop, it's pretty much a free-software clone of visual studio

Depends on your environment and how far you'll go to avoid brain damage. Calcium channel blockers (phenibut, magnolia bark, ginseng, celastrus paniculatus) can help, as can vitamins E and C, magnesium, and zinc. Some studies have shown ginkgo biloba to be helpful.

Unfortunately not. This is the same as asbestos, paris green, DDT, and myriad other dun goofed on purpose periods of human history. We knew better, and a subset of the population decided to do it anyway. Everyone else goes along.

If you want I can list some sources, spanning from the 70's to the present.

I made a blog post about implementing OOP features like privacy, inheritance, and constructors in C. Rate my blogpost, and also please rate the blog itself. What do you think? I made it from scratch

collin.moe/post.php?i=8

it's shit now fuck off

>recently someone on reddit...
Why does no one start his blog post with "recently someone on /dpt/..."?

HOLY SHIT IT WERRKS
I TAKE IT BACK C IS FUCKING GREAT!!111

take a break, play some video games or something then start programming when I get bored of those things.

Because if I'm writing a blog that a potential employer might see I don't want them to know that I browse Sup Forums

pretty nice. historical trivia: file explorer's oop hierarchy was written mostly in c

because everyone on here is a redditor

We are talking on a thread about an ebook viewer for that can do several formats. There is no single one but several that cover the majority of formats
github.com/aligrudi/fbpdf
nongnu.org/fbi-improved/fimgs.man.html
github.com/jichu4n/JFBView

So far a good suggestion is taking fim, an image viewer for the console and add it support to other formats through libraries like chmlib for chm and djvulibre for djvu.

What do you think?

Spaces or no spaces after cast?
(char*) ptr

or
(char*)ptr

(char *)ptr

gay

reinterpret_cast(ptr)

Why is the common idiom srand(time(NULL))? Why not srand(clock() ^ getpid())? Much more unpredictable and can be run more than once a second.

gross

>(char*)ptr

>If you pretend you can't do those things, letting yourself do them is not a reward.
Well it's a placebo, but the good thing about placebos is, they're known to work

It's not a placebo if you know its a sugar pill.

That would be true if there was such a thing as a singular "you", and dissociation and compartmentalization weren't things.

The state of all the brain's individual populations of cells just doesn't form a unified whole "self". If it did, lot of experiences wouldn't exist. Like anxiety.

getpid() isn't portable

How the hell did the last thread die?

In C++. I have a string defined with "MyName". I want to create an get function that returns "My Name", but I don't want to create a new variable and I don't want to redefine the current one.

Anyone have any suggestions?

What frequency spectrums?

Re-asking.

What do you mean?

it exists on all the major relevant platforms, if anything
>nm c:\winnt\system32\msvcrt.dll
>getpid

>collin.moe/post.php?i=8
What's with the fullscreen-sized "dystopian corporate-sponsored megapolis" banner photo tho?

Cats ate it's face

what programming language do chinese people use?

i got accepted to this chinese thing that i applied to like last year. i would be teaching CS but idk what they even learn over there since my school is shit and just used java

No, i didn't. How do I do it? (Be productive)

That would be the mall at Tyson's Corner, VA. I like pictures of cities

Seems like something you should ask them.

How did you get that job? Do you have a masters degree/PhD?

Does alignment really matter?
ma.c:
#include
#include
#include

#define GIGABYTE (1024*1024*1024)
#define AMASK (~((1

C, much more than western programmers even.

Most pulsed or modulated fields encountered in everyday life appear active to some extent. Some continuous waves are active, active at certain spatial alignment to the field, or active in certain windows. It is very complex and as yet a generalized model with sufficient predictive power concerning all low level details, hasn't been developed. Altered calcium flux, likely via acting on L-type voltage gated calcium channel's voltage sensor and the NMDA receptor, is a reliable constant.

GSM-900/1800, Wi-Fi, blutooth, electric blankets, transformers, electric ovens, power lines. Whatever, they're all active, and that mode of action appears to altered conformational behavior of membrane bound glycoproteins, generation of solitons, and intracellular calcium mediated pathways of oxidative stress. Curious aspects like pearl chain formation and rotation of certain parts of proteins probably play some role, altered hemodynamics and potentiated fenton reaction autoxidation is not a factor with fields below ~4T.

I should have casted to char*, fuck, but it didn't seem to make a difference anyway.
Fill complete!
tmp=46
Aligned access time: 6427066
tmp=7
Unaligned access time: 6262324

>Seems like something you should ask them.

true, im gonna call the guy in a few hours. i called him a few hours ago and it was just a bunch of chinese so i hung up and then realized it was like 2AM in china at the time so thats probably why he wasnt there

>How did you get that job? Do you have a masters degree/PhD?

i only have a bachelors degree and at the time i was still a student (but now im graduated). they had a booth at my schools career fair. they skyped me once like 2 months ago and it was literally just 2 chinese people that barely spoke english trying to say my name (i have a dutch name) for 2 hours and then they somehow decided i was good for the job based on that i guess.

Do you speak the chinese?

Awesome, dude. Is it with an agency or just with the university? I'm studying Korean and the ability to teach CS in South Korea would be cool

What's the purposes of parentheses for function call, really? What meaning would
var arg1, arg2, arg3;

have otherwise? Function names can't be type names, so not variable declaration.

what are you talking about

Why do I need to write
printf("formatstring%d\n", i);

instead of
printf "formatstring%d\n", i

?

You're basically just an IT teacher/teaching them how to speak english so that's not really an issue.

it was with this organization
www.chineseculturecenter.org

i never heard of that university prior to getting this message from them last night.

theres a lot of international internship things so maybe with luck you could get a korean one? i would also really like to go to south korea, it seems like a pretty really neat place.


i dont speak any chinese currently

shoo dumbfuck, go program with your containment haskell.

fuck, forgot semicolon but you get the point

because this is C, not lisp

If you go with the latter route, you can ditch the comma too. Once you have that, wrap the whole thing in parens and voila, you're Lisp! Once you have sub-calls for some of your args, you'll need parens anyway, or introduce some $ or

In Java how do I make Class2's method initiate an object in Class1?

because this isn't bash

>hasklel
>lisp
No.

It should be possible, though. HolyC does it, I think.
No, I might want to concatenate string literals, in which case the comma is needed. And you can have parens for arguments, e.g.
printf "asd%d", (et-st);

Would be nice syntactic sugar for some cases.

Isn't setjmp basically a closure?

public class Class2 {
public void setClass1Object(Class1 c1, MyObject o){
c1.setMyObject(o);
}
}

add mul 2 3 4 5

if add and mul are variadic functions, how do you know which gets however many args?

But in order to exposure to that many freq bands one would have to live in the woods, no electricity at all.

Syntax is for the brain. Look at your examples, imagine them in dense lines of other code, and ask yourself which is easier to parse and understand at a glance.

Protip, the brain likes clear delimiters and they're easily rapidly loaded into working memory, and efficiently stored.

add (mul 2, 3), 4, 5;

Well, then, go for it if *these* (but not *those*) parens trouble you --- write a front-end transpiler for your language that adds the parens you don't want to spell out

No, one would only have to live in a society that properly planned development, and coated its residential wiring in RF shielding.

Right now, yes you would have to get away from other people who don't know better, or don't care.

Why could it not equally be parsed as add (mul 2 3 4) 5

Function call parens and operator grouping parens are fundamentally different.
Since you add the parens yourself.

Not getting any help from the /sqt/, does anyone here know J?

VSCode is the best editor.

use Haskell