[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: 324
Thread images: 46

What are you working on, /g/?

Previous thread: >>61843381
>>
>>61852662
Because those functions are unsafe. Use strnlen and strlcpy.
>>
seg fault still. i think its in the realloc block, wtf

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dirent.h>

int main()
{
DIR *d;
struct dirent *dir;

size_t nfiles = 0, capacity = 8;
char **filelist = malloc(sizeof(char *) * capacity);
char *tmp;

d = opendir("/home/nick/Pictures");
if (d)
{
while ((dir = readdir(d)) != NULL)
{
if (nfiles == capacity)
{
capacity *= 2;
filelist = realloc(filelist, sizeof(char *) * capacity);
}

if (dir->d_type == DT_REG)
{
tmp = dir->d_name;
filelist[nfiles] = malloc(strlen(tmp) + 1);
strcpy(filelist[nfiles], tmp);
printf("%s\n", filelist[nfiles]);
nfiles++;

}
}
}

for (size_t i = 0; i < nfiles; i++)
printf("%s\n", filelist[nfiles]);

//Free allocated memory
for (size_t i = 0; i < nfiles; i++)
free(filelist[i]);
free(filelist);
return 0;
}
>>
File: hYMIItH.png (142KB, 511x564px) Image search: [Google]
hYMIItH.png
142KB, 511x564px
>>61852855
>(dir = readdir(d))
https://linux.die.net/man/3/readdir
>>
>>61852825
I'll never use any of these "safe" shitfuncs.
All they do is encourage to sweep the string truncation bugs under the carpet, instead of fixing them.
Run towards bugs, not away from bugs.
>>
>>61852885
Enjoy your buffer overflows.
>>
>>61852900
This, a buffer overflow is more serious than a string truncation.
>>
File: 1492085644340.png (339KB, 387x550px) Image search: [Google]
1492085644340.png
339KB, 387x550px
>>61852885
>Run towards bugs, not away from bugs.
This is what C "developers" actually believe!
>>
>>61852855
USE GDB OR VALGRIND YOU FUCKING PLEB
>>
>>61852921
A buffer overflow has a chance to be detected because there is testing, debugging, fuzzing. A string truncation stays undetected because it's under the carpet forever.

>>61852942
Thank you for the advice Rajesh
>>
File: wow anon.jpg (78KB, 884x574px) Image search: [Google]
wow anon.jpg
78KB, 884x574px
>>61852855
>for (size_t i = 0; i < nfiles; i++)
> printf("%s\n", filelist[nfiles]);

kek
>>
>>61852855
>C programmer does not check if malloc or realloc fails.
Why am I not surprised.
>>
>>61853054
haha
>>
>>61853054
that's one smug akari
>>
why does google search always put the duplicate stack overflow questions first
>>
>>61853039
>unironically arguing that a string truncation is more serious than a buffer overflow
You obviously haven't the slightest idea what the grave consequences of the existence of a single buffer overflow are.

>A string truncation stays undetected because it's under the carpet forever.
What is data flow testing?

Why do we allow rookies like this guy to post opinionated comments?
>>
>>61853110
Because they are more recent?
>>
>>61853129
Buffer overflows are literally harmless, your program just segfaults and quits.

String truncations make you lose data.

Now fuck off.
>>
>>61853145
>Buffer overflows are literally harmless
go back to r*eddit
>>
smarter than my compiler
>>
>>61853150
Somebody please tell me I just didn't read this...
>>
>>61853162
In the future it will be true.
>>
>>61853162
what do you mean?
>>
>>61853150
But he's right anon
>>
Repost from:
>>61852409

I've got an AGPL-licensed server. Its a game server but I don't want to release the game's content - just the source code of the engine. Is it OK to license the server's code with AGPL, but make it so that the Lua scripts that will be used on my own server will not be public (if the server is still runnable without those scripts, just not with the same content)?
>>
>>61853054
Thank you. I feel dumb but still segmentation fault. Don't bother helping anymore, im deleting c
>>
>>61853184
I mean just admit you lost the argument already instead of using a reductio ad reddittum.
>>
>>61853162
http://www.nationalcybersecurityinstitute.org/general-public-interests/understanding-the-dangers-of-buffer-overflow-attacks/

http://faculty.salina.k-state.edu/tim/CMST302/study_guide/topic5/buff_overflow.html

https://www.freebsd.org/doc/en/books/developers-handbook/secure-bufferov.html
>>
>>61852855
>using a language invented before memory protection was a thing
>complaining about segmentation faults
You brought this upon yourself, anon.
>>
>>61853190
If you wrote the game server then yes. They're separate things and it's your software. You aren't bound by licenses for your software, only your customers are.

If you didn't write the game server and only wrote the scripts then no.
>>
File: 1502471016761.jpg (420KB, 2000x1125px) Image search: [Google]
1502471016761.jpg
420KB, 2000x1125px
>>61853204
i'm not the same person, newfriend
>>
>>61853198
>deleting c
>>
>>61853237
Right. Well, obviously I am the author of the server. I want people to be able to mod the server and make their own content, but not use the same content I use. Cheers.
>>
>>61853247
source on the porn
>>
>>61852921
What kind of moron does't know how to catch stack overflow bugs in C in 2017?
>>
>>61853388
these bus can be silent.
>>
>>61853406
In exceptional circumstances yes.
There's worse bugs to worry about though. Especially with security conscious applications.
>>
I've lost my fucking motivation
I can't work on anything
How can I change this?
>>
>>61852855
time to use Rust
>>
File: png.png (11KB, 865x125px) Image search: [Google]
png.png
11KB, 865x125px
>>61853441
Take a long walk. Go dancing. Work on something practical.
>>
>>61853440
>In exceptional circumstances yes.
not so exceptional, exploits using bufferoverflow are reported every day.
>>
>>61853474
>exploits using bufferoverflow are reported every day.
They're morons. Most likely.
Sanitizing input is trivial.
>>
>>61853461
>trusting documentation from fucking Microsoft
Nigga, if you ever unironically use strlen, then you are asking for buffer overflow vulnerabilities in your software. 'Nuff said.
>>
>>61853497
Which is why they're writing software while you post about it on an online Mongolian throat-singing imageboard I suppose?
>>
>>61853538
>Which is why they're writing software while you post about it on an online Mongolian throat-singing imageboard I suppose?
I write software professionally too.
Why would you assume I don't?
>>
>>61853547
>'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''professionally'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Because you're not a professional if you trivialize buffer overflows like that.
>>
>>61853547
>Why would you assume I don't?
because you are on 4chan, on a weekday, at 1:30 pm
>>
>>61853497
>Sanitizing input is trivial.
Umm... no it isn't, anon. And if you really think it is, remind me to never hire you.
>>
>>61853499
Only if you use it on untrusted data, in which case you use strnlen. I have never seen anyone say that strnlen is a replacement for strlen.
>>
>>61853570
>> because you are on 4chan, on a weekday, at 1:30 pm
> everyone lives in my timezone and there is no other timezones
>>
>>61853570
>at 1:30 pm
Yeah the suns position relative to the earth is 1:30pm now. Huh, didn't notice. I suppose that's ample reason to assume. But no I'm not.
>>61853583
>Umm... no it isn't, anon.
Your input is a format you define or a format you inherit. If you inherit it you just take another gander at the way you parse this information and look for flaws. If you make it yourself you can make it very restrained without issue and give errors for anything that doesn't conform to your spec. It's absolutely trivial.
I don't quite comprehend how someone could think it's not unless they're working in an environment where they don't know the input data they will take and will always have to do best effort attempts. OR if you've never written any input handling code before. The path is clear.
It's fucking solved.
>>
>>61853499
MSDN docs are widely considered to be among the best
>>
>>61853709
Yes it's also known for its errors in specification of the win32 api and having to discover them the hard way.
>>
>>61853709
Except for the strange types they put everywhere.
>>
>>61853709
MSDN docs are terrible. That probably says something about how bad the rest is.
>>
File: IMG_0429.jpg (2MB, 4032x3024px) Image search: [Google]
IMG_0429.jpg
2MB, 4032x3024px
These are the books I'm powering through right now and I'm looking for next ones to buy cause I'm making good progress. I'm curious about OP pic, should I read that front to back too?
>>
>>61853758
>learning python
>that brick
Why? Do they really teach you that much? I thought python was a neat small scripting language. Everything I've seen about it indicates it's not that big.
>>
>>61853731
>Yes it's also known for its errors in specification of the win32 api and having to discover them the hard way.
Examples? I've always used MSDN for WinAPI docs and I've never encountered any sort of errors.
>>
>>61853750
they are great and praised by most
>>
>>61853499
>>61853709
>>61853750

MSDN docs are pretty good. I don't know about "widely considered the best", but compared to other companies, I've consistently got the info I needed in MSDN.
>>
>>61853795
you'd be surprised
>>
>>61853750
>go to page for API call
>function definition
>detailed list of what arguments it takes and what their functions are
>code examples
>any further notes for any specific quirks of the function
I'm not seeing the "terrible" part of it here.
>>
>>61853831
>you'd be surprised
Give me some of the advanced topics then?
>>
>>61853750
They really aren't. What's troublesome is finding what you need. They've been working on this but it's still not great. Once you find the functions/systems/whatever you need they're very neat and organized.
>>
>>61853868
this, the best way to use MSDN is to use an external search engine to search the site, just putting a general description of what you're trying to do into google or whatever will generally bring up the relevant MSDN pages in the first few results
>>
>>61852855
>20 line app to do simple shit
>pointers to pointers all over the place
>can't figure out what's wrong

use C++, brainlet
>>
Who can we petition to make the code window wider?
>>
>>61853948
Or at least flexible/enlargeable.
>>
>>61853948
How about you petition yourself to fix your stylesheets?

Stupid fuck. It's literally one simple modification.
>>
>>61853974
What did he mean by this?

I don't speak autistic webshit.
>>
File: Untitled.png (26KB, 1592x698px) Image search: [Google]
Untitled.png
26KB, 1592x698px
>>61853948
?
>>
File: anal beads.png (14KB, 493x395px) Image search: [Google]
anal beads.png
14KB, 493x395px
>>61853988
I'm not even a webdev, this is basic bitch shit.

Kill yourself, brainlet.
>>
don't care about portability and only make programs for x64 linux mint
>>
>>61854003
>code window

Like here >>61852855
>>
>>61853936
the C++ version would be the same but the line length would be changed to line width
>>
>>61854017
We should still make it better for everyone.

Why is that window not flexible??
>>
>>61854027
see
>>61854017
override the prettyprint style
>>
>>61854017
>using windows

kek
>>
File: Untitled.png (29KB, 1149x536px) Image search: [Google]
Untitled.png
29KB, 1149x536px
>>61854027
?
>>
File: 1502477825734.png (45KB, 1149x536px) Image search: [Google]
1502477825734.png
45KB, 1149x536px
>>61854074
are you retarded?
>>
>>61854043
>the C++ version would be the same

not even close, especially if you use boost
>>
File: anal beads.png (30KB, 673x821px) Image search: [Google]
anal beads.png
30KB, 673x821px
>>61854091
¯\_(ツ)_/¯
>>
>>61854124
Make these modifications default ffs.

Do it, faggots.
>>
>>61854140
Do it yourself.
>>
>>61854149
Why do you want /g/ to be shit?
>>
>>61854191
if /g/ becomes good, this place will be infested with normies
>>
>>61854091
>it works for the width but I wish it worked for the height also but I guess that's impossible
idk man just like stop being retarded yourself first
>>
>>61854204
Why do you want /g/ to only be infested by webshits who don't know programming?
>>
>>61854191
Creating simple barriers to usability helps to promote a more knowledgeable userbase.

4chan fucked up real bad when they started implementing 4chan X features into the actual website. Made it too accessible.
>>
>>61854230
>more knowledgeable userbase.
>webshit
>useful knowledge

kys
>>
File: 1497231334917.jpg (132KB, 795x1036px) Image search: [Google]
1497231334917.jpg
132KB, 795x1036px
>>61854122
>complains about the program being too big just to do something simple
>"use boost"
Thanks for the laugh, mate.
>>
>>61854224
>who don't know programming

speak for yourself. the anons who program good are only here when is around 10 pm
in Europe
>>
This syntax is valid in C
int x;
(((x)))=1;
>>
>>61854224
>webshits
>>61854242
>webshit

This has nothing to do with whether or not you're a web developer. This is basic problem solving that anyone who belongs on a technology board should be able to trivially fix.

You're welcome to keep spouting off nonsense, but you've got a solution to your problem, so fuck off.
>>
>>61854267
Bullshit, there's always 10pm somewhere.
>>
>>61854275
so?
>>
>>61854284
>This has nothing to do with whether or not you're a web developer.
Believe it or not, only webshits care about this kind of stuff. No offense to webshits.
>>
File: 1499244828080.png (75KB, 512x512px) Image search: [Google]
1499244828080.png
75KB, 512x512px
>>61854275
It's valid in a bunch of other (((language))) too
>>
>>61853221
>mistaking memory protection with memory management
>>
>>61854275
int Drumpf;
(((Drumpf)))=0;


back to /pol/
>>
>>61854275
This syntax is valid in C++, but not C.
int x, y;
(x < y ? x : y) = 0;
>>
>>61853221
>using a language invented before memory protection was a thing
lisp had a GC and predates c by what? 20 years?
>>
I'm working on a Crunchyroll downloader app that in Python. It supports 480p downloading so far but I need to find a way for cookies to work so I can implement 1080p downloads and simulcasting.
>>
>>61854458
requests supports cookies.
>>
File: 1482598443468.gif (203KB, 248x225px) Image search: [Google]
1482598443468.gif
203KB, 248x225px
>>61854458
>streaming anime
>>
I bump my question
>>61850579
>>
gee I wonder what this language is
        while (<$plan>) {
$. == 1 && s/^\x{FEFF}//;
s/(.*)[\s\t]+#.*$/$1/;
s/^\s*#.*$//;
s/^\s*//;
s/\s*[\r\n]?$//g;
s/ +/ /g;
next unless ($_);
>>
File: 1495553367533.jpg (69KB, 780x720px) Image search: [Google]
1495553367533.jpg
69KB, 780x720px
>>61854581
144fps anime is the only way
>>
>>61854275
and?
so are these:
2[a] = 5;
void g() {
printf("asdf");
}
int f() {
return g(), 1488;
}
x+++++y;
>>
>>61853795
That's just the language basics and I should read the documentation for more after. The second book is making real applications, so I can make servers email clients, databases, firewalls, webutilities etc
>>
>>61853758
they should make a book "forgetting python"
ha haha ha
>>
File: s.png (169KB, 1664x1013px) Image search: [Google]
s.png
169KB, 1664x1013px
>>61852783
>What are you working on, /g/?

Exploring the deepest, darkest corners of Racket.

Crafting a GUI Game of Life.

Wish me gambatte, /dpt/!
>>
Almost completed the AST parser for protobuf
>>
>>61853758
>upgrading and repairing PCs
why

>ubuntu
You need a book for that? You'd learn just as much if you just installing Ubuntu and using it as a daily driver for a bit.

>those yuge Python books
Completely unnecessary and a waste of time. I could see those books useful as a reference for C++ or ASM but not Python. Learn from one of those online tutorials and just jump in without a condom. If you don't know what you'd like to write, start with the challenges on project euler.
>>
>>61855106
neat
>>
File: PhilFish-610.jpg (140KB, 610x345px) Image search: [Google]
PhilFish-610.jpg
140KB, 610x345px
>>61852783
So after fucking with javascript and C/C++ for the last two years and not really getting anywhere that I like beside basic webdev, I've decided to jump into learning Java/Python. I bought Automate the Boring Stuff and a Java book that covers pretty much everything but they both spend a good portion covering syntax, inheritance, OOP, data types, etc...which is stuff I already know. So to supplement my reading, I want to start building some projects so I'm putting in the practice. Does anyone have a list of suggestions (possibly a link) or any ideas they can offer?
>>
>>61855249
google "g programming list"
>>
I heard about the fizzbuzz task.

What are some other typical tasks they give to unexperienced programmers to see if they're ok for the job?
>>
>>61853358
Extra Tall Babe vs Extra Small Spinner - Alice Merchesi & Lauren Phillips (2017-03-23)
>>
>>61855393
reverse a linked list
>>
File: 1469464095745.gif (384KB, 250x188px) Image search: [Google]
1469464095745.gif
384KB, 250x188px
[](){[](){[](){[](){};};};};

>mfw this is a valid c++ code
>>
>tfw your code doesn't work and you don't know why
>>
>>61855106
what is protobuf?
>>
>>61855419
>create a new linked list
>start from the end of original one
>copy elements one by one

is this it?

t. pleb
>>
>>61855249
I sometimes do stuff from this list:
https://github.com/karan/Projects
>>
>>61855484
https://en.wikipedia.org/wiki/Protocol_Buffers
>>
>>61854411
(x < y ? x : y) = 0;

Pretty neat.
>>
>>61855491
and how do you go backwards on a linked list? (assuming it's not a fancy doubly linked one)

you have to build the list backwards, in o(n) time baby
>>
>>61855491
>create a new linked list
not if you want to do it in place, but if you want to make a new list that's valid
>start from the end of original one
bad idea since linked list indexing is so slow. Even worse idea if it's singly linked. Better to build it up starting with the head of the original list.
>>
File: Untitled.jpg (77KB, 944x608px) Image search: [Google]
Untitled.jpg
77KB, 944x608px
>tfw too brainlet to get into c++
I don't get how pic related makes sense, x and y will always equal 0 as far as I can tell, since xx = 0 and yy = 0 the values they set in main for p1 and p2 will make no difference, no? Pls explain
>>
>>61852855
Use scandir instead: http://pubs.opengroup.org/onlinepubs/9699919799/functions/scandir.html.
>>
>>61855537
>not if you want to do it in place, but if you want to make a new list that's valid
how to do it in place?
>>
>>61855542
Those are default parameters. If you do
Point default;
then it will default to using xx=0, yy=0 but if you do
Point explicit(1, 2)
then it will use xx=1 yy=2
>>
>>61855444
>wahh I don't understand lambdas :(
Found the brainlet
>>
File: 1500777946139.jpg (20KB, 450x600px) Image search: [Google]
1500777946139.jpg
20KB, 450x600px
>>61855570
thank you
>>
>>61855559
Then you just iterate over all the nodes in the list and change the pointers to the next node to point to the previous node instead.
>>
>>61855600
nice.
but what about the first node?
>>
>>61855528
proc reverse(L, RL = NULL ) =
if L = NULL
RL
else
reverse( tail(L), pair(head(L), RL) )
end
end
>>
>>61855610
The head of the old list will be the tail of the new list and will therefore point to NULL
>>
File: Clipboard01.jpg (35KB, 758x162px) Image search: [Google]
Clipboard01.jpg
35KB, 758x162px
anyone using qt creator with clang model and gcc 7? ive read somewhere that clang doesnt support some c++ features that are implemented in gcc7 and the errors are because of that but ive tested it with gcc 6 and shit doesnt work either
>>
>>61855508
why are you doing this?
>>
>>61855681
that's classified.
>>
>>61855696 is not me

>>61855681
To get better at writing compilers and Racket, also there isn't an implementation already
>>
>>61855444
>>61855579
this is nothing, watch this
auto volume = (width,height,depth) ->* [] (int w, int h, int d) {
return w * h * d;
};
>>
File: 1471146723678.jpg (13KB, 345x299px) Image search: [Google]
1471146723678.jpg
13KB, 345x299px
What are arguments in gdb and how do I use them to debugg programs?
>>
>>61855715
http://planet.racket-lang.org/archives/murphy/protobuf.plt/1/1/contents/planet-docs/generator/
>>
File: Untitled.jpg (150KB, 1148x1060px) Image search: [Google]
Untitled.jpg
150KB, 1148x1060px
>>61855570
hey one last thing, I just remembered this other example, I can't see how length is ever set, setCoordinates(0, 3) sets m_x as 0 and m_y as 3, calls updateLength which sets m_length and that's it, how will v1.length() and v2.length() work?
>>
>>61855715
keep up the good work.
>>
>>61855735
why not
int volume(int w, int h, int d) {
return w * h * d;
}
>>
>>61855444
soon this will be too

[]<>(){[]<>(){[]<>(){[]<>(){};};};};
>>
>>61855735
????
What version of C++ is this?

>>61855444
(((((((((())))))))))
>mfw this is valid Lisp code

printf("%d\n", 1 + - + - + - + - + - 1);
>mfw this is valid C code


>>61855750
:-(

Well that looks like an ancient library so it won't hurt to make one that fits better into Racket 6.10
>>
>>61855796
>:-(
when you are thinking of developing some sort of application, you don't search if it exists first?
you just go straight ahead?
>>
>>61855755
updateLength gets called within the setCoordinates function. Every time you do setCoordinates, updateLength gets run.
>>
>>61855830
I searched a bit and didn't find it in any of the main repositories
>>
>>61855735
what's your excuse for not being able to do
auto volume = (() => w * h * d)();

?
>>
>>61855622
>knowing the tail of your list
>>
>>61855796
thats c++11 code
>>
>>61855796
>>mfw this is valid Lisp code
Except you can still understand what it's doing at a glance, even though it's objectively stupid.
C++ is an abomination.
>>
>>61855870
Can you tell me more about ->* in C++11 I've never seen that syntax before
>>
>>61855859
in python this is just
volume = lambda w,h,d:w*h*d
>>
>>61855888
>he can't understand C++
brainlet
>>
I have trouble with some of the sicp exercises, am I a brainlet?
>>
>>61855904
>understand C++
No one with an IQ of 300 has been born yet.
>>
Android game
Kotlin or Java?
First tried Python, but the so-called "duck typing" gives me the heebie-jeebies
>>
>>61855926
>Android game
>python

isn't android java?
>>
>>61855889
theres an ->* operator you can overload, just like you can overload -> operator, i think
>>
>>61855128
>upgrading and repairing PCs
Its a good book, there's a lot of really valuable insight and things I learned I wouldn't have tinkering around, and it's handy to keep around.
>ubuntu
It was an easy read and I've read many others but not on hard copy.
I've already read them both front to back.
>Python books
I did a lot of online stuff but again I find way more in here than I can get from online
>>
>>61855940
Eh, more and more support seems to be coming to android, and wanted to learn python properly.
I guess I'll keep Python to small scripts
IIRC you can use C++ with kotlin together with java
>>
>>61855923
Epic meme
>>
>>61855940
Python has an extension to make native android os apps and probably iOS too but don't quote me
>>
>>61855863
tail in haskell/ocaml/... returns the list without its first item (the head)

for example with the list (1 2 3 4)

head(L) -> 1
tail(L) -> (2 3 4)
>>
>>61856012
>not writing exclusively in c
>>
File: _.png (658KB, 600x800px) Image search: [Google]
_.png
658KB, 600x800px
>>61856005
>>
>>61856085
Oh noooooo...
>>
>>61856076
mods should ban all non-C programmers from /g/
>>
>>61856076
i am a programmer, not a 70's computers operator
>>
>>61854435
Goes to show how shit C is.
>>
>>61856191
There's a good memory checker for it but it has to be run on Linux I'm at least a VM
>>
>>61855955
Maybe, but what syntax is (width, height, length) then?
>>
>>61856267
objects that overload , operator
>>
>>61854435
>>61856191
Lisp is a fantastic language but you're comparing apples and oranges here. C was meant to be portable and simple above all else, and that means it's going to be unsafe.
Modern Lisp implementations like SBCL are pretty fast but back then Lisp was a slow, and before that, theoretical language.
>>
CL newfag here, given a file, and some #'prin1 'd data, how do I efficiently add/remove data.
i.e not just reading the entire file into memory, doing adjustments and then just :superseding the file
>>
>>61856285
lul, didn't know you could overload that one
>>
>>61856314
samenigger
is there a standard function that reads all data from a stream?
>>
>>61856380
it's for template magic or so I heard
>>
>>61856393
There's uiop:slurp-stream-forms.
>>61856314
Well you could invoke read with eof-error-p to nil, and process the top-level forms one by one.
>>
>>61855832
Yeah I said that breh, but as I pointed out updateLength doesn't change length at all, just m_length, right?
>>
>>61856458
I'm assuming it's a typo. The style of prefixing m_ is dumb anyway.
>>
>>61856453
but what if there's a huge file
how does vim do it
>>
>>61856458
length can't be changed. It's a function that always jut returns whatever m_length is
>>
>>61856498
Do you have a sample of the file format? Is it text or s-exps?
>>
>>61856491
Oh ok that's what I assumed too, thanks bud
>>
>>61856531
its prin1'd data
but its not big, I'm just wondering how standard text editors handle really big files.
surely they don't create an entire new file and copy the contents on to it, right?
>>
>>61852783

Is GDB the best debugger for C on Linux? Is the best resource to learn it man gdb?
>>
File: _a.png (20KB, 582x627px) Image search: [Google]
_a.png
20KB, 582x627px
>>61856605
>not using ddd
>>
>>61855742
The same arguments you give your program when you run it.
You can set them with "set args <arguments>".
>>
>>61856574
If I made a text editor, I would always keep a copy of the full buffer. Emacs does it like this, for any size of file. You could have a mmap region of the file on which you work. But it is way easier to copy that in a buffer of 32-bit unicode chars than to work on bytes directly. Because operations on char positions are O(1) in unicode vs O(N) in 8bit, that's a desirable performance benefit for editors.
>>
>>61856574
lots of editors just load the data directly into their own in-memory representation. This is usually done to prioritize inserts and the like:

https://en.wikipedia.org/wiki/Gap_buffer
https://en.wikipedia.org/wiki/Rope_(data_structure)

If you want to handle really large files, then you would want to only look at portions of the data at any one time. Newline handling and syntax highlighting can be a memory concern here. I wrote a really simple editor a while back though that used a fixed amount of memory regardless of the input file. It just memory mapped the file and relied on the OS to page in the appropriate data. The main problem with this though is that you are only backed by bytes and inserts and the like become much less performant.

This approach to really large files though is an edge case in many circumstances and has tradeoffs against the usual case which is why many won't prioritize this.
>>
>>61856657

Isn't that just a GUI?
>>
>>61856742
GUI for gdb and others

https://www.gnu.org/software/ddd/
>>
>>61856751
how good is it?
>>
>>61856756
no idea
>>
>>61856605
I am not a huge expert in gdb and find that this config helps me navigate it a bit better if you don't like the defaults.

https://github.com/cyrus-and/gdb-dashboard
>>
>>61856792

Cheers, I'll take a look.
>>
>>61856756
Pretty old and shit, since gdb is flexible enough to just have development tools interact directly with it, especially Emacs (or Vim).
>>
>>61856657
ddd is just a gdb wrapper.
>>
>>61856605
https://www.jetbrains.com/clion/
>>
>>61856605
lldb + visual studio code
https://github.com/vadimcn/vscode-lldb
>>
File: 1425416752222.jpg.png (100KB, 452x330px) Image search: [Google]
1425416752222.jpg.png
100KB, 452x330px
>>61856708
I feel dumb now
>>
>>61856917

> default debugger in Xcode.

Go away.
>>
>>61856605
https://github.com/cs01/gdbgui
>>
>>61856936
Eh, that's normal. Better get used to that feeling.
>>
>>61856946

I will be using it inside emacs.
>>
>>61856946
>browser based native program debugger
how and for what purpose
>>
>>61856966
I'm sure GNU Emacs has already a builtin module for gdb.
>>
So are these threads always just retards arguing with retards?
>>
>>61856998
It does, just making sure I'm not gonna learn it and finding out there's a better alternative.
>>
>>61856605
>not using gui
total pleb
>>
>>61856989
internet browsers are now the best toolkits for developing portable apps.
>>
File: Screenshot_20170812_010452.png (632KB, 1280x800px) Image search: [Google]
Screenshot_20170812_010452.png
632KB, 1280x800px
>What are you working on
An application to stream desktop apps from a windows machine to my linux laptop into their own windows, because it's too weak for virtualization
>>
Rate: https://pastebin.com/Q9VwEMfk
>>
>>61856946
That's sick. I'm really not sure which sense of the term.
>>61857134
That's sad but true. I'm really not sure which sense of the term.
Seriously fám if it gets java BTFO further I'm for it.

>>61857819
Die in a house fire/10
>>
>>61854275
This is valid syntax in many languages, e.g:
fn main() {
let x;
(((x))) = 1;
}
>>
>>61857717
can you show your screen fetch fully?

i was thinking of putting debian but i have

>CPU: AMD A10-8700P Radeon R6

and many distros just freeze to hell and back
>>
File: Screenshot_20170812_013720.png (158KB, 1280x800px) Image search: [Google]
Screenshot_20170812_013720.png
158KB, 1280x800px
>>61858125
>>
>>61858318
>intel

thanks anyway
>>
>>61858125
What do you mean freeze? In my experience, Linux distros have actually been more consistent in performance for the last few years.
>>
File: scrot.png (16KB, 1009x385px) Image search: [Google]
scrot.png
16KB, 1009x385px
>>61858387
tried a lot of distros (Manjaro, Ubuntu, Xubuntu ,...)
After some use the screen goes black and i have to do a hard shut down

i bought my computer this year and i guess the graphics driver is still new and ubuntu and such have problems with it

pic related was when i installed xubuntu 16.04. but after a while, the screen went black almost every 20 minutes
>>
>>61856963
brainlet tard
>>
>>61858464
Fuck I've experienced that too, though much more rare
>>
So I gather there's been a bit of a brouhaha involving Google recently?
>>
File: 1502179748737.jpg (136KB, 1200x825px) Image search: [Google]
1502179748737.jpg
136KB, 1200x825px
>>61858655
what have you heard?
>>
>>61855735
>>61855895

I guess in Haskell it would be either:
volume :: int->int->int->int
volume w h d = w*h*d

or as a proper lambda:
\w,h,d->w*h*d


I've never learned python, are functions first class citizens?
>>
>>61858684
lambdas are anonymous functions in python
>>
>>61858684
Int
types in Haskell begin with capitals

and for the lambda
\(l,w,d) -> ...
(takes a tuple)
\l w d -> ...
(curried)
\l -> \w -> \d -> ...
(same as above)
>>
>>61858664
That a Google employee wrote a document that conflicted with the company's values, his employment was later terminated, and this is apparently newsworthy.
>>
>>61858715
By firing him, they proved his point.
>>
found this on github

https://github.com/noether-lang/noether

>The Noether programming language
>>
>>61858684
>>61855735
On second thought the Haskell equivalent for that C++ code might be:
volume :: (Int->Int->Int)->Int
volume (w,h,d) = w*h*d

In case C++ can't into currying or proper higher order functions.

>>61858708
You're right about capitals. Wasn't really thinking.

About the tuples though, are you saying that C++ is only capable of dealing with product types and can't into currying (as I'm asking above)?

>>61858695
That seems like a gyp. They should call them something different then, imo.
>>
File: received_10213390473578003.png (932KB, 807x605px) Image search: [Google]
received_10213390473578003.png
932KB, 807x605px
Today I added a minimap to my RTS game. Fixed some AI, general gameplay things.
>>
>>61858751
So?

If I accuse my boss of impetuously lashing out whenever he is criticized, and he immediately fires me, then he has proven my point, but it is hardly newsworthy.
>>
>>61858781
why is your filename "received..."
?
>>
>>61858774
no, I was giving fixed Haskell syntax for lambdas
>>
>>61858824
Because reasons
>>
>>61858774
Oh, and your tuple type should be (Int,Int,Int)
>>
>>61852783
#include <stdio.h>

int main(){

int c = 5, d;
d = ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c;

printf("%d\n", d);

return 0;

}


How much is d?
>>
>>61858947
7
>>
>>61858977
Incorrect. You suck! The correct answer is 139.
>>
>>61858764
looks weird
>>
>>61858990
bazinga!

i don't care
>>
>>61858841
Oh, the commas.

>>61858855
Right, fuck.

No idea why I did that. I've been fucking retarded lately.
>>
>>>/biz/3029141

thoughts?
>>
>>61858947
See sequence point rules.
http://en.cppreference.com/w/cpp/language/eval_order
>>
Why is the JVM so fucking fast at traversing short linked lists?
>>
File: MicrosoftOrMicroshit.jpg (174KB, 1202x705px) Image search: [Google]
MicrosoftOrMicroshit.jpg
174KB, 1202x705px
I was familiarizing myself with C's portability and found something that boggles my mind. I made a simple loop that counts to 100,000 and it takes way longer on Win10 (121x longer on average) . I feel like I am failing to account for something. Thoughts? Am I retarded?
>>
>>61859403
Did you even turn on optimizations
>>
>>61859403
post the code?
>>
>>61859432
also, I wouldn't be surprised if you aren't taking into account the speed of the terminal emulator and printing is taking the entirety of your runtime.
>>
>>61859447
Yeah, That was it. Just tried it without printing and the times are nearly Identical. Turns out I was retarded.
>>
>>61859447
Forgot to say thank you. Thank you.
>>
>>61852783

what kind of faggot reads a book about refactoring code, or anything not based on mathematics?
>>
File: IMG_1245.jpg (26KB, 750x210px) Image search: [Google]
IMG_1245.jpg
26KB, 750x210px
>>61852783
Respected sir please answer me the question, I need understanding most respected teacher.
>>
>>61859200
and prayers
>>
>>61859569
you
>>
>>61859462
>Turns out I was retarded.
Not really, since the true extent of Win10's telemetry still surprises people.
>>
>>61859583
POO
>>
>>61852783

Can someone tell em why this doesn't open my shell in a new frame? I'm only 50 pages into the elisp tutorial and non the wiser.

(add-to-list 'display-buffer-alist
'("*Help*" display-buffer-same-window)
'("*shell*" display-buffer-pop-up-frame))
>>
File: gps.png (391KB, 1920x1079px) Image search: [Google]
gps.png
391KB, 1920x1079px
>>61852783
mapping my town's wifi
>>
New to programming? Not sure which programming languages to learn? Look at pic related to discover which languages are best suited to common development tasks.
>>
>>61859640
>>61859640
Your last argument corresponds to the boolean APPEND according to the manual of add-to-list. There is definitely an error in your code.
Do you mean to append two elements to the list instead?
(add-to-list 'display-buffer-alist '("*Help*" display-buffer-same-window) t)
(add-to-list 'display-buffer-alist '("*shell*" display-buffer-pop-up-frame) t)
>>
>>61860084
What's the population of your town?
>>
>>61860104
>literally who: the language(s)
>>
>>61860170
>not having heard of even one of those languages
I pity you.
>>
>>61858781
Reminds me of a game called Outlive.
>>
>>61860084
about 100k
>>
File: tiberian-dawn.jpg (52KB, 550x348px) Image search: [Google]
tiberian-dawn.jpg
52KB, 550x348px
>>61860242
or.. Command & Conquer
>>
>>61860184
Redpill me then
>>
>>61860437
https://en.wikipedia.org/wiki/Scheme_%28programming_language%29
https://en.wikipedia.org/wiki/Idris_(programming_language)
http://shenlanguage.org/
>>
>>61852783
I have a question for the wise men (traps not welcome) of /g/. I'm writing a program that is randomly creates Bears ('B') and Fish ('f') on a grid. They move around randomly 1 tile at a time, the bears eat the fish if they collide, and if they're the opposite gender and same species, they create a new bear/fish.

My question is how is the best way to manage them? Currently i've been iterating through the grid and updating the position that way.

I was wondering if it would make more sense for me to just make an arrayList of all the Bears and fishes and manage it from there instead.
>>
File: 7394231137[1].png (28KB, 1063x594px) Image search: [Google]
7394231137[1].png
28KB, 1063x594px
I tried to use the {code} {\code} thing but it said I was ip blocked?


Anyway, here is my first attempt at a program in python. I am making an alarm clock.

My first version involved a loop with no delay and my computer started acting very weird. Can you explain what was happening?
>>
>>61860590
How big is the grid? How many bears and fish?
>>
File: coq.png (5KB, 112x180px) Image search: [Google]
coq.png
5KB, 112x180px
turing completeness is overrated
prove me wrong
>>
>>61860603
infinite loop you dunce
>>
programming newfag here.
I am restarting college (Spent time as a neet 2 years then started working) and i need to crush my competition, what sources do i need to become a code artisan , the wiki isnt being quite helpful.
>>
File: anko_ehhhh.png (336KB, 477x719px) Image search: [Google]
anko_ehhhh.png
336KB, 477x719px
>>61860603
Are you a girl? Can you please be my coding gf?
>>
>>61860677
See >>61860104
>>
File: le pepsi puppy.jpg (7KB, 259x194px) Image search: [Google]
le pepsi puppy.jpg
7KB, 259x194px
>>61860617
The size is variable, but right now i'm working with 20x20. The amount of bears and fish is random based on whatever density you choose. Right now for every spot there's a 70% chance generate an empty space, 20% to be a Fish, and 10% chance for a Bear by default. I'll probably change that around once I actually get it working and see what works best.

I was thinking i'd add them to an array as they're created. Also i'm unsure if I should make separate arraylists for the bears and the fishes or if I should just use one arraylist for both of them.
>>
>>61860699
>20x20
I'd just use a char array to represent a grid at that size tbqh. 'B' means a male bear, 'b' means a female bear, 'F' means a male fish, 'f' means a female fish, anything else means empty.

Have two grids, grid1 and grid2 are pointers/references to them.
Write the next state of grid1 to grid2.
Swap grid1 and grid2.
Repeat.
>>
>>61860344
That too. Although I stopped playing C&C first.
>>
>>61860655
Ok but what does that mean for my computer?

I dont really know whats going. It was using the cpu at 97%. Does it just go as fast as possible?

Does it store the results somewhere or just delete them when its done?
>>
>>61860749
>https://stackoverflow.com/questions/10926328/efficient-and-fast-python-while-loop-while-using-sleep
TY vm
>>
>>61860603
instead of
 when = input("When do you want to wake up: ")

Alarm = when
;

Why not just do
 Alarm = input("When do you want to wake up: ")
;
>>
>>61860762
Yeah I should've elaborated more, that is exactly how i'm doing it. One grid to contain the locations, one grid is a char array to just update. I don't know how to go about making a GUI, I figured i'd do that later on.
>>
>>61860762
Oh and I guess i should've mentioned, the language is Java. So I just made a Abstract class "Animal" and then "Bear" and "Fish" extend that.
>>
>>61860783
With no sleep in your busy waiting loop, your process was using up every available bit of CPU time the OS would allow, 97% in your case. Anything else trying to run was getting starved for that resource.
>>
>>61858781
very very cool, anon. Still around? I'd love to hear more about your RTS
>>
>>61860105

That's it, thank you sir.
>>
>>61860832
What happens when a Male bear, followed by a fish, followed by a Female bear all wind up going into the same tile?
>>
>>61860677
>i need to crush my competition, what sources do i need
Humility.
>>
File: Blushing Autist.png (762KB, 841x709px) Image search: [Google]
Blushing Autist.png
762KB, 841x709px
>>61860892
>Humility

Humility wont work here senpai.
Since little i have been the big fish in a small pond and when it isnt i fall into a depressive state or i enter into a autistic learning craze to crush my competition.

>>61860696
I could use something marketable
>>
>>61860916
>Humility wont work here senpai.
Okay, now fuck off.
>>
>>61860916
We don't need you in this industry, son. Try sales.
>>
>>61860104
Who actually uses Shen? How do you even learn Shen? The docs are nonexistant
>>
>>61860916
stop acting like an autist. do the projects from your text books, do any extra credit programming assignments, join up on clubs and events with programming elements, go to hackathons and jams, enter online contests and challenges.

there is no shortage of programming opportunities.
>>
>>
>>61860888
That's a really good question I hadn't considered. That is easy though, in this case the fish is eaten and a new bear is formed. The greater question is what happens when 5 different creatures end up in one tile. I guess I'll do it where each tile is managed by a priority system. Bear eating fish is #1 on the hierarchy, then bears reproducing, and finally fish reproduction will be the lowest on the totem pole. So I guess if 2 female bears and 2 male bears and up on a tile with 3 fish or something, the 3 fish get eaten and then the bears have a orgy.
>>
>there are people ITT who don't understand garbage collection inherently gives better performance than OS-provided memory management
I want rookies to shut the fuck up about things they don't know.
>>
>>61861006
It may be worth your while to maintain a list of tiles with multiple occupants, so you can deal with just those tiles while running the feeding, fighting and farking functions.
>>
File: 1438864149598.jpg (6KB, 220x251px) Image search: [Google]
1438864149598.jpg
6KB, 220x251px
I'm writing my own implementation of C++ std::vector as a learning exercise. Basically a dynamic array class.
Tell me, would it make sense to have a reverse() method in the class, or should I write a reversing function outside of the class definiton for when I need it?
>>
>tfw not autistic enough to handle the borrow checker
>>
>>61861291
I'd only argue for it if it was that commonly used, or it there are performance benefits over using a friend/external function.

So in the case of reverse, I'd lean towards no.
>>
File: rlm feels.png (821KB, 1435x808px) Image search: [Google]
rlm feels.png
821KB, 1435x808px
>tfw converting VB6 code to VB.Net
>>61861291
In the class IMO.
>>
>>61861291
Just provide iterators. Reversing follows from <algorithm>.
>>
>>61861291
>>61861342
http://en.cppreference.com/w/cpp/algorithm/reverse
Basically your iterator needs to allow to be iterated with a++ and a-- and dereferencing it can lead to a swap call on it (but that depends on the value).
>>
>>61861123
Yeah, actually I realized I can't have tiles with multiple occupants the way i've implemented this. I don't even know how I should do that, aside from making every single tile on the grid an array with a list of occupants.
>>
>>61861406
if you don't have too many occupants, just use a bitmask approach with each member represented by a different bit.
>>
New thread:

>>61861536
>>61861536
>>61861536
>>61861536
>>
>>61859635
IN
>>
>>61861406
>aside from making every single tile on the grid an array with a list of occupants.
That's not much more work than you're doing already. Plus, it lays the ground work for having tile specific information modify the behavior of the animals there.
>>
>>61860804
My first version had it continually asking for input because I was dumb.

So i used that to fix it, but now its not necessary i guess.
>>
>>61860999
what time zone? EDT?
>>
>>61861006
Fish might have shorter reproductive cycles. Maybe they should spawn first.
>>
>>61861717
EST, aka UTC -5
>>
farewell humble bread
you will be missed
Thread posts: 324
Thread images: 46


[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.