[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: 329
Thread images: 34

File: 1481654229907.jpg (264KB, 1440x1080px) Image search: [Google]
1481654229907.jpg
264KB, 1440x1080px
What are you working on, /g/?

Old thread: >>58057800
>>
Why do people continue to use utter garbage like XML and JSON?
>>
(guess I may as well repost here)

I've been embedding and reading XMP metadata in PNG, JPEG, GIF, and SVG. Interestingly (at least to me), it was easier to do this with GIF than JPEG. For those who don't know, JPEG is a giant fucky mess and can burn in a fucking fire.

PNG has the best spec I've seen out of all of them. I wonder how FLIF is going to turn out in the end, since they're thinking of emulating PNG in a lot of things.
>>
>>58063973
Inertia?
>>
Working on akari-bbs!
I added an archive viewer, but I'm wondering if I should just turn it into an index instead.
That way it won't choke like 4chan's archive viewer that takes 5 seconds to list 15,000 threads.
>>
>>58063973
enlighten me, what's a better alternative?
>>
>>58063973
JSON is pretty good desu senpai.
>>
>>58063917
A learning exercise. Now that I have to write it all myself it's like all of that reading I did didn't stick and it sucks
>>
>>58063973
JSON is good
>>
>>58063973
What kind of retarded codemokney post is this

Do you guys discuss anything here other trivial banalities
>>
File: 1477151825894.jpg (76KB, 768x1024px) Image search: [Google]
1477151825894.jpg
76KB, 768x1024px
>What kind of retarded codemokney post is this
>Do you guys discuss anything here other trivial banalities
>>
>>58064055
Yes, when will humans kill themselves?
>>
>>58064015
Well JSON is the mainstream alternative to XML but itself is not very good either. If it needs to be human-readable, TOML is good, and if not, then you should just use an application-specific binary format.

>>58064019
>>58064026
Maybe I shouldn't have called it utter garbage but it's still not that good. For instance, it doesn't allow comments and it has weird OOP shit built into it. It's more bloated than TOML is for human-readable stuff.
>>
>>58064140
>it has weird OOP shit built into it.

It's an object notation.
>>
>>58064004
why are you using
fprintf(stdout, ...
instead of printf?
>>
File: .jpg (145KB, 600x631px) Image search: [Google]
.jpg
145KB, 600x631px
I have a revolutionary idea of unifying all programming languages, /b/!
We could have a couple of shared files, so (probably already compiled) program modules would process them in an unified way! Then everyone could choose her favorite HLPL and write big programs!
>>
>>58064015
https://en.wikipedia.org/wiki/S-expression
>>
>>58064230
In case I add gzip support in the future.
>>
>>58064243
Sounds gay
>>
What does /g/ think about XMLson?
>>
>>58064273
explain
>>
>>58064004
why do some people call her akari and others akarin?
>>
>>58063973
Name one thing that is wrong with xml other than it doesn't look pretty enough to match your portless mac.
>>
File: 1480460871680.jpg (47KB, 622x622px) Image search: [Google]
1480460871680.jpg
47KB, 622x622px
How do I move into Software Development if I'm currently in Business Intelligence? I'm tired of shit pay.

Don't have a CS degree, but I have great Python and SQL, and some Java and Lua
>>
>>58064303
Because her real name is Akariny
>>
>>58064361
Is that you posted SQL queries some threads ago?
>>
>>58064283
I didn't actually think it through, so I assume it would be as simple as outputting all printf statements to a memory buffer acting as a file and gzipping in memory before sending it out.
I'm not sure if it's worth it tho.
>>
>>58064346
Duplication. Not just the fact that you need both opening and closing tags, but also that there's both content and attributes.
>>
>>58064346
<replyto>
<postnumber>58064346</postnumber><message>too much duplication</message>
</replyto>
>>
File: nigella-lawson-hot-4816.jpg (35KB, 480x715px) Image search: [Google]
nigella-lawson-hot-4816.jpg
35KB, 480x715px
>>58064378
Nope

SQL is boring as fuck family
>>
>>58064403
SQL is pretty necessary if you want to build anything fun with the web.
Just think of it as a domain specific language that's only good at one thing, like javascript.
>>
File: 56884511_p0.png (981KB, 918x1302px) Image search: [Google]
56884511_p0.png
981KB, 918x1302px
>>58064425
>javascript
>good for the web
I almost fell for that bait.
>>
Game in C using SDL2
>>
>>58064446
>maki poster
>posting anything worthwile
Just like clockwork.
>>
>>58064446
>j-javascript isn't good for the web!!
>i swear!

kys retard
>>
File: salasi.jpg (33KB, 450x348px) Image search: [Google]
salasi.jpg
33KB, 450x348px
>>58064425
No I know, I use it errday at work, but it's so very, very boring.

Also, god help you if your company uses Salesforce or any Atlassian products. Turns out writing a "simplified" programming language specific to your products should be a criminal offence
>>
File: inthetrashnow.jpg (27KB, 948x711px) Image search: [Google]
inthetrashnow.jpg
27KB, 948x711px
Adding garbage collection support to my scripting language
>>
ay someone post that programming challenges thing i gotta roll
>>
>>58064140
TOML looks neat. Reminds me of Dorf Fortress's markup.

>>58064425
You should really work with an ORM if at all possible. Once you've taken DB101 and understand how basic queries work, It'll abstract away the boilerplate and (hopefully) protect you against entry-tier injection attacks.
>>
>>58064488
how does one even do that?
>>
>>58064455
>SDL
>not Allegro
>>
File: browser #113.png (2MB, 1920x1080px) Image search: [Google]
browser #113.png
2MB, 1920x1080px
just tinkering with some statusbar auto-hide code. feels good.
>>
File: 60017660_p0.jpg (97KB, 429x600px) Image search: [Google]
60017660_p0.jpg
97KB, 429x600px
>>58064470
>>58064471
hello thread
>>
>>58064512
>ORM
Is that like writing wrapper functions to copy the results of an SQL query to a container struct for you to read from directly?

Because I already do that.
It's not generic tho, I figured it would be too computationally wasteful to keep asking what the columns are when I already know what they are.
>>
>>58064512

what would you recommend as resources for self-teaching database theory? most of the reference material for databases seem like hot garbage
>>
>>58064488
what kind of GC, anon?
>>
http://erdani.com/d/bigo.html
>>
>>58064520
Sell me on Allegro
>>
>>58064550
Relational calculus
>>
Who the fuck keeps deleted the web dev threads?

You really want us in here that badly?
>>
File: 1479360902157.jpg (665KB, 1536x2048px) Image search: [Google]
1479360902157.jpg
665KB, 1536x2048px
Alright, let's have a discussion on using recaptcha with Javascript that's connected to a PHP page as an API that is going to do the validation.

How can I grab and direct the POST variable that the captcha sets?
>>
>>58063917
>Eva
Shit taste desu
>>
File: LfqyX3p.gif (43KB, 500x666px) Image search: [Google]
LfqyX3p.gif
43KB, 500x666px
>>58064488
Garbage collection? There's lots of ways to do it, assuming you've got things arranged correctly.

>>58064557
For now i'm just doing plain old boring mark-and-sweep. Normally I just delete objects by reference count, but since I added in arrays I need to do a basic cleanup of circular references.

Probably not going to be used much in normal code, I just hate having glaring holes.
>>
>>58064549
It also lets you craft queries in a form like ```People.name.contains("anon").sort("date_added",ascending)```
> computationally wasteful
You're calling out to a storage device. A couple pointer dereferences and a string concatenation isn't a large overhead to pay for correctness.

Generic solutions like sqlalchemy and WTF Rails does lets you decorate a struct and you just get the right queries.


>>58064550
Yeah, they mostly assume you know how relational DBs work and just teach you the syntax.
Maybe an open course? https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-830-database-systems-fall-2010/readings/
>>
>>58064643
>using recaptcha
kys onegaishimasu
>>
Miniature http server on winsock and c
Trying to manage how to write processing request data in stream
>>
>>58064678
Are you writing this scripting language for fun?
>>
File: KMB-SB.png (216KB, 360x608px) Image search: [Google]
KMB-SB.png
216KB, 360x608px
>>58064778
At this stage, yes.
>>
is it normal for a project euler problem to take 80 lines of code ot solve?
>>
>>58063917
That battleship project on the python codeacademy. I used to have basic knowledge but I've forgotten since then so I'm starting over.
I'm going to start the entire python course over so I can take notes.
>>
Alright, maybe /g/ can help me

i had trouble figuring out the point of pointers and how to use them

are there any good places to look online?
>>
>>58064527
Fill in that semi-transparency and it might look less like shit.
>>
>>58064903
>>>/g/dpt/
>>
>>58064925
ahem
>>
>>58064925
what the fuck
>>
File: Untitled.png (2MB, 1920x1080px) Image search: [Google]
Untitled.png
2MB, 1920x1080px
>>58064910
nah, that just makes it shittier.
>>
File: 0*a2Zih9c4O0IyhAoA.jpg (110KB, 1200x504px) Image search: [Google]
0*a2Zih9c4O0IyhAoA.jpg
110KB, 1200x504px
Who here works in the Bay Area?
>>
>>58064903
Pointers let you share arbitrary memory locations with other functions instead of making copies at every level of indirection you operate on.
This also makes them mutable.
They're most commonly used for operating on dynamically allocated memory blocks returned as a pointer by a *alloc family function.
>>
>>58064903
I'll give you a quick summary anon. Let's say you were programming a game, and occasionally the user clicked something, and you needed to store the location of that click for a while. You might think an array, but eventually it could cap, because you have to make an array statically. Instead, you can use malloc, which allocates memory dynamically and returns a pointer to the memory. The pointer is there so that you can reference the pointers as much as you like, and copy the pointer around, and if you want to give the entire array to another function to operate on but do not want to copy the entire 10000 bytes your shitty game has allocated into the function, you just pass a pointer to it.

Now you can call free(ptr) and deallocate the memory for further usage as the OS sees fit.
>>
File: Untitled.png (2MB, 1920x1080px) Image search: [Google]
Untitled.png
2MB, 1920x1080px
>>58064968
complete transparency is nice though
>>
size_t* pointer;
*pointer = &pointer;
>>
>>58064989
>The pointer is there so that you can reference the pointers
the array*

also, you should know that when allocating an array normally like so

int arr[5] = ..


arr is a pointer to the first element, and incrementing it by 1, then dereferencing it will give you the second element. *(arr+1) == arr[1] == *(1+arr)
>>
File: 1478454122527.jpg (123KB, 1280x720px) Image search: [Google]
1478454122527.jpg
123KB, 1280x720px
Do you need a really strong grasp of algorithms to do scientific computing?
>>
>>58065003
Not how it works
>>
>>58065003
noob
void *t;
t = (void *) &t;
**********************t;
>>
>>58065039
>how many layers of indirection are you on
>i dunno, like 6 or 7
>watch this
>>
>>58064707
Yeah quality fucking post. Exactly what's expected of /dpt/. A bunch of kid's with learn c++ in 24 hours books.

Now tell me why recaptcha is bad, retarded faggot. Because you don't like solving them? Should I just let the spam bots run my site?

Jesus christ, the only reason I would ever want to deanonymize the internet is so I could make a 4chan with an age gate so I could avoid zero quality posts like this.

Doho.
>>
>>58065039
(you) (you) (you) (you) (you) (you) (you) (you) (you) (you) (you) (you) (you) (you) (you) (you) (you) (you) (you) (you) (you) (you) (you) (you) (you) (you) (you) (you)
>>
I've gotten up to 3 levels of indirection, I can't imagine doing any more.
>>
Hahaha woooooo! Hahahahha

Welcome /wdg/! Forever!

Why is Javascript so amazing, guys?

If you don't know javascript then you aren't even a programmer.
>>
>>58065059
Okay, I'll explain why you're retarded and you should kill yourself.

All captcha are trivial to break and basically useless this days. Recapatacha is literally a botnet and you're a fucking annoying cunt.
>>
>>58065125
if captcha is so easy to break then i challenge you to post the "bean bag bucanners" pasta in every /g/ thread, preferable as the first post.
>>
>>58065125
>trivial

Cute.
So the other option is letting literally everyone do whatever the fuck they want with my website?

And yeah, absolutely certain recaptcha is slaving your PC and it has nothing to do with their image recognizing AI project.

/dpt/ breeding quality children here.
>>
>>58065039
*******************************************************************************
*******************************************************************************
**********************/* This is a function pointer. */************************
*******************************************************************************
******************************************************************************t
>>
>>58065161
eat shit, javatard code monkey
>>
The Fendippitous Eggmen are returning soon.
>>
>>58065013
Not as much. It's nice to have a passing familiarity with O(N) vs O(N^2) so you can find out why your program is taking so long.

Maybe a smattering of higher-order functions (map,fold, filter) to be able to apply and chain together basic functions.
>>
>>58064968
I take that back, it does look shittier.

>>58064991
It still looks like shit.
>>
>>58065161
Actually you don't even need to answer correctly to the neural mining botnet thus it's easier than that.

Stop annoying legitimate users with captcha and ban bots according to their IP address or user-agent.
>>
>>58065189
>java
Javascript, kiddo. No pajeet here.
>>
File: 1450471918068.png (51KB, 457x496px) Image search: [Google]
1450471918068.png
51KB, 457x496px
>>58065189
triggered the code artisan
>>
>>58064991
What is this?
>>
File: 223_S1Ep4.png (2MB, 1920x1080px) Image search: [Google]
223_S1Ep4.png
2MB, 1920x1080px
>>58065292
>javascript
>no pajeet

>tfw /dpt/ really wants me to leave
>>
>>58065298
desktop 4chan viewer. it's been my pet project for over 6 years.
>>
File: aoc2016.png (47KB, 733x1064px) Image search: [Google]
aoc2016.png
47KB, 733x1064px
I started to learn Python few weeks ago to get some rest from Java which I'm using every day at work. I had some contact with Python before in OOP class (though it was taught mostly in C++), so I've decided to give it another shot. I have to say, I fell in love with it.

Currently working on challenges from Advent of Code (adventofcode.com) to get used to the language, and it's a lot of fun!
>>
>>58065280
Sure. So one of my websites has no captcha, has a 5 minute post timer, and a moderation panel I made.

In 1 attack I had over 2000 posts in about an hour of SQL injection attempts. There is also 1 autist that spams his website through a Holla VPN bot every month. I also have another bot posting medical literature through VPN.

Now what experience do you have where you can make a suggestion as bad as "don't use captcha"?
>>
>>58065352
stop with this shilling
>>
>>58065362
python hater, java hater or aoc hater?
>>
just fucking kill me plz.

a = 21 
for i in range(19, 2, -1):
templist = []
if i == 19:
for x in range(i, 399, 19):
templist.append(ml[x])
elif i == 18:
for x in range(i, 399 - a, 19):
templist.append(ml[x])
else:
for x in range(i, 399 -a, 19):
templist.append(ml[x])
a += 22
count(templist)


sovled euler number 11 but it took me 80 damn grueling lines of python code.
>>
>>58065292
You're a valley pajeet. A poo hipster.

A poopster, if you will.
>>
>>58065327
Maki is a big slut. She never wears panties and loves wearing short skirts to leave her pussy goo on public transportation seats.
>>
>>58065352
hissss
>>
Just wrote a simple userscript to remove is.4chan links
>>
>>58065397
a = 21 
for i in range(19, 2, -1):
templist = []
if i == 19:
templist = [ml[x] for x in range(i, 399, 19)]
elif i == 18:
templist = [ml[x] for x in range(i, 399 - a, 19)]
else:
templist = [ml[x] for x in range(i, 399 -a, 19)]
a += 22
count(templist)
>>
>>58065445
what is that? that makes it less readable no?
>>
>>58065397
my solution to euler 11 in c
#include <stdio.h>

unsigned int table[20][20];

int main() {
unsigned int i, j, k, a, b, c, d;
unsigned int n = 0;

for (i = 0; i < 17; i += 1) {
for (j = 0; j < 17; j += 1) {
a = 1;
b = 1;
c = 1;
d = 1;

for (k = 0; k < 4; k += 1) {
a *= table[i][j + k]; //east
b *= table[i + k][j]; //south
c *= table[i + k][j + k]; //south-east

if (i > 2 && j > 2) {
d *= table[i + k][j - k]; //south-west
}
}

if (a > n) {
n = a;
}

if (b > n) {
n = b;
}

if (c > n) {
n = c;
}

if (d > n) {
n = d;
}
}
}

printf("%d\n", n);
return 0;
}

unsigned int table[20][20] = {...as given...};

>>
>>58065460
>what is that
list comprehensions

> that makes it less readable
no if you know what it does
>>
What do
#define SOMETHING

lines mean?
Why those empty macros are used?
>>
>>58065488
Usually for #ifdefs.
>>
>>58065488
because C is shit
>>
>>58065488

#ifndef SOMEHEADER_H
#define SOMEHEADER_H
...
#endif
>>
>>58065488
It is simply a macro that expands to, well, nothing.
However, now that the macro has been defined you can check with #if defined (or #ifdef) whether it has been defined.

#define FOO

int main(){
FOO FOO FOO
printf("Hello world");
}


will expand to

int main(){

printf("Hello world");
}


There are certain situations where this comes in very handy,
for example additional debug information, which you don't want to show in your release version:
#ifndef NDEBUG
#define DEBUG_MSG(x) print(x)
#else
#define DEBUG_MSG(x)
#endif

int main(){
DEBUG_MSG("Entering main");
/* ... */
}

If the macro NDEBUG (no debug) has been defined,
DEBUG_MSG will expand to nothing, otherwise you will get Entering main.
Note that the stray semicolon ; isn't a problem. It's a valid empty statement.
>>
>>58065473
what is even happening here? i feel so retarded i dont' even want ot post my entire solution. Funnily enough once you solve a problem in euler it allows you into a secret thread with other solvers and i never look because their code is so much cleaner and condensed.
>>
Are programming MOOCs a meme or are there actually good ones?
>>
>>58065488
>>58065494
I say "usually" because it's occasionally useful for porting. You might have a define for a calling convention that is empty on certain platforms because the default works.
>>
>>58065540
post it and i will optimize it / write a better version
>>
File: 1470075541860.jpg (21KB, 372x260px) Image search: [Google]
1470075541860.jpg
21KB, 372x260px
I just got accepted into college for a BS in computer science. I've only taken two classes in C and C++. Am I fucked ?
>>
>>58065540
What's the point of doing the fucking problems, then? Surely you want to improve?
>>
>>58065540
it's easier to write code than to read it. but writing easily readable code is real fuckin' hard.

that code is shit, using single letters for variables? what year is it, 1954?
>>
>>58065574
The ultimate code triangle (pick 2):
Short - Readable - Simple
>>
>>58065564
https://gist.github.com/ottor/7e90ef703fb0ec94c7a9712330ad2e10
>>
>>58065590
why would you need it to be short? it mattered when computers had 2 MB hard drives, now no one cares about code being light, it's way more important for it to be readable
>>
>>58065352

How does it work? You started it on time or just now?
>>
Python help
so I've got the following to bruteforce md5 using wordlists, but I want to modify it to use the wordlist as salt aswell but I've got no idea how to do it
https://ghostbin.com/paste/ky4tc

also any pointers on the code would be appreciated as long as it's not just
>using python
>>
>>58065624
And here we have the root source of those games of today which are 45GB in size
>>
>>58065624
By short I mean duplicate codes shall be factored.
>>
>>58065624
Probably means "short" as in "no duplication".
>>
>>58065629
I started friday when I was bored at work, don't really care about getting points for posting solutions quickly for the latest problem, just want to have something to sharpen Python skills on.
>>
Openstack
>>
Should the death penalty be available for spammers?
>>
>>58065640
long, descriptive variable names don't matter after compilation, they become adresses in memory...
>>
>>58065692
Loads of big adresses require more space & ram to be read & written, you fuck
>>
>>58065704
HOLY SHIT BATMAN IT DOESN'T MATTER
>>
>>58065710
FUCK OFF IM NOT RUNNING YOUR 2GB HELLOWORLD
>>
>>58065640
and here I am, thinking it's because of hd textures, 30 layers of bumpmaps and whatnot on every one of them, better detailed models and maps...
>>
>>58065704
This guy knows what's up.

16-bit code is better than 64-bit because it's 4 times smaller and faster.
>>
>>58065640
TIL long variable names are the reason games have grown so large...
why don't they just use shorter names? wtf...
>>
>>58065735
Hello I see you typed the wrong website address.
Here is a pointer:
http://reddit.com/
>>
>>58065704
do me a favor, write two programs, one using names like "z" for variables, and another one, with just variables changed for "nice_reasonable_long_descriptive_variable_name", and sprinkle some comments on top while you're at it. then compile that shit, run it and tell me you see a difference in memory usage or executable filesize
>>
>>58065744
a pointer
char* fuckoff = "reddit.com";
>>
>>58065744
here is a real pointer:
int *c;

xD
>>
>>58065735
i blame the overrepresentation of minority main characters who have really long names
>>
>>58065591
https://gist.github.com/anonymous/b54a6f9c56ccaa3b649c56ddbf31e490

i could even write a function to avoid repeating those 3 nested loops, but i'm tired
>>
>>58065763
int independence; //declaration of independence
>>
>>58063917
newb here guys
how do I fix
>package org.junit does not exist
how do I >>>>just set classpath xD
>http://stackoverflow.com/questions/16624022/cannot-find-package-org-junit-when-compiling-java-file-in-command-prompt
>http://docs.oracle.com/javase/7/docs/technotes/tools/windows/classpath.html
I read it but still don't get what the fuck I have to enter
I'm really dumb, please help me out you guys
>>
>>58065833
>you guys

Excuse me?

i'm a girl, hon.
>>
>>58065848
please help me out, you <enter politically correct desired gender or non-gender here>?
>>
>>58065848

Everybody knows that plural guy is gender neutral.
>>
Is there an online tutorial or a book that is laid out in a similar way as textbooks where they introduce you to new material, then give you some problems to solve and the output you should receive?

I'm currently in a PhD program that will likely not lead to many if any job opportunities but it is math related so I was hoping to brush up on programming especially dealing with data. Hopefully that would allow me to get some finance/banking related job.
>>
>>58065848
What's your favorite language?

just personal stats
>>
>>58065911
C and Python.
>>
>>58065897
even more so the word dude
you can call everything dude
e v e r y t h i n g
>>
>>58065923
Wearing girl cloth doesn't make you a girl anon
>>
>>58065932

for real, my dude.
>>
>>58065939
>OSGTP
Mustang master race.
>>
>>58065923
my personal favorites, too. good choices, anon
>>
Why the 4chan Tomorrow theme dark?

does it have any meaning?

because tomorrow will be a bad day?
>>
>>58065923
C + Haskell is the final form
>>
>>58065954

I'm not sure I follow, boss.
>>
>>58065986
yes and Futaba has the color scheme of a nice Futa dick
that's exactly the reason behind that
>>
>>58066018
What does OSGTP mean retard?
>>
>>58066000
Surely if you like Haskell you also realize there are far more advanced functional languages out there?
>>
>>58065553
What a retarded fucking question. Of course there are good ones. You just have to, y'know, dedicate time to them instead of being a fat lazy faggot who does nothing but shitpost on 4chan
>>
>>58066071
I'm giving (You) attentions. Isn't what you wanted anyway?
>>
>>58066031

Old School Graph Theory Project
>>
give me one good reason why i should read a C programming book from beginning to end right now
>>
>>58066282
Because you don't See Sharp
>>
>>58064484
Whats wrong with Atlassian? Miss Linux-support for Sourcetree :/ love to see, how my git-tree grows
>>
>>58066294

that'll do, thanks broski
>>
>>58065397
>>58065473
Hehe
>>
>>58066395
looks pretty slick
>>
Which of these source trees look better?
https://github.com/agrecascino/WAMPVOIPClientCPP/tree/rework
https://github.com/agrecascino/WAMPVOIPClientCPP/tree/master
>>
>>58066434
rework is nice and /modularrr/
also don't upload your *.o's dummy
>>
>>58066327
Oh actually yeah, Sourcetree is breddy good, I hate having to use Gitkraken on linux instead

But Jira, Confluence and Hipchat are hilarious pieces of shit
>>
I am new to programming and doing Think Python (ja-ja, I fell for the meme), question is:
I read and do exercises from chapter 8. Is it just me, or the whole stuff regarding operations with strings is retarded in Python? Like wtf man?

8.7 and 8.9 say
's' in 'shit'

would return boolean 'True' and
 
count = 0
for letter in 'shieeeeet':
if letter == 'e':
count = count + 1
print(count)

would print '5'
Like why and how the fuck does it work? Does it run trough the string, then hits 'True', and when it does, it continues to run through? Makes no sense to me, do other languages like C or Lisp do string jobs in a same manner?
>>
>>58066727
Strings are iterables, so it runs through each item in the iterable and checks if it's true.

So for the first one, it begins checking from the 0th index, sees that the condition is true, so it stops.

For the second one, it goes through each index in order and if that particular index returns True is performs the actions. As you haven't specified what happens if it returns False, it does nothing for anything that isn't 'e'.

Not sure about C or Lisp, but that's my understanding for Python anyway
>>
>>58066727
Pretty much this: >>58066855

And C doesn't have strings, just char arrays desu~.
>>
>>58066727
I imagine "in" by itself is just a completely different thing from "for...in".
>>
Redpill me on Pascal, please.
>>
>>58066882
A null-terminated char array IS the definition of a string in C.
>>
>>58066727
The first one is a proposition, checking if 's' is a part of 'shit'. The second one is a loop, iterating over each character in 'shieeeeet'.
>>
>>58066882
> just char arrays
Sounds way more pleasant than this. Cause the first time I saw this, I thought every string in Python is an array. I don't know yet, but soon I'll figure it out.
>>58066894
Makes no sense to me [yet].
>>
>>58066918
It's old.
There is no reason to use it these days.
>>
File: pepe sweating.jpg (55KB, 500x473px) Image search: [Google]
pepe sweating.jpg
55KB, 500x473px
>when you look back at some of your code and you commented one of your subroutines as ``black magic''
>>
>>58066928
I would say it still iterates (loops) in the first case, but breaks in case of a result (or end of string)
>>
>>58066935
What I mean is that there's no relation between the two besides that they use the keyword "in".
>>
>>58066950
Fucking retarded reddit frog.
>>
>>58066953
That would be an implementation detail.
>>
>>58066955
I dunno I don't even like python and I think it's pretty reasonable.

in fact, the less reserved words the better as long as it doesn't make things unreadable or nonsensical
>>
>>58067006
I'm not criticizing it, I'm explaining that to >>58066727 who thinks that they are related and is confused because of that.
>>
>>58066727
>what is context

in the former case it uses the __contains__ overload
in the latter it uses the iterator
>>
what is the preferred/most common language for working with large amounts of data, python, c++, java, or something else?
>>
def in_both(word1, word2):
for letter in word1:
if letter in word2:
print(letter)


This makes no sense to me either. So, "in" should return Boulean, but in this case, it compares two Boleans and returns the letter.
>>
>>58065292
java pajeets are worth more than javascript kiddies
>>
>>58067131
for x in y
is not the same as
for (x in y)
. How hard is this to understand?
>>
>>58066727
> Does it run trough the string, then hits 'True', and when it does, it continues to run through
yes, exactly
the goal in this situation is not to juts determine whether it contains 'e' but to determine the total count instances of 'e' in the string, so it must go through the entire string
when it does hit True, it just adds 1 to the count

>>58067131
for x in L:
...

executes the statement(s) contained in ... for every member x in L

x in L (without for) simply determines whether L contains the member x, yielding a boolean value
>>
Any good books to recommend somebody who has a fairly good grasp on various functional and imperative programming languages who wants to learn how to properly structure Object Oriented code to land a job?
>>
>>58067153
> whether L contains the member x, yielding a boolean value
So, how does a boolean "evolves" into a certain letter? I am missing the point. Does "x in 'xyz' " return only boolean, or this exact letter?
>>
File: 186837.jpg (43KB, 283x400px) Image search: [Google]
186837.jpg
43KB, 283x400px
>>58067188
>>
>>58067206 goes >>58067169
>>
>>58067206
for x in y

Loops through y, binding each element to the variable x and executing the block as it goes.
x in y
Checks if the element x is in y.
>>
>>58067188
Why don't you build a considerable portfolio? That way you can train your OOP and have something to show to the employees.
>>
>>58067131
[code ]for letter in word1: [/code] initiates a for loop that iterates letter times (where letter is the amount of members equivalent to letter in set word1) while
 if letter in word2: 
evaluates whether or not there exists a member in set word2 equivalent to letter and executes the statement proceeding it accordingly.

The function (unless you've truncated part of it for the purposes of posting) doesn't return anything, it just may or may not produce a side effect depending on whether or not word2 and word1 both contain shit equivalent to letter.

Pretty drunk at the moment, so somebody can correct me if I'm wrong.
>>
>>58067308
I already have a pretty decent portfolio, but I don't understand how you're supposed to neatly organize OOP code.

The only well-organized projects I've seen written in OO languages hardly made use of OOP features at all (eg. Doom 3's source code)
>>
>>58067355
>I don't understand how you're supposed to neatly organize OOP code
Because it's not really possible. "Properly structuring OOP code to land a job" is one thing but "properly structuring OOP code" based on objective qualities just doesn't happen.
>>
File: twisted sex changers.png (163KB, 759x813px) Image search: [Google]
twisted sex changers.png
163KB, 759x813px
Are traps part of computer science?
>>
>>58067206

"x in 'xyz'" is an expression

"x in 'xyz'" is true
"x in 'abc'" is false

we write
if <expression>: <code>
to mean "if <expression> is true, execute <code>"
>>
>>58067421
yes
>>
File: 0e9.jpg (27KB, 600x600px) Image search: [Google]
0e9.jpg
27KB, 600x600px
>>58067366
what are design patterns
>>
File: gof_cover.jpg (93KB, 520x648px) Image search: [Google]
gof_cover.jpg
93KB, 520x648px
>>58067188
and effective java if you're using java
>>
What functional programming language should I learn? Scala or Clojure?

Please no Haskell, the syntax is beyond hideous.
>>
>>58067421

only in web dev. Trannies, feminists and nu males fill 99% of web dev jobs. Beware!
>>
>>58067439
This but head first patters is good as an introduction to read before the gof book
>>
>>58067425

goddammit fucked up my quotes

obviously i mean " 'x' in 'xyz' " etc
>>
WHERE ARE THE BOOK RECOMMENDATIONS? AHHHHHHHHHHH
>>
>>58067439
>>58067435
"""design patterns""" are fucking garbage.
They're over-engineered, inelegant, ridiculously verbose, and only really exist to overcome shortcomings in Java.
>>
>>58067443
Check out this book on scala and theres a pretty good coursera course you can find on thepiratebay to go along with it
>>
>>58067473
what kind of book do you want famalam?
>>
File: pr.jpg (747KB, 2310x2306px) Image search: [Google]
pr.jpg
747KB, 2310x2306px
>>58067473
Here.
>>
>>58067473

C Primer Plus. Then move to C++ Primer Plus. Then after that you can use whatever language you want. Not starting with C would be a disgrace.
>>
>>58067435
To make it easier to understand already-written super-OO code and describe it to others.

If you consider them to be tools, they are mostly just solutions to avoidable problems (like singleton) or equivalent to functional things like higher order functions (strategy) and pattern matching (visitor).
>>
>>58067500
meh/10
>>
>>58067489
Thanks, just downloaded that and enrolled on the Coursera course which starts tomorrow.
>>
>>58067500
>slavscum detected
>>
>>58067473
http://www.groupes.polymtl.ca/inf2610/documentation/ComputerSystemBook.pdf
>>
>>58067131
read >>58067113

depending on the context, it either calls __contains__ function or uses the iterator

how is the concept of context too hard for you to grasp?
>>
>>58067496

books for C+, data structures and algorithms

>>58067500

naisu

>>58067533

C a SHIT, SHIIIIIIIIIT. It's not shit but I think I'm better off tackling the beast that is C++ than starting off with C
>>
>>58067489
>>58067524
Beware, if you read the book before doing the course, you will feel that the course is shit. Be book is very good and will teach you more in 4 chapters. I would also recommend Scala school from Twitter.
>>
>>58067616
>It's not shit but I think I'm better off tackling the beast that is C++ than starting off with C
you're not, it will be easier to start with C, it'll just take more time. You're gonna need to learn how to translate backwards if you start with C++, where as you only need to learn new concepts going from C - > C++
>>
>>58067447
I know one software developer mtf and one information security mtf. I don't know any web dev mtfs
>>
>>58067447

The web was a mistake.
>>
>>58067616
>I think I'm better off tackling the beast that is C++
You're not. C++ is a massive pile of shit.
It's just a bunch of random mismatched features piled on top on random mismatched features.

Learn C first. It's a language that was actually designed somewhat competently.
It'll give you a better perceptive on programming language quality.
>>
>>58067533
That book looks like a pretty good refresher on a lot of cs concepts. might have to look into buying it
>>
You know you can do programming tests online like this:https://www.tutorialspoint.com/cplusplus/cpp_online_test.htm

What's your opinion on them?
>>
>>58064455
I can post some of mine if people need examples.
>>
>>58067650
C doesn't "lead on" to C++. Modern C and Modern C++ are completely different beasts, and should be treated as such. Your style of thinking is incredibly outdated.
>>
>>58067706
Yeah Im sure I can find it free on the internet. I just like to have the actual book to add to my collection.
>>
>>58067709
Yes it does. Modern C++ is still syntactically based off of C despite having 'modern' (fucking lmao) things like lambdas.
>>
>>58067644
Fair enough, I mostly go through MOOCs on 2x speed anyway.
>>
>>58067709
Which is dumb, they could have repaired better the language if change was necessary
>>
>>58067670
What went wrong though?
I legitimately think JavaScript is what killed the web. HTTP went from graph structured documents with enriched text to shitty app store.
>>
>>58067709
Where did I say C leads on to C++? What are you even on about?

Going from C++ to C is harder because you're going to need to learn how NOT to apply knowledge to C and learn how to cope with the tools you've got. Building onto C with C++ is easier since you can just deprecate old practises with new ones. Regardless that modern C and C++ are different beasts, C++ compilers are 95% compatible with C, and you can simply substitute in new practises until you're writing modern C++. I'd reiterate my point but I'd just be repeating what I posted first; what does that have to do with anything? You are objectively losing features and language size going back to C from C++. Hence "backwards" and "forwards".
>>
>>58067744
>Modern C++ is still syntactically based off of C
So is Java and plenty of other languages. Do you think your point still stands?
>>
>buy hotlegsandfeet.com subscription for 10 bucks
>write python script, with requests and beautifulsoup to download the clips
>downloaded 300GB of FullHD feets in the last 3 days
>jerk it 7 times a day

The last couple of days weren't really productive
>>
File: C++ in a nutshell.png (72KB, 1016x98px) Image search: [Google]
C++ in a nutshell.png
72KB, 1016x98px
>>58067744
>Modern C++ is still syntactically based off of C
So is every C-like language. That's nothing to flaunt.
Also, image related is nothing like C.
>>
>>58067775
This is your argument:
>learning C doesn't give you an advantage for C-style languages which have 'modern' (lmao you're an idiot) features
>>
>>58067787
actually, yes, it is. it just has superfluous and unnecessary type descriptors.
>>
>>58067787
I'm not him but the image is definitely C just with "abstract" types
>>
>>58067787
I don't see a problem there
and it still looks better than hasklel
>>
>>58067798
>>58067803
Where the hell does your stupid thinking end?
Your argument is so stupidly general, that EVERY single language imperative and structures is "just like C".

There are so many things in that image that are completely different to C syntactically, that it massively outnumbers the things that are similar.
>>
>>58067851
>EVERY single language imperative and structures is "just like C".
I rewrote that sentence at one point and fucked up the grammar. Let me do that again:
EVERY single language that is imperative and structured is "just like C".*
>>
>>58067851
C has macros, so if you're trying to discreetly point towards templates, then you're mistakenly thinking it for yet another no-so-modern feature of meta-programming and also generics.
>>
>>58067851
If you replace the templates in this code by some random types you could very well have a valid C code.
>>
File: Brendan.jpg (208KB, 1000x1414px) Image search: [Google]
Brendan.jpg
208KB, 1000x1414px
>>58067776
>tfw you spend hours writing perl scripts to download hundreds of GB of porn imagesets and videos
>>
>>58067851
>>58067787
stop moving the goalposts you retard

none of those languages are actually compatible with C. Ruby was written in C, run a ruby interpreter over a printf and watch it die. Now run a C++ compiler over it and it compiles. That was my pointer, you go from C to C++ and all the knowledge you have still applies to C++ at the very least in the background, you just don't have to use it occasionally.

>if I ignore the rest of his posts and arguments and argue with some other retards about completely different concepts, I'll be correct, right??
>>
>>58067885
Life is good
>>
>>58067885
lamo I think this is a rite-of-passage for programmers
>>
>>58067771

Gopher should have won.
>>
>>58067903
> have a job as junior dev
> full of self doubt
> don't consider myself a programmer
> write a script to auto download picture sets of bitches
> tfw I'M THE GOD OF CODE
>>
I'm making a mega collection of data structures all hand-written in C++ using templates; however binary trees are the only ones that have given me issues at the last minute so far.

http://pastebin.com/wq9ie3K5

In the add method, I keep getting compiler errors like:

"left of '.myObj' must have class/struct/union"
"left of '.myLeft' must have class/struct/union"
"left of '.myRight' must have class/struct/union"

I used the exact same process for my LinkedList-based classes, why is this the only one giving me issues? I'm less familiar with C++ than C# or Java, which is where I mostly wrote the mockups of these classes.
>>
>>58063973

People continue to use XML because they don't know about JSON.
JSON is probably one of the better text serialization formats.
>>
>>58067884
>If you remove basically everything, you get C code which is nowhere near equivalent
Good one.

>>58067886
>none of those languages are actually compatible with C
>Now run a C++ compiler over it and it compiles
C++ is NOT a superset of C, as you seem to think. There are lots of things added in C99 and C11 which is not valid C++ and never will be.
>the knowledge you have still applies to C++ at the very least in the background
Sepplesfags seem to scorn you for using C features when a C++ equivalent exists.
Why use printf when you can use our objectively inferior and incredibly ugly iostreams?
>>
Just finished implementing a pathfinder for enemies in my game, feeling bretty gud.
>>
>>58067947

"C was a mistake." - Dennis Ritchie
>>
>>58067969
Why didn't you post the image, dumb tripfriend.
>>
>>58067979

If I did, you wouldn't have responded.
>>
>>58067947
with the exception of a few edge cases, C++ *is* a superset of ANSI C.
>>
>>58067930
>>58067903
>>58067885
>>58067776
I mean that's like the ultimate goal
what else is there to achieve?
>>
>>58067947
>C++ is NOT a superset of C, as you seem to think.
Where do you get that from? You're just making shit up, at this point. I'm not arguing FOR or AGAINST C++. All I'm saying, it it's easier to go from clean and small (C) to huge and messy (C++). That is objective, you're delusional if you think that's wrong.
>>
File: .gif (2MB, 500x281px) Image search: [Google]
.gif
2MB, 500x281px
>learn X program language
>the left time you spend on learning various libraries procedures
halp
why is this allowed
>>
>>58068022
>With the exception of one edge case, {1, 2, 3, 4, 5} is a superset of {3, 4, 5, 6}
>>
>>58068022
>exception of a few edge cases
And basically you've said that C++ is definitely not a superset of C, you fucking idiot. "Almost supersets" are not helpful. Even then, there are still a lot of things that are the same syntactically between C89 and C++, but have different semantics.
Also, this has been about Modern C (C11) and Modern C++ (C++14), i.e. the current ones. Stop bringing up outdated shit.
>>
>>58068081
It is though.
>>
>>58068075
this is an English board, friend
>>
>>58068051
From C++ to C: "Oh, I can only use these things, alrighty then."
From C to C++: "What the fuck!?"
>>
>>58068100
C to C++: Oh I can start using x instead of y.
C++ to C: Nothing I've learned applies, time to start all over again.
>>
>>58068099
I thought that's American board
>>
>>58068112
>Oh I can start using x instead of y.
No the "What the fuck!? Who the hell thought this was a good idea?" is definitely the more typical response.
>>
>>58067771

>JavaScript is what killed the web
The alternatives were Flash and Java. Both were incredibly more insecure, and incapable of being sandboxed.

>>58067886

There are plenty of C programs that a C++ compiler will not build, especially those that use the latest standard of C, which is C11.

>>58067944

prev and spot are pointers. You can't use a . operator on a pointer because it's not a structure. You have to use the -> operator. For any type A with member B, to access B from variable C of type A*, you would use C->B, or (*C).B.
>>
>>58068123
>No the "What the fuck!? Who the hell thought this was a good idea?" is definitely the more typical response.
Reponse to what?


#include <stdio.h>

int main() {
printf("Hello world\n");
}



This is valid C++ code. This can be fully and efficiently compiled by typing g++ hello.c
>>
>>58068092
>Even then, there are still a lot of things that are the same syntactically between C89 and C++, but have different semantics.
give me an example.
>>
>>58068139
>not compiling your hello world with -o3
>>
>>58068131
C++14 supports most of C99, which is what most C libraries are written in.
>>
>>58068156
everyone knows O3 is placebo. O2 printf master race.
>>
>>58068112
C++ to C: Just a subset of language features exists, got to just work around them.
C to C++: Better start studying syntax changes, language features and STL among other things, miss out on most of them and end up writing horrific C/C++.
>>
>>58063917
Just finished a Computer Science course on java, but i can't find any good courses that take me further, what can you recommend?

Programming in Java in Eclipse
>>
When should I use C over C++?
>>
I always like the shitposting about c++ features no one is forced to use in these threads
makes me feel all cozy inside
>>
>>58068131
I knew it was something stupid I was totally glancing over. Thank you so much! I always forget about the arrow operator after doing so much C#.
>>
>>58068188
Java is not computer science. I realize that it's not your fault, just trying to help you avoid making the same error in the future.
>>
>>58068200
When you don't have a C++ compiler available for your target platform.
>>
>>58068200
Just when you want to get closer to the hardware.
>>
>>58068200
When you need to write drivers, kernel-level stuff, have an actual need for speed, writing a feature for another language, or C simply handles the job the best (your opinion).
>>
>>58068200
probably every time you don't need any c++ features
>>
>>58068200
If you don't have a C++ compiler for your target platform. If your current developers only know C.
>>
>>58068139
That is not representative of a typical C++ program.
C++ is not "C with classes" or "C plus some other shit".

>>58068147
sizeof('a')
mytype uninitialised_var;
non-static inline
const variables.
auto
Off the top of my head. I can't be botherd digging very deep into both languages right now.

>>58068158
>supports most of C99
>No VLAs
>No designated initialisers
>No compound literals
>No restrict pointers

>>58068200
You want a stable ABI.
You want a language that isn't a pile of shit.

>>58068202
>features no one is forced to use
>le my subset of C++ argument
>>
>>58068181
>Better start studying syntax changes
There are barely any. Same operators, now you can overload them. Same structs, now you don't need to typedef/alias them. Same function pointers, you might not use them as much because classes/objects. No more implicit casting of malloc, now you'll probably be using "new/delete" more. You're just going from having things to having more things. It's not like you're going to start C++ by writing a giant networking application, you can just take it step by step as anyone should learning literally any language.

>>58068200
Always.
>>
>>58068158

Except for, you know, restrict pointers.
>>
>>58068230
but classes are useful
>>
>>58068252
epic trell post my friendo of le well thought of memes

>what is a struct
>>
>>58068252
I find function overloading more useful than classes. classes most of the time can simply be scoped files in C.
>>
>>58068267
And you end up recreating classes in C whenever they are necessary.
Brilliant plan.
>>
>>58068289
It's not hard.
>>
>>58068298
It is, however, tedious.
>>
>>58068289
why would I use c++ just to have classes if a struct would do the job?
>>
>>58068240
>No more implicit casting of malloc, now you'll probably be using "new/delete" more.
And that pretty much shows how archaic your knowledge on the subject is.
>>
>>58068289
>recreating classes in C
Nobody sane actually puts a bunch of stupid function pointers in their structs.
A typical C thing is "structs, and functions which work on those structs". However, that is a staple of imperative/procedural programming and has nothing to do with classes.
>>
How does this make you feel?

https://cytu
.be/r/v_watches
>>
>>58068311
nice argument
>>
>>58068306
Not really.
>>
>>58068249
That's why I said most.
>>
>>58068320
>a shady link on 4chan
makes me feel nope.png
>>
New thread:

>>58068337
>>58068337
>>58068337
>>
>>58068334
>he hasn't heard of cytube
It's a livesync site you nonce.
>>
>>58068333
Sepplesfags can't do this
bool is_whitespace[UCHAR_MAX] = {
[' '] = 1,
['\t'] = 1,
['\v'] = 1,
['\n'] = 1,
};
>>
>>58068310

RAII.

>>58068313

>Nobody sane actually puts a bunch of stupid function pointers in their structs.
Point is to duplicate virtual functions, not regular member functions.

>>58068334

Cytube is safe.
>>
>>58068334
>le hacker for chon
>>
>>58068369

Better:
bool is_whitespace(char c)
{
return c <= ' ';
}
>>
>>58068371
>Point is to duplicate virtual functions, not regular member functions.
Yes, but member functions are in essence, pointless. They provide no real benefit over normal functions.
>>
>>58068394
The null character is not whitespace.
The bell character is not whitespace.
The character return characters is not whitespace.
Not to mention, you code has a reliance that ASCII is the encoding.
>>
>>58068418
>Not to mention, you code has a reliance that ASCII is the encoding.
First 128 places in Unicode are the same as in ASCII, famicom.
>>
>>58068465
That's irrelevant.
Neither C or C++ have a guarantee on the character encoding that is used.
>>
>>58068418

>The null character is not whitespace.
>The bell character is not whitespace.
>The character return characters is not whitespace.
I would define all of the above as whitespace. Unless you can show me a glyph that could reasonably represent any of these characters.

>Not to mention, you code has a reliance that ASCII is the encoding.
Write a different function on special snowflake systems.
>>
>>58068583
>I would define all of the above as whitespace
They're (mostly) non-printing characters, which is clearly distinct from whitespace.
Can I use ASCII bells to separate tokens in my programs?

Anyway, this is all irrelevant. C++ doesn't have designated initialisers, I very useful feature.
>>
>>58068614
>I very
a very*
>>
>>58068397
But how would you modify your object's state, then? Passing the object as an argument?

Ew, that's heresy.
>>
>>58068647
>Passing the object as an argument?
Yes, obviously. That's what languages with classes are doing under the covers, with a hidden 'self' argument.
>Ew, that's heresy.
You're stupid.
>>
I would like to see the source code of Javascript's
Array/String.prototype.indexOf
, where can I go to view Javascript's source?

I'm curious and want to find out how indexOf is implemented.
>>
>>58064829
Depends on the problem.
Thread posts: 329
Thread images: 34


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