[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: 327
Thread images: 40

File: 1481034157681.jpg (64KB, 1024x906px) Image search: [Google]
1481034157681.jpg
64KB, 1024x906px
What are you working on, /g/?
Old thread: >>58410286
>>
Back to your subreddit
>>
>>58422674
redditors who are actually here to post on topic are an improvement to this general
>>
File: Screenshot_2017-01-10_18-12-03.png (296KB, 876x753px) Image search: [Google]
Screenshot_2017-01-10_18-12-03.png
296KB, 876x753px
trying to come up with a decent look for my buttons

they correspond to "play now" and "add to queue"
>>
>>58422691
fuck off back to your subreddit
>>
>>58422700
What's up with the font rendering?
>>
>>58422700
buttons look good enough

what is this exactly
>>
>>58422700

is this modern UI design?
>>
>>58422711
it's electron (chromium) which is why fonts might look off

>>58422722
a music player
instead of playing files from your pc i'm building an engine that will look across multiple websites like youtube and soundcloud and let you play from there
>>
>>58422691
>to this general
subreddit you mean?
>>
>>58422730
yeah i'm going for the meme look because
>we want normie audience
>>
>>58422742
that's an ok idea, though im not sure much is gained from not just using youtube in one's browser
>>
>>58422756
so you want your friends and yourself to use it?
>>
File: scrot689.png (1MB, 1539x1087px) Image search: [Google]
scrot689.png
1MB, 1539x1087px
I made a CRUX port management utility. This is my first go project, and my first project in a "real" language (aka not shell).

If someone could give me some feedback or criticism that would be nice.

https://github.com/onodera-punpun/prt
>>
>>58422768
people use mps-youtube all the time

>>58422774
i want it to be a free replacement for that piece of shit called spotify
>>
>>58422652
whats a small project a beginner can do in python in under a week? I was thinking of something like palindrome checker, coin flipper (you pick how many times it flips and it outputs as percentages) or something like that what do you guys think?
>>
Guys, tell me please someone how do I pass arrays to functions
>>58421939
>>58421846
>>58420644
>>58422281
>>58422235
>>58422232
>>58422414
>>
>>58422821
1D array (int []) corresponds to int*

2D array (int[][]) corresponds to int**

that's literally it
>>
>>58422821
Fuck off, plebbitor.
>>
pets = [ 'cat' , 'dog' , 'fish' , 'bird' ]
for i in range(len(pets)): # i is assigned 0, 1, 2, . . .
print(pets[i])


how do I make it only print 'fish'?
>>
>>58422821

void foo(int *ptr_to_first_element);
>>
>>58422844
pets = ['cat', 'dog', 'fish', 'bird']
for i in range(len(pets)):
if i == 2:
print pets[i]
>>
>>58422821
function f(int *arr, int length)

int array[10] = { ... }
f(array, 10)
array = &array[0]
>>
>>58422691
he's right
you retard spergs post nothing of value, at least redditors like information

>>58422652
Our system thinks your post is spam. Please reformat and try again.
>ITT let's not share code b/c 4chan is garbage
>>
>>58422830
yes, I know, but this doesn't help me get any clue of what the actual fuck is wrong in how I pass it to function in line 43
http://pastebin.com/BmmQXFYU
>>
>>58422880
thanks, is there a way to do it in the print statement?

like print(pets[2]) for example (obviously fails because it prints it 4 times)
>>
>>58422953
learn about the 'break' keyword and what it does
it basically interrupts the loop
>>
I'm about to make a convolutional neural network. The easiest would be to identify hand written digits on a page...but I was wondering if I could do more with this? could it solve math problems? Or any other ideas? words on a page maybe?


I'm looking for any good resources on this subject. Any help would be appreciated, at the moment I'm just googling information and it's a little overwhelming. Guess I'm going to be using python..
>>
>>58422881
what if that function is meant to alter arr elements, it' still f(int *arr, int length), not f(int &*arr, int length) or anything, right?
and I don't get your last line.

>>58422870
and what if the array is twodimensional?
>>
>>58422977
wtf dude pointers arent THAT hard
>>
>>58422975
http://cs231n.github.io/

https://www.youtube.com/playlist?list=PLkt2uSq6rBVctENoVBg1TpCC7OQi31AlC
>>
>>58422953
if you don't want to repeat, don't use a loop
pets = ['cat', 'dog', 'fish', 'bird']
print pets[2]
>>
>>58422975
make it recognize all pictures with store fronts
>>
>>58423021
wow, thank you!
>>
if (d < 0){
return startY <= ty;
}
else if (d > 0){
return startY >= ty;
}


Is there a way to make it shorter?
>>
>>58423054
I kek'd
>>
>>58423067
return d < 0 ? startY <= ty : startY >= ty;
>>
>Spend 10 minutes working on program
>Feel the tiniest bit of frustration or tiredness
>Close it down
>Shitpost for 15 minutes
>Open it back up
>Repeat
I fucking hate not having any impetus except my own to write code. I used to do it 10 hours a day nonstop without issue but school provides absolutely no challenge (3 week projects take me an afternoon at most) and I don't have any of the discipline to work on anything consistently.
>>
>>58423083
Thanks!
Is it faster this way? Or is it the same?
>>
>>58423067
switch case?
>>
>>58423067
return d < 0 ^ startY > ty;
>>
File: 1478307415068.png (749KB, 1000x750px) Image search: [Google]
1478307415068.png
749KB, 1000x750px
I need some assistance on how to use fseek() and ftell(). I tried to do it as the book specified but I can't make it work.

The exercise specifies me to let the user enter the position where he wants to go and then just print from there on.

 #include <stdio.h>

int main(int argc, char * argv[])
{
FILE * fp;
int pos;
int c;

fopen(argv[1], "r");

scanf("%d", &pos);

fseek(fp, pos, SEEK_SET);

c = getc(fp);

while(c != EOF)
{
putc(c, stdout);

c = getc(fp);
}
}
>>
File: anal beads.png (78KB, 282x300px) Image search: [Google]
anal beads.png
78KB, 282x300px
Could you somehow mimic orgasm/sensory buildup/cooldown mechanics to make your programs *want* to do a particular task, rather than forcing them?

As in, replicate the primitive urges to reproduce and self-preservation to encourage your application to do specific things and be rewarded with stimulation of some sort.
>>
>>58423121
Not really, but it is shorter and more elegant.
Depending on the language it will also have a smaller memory footprint because there's less branching
>>
>>58423083
>>58423125
assume d == 0 has the same effect as d > 0, which is not necessarily the case in >>58423067.

What happens when d == 0?
>>
>>58423144
https://www.youtube.com/watch?v=xOCurBYI_gY
Yes, but it doesnt mean it's going to be any good at it or make any sense
>>
>>58423169
d is never equal to 0.
>>
>>58422700
maybe have the buttons consist of white outlines over a transparent background and white icons (like the new instagram icon)
>>
I want to create an automated release process for my C++ project, which includes both 64 and 32 bit binaries. I'm using CMake and got everything to work on Linux fairly quickly, but Windows/Visual Studio is being a piece of shit.

I got it working by manually creating the x64 solution configuration, but I haven't found a way to automate this yet. Any advice?
>>
>>58423195
That mindset is what leads to unfindable bugs down the line.
Account for it now. Don't practice shit habits.
>>
why do graphics processing use floats when computing on them isnt always accurate? :3
>>
>>58423238
Because accuracy isn't always as important as speed.
>>
File: 1452104292747.png (153KB, 351x351px) Image search: [Google]
1452104292747.png
153KB, 351x351px
>make a new variable
>Warning: The value of the field Faggot.dicks is not used
>>
>>58423238
It's because it's almost never required to be this precise.

For example, in OpenGL ES, we have 3 precision levels for different applications. Sometimes it's okay to be a bit inaccurate if it's faster.
>>
Just ordered C++ Primer off Ebay. It's arriving in 8 days. For the time being, what should I do to get started on C++? My ultimate goal is video game development.
>>
>>58423282
https://thenewboston.com/videos.php?cat=16
>>
>>58423269
>start writing a new line
>syntax error: ';' expected
>>
>>58422652
What's it like programming on a macbook?
Might want to learn c++ as my first language
>>
>>58423207
yeah use gcc
>>
>>58423294
thanks man
>>
>>58423294
>>58423282
Do not use The New Boston. It's a fucking terrible resource.

Go on http://gen.lib.ru.sc and download some C++ books and work through them.
>>
>>58422789
you're a girl?

looks good either way
>>
>>58423334
That should be http://http://gen.lib.rus.ec

My bad.
>>
>>58423303
You mean the MingW thing?
>>
>>58423354
>>58423207
what is cmake doing on windows, exactly?
>>
>>58423354
ye
>>
>>58423367
It's creating a Visual Studio project, though only with one build configuration. Would be okay because you can build it with msbuild if it wasn't for that missing x64 configuration thing.
>>
Shit I didn't know you could write desktop apps with HTML and JavaScript these days. This is legitimately exciting. Now I can be a real programmer too.
>>
>>58423407
>real programmer
>HTML and javascript

No
>>
I'm new to C++. If I eventually want to get into video game development, should I jump right into video game projects or should I tackle smaller things first since I'm new to the language?

If the second language is more sound, anyone mind posting that image that has a list of like 100 different beginner projects so that I can save it and use it later on?
>>
>>58423420
HTML and CSS are fantastic languages for building GUIs.
>>
Reposting this here because I'm a moron and I didn't realize there's a new thread.

Working on an android app that tracks your location constantly.
What would be the best way to store location data? I thought about using an SQLite database with columns for time, latitude and longitude, but after a while it sounds like it would slow down due to the massive number of entries. Alternatively I could just save to a binary file format of my own creation, but that sounds like it would be more error-prone. What do you think /g/?
>>
>>58423466
Well, if I store a location every 5 seconds constantly, that's going to be 17280 entries per day. After a few weeks it sounds like it would become slow to query, for example, every entry on a certain day.
I also thought about creating a new table each day or something, but creating tables on demand seems to be something of a nightmare in Android.
>>
>>58423546
>Well, if I store a location every 5 seconds constantly
why would you do this?
>>
>>58423559
That's my worst case - if the user is moving around non stop. I'll discard entries that are the same as the previous one. I guess considering that most people only spend about an hour actually moving around each day it's a lot more reasonable.
>>
Guys, I'm learning Java and I have this exercise where I need to find a pattern from a vector in a matrix and then copy the number of the rows where the pattern is found to another vector.

I'm trying to copy each row of the matrix to another vector and then compare it with the pattern, but it only saves the first row where the pattern is found

for (i=0;i<N;i++){
repeated = false;
for (j=0;j<N;j++){
aux[j] = m[i][j];
}

z = 0;
found = true;
while (z <= N-vLon) {
j = 0;
while (j<vLon && found) {
if (aux[z + j] != pattern[j]) {
found = false;
}
j++;
}
if (found) {
repeated = true;
}
z++;
}
if (repeated) {
res[k] = i;
k++;
}

w = k;

}
>>
>>58423591
for example in dropbox, if you have 500 copies of an image A, they only store the image A and not the 500 copies, since the hash is the same
>>
>>58423008
thanks for quality input
>>
>>58423546
>>58423591
Assuming your very worst-case scenario with no optimization at all, you're only looking at about a gigabyte of growth per 20 users per year, and that's also assuming you keep data for an entire year in non-cold storage (or on a local device? why?), which would be just silly.
>>
File: 1483122223020.jpg (31KB, 400x333px) Image search: [Google]
1483122223020.jpg
31KB, 400x333px
Any CSharpers (C# for ctrl+f purposes) in here tell me whether they prefer LINQ to SQL or the Entity framework for use in backend applications?
>>
>>58423710
I mean I don't use C# but aren't they just different beasts? You use SQL to interface with databases wheras LINQ is just SQL-like syntax to query your data structures in the program.
>>
>>58423756
From the book I'm reading:

"""LINQ to SQL is simpler and faster than Entity Framework, and has historically pro‐
duced better SQL (although Entity Framework has benefited from numerous
updates). Entity Framework is more flexible in that you can create elaborate map‐
pings between the database and the classes that you query, and offers a model that
allows third-party support for databases other than SQL Server. """ - C# 6.0 in a Nutshell

I'd just like to know which is more preferred during development.
>>
>>58423710
Entity Framework for complex things.

Simple
SqlConnection
+ anonymous objects for quick and dirty.

>>58423756
>wheras LINQ is just SQL-like syntax to query your data structures in the program
That anon is referring specifically to "LINQ to SQL", which is a component of LINQ that allows you to interface directly with databases, like directly to a valid MDF.

Also, it's worth noting that LINQ isn't just "SQL-like" syntax; it has both query syntax and expression syntax, with the latter utilizing lambdas and being more familiar with functional language concepts.
>>
File: wizard_by_gerezon-d5d1i0h.jpg (362KB, 600x840px) Image search: [Google]
wizard_by_gerezon-d5d1i0h.jpg
362KB, 600x840px
>>58423832
Thanks for answering, wise anon.
>>
>>58423453
not really for anything non-trivial, for example twitter had some serious bugs for a long time
>>
Maze Generator in x86 assembly
>>
i just started reading SICP and im wondering if "define" is actually used to define variables and stuff on LISP or is just syntax training. I want to use a LISP compilator (online) to test some excercises (i'm at job) but dunno if that breaks the purpose of the chapter.
>>
If C standard can have "optional" features such as threading why didn't they add more optional features that would make C little better like: commonly used allocators, directory listing and other directory functions.
>>
>>58424001
>started reading SICP

nice meme
>>
>>58423911
>write in C
>have gcc spit out the asm version (O0 march=i386)
>?????
>PROFIT
>>
>>58423682
int **ptr or int *ptr[] lol, the former is preferred
>>
>>58424023
different on all the hundreds of supported systems and useless on mbed devices (in my experince)

also the thread stuff is c11 which no one has a compiler for :^)
>>
>>58424023
"Optional" only really means "shall be implemented on any compiler in the general case, but not for embedded systems". VLAs and threads may be not be very sound features on very constrained systems.
>>
>>58424079
VLAs are literally just exposing that stack allocations can be of a dynamic size.
>>
>>58424001
'define' mutates the environment (rather than creating a new scope with let/lambda/etc). It's primitive, since environments are not first-class.

There is some syntactic sugar applied in that
(define x 10) ; binds a non-function value
(define (square x) (* x x)) ; sugar for binding a lambda value
>>
Sup, /g/. Currently doing some front-end development for this app I'm helping out with. If I want to be a lazy shit, should I use Bootstrap or Dreamweaver?
>>
>>58424041
holy shit
>>
>>58424273
Bootweaver
>>
>>58422652
Can I allocate that struct without initialisation and then cast it to the class in C++?
If I have a class like
class Thing {
OtherClass other_class;
int x;
int y;
}

and a struct like
struct Thing_struct {
OtherClass_struct other_class;
int x;
int y;
}

and then do shit like
Thing_struct thing;
thing.class= // do shit
thing.x = // do shit
thing.y = // do shit


>inb4 why would you ever want to do that
deserialisation without allocating a single byte beyond the bytes needed for the payload (Thing in this case)
I could always just save the stuff on the stack and then do Thing(other_class, x, y) but that's inefficient.
>>
I'm sort of confused here:

stations = ['Amsterdam Centraal', 'Amsterdam Amstel', 'Utrecht Centraal']
f = open('stations.txt', 'w')
for station in stations[:1]:
f.write(station + '\n')
f.close()


Basically it prints

'Amsterdam Centraal' \n, 
'Amsterdam Amstel', 'Utrecht Centraal'


right?

or does it print

Amsterdam Amstel
Utrecht Centraal


only?
>>
>>58424314

Thanks. You're a peach.
>>
>>58424345
slicing with [:1] will only give you the first two elements of your list
>>
>>58424345
why are you asking what it prints instead of just running it and seeing what it prints yourself?

\n is often a special character which means "newline"
>>
>>58424368
no, it gives everything before [:1], so in this case [0].

>>58424378
I don't have the console downloaded and you can't do it in repl.it since you can't import files.
>>
>>58424368
first element only, ranges in Python array slices are exclusive
>>
>>58424182
I should clarify that you can indeed bind lambdas with the first form, it's just lacking sugar:

(define square (lambda (x) (* x x)))


That was quite misleading, my bad.
>>
>>58424414
>>58424438
holy shit, 10 years with python and i still have to run a minitest in a terminal to make sure it works like i think it works (and i'm still getting it wrong on a regular basis)
>>
>>58424448
Maybe you should use a decent language, like OCaml, Haskell or Coq.
>>
>>58424448
Much as I appreciate the traditions of C, indexes should probably be 1-based and inclusive, for example:

list = [1, 2, 3]
list[1:2] # => [1, 2]


As inelegant as it is, it's pretty damn hard to make mistakes this way.
>>
>>58424378
doesn't "w" clear the entire list? in order to update something you need to "a" (append) it.
so I guess the answer is only "Amsterdam Centraal"
>>
>>58424414
Here's a cool tip, you can use stdin (standard input) and stdout (standard output) as files too

from sys import stdout

stations = ['Amsterdam Centraal', 'Amsterdam Amstel', 'Utrecht Centraal']
#f = open('stations.txt', 'w')
f = stdout
for station in stations[:1]:
f.write(station + '\n')
f.close()[/code
just replace the line opening a new file with one assigning f to the existing stdout file. Now whatever would have been written to 'stations.txt' will be written to the console.
>>
>>58424532
yes, opening a file in "w" (write) mode will overwrite the current contents.
>>
>>58422652
how do i extract numbers from a string in c?
for example:
"m32, 9a@,84,_f ,p0l"
how would i extract 32, 9, 84, 0?
>>
how the fuck do i catch a SIGWINCH in D?
>>
>>58424625
Regular Expressions?
>>
>>58424522
>indexes should probably be 1-based and inclusive
kys
>>
>>58423144
yes, there's this new little field called machine learning, you might of heard of it
>>
>>58424522

Inclusive, yes. 1-based, no. All indexing on computer systems should be 0-based until the end of time. We got it right to start with.
>>
>>58424629
http://forum.dlang.org/thread/[email protected]
>>
>>58422652
why is shinji dressed like a girl
>>
>>58424625
strtok
>>
File: replit.png (31KB, 938x396px) Image search: [Google]
replit.png
31KB, 938x396px
>>58424414
Actually, I just looked at repl.it and you CAN use files in their beta Project Mode
https://repl.it/languages/python3
click "Add new file" to enable it
>>
>>58424705
what do i set my delimiter as?
>>
>>58424625
sscanf
>>
>>58424678
They exclude the end because it means less typing -1's on everything that way.
>>
>>58424625
char *str = "m32, 9a@,84,_f ,p0l";
char *p = str;
while (*p) {
if (isdigit(*p))
long val = strtol(p, &p, 10);
printf("%ld\n", val);
} else {
p++;
}
}
>>
>>58424711
All the chars that aren't needed. But >>58424715
is probably right.
>>
File: browser #113.webm (3MB, 960x852px) Image search: [Google]
browser #113.webm
3MB, 960x852px
4chan browser #113.

http://www.mediafire.com/file/4osqatwu3sw3sn2/browser_113.zip

pw: CRUISECONTROL
>>
>>58424754
post some boards statistics
>>
>>58424786
nah. too much of a hassle. maybe later.
>>
>>58424738
>>58424743
i need basic c with string.h
>>
>>58424738
i recommend this
>>
>>58424730

Better than subtracting 1 from the index every time you dereference.
>>
>>58424836
That is basic C
>>
>>58424863
i meant default library because im just learning c
but nevermind, i will try to make isdigit() by myself. thanks
>>
>>58424886
isdigit is in ctype.h, which is a standard library.
>>
File: anal beads.png (16KB, 249x699px) Image search: [Google]
anal beads.png
16KB, 249x699px
>>58424786
Not that anon, but I could probably scrap up statistics on a board pretty easily.

What do you want to know?

Pic is top words on /g/ right now.
>>
>>58422700
listen to real music u nazi gaylord
>>
>>58422700
Just a plus in white or something like white that goes too purple a bit so it fits in with the backgroung(I don't mean so you can't see :pp) same goes for the play one or maybe that one should be black I'm not sure. I like your colours though, I'd fuck you if you were a girl desu, then again I'd fuck any girl (heh I'm despo)
>>
>>58422844
put this before print in your loop
if(pets[i]=="fish")
>>
>>58424901
can only use stdio.h and string.h for my course; this is what i meant.
>>
File: g words.png (66KB, 226x1080px) Image search: [Google]
g words.png
66KB, 226x1080px
>>58424902
and here's browser's list.
>>
>>58424738

but what if *p points to a zero?
>>
>>58424962
Yeah, I've begun filtering out many words I consider non-significant, like the top 40 or so in your image.

Knowing "the" occurs many times is just noise.
>>
File: g fags.png (63KB, 441x818px) Image search: [Google]
g fags.png
63KB, 441x818px
>>58424962
current name/tripfags
>>
>>58424961
That's retarded, and stdio.h itself likely includes ctype.h so isdigit should be available
>>
>>58424625
#include <stdio.h>

const char *text = "m32, 9a@,84,_f ,p0l";

void print (size_t start, size_t len) {
size_t i;
printf ("%ld %ld: ", start, len);
for (i = 0; i < len; i++) {
printf ("%c", text[start + i]);
}
printf ("\r\n");
}

int main (void) {
int numbegin;
size_t index;
char c;
index = 0;
numbegin = -1;
begin:
c = text[index++];
if (c == 0) {
goto end;
} else if (c >= '0' && c <= '9') {
numbegin = index - 1;
goto pint;
} else {
goto begin;
}
pint:
c = text[index++];
if (c == 0) {
goto end;
} else if (c >= '0' && c <= '9') {
goto pint;
} else {
goto endint;
}
endint:
print (numbegin, index - numbegin - 1);
numbegin = -1;
goto begin;
end:
if (numbegin >= 0) {
print (numbegin, index - numbegin - 1);
}
return 0;
}


Too lazy to write the float version
>>
File: words.png (942KB, 960x1040px) Image search: [Google]
words.png
942KB, 960x1040px
>>58424992
true, but I think the words list in general is just noise. I do filter them for each thread though.
>>
I undestand methods, but classes are a fucking mystery to me.
I feel dumb.
>>
File: anal beads.png (21KB, 371x757px) Image search: [Google]
anal beads.png
21KB, 371x757px
>>58424993
>tfw can't into moonrunes in Windows shell
>>
>>58425165
search "windows shell unicode"
I think you need to use a unicode font. very few of them have most/all chars.
>>
File: qa1ef.png (11KB, 662x118px) Image search: [Google]
qa1ef.png
11KB, 662x118px
PHP library that makes front-end development easier
>>
File: 1466591487748.png (174KB, 600x600px) Image search: [Google]
1466591487748.png
174KB, 600x600px
Is a run time environment the same as an interpreter?

Like can I say nodejs is an interpreter for javascript?
>>
>>58425224
So just like Twig except worse?
>>
>>58425165
Here's the code. Why write something readable when you can make a single LINQ query to do everything?

var boardId = "g";

Range(1, Chan.GetBoard().Boards.FirstOrDefault(x => x.BoardName == boardId).Pages)
.SelectMany(page => Chan.GetThreadPage(boardId, page).Threads)
.Select(x => x.Posts[0].PostNumber)
.Select(x => Chan.GetThread(boardId, x))
.SelectMany(x => x.Posts)
.GroupBy(x => x.Name).OrderByDescending(x => x.Count())
.ForEach(x => WriteLine($"{x.Key?.PadRight(30)}: {x.Count()}"));
>>
>Decide to try out python
>It's really quick to pick up
>Can do some comfy and quick scripting
>Most things work the way I want them to
>Try to make something that's grid based
>Think a 2D array would be a good start.
>2D arrays don't exist
>The equivalent in tuples is fucking retarded.

What the fuck is this shit?
>>
>>58422805
I liked it. You are doing it in what language?
>>
>>58424678
One of the main reasons for being 1-based is for symmetry with referring to the last item as '-1' (and so on) in very high level languages. If this isn't the case, all of the resulting index arithmetic suffers.
>>
>>58425283
With Twig you still have to write HTML code. My goal is to create a website with only PHP
>>
>>58425388
It's Python.
>>
Is the book "The C Programming Language" outdated?
>>
>>58425406
thanks

it's electron (javascript, html, css, react.js)

i've never touched javascript before
>>
>>58425388
>2d arrays don't exist

it's just literally list of lists you mong
>>
>>58425428

How could it be?
>>
>>58425388
What's wrong with
array[x][y]
?
>>
>>58425449
>C
>>
>>58425388
I just ignore that when using python. The creation of them look ugly, but once it's done you use them the same as in any other language.
>>
File: I'm bad at everything.png (88KB, 1366x768px) Image search: [Google]
I'm bad at everything.png
88KB, 1366x768px
I'm remaking in pico-8 a game I'd made on a TI83 in highschool. it's a lot of fun, feels like sitting in math class again but with less pretending to listen
>>
>>58423182
top video, best response to
>>
>>58425598
STFU
>>
>>58425616

ALRIGHT
>>
File: image.gif (4MB, 426x232px) Image search: [Google]
image.gif
4MB, 426x232px
I really want to learn the actual fundamentals of programming before I jump back in. Anyone want to recommend a good book?
>>
>>58425694
The Bible
>>
>>58425694
>the actual fundamentals of programming
What do you mean by this?

The fundamentals of low-level programming, or more common high-level programming?
>>
DEAD THREAD OMG
>>
>>58425727
I'd like to start with high-level.
>>
>>58425802
http://www.robmiles.com/c-yellow-book/

It's a C# book, but starts out with some really good general programming knowledge before it even really starts to hit the code.
>>
>>58425814
Thanks anon. I'll give it a read.
>>
>>58425814
Are you a pajeet game developer?
>>
why doesnt /g/ show country of origin?
>>
>>58425877
because they're all indian anyway

t.Radesj
>>
>>58425224
why not just write html?
>>
>>58425224
show us what it looks like?
>>
>>58426012
what if you want to dynamic create the html from some sort of logic?
>>
File: 1481167984985.png (1MB, 1000x1400px) Image search: [Google]
1481167984985.png
1MB, 1000x1400px
>>58425877
For what conceivable reason would it need to. It would only increase shitposting tenfold.
>>
>>58425877
Because go the fuck back to plebbot, newfriend
These boards are anonymous for a reason
>>
>>58426051
<html>
<body>
<?php //dynamic ?>
</body>
</html>
>>
could AI ever become a threat to humanity if we dont connect it to the internet?
>>
>>58423428
If you only want to get in into game development and nothing else I think you should learn an engine like unity and scripting as you go.
>>
>>58426082
eww
>>
Sup fa/g/s, learning java in a programming class. Professor recommends using jgrasp or jdk on Windows. I want a /comfy/ nice looking dark setup for beginners on linux. Suggestions?

And no, I am not a /g/ regular.
>>
File: php programming.gif (2MB, 320x212px) Image search: [Google]
php programming.gif
2MB, 320x212px
>>58426126
what did you expect from php, paamayim nekudotayim?
>>
>>58426203
install openjdk-8-jdk
>>
>>58426203
you'll need the jdk regardless, since it includes the library and all the standard library jars

full enterprise tryhard mode? intellij idea with darcula theme
otherwise, things like emacs or vim
>>
>>58423119
Help some github projects. Try developing a community through a project that people want so they can ask you for things.
>>
>>58426217
Looks like an old runescape bot

>>58426225
How to install themes on intellij?
>>
>>58422652
This thing: https://github.com/shdown/luastatus
Probably will add some comments and then release. Where am I supposed to promote such a project? Reddit maybe?
>>
>>58426306
HN
Reddit
>>
>>58426306
>API made accessible through predefined global functions
Gross. 'require' is a thing.
>>
>>58426280
intellij comes with a dark theme, both for editor and gui since like version 12 (2012~)
>>
Tell some good reasons, why do you think that C++ sucks?
>>
>>58426464
dependence on header files
>>
Are file specific global variables ok in C?
>>
>>58426464
it's a FRANKENSTEINS MONSTER
>>
>>58426503
everything is fine in C
dont let the newly grad pajeets tell you how to program, big guy.
>>
>>58426464
the FQA has some pretty good reasons.
>>
What's the best /g/ approved strategy for implementing the disposal pattern in a OOP language without destructors?
>>
>>58426612
besides, say, SmallTalk what OOP languages don't have a form of destructors? (ignoring the determinism of dtor impls)
>>
>>58426708
Java
>>
>>58426708
java I think
>>
File: Screenshot_2017-01-10_23-01-18.png (357KB, 956x882px) Image search: [Google]
Screenshot_2017-01-10_23-01-18.png
357KB, 956x882px
added some simple alerts for various messages
>>
>>58426722
>>58426737
and what does finalize() do? its a non-deterministic destructors, just like ~T()/Dispose() in C#

if you need to clean up non-managed resources, try-with-resources / using (java / c#) can help, they'll call your finalize/dispose methods.

so again, what OOP languages can't do this? they aren't deterministic, but they'll eventually be called by the GC
>>
>>58426885
Don't quote me on this but I think there is no guarantee the JVM will ever call finalize().
>>
is there any easier way to generate an instance of a class from text fields and such in java? Right now I'm doing it like
MyClass thing = new MyClass();
thing.setProperty1 = txfProperty2.getText();
thing.setProperty2 = txfProperty2.getText();

and so on, but that's a lot of work when there's like 15 texf fields and shit
I've tought about iterating over all components, but I don't know how I'd map them to the setters without writing it all out, which would kinda defeat the purpose of doing it this way (I'm doing this with swing btw, without data binding because this is an older project and I don't feel like completely reworking it)
>>
>>58426885
forgot to state that t-w-r relies on the Closable (and AutoClosable) interface, just like C#'s using relies on IDisposable. So, in those interfaces your dispose of your manage resources, zero out objects/arrays, whatever, and tell the GC your intention of not using said references/data any more (finalize())

>>58426928
you are correct, but that is because of safety. if it notices that the object keeps getting moved downward in the GC generations then it'll not try because you may get an unexpected NRE, or similar. In C++ if you were to delete an object (non-smart pointer) that was still in use, and you try to use it again you'll have some fun times.
>>
is /dpt/ an outsider group on /g/?
>>
>>58426991
That first one should read txfProperty1, obviously
Also it's not just text fields, it's also check boxes and combo boxes
>>
How long does it take to become fluent in Haskell?
>>
>>58427022
3 minutes
>>
>>58427012
depends how you look at it
most /g/ threads are /v/ users looking for technical support for their manchild games, and it chases away people who want to discuss technology on a non-topical level.
>>
>>58427082
>most /g/ threads are about games
No. Not most. Maybe 20%.
>>
>>58427101
oh yeah i forgot, the other 70% is smartphones and "tell me what to buy geeee"
>>
>>58427000
>C#'s using relies on IDisposable

WHY DO I HAVE TO WRITE AN ENTIRE ESSAY TO DISPOSE OF A SINGLE FUCKING SOCKET
>>
>>58422844
l = ['bird','dog','cat','fish','chips']
a = 'fish'
If a in l:
print(a)
>>
>>58422844
print("fish")
>>
>>58427209
Should be:
if a is in l:
>>
>>58427082
/prog/ again when
>>
>>58427247
lol no

don't try misleading him
>>
when I type it like this

pets = [ 'cat' , 'dog' , 'fish' , 'bird' ]

for pet in pets:
if pet == "fish":
print (pet)


does the interpreter literate through the entire list? is this inefficient code?
>>
File: mite b cool.jpg (27KB, 500x384px) Image search: [Google]
mite b cool.jpg
27KB, 500x384px
>>58427262
I never visited prog when it was around, but if it was revived I think I'd go there a lot - just so long as it's an image board instead of a text board.
>>
>>58427288
And increased the post size to something reasonable.
>>
>>58427285
Yes, you could write different code that stops as soon as you find a match.

However, in the worst case you still have to iterate over the entire list unless you know the list is sorted.
>>
>>58427285
don't know python but if you only want it to find one instance, put a break in the if block
>>58427288
images->nonpersistence
prog threads were archived from the board's inception and any could be bumped/replied to
you can link to ix.io or a gist or whatever if you have large blocks of code or a pomf clone for demonstration of a program
>>
We need to revive /prog/, and we need to make it an image board. And we need better code tags that don't fuck up the ' character in languages where it's valid to use it on its own (i.e. Scheme, Rust), preferably something like highlight.js.

But Mootwo will never give us shit :<
>>
File: vs.png (10KB, 560x186px) Image search: [Google]
vs.png
10KB, 560x186px
>>58427158
but sockets already implement IDisposable, anon

its for when you want your type to do it. if your class is using a socket (not inherited), just delegate IDisposable.Dispose() to the sockets.Dispose()

also use an IDE that does this for you in 3 keypresses.. the language and the one it copied are designed so tooling can and will do most of the boring boilerplate for you.

if you're just using a temporal socket, then why not:
var info = new SocketInformation(); // TODO set up info
using (var sock = new Socket(info))
{
// use the socket here
} // it'll get disposed here. Java has basically the same thing, but with:
/*
try (Socket sock = new Socket("foo", 1234)) {
// use socket here
} // it'll get Closed here
*/
>>
>>58427262
>>58427288
>>58427340
http://bbs.progrider.org/prog/
>>
>>58427372

Nah, fuck that noise. Needs to be hosted on 4chan itself. We need posters.
>>
File: 1483835239568.jpg (113KB, 473x496px) Image search: [Google]
1483835239568.jpg
113KB, 473x496px
>>58427406
>>
>>58427372
>>58427372

that's so bad.

also it's boring without pictures.
>>
>>58427285
yes, it will iterate through all it.

to check if an element is in a list:
"string" in ["string", "otherstuff", "morestuff"]


that evaluates to a boolean, so use it like:
if "string" in list:
print("string")

if you need the index:

["string", "otherstuff", "morestuff"].index("string")


.index is a method of List that returns the first occuring index of an element in a list (it errors if the element does not exist in the list)
>>
File: anim.webm (714KB, 1120x730px) Image search: [Google]
anim.webm
714KB, 1120x730px
figured out a way to update the play queue

my autism tells me the buttons are suboptimal but i don't know how to fix this and designing guis is hard
>>
>>58425240
i wanna fug this anime
>>
>>58427555
how about hiding the buttons until the list element is selected (mouseover, whatever)? that way it won't be as cluttered

also, try changing the button styling to fit better with those two purples.
>>
>>58427555
Rather then having play and add to queue buttons, have an option to click on the whole video in the list and have it either play or add to list
>>
>>58427585
>how about hiding the buttons until the list element is selected (mouseover, whatever)?

this is a brilliant suggestion HOWEVER it would be tricky to implement without it being a pain in the ass - if you want to add 10 items to the queue, if you have to wait even 0.1s for the buttons to appear each time, or if you have to move the mouse around to find the buttons i can see it being pretty annoying

>>58427606
how to offer both options though? maybe clicking the thumbnail could trigger playing it, but what about adding to queue/potential future options?

for what it's worth, deezer has tiny checkboxes next to every song on a list which looks ugly as shit
>>
>>58427633
> clicking the thumbnail could trigger playing it
This is clever, didn't think about that, I was just thinking to offer one of them by default and have a settings entry to change the behavior.
>>
File: bubble sort.jpg (219KB, 1024x768px) Image search: [Google]
bubble sort.jpg
219KB, 1024x768px
Have you checked your algorithms for privilege lately?
>>
>>58427663
Is there any text transcript?
>>
File: fesa.jpg (58KB, 582x582px) Image search: [Google]
fesa.jpg
58KB, 582x582px
What maths do I need learn to be a good programmer senpai?
>>
>>58427709
linear algebra, lambda calculus, computation theory, differential calculus
>>
File: 1484077194201.gif (3MB, 533x300px) Image search: [Google]
1484077194201.gif
3MB, 533x300px
>>58427709
all of it
>>
File: 4th-dimensional-card-shuffle.webm (2MB, 160x120px) Image search: [Google]
4th-dimensional-card-shuffle.webm
2MB, 160x120px
More GLUT
>>
>>58427709
Just geometry really.
>>
>>58427709
Depends on the field, but fizzbuzz must not be OMG MATH.
>>
>>58422700
Make the buttons look like an outline. Then make the buttons blur what's behind them.
>>
File: Screenshot_2017-01-11_00-17-09.png (109KB, 448x851px) Image search: [Google]
Screenshot_2017-01-11_00-17-09.png
109KB, 448x851px
>>58427791
i have a sidebar that will contain settings I guess that does the blur already, might reuse the css for the buttons
>>
>>58427709
lamda calculus, category theory, type theory
>>
>>58424625
still waiting for the haskell solution
>>
>>58427022
2 week
>>
>>58427688
probably something about training data or not accounting for something in test cases
really not worth it
>>
>>58422652
I'm currently trying to learn some program langauges and I chose html to start off.

Should I continue learning html or should I chose another language to learn?
>>
>>58427814
what if youtube updates its site ook, and so the parsin will fuck up?
>>
>>58427928
this is bait
>>
>>58427928
HTML is markup language (duh) and you will not learn programming with it.
Learn C.
>>
>>58427928
Yes, learn it and then continue with Haskell. HTML will teach you beginner to intermediate math
>>
>>58427934
I'm not scraping the website, youtube has an obscure interface called get_video_info, which can give you links to stuff like thumbnails and audio tracks, and other information like the title, ratings, length, and so on. I haven't seen it documented and it's a big mess but once you make some sense of it it's got everything you need.
>>
>>58427884
import Data.Char (isDigit)

s = "m32, 9a@,84,_f ,p0l"

nums = reverse . map reverse . filter (not.null) . nums' [] []

nums' ws ds [] = ds : ws
nums' ws ds (x:xs) | isDigit x = nums' ws (x:ds) xs
| otherwise = nums' (ds:ws) [] xs
>>
>>58428048
numbers :: String -> [Int]
numbers [] = []
numbers (l:ls) = if ord l >= 48 && ord l <= 57
then (ord l - 48): (numbers ls)
else (numbers ls)
>>
>>58428048
>>58424738 is shorter
>>
>>58428140
It also doesn't work.
It prints the numbers rather than extracting them
>>
>>58428178
>It also doesn't work.

it does tho.
>It prints the numbers rather than extracting them
so? if you want to store them, go ahead.
its just proof of concept
>>
>>58428208
>it's just a proof of concept
nums = getNums
>>
>>58428208
s = "m32, 9a@,84,_f ,p0l"

nums [] = pure ()
nums (x:xs) =
case reads (x:xs) of
[] -> nums xs
[(i, s)] -> print (i :: Int) *> nums s
>>
>>58428259
>>58428208
Version that returns them

nums [] = []
nums (x:xs) =
case reads (x:xs) of
[] -> nums xs
[(i, s)] -> (i :: Int) : nums s
>>
>>58424625
>>58428261
Fucked up the tags.

extract s = catMaybes $ map readMaybe $ groupBy (on (==) isDigit) s :: [Int]
>>
>>58428261
>>58428280
import Text.Read (readMaybe)
import Data.Maybe (catMaybes)
import Data.List (groupBy)
import Data.Char (isDigit)
import Data.Function (on)
>>
>>58424738
>>58424738
>>58424738

what if *p points to a zero in the string?

i dont think this works
>>
>>58428275
Bonus round

nums :: Read a => String -> [a]
nums [] = []
nums (x:xs) =
case reads (x:xs) of
[] -> nums xs
[(i, s)] -> i : nums s



s = "(3,4) 3 7 (7,2) 7 6.3 3 (932, 345)"

eg1 = nums s :: [Int]
eg2 = nums s :: [Double]
eg3 = nums s :: [(Int, Int)]
>>
>>58428324
eg1 is [3,4,3,7,7,2,7,3,932,345]
eg2 is [3,4,3,7,7,2,7,6.3,3,932,345] (6.3 added)
eg3 is [(3,4), (7,2), (932, 345)]
>>
File: Untitled30.jpg (752KB, 1000x1000px) Image search: [Google]
Untitled30.jpg
752KB, 1000x1000px
>>58427814
This is the shit version I made in Photoshop.
>>
File: Untitled31.jpg (611KB, 1000x1000px) Image search: [Google]
Untitled31.jpg
611KB, 1000x1000px
>>58427814
>>58428424
Here's the less shitty version. Not enough blur in my opinion.
>>
How does piping work in linux?
Is it front to back or back to front?
>>
>>58428450
What?
>>
>>58428450
>back
>front
It goes left to right.
>>
File: Screenshot_2017-01-11_01-00-24.png (197KB, 690x650px) Image search: [Google]
Screenshot_2017-01-11_01-00-24.png
197KB, 690x650px
>>58428424
>>58428446
I've made something like this. I'm working on aligning them with the thumbnail. Maybe I'll also make them only appear when you hover your mouse over them, and remove the darkened colour.
>>
>>58426840
Looks good so far anon. The only thing i personally dont like is the background colour but thats insignificant
>>
>>58423407

> Bring the web mess to desktop

kys
>>
>>58428621
There is no mess with electron, because you only target one "browser". It's really a great framework and allows you to play with tons of existing technologies.
>>
File: anim.webm (273KB, 538x686px) Image search: [Google]
anim.webm
273KB, 538x686px
>>58428484
a couple of css lines later...
>>
File: 1474949204825.gif (337KB, 640x360px) Image search: [Google]
1474949204825.gif
337KB, 640x360px
>>58428788
>anim.webm
>no anime
>>
>>58428796
>>>/a/
>>
>>58426840
Nigga re-center that plus sign, and make them white line no fill, or like 50% opacity fill
>>
>>58428472
Like what is the order? Does it work from right to left returning the values from each command, or?
>>
>>58428660

It's still a mess anyway. HTML/CSS/JS and dozens of frameworks only adds complexity to bring the "eye-candy" effect.
>>
>>58428853
Left to right
prog1 | prog2

stdout of prog1 is piped into stdin of prog2
>>
>>58428322

p++ does the trick.
>>
>>58428853
You appear to have completely missed >>58428480
>>
>>58428788
Nice
>>
>>58424287
please explain
>>
everything must be specified or we will fail. under-specifications resulting in poor communication and bad projects is the essence of imperfection. the specificity will be ever increasing ever growing ever becoming more precise so precise as the sharpening of the tools and images of pixels on the screen. we will root out ambiguity and make everything perfect down to the last specification of perfection
>>
>>58429399
[]
>>
c++ question (new try, tired as fuck)

got a function like this

void log(QString text);


when I call it like this:

log("Hello"+22);


when debugging the QString argument text of the function mentioned above contanins
"/include/qt/QtCore/qarraydata.h"


instead of

"hello22"


what the fuck?
>>
>>58422821
Like this `void foo(int const x[static restrict const 20]);`.
>>
>>58429433
you overwrote the null byte with 22
see if qstring has an append function
>>
>>58429433
try: `log(((Qstring)"Hello")+22)`
>>
>>58429487
thanks for the answer

changed my shit to c++11

function:
void log(std::__cxx11::basic_string<char> text){
window->writeLog(QString::fromStdString(text));
}


call:
log("ahdsh"+to_string(22));


C++ does not like string concatenation with int, to_string() can be done besides some other ways
interested anons can lookie here: http://stackoverflow.com/questions/191757/c-concatenate-string-and-int
>>
>>58429159
its a joke retart
>>
I have a small lambda calculus reply I built a while back I had forgotten about. I was working on it today and realized it had nothing akin to a stacktrace. How should I go about that? I was thinking just keeping a temporary log of the redexes and conversions in reverse order and spitting it out if it errors.
>>
>>58429716
you could have a step by step evaluator, e.g.

>eval e
>step 1 e
>step 5 e
>>
>>58429780
Yeah. This made me realize all I have is a small portion of what I would like to have.

Anyone want to pick up a project with me? I have a good portion of the layout done. The goal was to implement a lazy-evaluated Lambda Calculus REPL in a naturally non-lazy language (i.e. Python)
>>
>>58429890
You could've done it with Haskell and the Strict extension
>>
>>58429927
Exactly. I chose python to make people say "Why isn't this god-awful piece of shitstained vomit in haskell?". I want it to be semi-joking in taste, but, i Might change that idea.
>>
File: ascii table.png (230KB, 1280x851px) Image search: [Google]
ascii table.png
230KB, 1280x851px
>>58428322
There's a difference between the integer value 0 and the character '0'. The value of the character '0' in ascii (and UTF-8) is 48 in decimal.

A '0' and a NULL character are two very different things in C.
>>
>>58423407
Performance is a real issue there.
Just fucking use C# and WPF, it's easy and also not super slow, tho slower than unmanaged languages.
>>
>>58424754
Dear lord. What's next, will you beam the contents of every thread into the user's brain?
So efficient that it kinda takes the fun out of it desu.
>>
>>58430033
>There's a difference between the integer value 0 and the character '0'

Where does it say that in the C standard?
>>
>>58426442
I've installed Intellij and so forth, although on Linux Mint it continues to not recognize my Java SDK. I have it working on Eclipse and Netbeans but I really do prefer the look Intellij has.
>>
>>58430083
one is integer and the other is a character
>>
>>58430112
'0' could be equal to 0
>>
how do you know if programming REALLY isn't for you, i mean i enjoy doing it but there are some times when i get stuck at trying to solve/achieve something i just think i wont make it as a programmer because i think if i had a job as a programmer and i need to do something specific and i get stuck and can't figure it out, what if i couldn't do what i needed to do. when im programming on my own i can figure things out slowely overtime but on a job one normally has deadlines so.. idk this makes me depressed
>>
>>58430144
>48 == 0
>>
>>58430144
Actually, no it can't.
It guarantees that the null character has the integer value of 0.
>>
File: 1483761735339s.jpg (3KB, 107x125px) Image search: [Google]
1483761735339s.jpg
3KB, 107x125px
>>58427709
If you haven't already mastered analysis, galois theory, and topology then you will never get a job at a super hip startup writing the javascrit backend for a MEAN stack webshit faplication and may as well just kill yourself right now.
>>
>>58430144
not sure about in C, but in c++ the value of the character '0' is constant if you put it in single quotation marks
>>
>>58430236
subtracting character literals is a very common C idiom
>>
>>58430195
this is what i meant by >>58430083
>>
new thread: >>58430378
new thread: >>58430378
new thread: >>58430378
Thread posts: 327
Thread images: 40


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