[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 315
Thread images: 20

File: 146738840786.jpg (95KB, 720x720px) Image search: [Google]
146738840786.jpg
95KB, 720x720px
What are you working on, /g/?

Old thread: >>59177041
>>
This thread is 5 seconds younger. Praise anime!
>>
>>59184960
C# is glorious.

Fun to write in, easy to get shit done.

You cannot dispute this without resorting to memes.
>>
>>59185024
But it is limited to MS platforms.
>>
>>59185036
Wrong
>>
>>59185024
Not my fault OOP has become a meme. I like OOP in some cases, but not when OOP is forced on me by the language.
>>
>>59185049
It runs like shit on anything non-windows.
>>
>>59185050
C# is multi-paradigm, and can basically be written straight procedural.
>>
>>59185049
How?
It's not as wide as Java,
it was partially open-sourced only a couple of years ago,
WPF is still closed.
For cross-platform development it's not a good choice.
>>
>>59185070
But the standard library is OOP and you can't even have simple things like global variables without a retarded OOP wrapper around them.
>>
>>59185067
The performance is fine.

Considering arbitrary benchmarks for trivial computational tasks is useless. These types of things ought to be abstracted to a C-lib when necessary.
>>
>What are you working on, /g/?

Just restarted my NVMe stuff from scratch, so now I'm working on a userspace NVMe driver using sysfs and will eventually do some fancy stuff with the GPU (perhaps hosting IO submission queues in GPU memory)
>>
>>59185098
If you're referring to writing a cross-platform user application, Java isn't a good choice for cross-platform GUI development, either.

This marketspace mostly belongs to totally-not-web-browser-based GUIs running on Atom and its ilk.
>>
How many nested functions are you on right now?
>>
>>59185171
17
>>
>>59185171
Like, maybe 5 or 6 right now, my dude.
>>
>>59185108
>But the standard library is OOP
How does this affect the way you use the functionality in the standard library? Can you give a code example of how you would write something and how you think it should be written?

>you can't even have simple things like global variables without a retarded OOP wrapper around them
Can you give an example of a global variable you would want in a non-trivial application? These are generally dubious at best, and one ought to stake a flag next to them describing their exact behavior if literally every bit of code can access it in some way.
>>
>>59185153
>totally-not-web-browser-based GUI
But it is too heavy.
>>
Does "2GFY" mean "to go fuck yourself"? English isn't my first language. Does it mean anything else?
>>
File: 1362376549834.gif (28KB, 600x600px) Image search: [Google]
1362376549834.gif
28KB, 600x600px
>too stupid to understand API documentation as-is
>start using lazyfoo to learn SDL2 again
>80% of code is dedicated to error-handling for errors that will never happen
>10% is redundant code to make things "easier"
>the remaining 10% is actual learning material

I guess I have no right to complain since it's the only tutorial easy enough for me to comprehend, but Jesus Christ
I just wish there was a middle ground between "You'll only understand this if you already know 90% of it anyway" and "I'm going to repeat this core concept for the 6th time in case you didn't catch it"
>>
>>59185304
I've never heard anyone say that. It could mean anything.
>>
>>59185304
I think Urban Dictionary has more information on that.
>>
>>59185388
consider writing your own layer of abstraction between sdl2 and the rest of your program

if you "just" want to draw a texture at a point in the window, write MySDL_DrawTexture(Point position) or something, and then do what you need to make that function work as expected. repeat for common tasks until you're where you need to be
>>
Alright you autist why are there 2 fucking threads?
>>
Name one (1) number <1000000 that has a longer Collatz sequence than 910107
>>
>>59185470
This thread was made earlier, why are you asking him?
>>
>>59185195

you are not by any chance my boss are you?
>>
>>59185520
Solve Problem Euler on your own.
>>
>>59185520
5226
>>
>>59184960
Question for andriod app devs

Can I use resources for my app that were released after the current level of the API? For instance SMS manager is the go to way to send text messages for your app but it was released with Kitkat.

Can I still use it and have my app be compatible with the pre-kitkat android users out there?
>>
File: 1458862342299.jpg (19KB, 259x270px) Image search: [Google]
1458862342299.jpg
19KB, 259x270px
RAII is programming god-mode, prove me wrong /dpt/
>>
>>59185919
I am too intelligent to know what is that
>>
>>59185919
a ruff victory

>>59185280
Doesn't change that it's the standard now.
>>
>>59185828
No, but you can try if the support library has a backport available.
>>
>>59184960
How does anyone here even start a project? I don't even know what I want to do.
>>
>>59186258
From an idea.
>>
>>59186258
It helps to have a job or want extra functionality from something.
>>
>>59186258
open notepad.exe
write your program entry point function
save to a folder
compile
>inb4 interpreted shit
write more if you want to
>>
$ curl -s 'https://imgur.com/a/RTFeJ' | grep '^\s*image\s*:\s*' | grep -o '{"hash":"[^\"]*","title":"[^\"]*","description":null,"width":[0-9]*,"height":[0-9]*,"size":[0-9]*,"ext":"[^\"]*"' | sed 's/^.*ash...\([^\"]*\).*ext...\(.*\).$/https:\/\/i.imgur.com\/\1\2/g' | xargs --p 16 -n 1 wget -q -nc --show-progress


this oneliner rips lewds from a hestia album
does this count as programming or degenerate pajeetery?
>>
>>59186335
typo! the xargs args should be
xargs -P 16 -n 1 wget -q -nc --show-progress
>>
>>59185206
You're like a little kid, watch this:
>>
>>59186335
Pajeet of a code P(c) ~= (number of regular expressions in c) ^ 3

sorry anon
>>
>>59186433
oh no
>>
Bored out of my mind and I want to program something. Someone post some non retarded challenges? Networking? Implementing application protocols(already did most of the popular ones)?
>>
>>59186525
http server in haskell
>>
>>59184960
A timetable parser for the Untis timetable web frontent. They use HTML 4 and earlier, and it's completely malformed. They open tags they never close, they nest tables in tables and other tags in which they aren't allowed, sometimes you'll find random characters in between the tags (like ``) and they create new tables with redundant empty tags in them to create spaces. Their timetables are defined in rows, not columns. If a lesson spans over multiple rows, it is done via an attribute that defines it's height in the starting row, the rows afterwards it isn't mentioned at all. That means that you have to keep an array with counters you check and reduce on every row, and increase the index manually if one of the lessons in the previous rows spans into the current row, else lessons will shift to the left and end up in the wrong days. Additionally, for every row with content, a useless empty row follows, except on the first two rows, which both have content. I recently found out that lessons can also be split into several sublessons that can span different row heights. One would think that they'd achieve this by using nesting, but in fact they just define the width for a double split lesson as half the width of a regular lesson in the root structure. I'm starting to question my life choices.
>>
>>59186258
Write a program for a problem you face. Automate something that annoys you every time you have to do it. Write a helper program that assists if automatization is not possible.
>>
>>59186687
You basically have to have a menial job for this, though.
>>
>>59186710
Mine is called school
>>
>>59185024
>CLR based
D is better in that regard
>>
File: unref.png (197KB, 960x1052px) Image search: [Google]
unref.png
197KB, 960x1052px
My brain has been fucked, what should I do?
>>
File: dangerous-pepe.jpg (13KB, 222x216px) Image search: [Google]
dangerous-pepe.jpg
13KB, 222x216px
>>59186525
MMORPG in ASM x86
>>
>>59186798
>2017
>x86 assembly
>>
File: 1487965334358.png (141KB, 400x300px) Image search: [Google]
1487965334358.png
141KB, 400x300px
>>59186798
I like the way you think anon
>>
>>59186780
brain surgery
>>
>>59186840
Not an argument, unfortunately.
>>
File: Screenshot_2017-03-01_22-54-39.png (17KB, 278x178px) Image search: [Google]
Screenshot_2017-03-01_22-54-39.png
17KB, 278x178px
Cross-compiling is a fucking pain.
>>
>>59186047
>Doesn't change that it's the standard now.
The good thing about standards is that there'll be another one along in a few minutes.
>>
>>59187022
Yeah, it's funny how all you are actually doing is writing the assembly for different language. That should be that hard.
Still wondering why there isn't compiler that you cant just give source code and you could just pass paramere --arch=arm or something like that. Of course dynamic linking would be little problem but can't fall to that can it?
>>
>>59187105
Many modern languages like Go and Rust already do that, but only if you don't link against any C libraries. Then you're back in cross-compiling hell.
>>
>>59187022
It's not a problem with Java.
>>
Daily Daily Reminder

You all could be making web business apps and make a lot of money
>>
>>59187184
I'm building for desktop PCs, not Enterpriseâ„¢ servers. Those won't have 50 GB of RAM just lying around.
>>
File: 1463061905756.jpg (98KB, 620x520px) Image search: [Google]
1463061905756.jpg
98KB, 620x520px
>>59187200
>You all could be making web business apps and make a lot of money
But who will pay a lot of money if all programmers will make web business apps?
>>
>>59187200
>make a lot of money
not in canuckistan, anon
>>
>>59185111
>abstracted
This word needs to stop being used, it doesn't mean what people want to say when they employ it.
>C-lib
You mean Fortran, right?
>>
>>59187240
>>59187259
medium to large businesses for IT solutions to reduce their costs in business
>>
Can anyone recommend me a good WPF book to help me pick it up in my free time and use as a desktop reference at work?
>>
>>59185919
>prove me wrong /dpt/
You don't exactly control when your memory gets freed. If many containers go out of lifetime at the same time it can introduce a nasty pause in your program.
But I agree it's very good for non-real time applications.
>>
File: 1479274506924.jpg (195KB, 1280x1440px) Image search: [Google]
1479274506924.jpg
195KB, 1280x1440px
How do I speed up computation time in C++? Is overclocking the only way?
>>
>>59187371
If you use classes as array of structures change it to a more cache friendly layout.
Remove virtual calls as much as possible.
Which brings me to the next point to put templates everywhere instead of inheritance to make as much shit as possible get optimized at compile time on top of no longer having any sort of semantic completion for your IDE. Once you've done all of that, kill yourself when noticing how dumb and ugly C++ actually gets when you try doing high performance computing with it.

Basically the story of my life.
>>
>>59187371
-O3
>>
>>59187371
yes, overclocking is the best way. most of my programs automatically overclock until the user's cpu is running fast enough
>>
>>59187200
What's the price of your soul?
>>
>>59187371
>>59187404
I have some other tips but I need to know how your program is structured if you want me to give you more ideas.
>>
>>59187371
use C/C++ with unity build strategy
or just don't use sepples
>>
>>59187404

Don't use classes you kuk
>>
>>59184960
working on a list of different kind of ways of committing suicide, since I decided to get a job in software development.
More recommendations are always welcome
>>
>>59187301
>You don't exactly control when your memory gets freed
you can if you need to. one easy method is to push objects slated for deletion into a vector of shared void pointers and then prune or clear the vector when convenient
>>
>>59187479
build the first AGI with no ethics or alignment to humanity
>>
How do I come up with an abitrary meaningless name for my ML-clone language? I just want to get coding but I can't set up the project / git repo / namespaces without a title and it's annoying as fuck
>>
>>59187539
MLess
>>
>>59187539
Serendipity
Start coding
>>
>>59187539
Lambda-lang
>>
>>59187539
I'll start on the logo
>>
>>59187539
PHPScript
>>
What are the objective benefits i would get from using C++ instead of C?
>>
>>59187574
+ and +
>>
>>59187574
>objective benefits
very funny
>>
File: fedora-006.jpg (752KB, 2276x1708px) Image search: [Google]
fedora-006.jpg
752KB, 2276x1708px
>>59187539
MLady
>>
>>59187574
templates
>>
>>59187405
>undefined behavior
ishyggy
>>
>>59187574
struct {}; instead of typedef struct {}; is a little "nicer," unless you're linus

function overloading is nice
>>
>>59187606
kek someone do this
>>
File: 1481937068412.jpg (12KB, 249x225px) Image search: [Google]
1481937068412.jpg
12KB, 249x225px
>>59187600
>>
>>59187613
>typedef struct {};
doesn't compile
>>
>>59187574
shorter syntax on some declarations
other shit only niggers care about
>>
>>59187574
A few things that won't kill you if you use them:
- Function overloading.
- Operator overloading if you only use it for aggregate types is very nice as it doesn't create 50 objects behind your back.
- Templated functions allow for some compile-time optimizations you wouldn't get from C if you had to throw function pointers instead.
That being said I like using the meme that the only "sane subset" of C++ is C, but you still have a few nice features some of which I mentioned.
>>
>>59187614
kek someone do what this guy said
>>
>>59187641
kek this
>>
>>59187629
>c++
>shorter syntax
lad...
>>
>>59187649
He's right:
struct nigger { int faggot };

vs
typedef struct { int faggot } nigger; 
>>
>>59187638
>Function overloading.
not a benefit
>Operator overloading
at this point it's safe to assume you're retarded
>>
>>59187371
-march=native
avoid allocations
avoid virtual functions
write cache-efficient code
using caching where applicable
use constexpr/literals where applicable
use arrays over vectors when you don't need resizing
and watch this

https://www.youtube.com/watch?v=uzF4u9KgUWI
>>
>>59187674
>le epic operator overloading is bad
Whatever you say man.
>>
>>59187668
>He's right
no, the first one is valid in both C and C++; why post if you're mentally ill?
>>
File: 1460076766909.png (86KB, 600x1200px) Image search: [Google]
1460076766909.png
86KB, 600x1200px
>search Ada Reference Manual for undefined behavior
>Only result is in a comment on an example, pointing out the undefined behavior in c's strcpy
>>
VS Code 1.10 is out https://code.visualstudio.com/updates/v1_10
>>
>>59187685
>I have no arguments
so the assumption holds
>>
>>59187693
so is the second. why post if you're mentally ill?
>>
>>59187704
Nobody cares, microcuck.
>>
>>59187699
That just means they aren't telling you where it is.
Make no mistake, ALL languages have undefined behavior. C is not worse than any language.
>>
>>59187574
c++'s explicit design goal is that a feature is not worth excluding due to the potential of a programmer misusing it. for virtually any feature you can point to examples of a pajeet making a garbage mess out of it and scream "see see c++ is shit see"

pick and choose the features that you need, apply things like overloading sensibly and sparingly, and you can get a better experience

>objective
oh you're just meemeeing
>>
File: Jonathan-Blow.png (129KB, 450x311px) Image search: [Google]
Jonathan-Blow.png
129KB, 450x311px
/dpt/ have you accepted the rightful caliph into your heart yet?
>>
>>59187638
>>59187674
Even though I agree that function overloading is pretty useless most of the time, C actually supports this with _Generic.
Operator overloading is a travesty as well. << std::endl
>>
>>59187704
and this is related to programming how?
>>
>>59187710
>I'm literally retarded
we knew
>>
whats a hashmap? Ive heard of hashtables and hashing itself. Is it the java equivalent of C#'s dictionary?
>>
>>59187693
>the first one is valid in both C and C++;
You're wrong. First one has to be prefixed with struct when declared.
>>59187707
You sure gave some compelling arguments on your end.
>/dpt/ in charge of not being retarded
No wonder we have so many Rust shills around.
>>
>>59187574
higher-order constexpr generic lambdas
>>
>>59187742
>still no argument.
top kek

kys
>>
File: 1451970702151.jpg (634KB, 2943x2155px) Image search: [Google]
1451970702151.jpg
634KB, 2943x2155px
>>59187704
>shitty, slow editor written in javascript
>>
>>59187731
>function overloading
>C actually supports this
false
>>
>>59187721
>apply things like overloading sensibly and sparingly
You put too much fate into retarded average programmer
>>
int independence; // declaration of independence
>>
Rust and Go are hipster memes

C++ and D are not
>>
>>59187731
So, I don't know, maybe don't overload <<? You will still get a much better time doing algebra, for example when doing vector math in 3D.
>>
>>59187707
neither of you have arguments
/g/ is a shitfest

>>59187720
>ake no mistake, ALL languages have undefined behavior. C is not worse than any language.
LMAO the C stockholm syndrome is real. Most languages have barely any undefined behavior, if any. The most you usually might see is like, nondeterminism in threading or memory (e.g. when does recursion result in a stack overflow? when do you run out of memory and what happens when you do?). It is NOT difficult to make a language without undefined or even unspecified behavior.
C is absolutely full of undefined behavior for portability reasons, such that you can stretch the C standard to correctly port C to any arcane device if you wanted to.
>>
>>59187749
>You're wrong.
you're retaded
>>
>>59187785
>Rust and Go are hipster memes
Why? Explain your reasoning.

>C++ and D are not
Explain.
>>
>>59187782
>//
sepples fag pls leave
>>
>>59187574
portable threading support in the standard library
>>
>>59187747
how about googling it
[map, hashmap, hash, hashtable, table, dictionary] are usually all synonymous.
>>
>>59187803
>what is C99?
>>
>>59187803
you need a safe space, tumblrina?
>>
>>59187789
>vector math in 3D
>muh *
>muh dot product
>muh cross product
tough choice
>>
File: 1483369018888.jpg (20KB, 310x156px) Image search: [Google]
1483369018888.jpg
20KB, 310x156px
>>59187782
>uninitialized variable
>>
>complains about C++
>uses C++ style comments
cuck'd
>>
>>59187815
what do i google?
>>
>>59187816
obsolete
>>
>>59187574
>What are the objective benefits i would get from using C++ instead of C?
1) RAII allowing dynamic container types and safe pointers
2) Powerful STL containers for all the data types you can imagine
3) Neatly break out of execution path by using exceptions

>>59187747
Some languages, like Java, use hashmaps as a synonym for a hash table (Java's hashmap is a hash table data structure that implements the Map interface).

Other languages use Red-Black trees (or some other self-balancing tree) to implement hash maps. Python dictionaries, for example, are implemented as a balanced binary search tree. Here the hash code is simply used to determine how to traverse the tree.

I'm not sure how C# dictionaries work because I don't know anything about them.
>>
>>59187797
struct s {
int a;
};

int main() {
s a;
return 0;
}

main.c: In function ‘main’:
main.c:6:5: error: unknown type name ‘s’
s a;
^

>m-maybe if I call him names no one will realize I don't know what I'm talking about!
>>
>>59187798
He doesn't have to explain shit. They're memes. Discussion over.
>>
>>59187833
if you use C++ style comments you're a cuckold?

who knew
>>59187847
back to le reddit
>>
>>59187371
I recognize that bulge.
>>
>>59187838
"what is a hash map"
"difference between hash map and hash table"
>>
>>59187842
>I don't know C
>no one will realize I don't know what I'm talking about!
>>
>>59187823
If you use * for either of these you haven't done math.
>>
>>59187842
you have to
typedef struct s s;

welcome to programming btw
>>
>>59187775
Do you even know about _Generic?
How do you think tgmath.h might even work?
int thing_int(int a)
{
printf("%d\n", a);
}

float thing_float(float a)
{
printf("%f\n", a);
}

#define thing(a) _Generic((a), int: thing_int, float: thing_float)(a)


>>59187789
When your fucking standard library can't even be trusted to not fuck it up, I'm not going to expect other programmers to not be stupid.
Really though, operator overloading is a example of information hiding, and just makes your code harder to reason about.
>vector math
Why do you idiots always bring that up?
Now you have to extremely unobvious fact of whether * is the cross or dot product.
>>
>>59187865
>muh backpedaling
>>
>>59187823
>muh dot product
>muh cross product
literally neither, shitter. component-wise product comes up way more often than anything else
>>
>>59187861
any more googling tips?
>>
>>59187887
>his language doesn't support a generic monoid operator
>>
>>59187868
>int thing_int(int a)
>float thing_float(float a)
not function overloading
>#define thing(a)
thing is a macro, not a function
>Do you even know about _Generic?
do you even know what the fuck a function is?
>>
>>59187867
>>59187863
Which brings us to the initial point: C++ has some shorter declarations.
You should at least be able to read to post here, assuming you're above 18.
>>
throw null; // throw a null pointer exception
>>
>>59187887
>component-wise product comes up way more often than anything else
found the fizzbuzz toddler
>>
Anons, I don't like this "unironically a webapp in a window on a desktop" trend at all desu
>>
File: 1478910870851.webm (797KB, 1196x887px) Image search: [Google]
1478910870851.webm
797KB, 1196x887px
>>59184960
>What are you working on, /g/?
Still my arrow-key based board navigator. Have got scolling through quotelinks and nested quotelinks working :)

Think the aesthetics could do with some refinement and need to add backlinks support too but it's coming along alright.
>>
>>59187907
temp += 1; // increment the variable by one
>>
>>59187902
>You should at least be able to read to post here, assuming you're above 18.
>implying anyone ever notices what you say
>>
>>59187704
>minimap
noice
>>
>>59187929
Why are you even posting? It's obvious you don't try to bring anything to the discussion.
>>
>>59187902
did you learn to read at 18? talk about retarded!
>>
>>59187925
which variable? it is best to be clear in comments
>>
>>59187932
>sublime text: the clone
disgusting.
>>
>>59187946
to play around with thin skinned fragile ego kids like you. it's fun!
>>
>>59187932
Did they steal this from sublime? Or did they themselves steal it from someone yet earlier?
>>
>>59187948
epik burn /b/ro
>>
>>59187962
>steal this from sublime
no, sublime still has it
>>
public User FindUserThrowInvalidArgumentExceptionIfUserIdIsNotValidReturnNullIfUserSuspended(int userId)

self documenting code :)
>>
>>59187900
>You can easily use a feature to implement some behaviour
>HURR IT DOESN'T COUNT. IT NEEDS TO DONE DIRECTLY
How is it not function overloading? You're calling a function based on what type the argument is.
It's what _Generic was fucking designed for, so it's not like people were just abusing the language features in novel ways to do something. They just designed _Generic in such a way that it wouldn't fuck with C's simple ABI and could possibly be useful in other situations.
>>
>>59187747
>Is it the java equivalent of C#'s dictionary?
A C# dictionary is a hashtable.

Java hashmap != hashtable.
>>
>>59187973
You know what I mean you pedantic fuck
>>
>>59187962
VS Code looks like sublime text

microsoft just had to make a text editor to say they did
>>
>>59187962
>Did they steal this from sublime?
VS Code is "stealing" many great features from other text editors.

And there's literally nothing wrong with that. It's great.
>>
>>59187977
Another name would look better. But it would be incorrect.
>>
>>59187919
pls r8
>>
>>59187992
At least VS Code is open source, unlike Sublime Text
>>
>>59188011
It looks nice bro keep it up.
>>
>>59188011
>Bumping your post 5 minutes later

Holy shit, end your life.
>>
>>59187917
says the guy who apparently only uses vectors for canonical linear algebra. that's cute
>>
Valgrind says I have twice as many allocs as frees. Why is that? Here's my function that frees the allocated space (I'm not posting the function that allocates the memory because I'm sure that the problem is in this function)
/*
* frees the memory associated with this node and all subsequent nodes
*/
void destroyList(struct listNode *pNode){

struct listNode *cursor = pNode;

//If we are at the end of the list, free this node and exit.
if(pNode->next == NULL)
{
free(pNode);
exit(-1);
}
else
{
cursor = pNode->next;
free(pNode);
destroyList(cursor);
}
}
>>
>>59187973
"steal" is an overloaded word now idiot
>>
>>59188025
kys you retarded faggot
>>
>>59188039
next may not be null, stack based storage always has garbage if unitialized
>>
>>59188039
Why is the function called destroyList calling exit?
>>
>>59188039
Your implementation of that function is really stupid, but I don't think the problem is in there.
>>
>>59187983
>How is it not function overloading?
because it's a macro
>You're calling a function based on what type the argument is.
yes, you can also do that with an "if" statement, doesn't make it function overloading
>>
>>59188036
>I don't know how to use vectors
we know
>>
>>59188115
>because it's a macro
So?
>you can also do that with an "if" statement
No you can't you fucking idiot. A type is not an expression in C.
>>
>>59188039
Perhaps the issue isn't in your free functuon, but in your allocation function. Also, why the fuck are you calling exit for a perfectly valid comdition?
>>
>>59188039
>undefined behavior
ishyggy
>>
>>59187841
>I'm not sure how C# dictionaries work because I don't know anything about them.

iirc (had this last year @ datastructures, our uni uses C#):

C#'s dictionary is regular hashtable with just a list when collision occurs;
C#'s sortedDictionary is red-black tree
>>
>>59188133
because my professor said i must call exit(-1) in every program i write,
>>
>>59188048
literally, weeb?
>>
Alright kids, let's agree once and for all
cross_product = x ^ y;
dot_product = (x, y);
>>
>>59188154
That's really stupid. Tell him that someone on the internet thinks that he's really stupid.
Non-zero return codes indicate failure. Your program is not failing.
>>
>>59188094
>>59188133
because I'm gay/retarded

>>59188099
I agree, in fact if it were up to me this wouldn't even be using recursion
>>
>>59188177
x `cross` y
x `dot` y
>>
>>59188131
>So?
macros are not functions; do you know anything about C?
>No you can't you fucking idiot
I sure can; maybe you can't, since you don't even know the difference between a function and a macro
> A type is not an expression in C
I didn't claim otherwise
>>
>>59188177
>cross_product = x XOR y
>dot_product = tuple(x, y)

Not approved.
>>
>>59188189
Take your 1 gb of data per second and choke on a zygohistomorphic prepromorphisms
>>
File: shepard.jpg (16KB, 249x300px) Image search: [Google]
shepard.jpg
16KB, 249x300px
>>59188200
>>
>>59188039
>Not using a storage pool
Wew
>>
>>59188177
No.

I agree on cross but not on dot.

For dot you have '*' or '.'
>>
how I do get valgrind to like my program?
int main(int argc, char **argv) { 

if (argc < 2) {
printf("%s\n", "usage: \tgrep pattern");
exit(2);
}

char* search = argv[1];
char* line = NULL;
size_t size;
ssize_t length;
while ((length = getline(&line, &size, stdin) > 0)) {
if (strstr(line, search) != NULL) {
printf("%s", line);
}
}
}
>>
>>59188192
>macros are not functions
And? Macros can act like functions, and are commonly used to write APIs which look like you're calling a function, but are actually doing something which will only work in a macro.
Also, who said that function overloading had to be implemented using actual functions.
>I sure can
Please write an if statement, in standard C, which will test true if and only if the argument is an int.
That's a pretty dumb thing to ask, considering C is statically typed. but I want to be able to change JUST a variable type, and have to rest of the code deal with it, without being altered.
>I didn't claim otherwise
Then how did you think that you could type-switch in C without _Generic, then?
>>
>>59188129
>all the other binary operators are heterogeneous, but fuck it let's just make an exception for this one!
>forgetting that normed vectors are particularly derived
what would your * operator do for an abstract vector? just nothing? kek
>>
>>59188250
Set size to 0. getline will read that value to see how large the buffer is, and you're just handing it uninitialised shit.
Also, line needs to be freed at the end of the program.
>>
>>59188245
>'*'
In linear algebra cross products are usually written (.,.) or <.,.> in Hilbert spaces.
* would be for the second composition law in a ring (which is indeed also noted with a dot).
So I really don't see why you'd use it in this context instead of the canonical, traditional comma.
>>
>>59188099
>>59188133
>problem in allocation, not free

Well, I double-checked, but I'm not seeing it there. Here's the function for that:
/** inserts the address addr as a new listNode at the end of
* the list
*/
void insertBack(struct listNode *pNode, const char *addr){

struct listNode *tempNode;

//Check if next node is NULL; means we are at the end of the list
if(pNode->next == NULL)
{
//Create new node
struct listNode *newNode;
newNode = (struct listNode *)malloc(sizeof(struct listNode));

//Check if done properly
if(newNode == NULL)
{
printf("\nFailed to Allocate Memory.");
exit(-1);
}

//Initialize newNode->addr
strncpy(newNode->addr, addr, MAX_ADDR_LENGTH);

//Insert newNode
pNode->next = newNode;
newNode->next = NULL;
return;
}
else
{
//else set tempNode to the next node and try again
tempNode = pNode->next;
insertBack(tempNode, addr);
}
}
>>
>>59188308
oh shit I see it, nevermind
>>
>>59188304
Forgot to mention . is also used for non-commutative groups (with + traditionally given to commutative ones). I understand the dot product sounds like you're multiplying two vectors because it's the case in dimension 1 but it seems shortsighted to me to want to generalize this notation for the dot product.
>>
>>59188245
I agree that matrix multiplication can use * though.
>>
>>59184960
Anyone experience with Tensorflow and threading?

I have to pre-trained models which i use for face detection and feature extraction.

I want to work on as many images as possible, utilizing the 24 threads of the server i am working on.

Can you load a model per thread, thus using 24 models in parallel?
At the moment i am loading the models a single time and use them across all threads, which for some reason works well on the feature extraction model and pretty bad on the face detection model.

I tried creating a graph and a session per thread and loading the model but it performed essential the same.

I suspect the session were shared or something and not running completely separated from the other threads.

Is this even possible with tensorflow?
>>
>>59188304
>(.,.) or <.,.> in Hilbert spaces
Dayli reminder that anglo notation are a joke in math. Only french notation are relevant.
>>
>>59188257
>And?
they are not functions; are you literally retarded?
>>
>>59188391
What do you mean?
>>
>>59188275
I still get
==74252== LEAK SUMMARY:
==74252== definitely lost: 0 bytes in 0 blocks
==74252== indirectly lost: 0 bytes in 0 blocks
==74252== possibly lost: 0 bytes in 0 blocks
==74252== still reachable: 16,384 bytes in 1 blocks
==74252== suppressed: 39,089 bytes in 418 blocks

after size_t size = 0 adding a free(line) to the end
>>
>>59186258
https://better-dpt-roll.github.io/
>>
>>59188409
The usual notation is u.v or just uv for the dot product of u and v. <u|v> is a physicist notation so it's irrelevant.
>>
>>59188308
>>59188331
Never mind, I thought I saw the problem but now I guess I was wrong.

Apparently it's allocating memory twice, but I'm not sure why.

Anyone else see it?
>>
>>59188455
What are you smoking man?
Inner products are quite universally denoted with (u,v), even in France (I should know since that's where I'm studying). u.v is some high school shit but it quickly shows its limits when you have large expressions, for example when doing optimization or functional analysis.
>>
>>59188397
Again, who said they even need to be functions?
You're just using some construct to call some other function, based on the types of the arguments.
The macro doesn't even do any of the work. All of it is actually done by _Generic, but you would have to write that shit inline, which would be incredibly stupid, so it goes into a macro.

I'm starting to think that you're just trying to pretend you were just pretending to be stupid and trying to bait the whole time, to try and save face.

>>59188431
>still reachable
This is a more benign kind of "memory leak". Some might argue that it's not a memory leak at all.
You're probably using a library which is allocating a bunch of shit statically, and is not freeing it.
Valgrind has some options to be more verbose to show where these things are allocated. I think it was --leak-check=full --show-leak-kinds=all or something like that.
>>
>>59188455
>>59188455
I agree <u|v> is dumb though.
>>
>>59188482
>denoted with (u,v), even in France
No. It's my country, I did math (oone of the best school in my country) and no it ain't the notation for dot product.
>>
>>59188017
open source doesn't mean shit when it's on a trivial platform like atom
>>
>>59188533
what you mean
>open source doesn't mean shit
?
>>
>>59188533
That's a really awkward use of "trivial", and VS Code is built off of Electron, not Atom. Atom is also built off of Electron, but VS Code has a a bit better performance due to being built better.

It's true that neither of them have the performance that Sublime has, however Sublime doesn't have near as many features or available addons.
>>
>>59188610
why didn't they do VS code in C++ and python like Sublime did»
>>
>>59188507
Interesting. Did you study applied mathematics?
As for the notation it's not as universal as I thought but still most papers I can find use such notations, except for strong forms of PDEs where the dot is nicer since usually functions are a single letter with a differential operator symbol
http://www.math.polytechnique.fr/xups/xups99-03.pdf
https://www.ljll.math.upmc.fr/privat/documents/mainOptimisation.pdf
Like I said it's much clearer when you have big expressions for each terms of your products.
>>
>>59188640
Because muh TypeScript.

>»
What communist shithole country has this on a keyboard, ready-to-type?
>>
>>59188507
And then there are the few hipsters doing u^Tv
>>
>>59188658
>applied mathematics
No fundamental.
>most papers I can find use such notations
English papers? France is now stupid. rance should do like in the past and impose it's notation, like for metric system. Because Anglo-Saxon notations are totally stupid.

By the way, notations of applied mathematics are irrelevant too.
>>
>>59188702
I only looked for French.
>notations of applied mathematics are irrelevant too
Now you're just looking childish (and unwarrantedly pretentious). By the way Jean Pierre Serre uses the comma.
>>
>>59188824
>Jean Pierre Serre uses the comma
In French papers?
>>
>>59188659
>What communist shithole country has this on a keyboard, ready-to-type?
my HP laptop has that key

dunno why
>>
>>59188835
https://www.college-de-france.fr/media/jean-pierre-serre/UPL6358833361065286663_7___expos__s_de_s__minaires.pdf
>>
>>59188861
Where did he use the tuple notation for a dot product? Could you point a page?
>>
>>59188974
Bottom of 96 in PDF, top of 98. He uses dot for scalars. Granted he might not be the one who typed it but he says in the intro he corrected notations. Plus in his older papers (he typed himself) he uses brackets.
>>
>>59189015
Ok. Nobody is perfect. That's sad because that notation is stupid.
>>
>>59189059
>that notation is stupid
How would you use several Hilbert spaces in the same equation (or even different inner products) by using the dot notation then?
>>
>>59189120
If there is only one dot product for each vector space there is no confusion.
>>
>>59189186
hehehe
>>
I was wondering if this was defined behavior on linux. I am trying to read from the memory of a process and the easiest way to get the address is to a region of mapped memory which is "deleted".
In /proc/pid/maps on the memory region which I'm reading it says the file is deleted (after the filename it will put (deleted)).

Since it's "deleted" I can't read the memory with process_vm_read() or via ptrace. I CAN read it with a pread64 call to it's /proc/pid/mem.
Is the program doing something screwy? This approach works just fine and was wondering if I was relying on undefined behavior.
>>
>>59187668
These are both faulty, since there is no semicolon after 'faggot'.
>>
If your language doesn't have dependent types, why are you using it?
>>
>>59188484
>function overloading
>who said they even need to be functions?
you sure seem retarded
>>
>>59190356
Do C VLAs count?
void my_fn(int n, int array[static n])
{
// ...
}
>>
>>59190395
No.
>>
File: 1456266190790.jpg (125KB, 587x700px) Image search: [Google]
1456266190790.jpg
125KB, 587x700px
>>59187404
>>59187442
Might try some of these. Thanks anon-chan.
>>
>>59190395
that's a pointer
>>
File: adamascot.png (196KB, 1553x1685px) Image search: [Google]
adamascot.png
196KB, 1553x1685px
>>59190356
But I think it does?
>>
>>59190161
Yeah, there is no way that relying on that is a good idea.
>>
>>59190446
I don't see it listed here: https://en.wikipedia.org/wiki/Dependent_type#Comparison_of_languages_with_dependent_types
>>
>>59190507
I only did I quick search but I think Ada's dynamic predicate system covers the minimum.
>>
>>59190571
Interesting - and do the checks happen at compile time? (I don't know Ada.)
>>
>>59190161
Is the memory in question actually released by the process? If not you should be able to ptrace it.

From my understanding under linux, any memory freed or unmapped is only cleared when it's allocated to another process for efficiency reasons. Between the point where it's freed and reused it keeps the same data.

You should only be able to access that memory as root by hacky techniques like reading swap, /dev/mem, kmem or stuff like that. I don't know if /proc/pid/mem falls under that category but I don't think so(or feel it should) if it's released by the process it should no longer be available by that interface. If so this MAY be a pretty bad bug.
>>
>>59184960
Downloaded a couple PDFs to research into the data structure of text editing. I am planning on starting my own text editor.
>>
>>59190661
What will it offer over, say, emacs?
>>
>>59190634
I think that's implementation defined. Generally static predicates are checked for obvious errors but dynamic is left for run time. Running an analyzer like spark will definitely check.
>>
>>59190682
command voice recognition
>>
>>59190749
I'm mute.
>>
>>59190761
sucks to suck.
>>
>>59190761
For someone who's mute you sure do type a lot
>>
>>59190770
I'm not illiterate.
>>
>>59190791
that's not what i meant
>>
>>59190749
Interesting.

I actually use this:
https://marketplace.visualstudio.com/items?itemName=MadsKristensen.VoiceCommands
in my daily workflow and it works quite well.

Would be interesting to see a text editor come with that out-of-the-box, but how are you going to implement it?
>>
>>59190820
Why would being mute prevent me from typing?
>>
>>59190822
i was joking
>>
>>59190658
It's doesn't just retain the data but it stores live data (that I'm listening too). I'll try running it with strace and hopefully track down what's going on.

Maybe the (deleted) just means that the mapped file is gone but the memory had not've been freed.
>>
>>59190830
Odd thing to joke about. It's actually quite effective.

Plus, I can feel like I'm commanding around a crew of little chinese people in my computer.
>>
>>59190824
>>59190820
>>
>>59186335
>this language
What is this Sanskrit
>>
>>59184960
There is no mention of Lisp in this thread except for this one.
LIST PROCESSOR
>>
>>59185024
>Fun to write in, easy to get shit done.
While this is true, it doesn't excuse the other issues.
>>
>>59190914
I don't understand, anon.
>>
>>59190951
For fucks sakes, I am saying you talk too fucking much you annoying faggot. It's a fucking pun and insult.
God you're annoying
>>
>>59190968
>It's a fucking pun
wrong

It was a non sequitur attempt at humor.
>>
>>59190986
No wonder you can't speak, you don't fucking know english
>>
>>59190997
>you
I'm not the mute anon you were responding to originally.
>>
>>59190968
I still don't understand, anon.
>>
>>59191008
No, he's the mute one and you're the deaf one
>>
>>59191020
What?
>>
File: 1486959152458.jpg (43KB, 449x449px) Image search: [Google]
1486959152458.jpg
43KB, 449x449px
>>59190997
Hey retard its a programming language
>>
>>59191031
Still no eyed deer
>>
>>59184960
I'm attempting to find the highest prime factor of a large number using haskell(project Euler problem) It has worked for small numbers but it is taking a while with larger numbers I'm wondering if it doesn't work or why it doesn't work.

isComposite :: Int -> Int -> Bool
isComposite n 1 = False
isComposite n m = if((mod n m) == 0) then True
else (isComposite n (m-1))

isPrime :: Int -> Bool
isPrime n = not (isComposite n (n-1))

--lpf :: Int -> Int
--lpf 1 = 0
--lpf n = if((isComposite n (n-1)) && isPrime(n-1)) then (n -1)
-- else (lpf (n-1))


factors :: Int -> [Int]
factors n = [x | x <- [1..n], n `mod` x == 0]

primeFac :: [Int] -> Int
primeFac n = if(isPrime(last n)) then (last n)
else primeFac (init n)

largestPrimeFac :: Int -> Int
largestPrimeFac n = primeFac(factors n)

main = do
print (largestPrimeFac (25))
print (largestPrimeFac 600851475143)
>>
>>59190658
Ok. I strace'd it and I'm pretty sure I understand what it's doing.

>creates file that's going to be mmaped and get it's fd
>unlinks it (we have the fd so technically it still exists
>ftruncates the file to set the size of the total mmap
>mmaps memory regions to the file

When the program is exiting
>munmap the memory addresses that were mmaped to the file earlier
>closes fd (which'd let the fs finaly treat it as actually deleted)

Since it's unlinked process_vm_read and ptrace won't let me read it. Since the program still has the file descriptor it should still be able to use the file (and I should be able to listen in to those memory regions without trouble).
>>
>>59191045
You should look up prime sieves and wheels
>>
>>59191045
Just use the built-in function.
>>
>>59190305
It's only a warning though. But yeah it's better with ;
>>
if an app shares its API to the public does that mean it gives you a JSON string so you can parse it and do things with it?
>>
>>59191156
What kind of app?
>>
>>59191188

any app. Whatever I find that as a public api
>>
>>59191156
>>59191204
Pretty much.

https://a.4cdn.org/boards.json

Most have rules saying not to spam requests, like 1 per second max.
>>
>>59191204
Check this out: https://github.com/toddmotto/public-apis
>>
>first computing lecture
>We're learning the Processing programming language
What am I in for?
>>
>>59191311
Pure hell.
>>
>>59191311
LOL
>>
>>59191318
>>59191321
I-is it really that bad?
>>
>>59191343
It sounds like some shit your prof has made up.
>>
>>59191352
It's a real language m8
>>
>>59187371

Intrinsics
>>
>>59191218
>>59191277

sweet thanks
>>
>>59191311
It's pretty much a watered down java with an easy graphics api.
>>
>>59191372
Oh, maybe it won't be so bad then.
>>
Why does anyone use dynamic typing these days?
>>
>>59191500
Strong static typing is a meme.
>>
>>59191500
>>59191515
>/dpt/ - Daily Programming Thread
>>
>>59191527
Dynamic languages aren't programming, they're basically Lego.
>>
>>59191598
What's wrong with LEGO, you faggot?
>>
>>59191630
It's for children.
>>
>>59191651
So is programming.
Thread posts: 315
Thread images: 20


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.