[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: 319
Thread images: 31

File: hime sly pose.png (308KB, 689x779px) Image search: [Google]
hime sly pose.png
308KB, 689x779px
old thread: >>56275136

What are you working on, /g/?
>>
>>56279719
everything
>>
>>56279719
Fuck off I'm not doing your homework.
>>
>>56279719
that looks god fucking awful
>>
First for OOP
>>
>>56279741
>"""silver bullets"""
>>
>>56279701
Fuck off this programming fap meme
>>
>>56279756
Fighting werewolves aren't we you homoerotic faggot?
>>
any of you have any experience with machine learning?
how hard is it to make a captcha solver?
>>
File: akari3.jpg (92KB, 912x576px) Image search: [Google]
akari3.jpg
92KB, 912x576px
I added support for pages to my simple CGI commentboard written in C!
http://45.32.80.36/board.cgi

Now you don't have to load 10000 posts on every pageload!
>>
File: sweaty pepe.jpg (20KB, 241x228px) Image search: [Google]
sweaty pepe.jpg
20KB, 241x228px
>tfw binary multiplier implementation worked first try
>keep throwing things at it and it keeps returning the correct answer
i don't trust it
>>
>>56279785
im not clicking that shit LA cuck
>>
File: i aint clicking that shit nigga.jpg (113KB, 765x757px) Image search: [Google]
i aint clicking that shit nigga.jpg
113KB, 765x757px
>>56279785
>>
>>56279788
>How many jobs have you actually applied for anyway?
About as many as I can find. Indeed, etc. I'll look into the GitHub thing. I've made it to the first phone interview a couple of times but my autism gets in the way and I throw all interview etiquette out the window.

Doesn't help I live in the worst possible place to get a developer job.
>>
How should I start setting up a portfolio? What are things people look for in a portfolio specifically? Obviously if I'm applying for a job using ebedded C programming they don't want to see PHP websites. Or do they like a healthy balance?
>>
File: 404-Anonymous-7.png (269KB, 500x471px) Image search: [Google]
404-Anonymous-7.png
269KB, 500x471px
in Java, what's the difference between:
str
string
String
?
>>
>>56279913
one of them is a datatype
>>
>>56279833
you live in east central Indiana, too?
howdy, neighbor!
>>
>>56279937
oh wow i live in india too
>>
>>56279913
pretty sure "str" isn't a thing, and i don't think "string" is a thing either. String is the class for strings
>>
>>56279913
yes
>>
>>56279933
 public class Main {
public static void main(String[] args) {
Scanner userInput = new Scanner (System.in);
str commonName = new str;
System.out.println("What do most people call you?");
commonName = userInput.NextLine();

am i using the wrong one here?
>>
>>56279966
https://docs.oracle.com/javase/7/docs/api/java/lang/String.html
>>
>>56279785
Stop advertising.
>>
>>56279937
No, South Carolina
>>
>>56279966
String commonName = new String();
...
commonName = userInput.nextLine();
>>
>>56280029
don't spoonfeed, it just makes them keep clogging up the threads and keeping us away from anime/trap discussion
>>
>>56280037
post ur sexy legs wit them socks then bb
>>
>>56279966
>>56280029
str Common Name = new[] Strink;


ftfy
>>
my dik iz big
>>
File: mentally ill trap.jpg (334KB, 800x600px) Image search: [Google]
mentally ill trap.jpg
334KB, 800x600px
>>56280054
i dont own socks sorry, here's me though. guess what my favorite language is
>>
File: ANGELS.jpg (186KB, 1280x720px) Image search: [Google]
ANGELS.jpg
186KB, 1280x720px
trying to create a full, non-toy compiler for my programming language and it's hard.
no end in sight
>>
>>56280019
gorgeous state! not too far from ATL
maybe search for jobs there that will let you telecommute, but if they need u onsite, u can get there

friend of mine lives in NH employed by rackspace in TX. she only goes to TX 1-2 times/year
>>
>>56280096
Sounds like a good idea. Thanks for the suggestion.
>>
>>56279913
String is a datatype.
string or str can be the name of the String object you are creating but the name can be anything you want

 String str = ""; 
String string = "";
>>
File: 1468246784892.jpg (936KB, 1500x751px) Image search: [Google]
1468246784892.jpg
936KB, 1500x751px
Is anybody here learning R? I'm doing the free course on coursera from JHU, but I'd like another source to learn as well. Help?
>>
>>56280121
why are you learning R?
>>
File: Screenshot_2016-08-17_13-39-58.png (30KB, 139x175px) Image search: [Google]
Screenshot_2016-08-17_13-39-58.png
30KB, 139x175px
>tfw mario.c compiles
>>
>>56280112
If you're having trouble with the interview itself watch interview videos and tips etc.

God spped
>>
oh god I'm doing it
I'm making an animated chinese rock carving and I have no idea what the fuck compilers would be when it comes to objects cute grills would use
>>
File: divisionshit.png (9KB, 558x159px) Image search: [Google]
divisionshit.png
9KB, 558x159px
I made that anon's fraction math program in Python. It actually works afaik and I think I've done it fairly cleanly. Critiques?


n0 = input('Input your first fractions numerator: ')
d0 = input('Input your first fractions denominator: ')
n1 = input('Input your second fractions numerator: ')
d1 = input('Input your second fractions denominator: ')

print ('Your fractons are {}/{} and {}/{}, what would you like to do with them?'.format(n0, d0, n1, d1))

user_choice = input('You can choose to divide, multiply, add or subtract these fractions: ').lower()

def simplify(num, den):
for i in range(min(num, den), 0, -1):
if num % i == 0 and den % i == 0:
num = num / i
den = den / i
return ('{}/{}'.format(num, den))

def fractionMath(user_choice):
if user_choice == 'divide':
num = (int(n0) * int(d1))
den = (int(d0) * int(n1))
elif user_choice == 'multiply':
num = (int(n0) * int(n1))
den = (int(d0) * int(d1))
elif user_choice == 'add':
num = (int(n0) * int(d1)) + (int(d0) * int(n1))
den = (int(d0) * int(d1))
elif user_choice == 'subtract':
num = (int(n0) * int(d1)) - (int(d0) * int(n1))
den = (int(d0) * int(d1))
print ('If you {} {}/{} and {}/{}, your unsimplified answer is: {}/{}'.format(user_choice, n0, d0, n1, d1, num, den))
print ('Your simplified answer is: ', simplify(num, den))
print ('Your decimal answer is:', num/den)


fractionMath(user_choice)

>>
>>56280120
thank you!
>>
>>56280093

Let LLVM handle all of your backend shit. That will at least make things a little easier.
>>
>>56280212
>Your fractons are 15/5 and 5/1, what would you like to do with them?
>You can choose to divide, multiply, add or subtract these fractions: lmao
>Traceback (most recent call last):
> File "lmao.py", line 35, in <module>
> fractionMath(user_choice)
> File "lmao.py", line 30, in fractionMath
> print ('If you {} {}/{} and {}/{}, your unsimplified answer is: {}/{}'.format(user_choice, n0, d0, n1, d1, num, >den))
> UnboundLocalError: local variable 'num' referenced before assignment
>>
Does the 'p' in "dpt" stand for Pajeet?
>>
What's the coolest thing you've ever programmed, /dpt/?

I wrote a name generator that takes a bunch of input data, builds a statistical model, and then generates names that could reasonably fit into that data.

I fed it a bunch of african-american names and got this:
Liatonta
Qunanima
Lajan
Linesha
Tondeen
Sha
Lantand
Tarickickararel
Kekan
Kekes
Lenandr
Tys
Lanar
Kat
Andea
Kique
Dedei
Kaya
Denik
Tays
Tori
Dan
Jaqual
Daranie
Nimatinylina
Keshan
Qua
Toryalauane
Lickis
Tyrqui
Majashata
Ryl
/code]
>>
>>56280212
You could probably clean up the output dialog a little
>>
>>56280247

tfw I can't lmao my fractions
>>
>>56280163
I'm a psychologist, doing cognitive experiments, and I want to really know the statistics I'm using. At school they taught us SPSS, but that's just clicking buttons without really knowing what's going on. I want to understand the 'behind-the-scenes'. Does that make sense?
>>
>>56280290
Do you consider yourself to have a low, average or high interpersonal IQ?
>>
>>56280272
Ummm why do those names have to be "African-American" names?

My wife's son is white (ugh) and she named him after his father Jamal.. Just sayin'
>>
>>56280272

That's fucking hilarious
>>
>>56280308
lel, I'd say average to high. Most of my friends come talk to me about their issues and shit, I'm a good listener.
>>
>>56280088
wanna have sex? :^)

is it Java?
>>
>>56280325
if (age <= 12)
racism = funny
else
GROW UP
>>
>>56280272
>Kekan
>Kekes
kekd
>>
>>56280328
Have you seen The sopranos?

what do think about Dr. Melfi?
>>
>>56280272

Could you give details as to how you did it? I'm actually really interested. Also could you use reinforcement learning to get it to make better names, for example, you can say Lanar, Jaqual, Keshan etc are good and to generate more like them?
>>
>>56280272
Pontificate us anon. What is this statistical model? I've only ever bothered with markov chains.
>>
>>56280338

how is it racist to laugh at stereotypical names? Literally everyone does that...nigger.
>>
>>56280272
>builds a statistical model
how did you do it, just the principles of it
>>
>>56280356
I've seen a couple of episodes, but I don't remember Dr. Melfi, desu.

Any help with my original R question?
>>
>>56280377

I wanna learn R too for ML and AI but it seems very dense. The only people that seem to really get it are Data Sci PhD's, but I'm not entirely sure about that.
>>
>>56280358
could attach to a GUI and have users select the top 5 names they'd name their kids. rerun the 'statistical model' after each use = more accurate lists
>>
>>56280368
>nigger
Racist!
>>
>>56280338
Don't you have to snitch on some github users?
>>
>>56280427
sounds good. but i think you should show them a list of ten have them pick the best one, repeat until they are tired of it.
>>
>>56280441
No?
>>
Anyone here learning AI/ML?

Any good resources for that?
>>
>>56280408
I do some neural network modeling in Matlab, it's pretty cool. But R is the best for stats in general, so I'd be getting stats + ML, two birds with one stone.

I'm not Data Sci level, but I am going balls-deep into a lot of stats classes.

What is dense, R or ML? Because Neural Network are just learning by error reduction, pretty simple.
>>
>>56280481

The language R. I'm currently doing some basic ML stuff in Python and it's pretty fascinating.
>>
>>56280520
I might be wrong, but R doesn't seem as complicated as C/C++. It's pretty similar to Matlab actually, you can get something running in just a few minutes.
>>
>>56279785
add in usernames and boards
>>
>>56280272
That's the coolest thing you've done?
>>
Had an interview for a postdoc position and on top of generally doing very well I was asked the best question ever.

We were talking about how I would approach a particular problem and the professor in charge asked if I've heard of a certain program (really just a fancy parser for the sort of data used in such problems which also generates useful summaries).

I answered truthfully that I developed it. He seemed quite impressed.

I ended up getting the offer.
>>
>be me
>do something
>blog about it on 4chan
>mfw
>>
File: 1471646637226.gif (1MB, 250x141px) Image search: [Google]
1471646637226.gif
1MB, 250x141px
>>56280690
>mfw you have no face
>>
>>56280676
that's impressive.

what tool?
>>
>>56280676
>I developed it

how come you didn't put that on your CV/presentation letter?
>>
File: 1466378529394.png (677KB, 720x713px) Image search: [Google]
1466378529394.png
677KB, 720x713px
>>56280318
>My wife's son is white (ugh)
>>
>>56280830
newfag
>>
what is the best way in C++ to compare 3 different numbers and assign the lowest number to an int using ternary operator?

Im trying to get 3 runner's times and assign the lowest to 1st place etc. etc.
>>
>>56280861
Use the ternary operator to implement a min function and use that.
>>
>>56280830
>falling for obvious bait
>>>/pol/
>>
>>56280872
I'm just trying to do this in the main function because I haven't learned about making different functions yet
>>
>>56280212
>from fractions import Fraction
>>
if only there was a way to get the size of windows in ncurses
>>
>>56280959
*dimensions
>>
how do I make a page switching effect like in most ebook readers?

is there any easy tool to make an ebook reader app?
>>
>>56280886
You would have to nest the ternary with another ternary
int a,b,c;
...
int lowest = a;
lowest = (lowest < b) ? b : ((lowest < c) ? c : c)
>>
File: 1468546966467.jpg (53KB, 960x960px) Image search: [Google]
1468546966467.jpg
53KB, 960x960px
I hit a breakthrough in my current project and thanks to that i'm in the process of adding things i didn't originally plan on, and just making it more ambitious in general.

How fucked am i?
>>
>>56281082
oh shit I goofed, that last c should be lowest.
>>
>>56281102
>How fucked am i?

What? What a stupid question
>>
>>56281082
>nest the ternary with another ternary

Mind brain just shit itself
>>
>>56281102
Very very fucked. I have ~60 issues on Github that are all public TODOs made by me.
>>
>>56281082
>>56281129
So there should be 27 possibilities right?

So I would have to right 3 ternary conditional statements with 3 possibilities?
>>
>>56280430

>Racist
While global rule 3 does state that among other things, racist content should be kept on /b/, the rule is lightly enforced, and nobody really gives too much of a shit about it. Shouting "racist" on pretty much any board here is fairly ineffective.

>>56281066

>is there any easy tool to make an ebook reader app?
Android Studio.
>>
Is there a recommended book list? I'm trying to see what books I should get from my library besides the obvious ones.
>>
>>56281205
I only wrote two ternarys there.
>>
>>56281206
yeah, but how do I code that flipping page effect where you grab the page corner?
>>
>>56281250
Oh boy, this gon be gud.
>>
File: 1465950690966.png (225KB, 470x496px) Image search: [Google]
1465950690966.png
225KB, 470x496px
>>56281066
>>56281250
27 year old neet LOL
>>
File: 1450578275241.jpg (195KB, 983x1013px) Image search: [Google]
1450578275241.jpg
195KB, 983x1013px
>>56281275
>posting /lat/ memes in /dpt/
>>
>>56281275
che chori.
>>
>>56281283
>being cristian
>>
>>56281250

Well, most of us here have never written an ebook application, so that would be something for you to figure out on your own. Start brainstorming some ideas for how it would be done at a higher level, then work it out in code.
>>
>>56281206
>falling for bait
>>
>>56281320
I don't have any idea to be honest.
it seems like they make a 3D mesh, or they use a mask and another shape that grows dinamically on top.
>>
>>56281297
My name's not christian
>>
>>56281351

Does it need to be a 3D mesh, or can one find a way to duplicate the animation using more primitive means?
>>
>>56279785
Are you using a DB to store the posts? Is it MySQL or sqlite or what?
>>
>>56281459
I dunno, I don't have a fucking clue over how to do it.
>>
>>56280272
I once made a Tox client in Racket but I lost steam and it's very out of date. Currently I'm working on a taggable image viewer, also in Racket.
>>
>>56281486

Well, since you have no idea how to approach it, let's work through the idea. First: do you believe it practical to use 3D graphics in an ebook reader?
>>
>>56281515
He was asking in AGDG what "engine" (game engine) they used. Draw your own conclusions.
>>
>>56281515
I dunno, how would you approach it.

>>56281522
I'm asking bro, I always wanted to know how they coded that effect.
>>
>>56281515
Yes? Everything is hardware accelerated anyway. If you're doing a genuine 3D effect where you press and drag on the corner and then the page kind of follows your finger, bending in different directions depending on how you drag it, I can't see any way of doing that in 2D without using a shit ton of sprites. You could get away with a poor man's implementation by having maybe 4 sprites that you alternate between depending on how "far" you pull the page back but it wouldn't be as dynamic as, say, the Kindle app, or the iPad book app.
>>
>>56281476
I'm using sqlite right now.
It's actually pretty intuitive.

SQL is not however, and the fact that I can't use aggregate functions on statements with LIMIT and OFFSET forced me to write duplicate code for my main use case.
>>
File: effect.png (2MB, 1440x900px) Image search: [Google]
effect.png
2MB, 1440x900px
>>56281515
here it's one example.
>>
>>56281618
I can easily do that even with fucking sdl in a few lines.
>>
>>56281643
I'm not a CS guy, barelly a begginer or intermid guy, but would love to hear how to do it.

I'm sure you need a 2D shape and some heavy use of linear algebra.

but I suck at linear algebra bro.
>>
What are your top 3 go to programming languages?

For me it's
1) Java
2) Python
3) C

I'm thinking of picking up C# more too
>>
>>56281643
Good for you?
>>
>>56281603
>>56281618

Okay, that I would definitely assume the use of 3D graphics. I've seen some other ebook applications that use different animations that might be do-able using some sort of imagemagick-like library though.

That said, I was trying to see if I could get Anon to come up with some of his own ideas using the Socratic method or some shit.
>>
>>56281690

is Ruby a meme language?
>>
File: effect.png (8KB, 421x397px) Image search: [Google]
effect.png
8KB, 421x397px
>>56281690
this is my best idea as to how to do it.
they overlap another 2D shape and use linear transformations to overlap it.

but I suck at math.
>>
>>56280272
HTTP server in C
>>
>>56280088
HTML?
>>
>>56281719
You don't need to mirror the interior, just rotate.
>>
>>56281669

Ruby, C, and C++ are what I use for most jobs. I can use most languages circumstantially, but don't consider myself an expert on most of them.

>>56281712

Rails is a meme. Ruby on its own is a pleasant experience.
>>
>>56281744
how do you slice a 2D rect?
>>
>>56280088
>fag
Javascript
>>
>>56280088

>I don't own socks
Do you walk around in sandals all day, or do you wear normal shoes with no socks? Because the latter would seem uncomfortable.
>>
>>56280212
Plus you're using simplify to loop all the way through to min(num,den). Why? You only have to go to min(num,den)/2 and then check min(num,den) separately. Lots of wasted cycles.
>>
Has anybody here ever tried to write their own database engine?

How fucked am I if I want to try and create one?

If I keep building on it I think it'll be doable.
>>
>>56280272
Qunanima? WTF?
>>
Recently ran into a problem in which i compiled with -march=native and other people were crashing on "vfmadd213sd". Is it really that horrible to assume that a processor will at least have FMA3 enabled like come on.
>>
>>56281786
I mean you have nothing to lose except time if you attempt to program one, and fail.

Give it a shot
>>
>>56281799
FMA3 is pretty damn recent.
>>
>>56281786
If you want to build something minimalistic like SQLite, it's doable. If you want to make anything actually useful and horizontally scalable, you're thoroughly fucked.
>>
>>56281799
>https://en.wikipedia.org/wiki/FMA_instruction_set
>FMA3 is supported in AMD processors starting with the Piledriver architecture and Intel starting with Haswell processors and Broadwell processors since 2014.
>Intel introduced hardware FMA3 in processors based on Haswell during 2013.
>2013
Yes, it is horrible to assume that a processor will have FMA3.
Also, why the hell would you distribute -march=native code?
>>
>>56281669
1) C
2) C++
3) Python
>>
>>56281752
use a mask/stencil
>>
>>56280088
Post your soles while barefoot.
>>
>>56281873
SQLite is basically perfect.
Nobody needs anything more unless their data requires a whole datacenter to store it.
>>
Still working on my crawler.
I got a thing on for Python now, actually. This works smooth with only a few lines of code.
Looks like ass, though.
>>
>>56281873

Erm... it is worth noting that while SQLite may be a relatively minimalistic library, the amount of work put into it is not exactly small. There is 787 times as much test code in SQLite as there is code to the actual library, so as to ensure that it is both secure and performant.
>>
File: montage.png (1MB, 1084x1079px) Image search: [Google]
montage.png
1MB, 1084x1079px
>>56280272
Speaking of generative models, I'm working on my own modified version of generative adversarial networks (https://arxiv.org/abs/1406.2661) using Tensorflow. Here are some images it generates after being trained on a dataset of about 20000 anime faces. All the code will be on Github soon.
>>
>>56281869
>>56281876
this is in the context of 3d simulation work you would think the people running my code would at least have something from within the last 3 years
>>
>>56281945
That is very exciting.
>>
>>56281968
Not everyone is a gaymer fag who upgrades their CPU and GPU every year.
>>
>>56281945
Pretty cool.
>>
>>56281945
This could be amazing. If you feed it only smug anime faces, would it produce smug faces only?
>>
>>56281906

SQLite is perfect if you're doing a lot of reads and not a lot of writes. Otherwise, try PostgreSQL
>>
>>56281945

You need to train it more.
>>
>>56281302
Thanks for the response. I ended up picking the augmented reality project. To be honest there wasn't a lot to the description so I'll see if it ends up being something completely out of my depth. The black box thing does instill some confidence in me though, I assumed that I had to know everything. We'll see
>>
>>56282099
could 4chan run on sqlite?
>>
>>56281608
>the fact that I can't use aggregate functions on statements with LIMIT and OFFSET forced me to write duplicate code for my main use case.
But you can

select name from product group by price having sum(price) > 1000 limit 10 offset 1;

works on my machine with sqlite3
>>
File: 1469927263199.webm (1MB, 853x480px) Image search: [Google]
1469927263199.webm
1MB, 853x480px
How big of a meme is Ruby on Rails exactly? I want to learn Web development, am I dooming myself by learning an aging technology? What should I learn instead?
>>
stupid java question:
since there's no such thing as hasNextChar (despite all the hasNextInt, hasNextLine, etc methods being things)
what's the best way to run through a string and evaluating each char?
 
{
//excerpt
Scanner commonName = new Scanner (System.in);
String cn = commonName.nextLine();
Scanner fromCN = new Scanner (cn); while (fromCN.hasNextChar())
//do stuff
{}}
>>
>>56282195
Don't you have access to the length of a string in JAva?
>>
File: tumblr_lkj69gfV2V1qze5g2o1_500.gif (261KB, 499x281px) Image search: [Google]
tumblr_lkj69gfV2V1qze5g2o1_500.gif
261KB, 499x281px
What C books actually use C11 instead of C99 or even older versions?
>>
>>56282191
If you're doing webdev I'd will went full maymay and learn Node, React, MEAN, and all those things.
>>
>>56282213
yes.
why do you ask?
>>
 
//Race
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

int main()
{
string r1_name, r2_name, r3_name; //Runner's names
int r1_time, r2_time, r3_time; //Time assigned to each runner


cin >> r1_name >> r2_name >> r3_name;
cin >> r1_time >> r2_time >> r3_time;

if (r1_time && r2_time && r3_time > 0)
{
if (r1_time < r2_time)
{
if (r2_time < r3_time)
cout << r1_name << r2_name << r3_name;
else
cout << r1_name << r3_name << r2_name;
}
else if (r2_time < r3_time)
{
if (r3_time < r1_time)
cout << r2_name << r3_name << r1_name;
else
cout << r2_name <<r3_name << r2_name;
}
else if(r3_time < r1_time)
{
if (r1_time < r2_time)
cout << r3_name << r1_name << r2_name;
else
cout << r3_name << r2_name << r1_name;
}

}
else
cout << "Time not greater than 0.";

return 0;
}


I finally figured this shit out
>>
>>56281945
is there a way to download this?
>>
>>56282230
i think what
>>56282213
is aiming at is using arrays, which i know fuck about... so i can't help
>>
>>56282195
for (char c : someString.toCharArray()) {
// some shit
}

Not sure why you made the fromCN variable. You already have the user's input as a string.
>>
>>56282230
stupid answer:
you could just use a for loop to go through each index with (i < string.length) as the loop guard
But you asked for the best answer and I don't know if that's the fastest way
>>
>>56282214
The new C specs are almost as cancerous as the new C++ specs. Stick to C89, it's objectively the best.
>>
>>56282248
was following a tut where they were taking int from string and they had fromStr
>izanub
>>
>>56279966
No dimwit, there is only String in Java. If you have string (lowercase) it is just a variable name.

Ex:

String string = "Sample text";
// String is the variable type (aka the object)
// string is the name of the var (aka the instance of the object)
>>
>>56282224
>mongodb
/dev/null is both faster and provides read and write consistency, unlike mongo.
>>
trying to figure out fun projects with C and math, any ideas?
>>
>>56282214
I think "21st Century C" uses C11, but I'm not certain about that.
Even then, the changes from C99 to C11 are really small. You can pick up most of that shit from the wikipedia article and maybe a few random blog posts.
>>
thanks to all helping this nub(ile ) with my stupid java Q

many luv$
>>
>>56281945
What's your github so I don't miss it?
>>
>>56280338
> statistics are racist
>>
File: shitty 12 year old brother.png (9KB, 169x359px) Image search: [Google]
shitty 12 year old brother.png
9KB, 169x359px
>>56282278
3d graphics
>>56282258
_generic was such a joke

pic unrelated
>>
I have a stupid question.

K&R says printf isn't part of the C language (it's a library function) and that there is no input/output defined in C itself. So how is stuff like printf even made?
>>
>>56281227
I still can't believe nobody has answered this. Are """"coders"""" so illiterate now a days that they don't even read books anymore. Do you guys only do tutorials?
>>
File: required reading for (You).png (381KB, 528x528px) Image search: [Google]
required reading for (You).png
381KB, 528x528px
>>56281227
>>56282396
>>
>>56282396
Are you looking for something specific?

I'd recommend Code Complete to start off if you're just looking for general programming books.
>>
>>56281227
>>56282396
There's a massive recommended book list on the wiki.

For a resource with clearly a lot of work put into it, no one ever seems to check it.
>>
>>56282387
Can't directly answer your question but i guess they used the asm directive in the specific architecture for that purpose as printing data is not as complex as just the operations C was designed to do.
>>
>>56282385
>_generic was such a joke
C99 made <tgmath.h> have some "compiler magic" to automatically select the function based on the type of the argument, because having to worry about the difference between cabsf and fabs was too much of a pain in the ass.
They just decided to make this "compiler magic" standard. Its use cases are somewhat limited, but it's nothing to really complain about.

The real joke of C11 is annex K, but pretty much every implementation thinks that too and nobody implements it.

>>56282258
You're an idiot.
There are shitloads of helpful features added in the newest C standards that make it much nicer to write.
C89 does some pretty retarded things and disallows some pretty basic shit.
>>
>>56282185
Doesn't work with count(*).
It literally returns nothing.
>>
>>56282423
So the C standard library contains functions written in assembly? That's pretty neat.
>>
>>56282402
Obviously I said i knew what the obvious books were
>>56282418
I found code complete, programming pearls and SICP at my library which prompted me to find other books. I'm reading Code Complete right now. >>56282411
I just wanted to supplement my education to become a better programmer and computer scientist. >>56282418
I guess I forgot there was a wiki. I'm guessing it's on the sticky.
>>
>>56282258
The only worthwhile feature from the later standards is the ability to mix code and variable declarations together.

And every single compiler worth a damn supported it even when the ISO C90 standard said no.
>>
>>56282470
Sorry for formatting. Writing on my phone right now.
>>
>>56282387
>printf isn't part of the C language (it's a library function)
It's part of the standard library, so if you're writing hosted code (which you are doing 99.99% of the time, unless you're writing a kernel or some shit), it's available.
>So how is stuff like printf even made?
It's system-specific. You make a syscall (in assembly), which will tell your kernel to do something.
For printf in particular, you make a write syscall with the standard output file descriptor.
>>
>>56282387
>K&R says printf isn't part of the C language (it's a library function) and that there is no input/output defined in C itself
This is wrong, it is part of the C standard and thus part of the C language.
>>
>>56282477
>designated initialisers
>compound literals
>variadic macros
>restrict pointers
>VLAs
>inline
>No implementation defined % for negative numbers
>stdint.h
>>
>>56282442
It should never have been a compiler macro in the first place
>>
>>56282529
>designated initialisers
>compound literals
>variadic macros
>restrict pointers
>VLAs
>inline
>stdint.h
Most of these are nice.

>No implementation defined % for negative numbers
??
>>
>>56282463
Yeah well i imagine it was the purpose of the C lang, it may have been a pain to write so many new things in asm, just to have to write them again for another chip.

I don't really know much about it,but it is definitely an interesting piece of history.
>>
>>56282554

Which is why it's built in now.

Seriously, it's probably the best feature to come out of C11 for general use other than the align mechanisms.
>>
File: K&R Chapter 1.png (12KB, 738x122px) Image search: [Google]
K&R Chapter 1.png
12KB, 738x122px
>>56282492
>It's system-specific
I hear this a lot in terms of assembly and low level languages, but I'm not sure how it works. How do C compilers manage to work on all the different architectures in the world if ultimately, they have to convert code into assembly before executing it? I can't ask without sounding like an idiot, but how do they know what type of assembly to turn the code into?

>>56282522
I really don't know enough about programming or C to argue this, but pic related is from K&R.
>>
>>56282572
They should've added proper parametric polymorphic features (aside from runtime specialisation) rather than a macro
>>
>>56282585
>but how do they know what type of assembly to turn the code into?
They convert to the assembly you ask them, or by default on most compilers into the an assembly native to your system.

>ultimately, they have to convert code into assembly before executing it?
They don't have to do that actually, it's just what most of them do.
>>
>>56282560
In C89, using the % operator with negative numbers was implementation defined.
C99 removed that, and it is well defined.

http://www.open-std.org/jtc1/sc22/wg14/www/C99RationaleV5.10.pdf
>Page 67
>In C89, division of integers involving negative operands could round upward or downward in an implementation-defined manner; the intent was to avoid incurring overhead in run-time code to check for special cases and enforce specific behavior. In Fortran, however, the result will always truncate toward zero, and the overhead seems to be acceptable to the numeric programming community. Therefore, C99 now requires similar behavior...

Reading this, I realised it actually applied to division too.
>>
>>56282585
>how do they know what type of assembly to turn the code into?
The compiler knows because it's been ported to the specific architecture beforehand. Unless you specify another architecture, it'll target the one it's been ported to.
>>
>>56282595
this desu
runtime specialisation however?
>>
>>56281066
flip.js anon
>>
>>56282613
Ah yes, I remember that. I thought you mean from printf.
This does suck indeed.
>>
What's something that is difficult to code an implementation of?

Tell me, and I'll try to code it
>>
>>56282642
A compiler.
>>
>>56282642
C++ compiler
>>
>>56282642
program God
>>
>>56282642
>>56282654
Yes, definitely a C++ compiler and runtime to go with it.
>>
>>56282612
>>56282617
Is there some kind of auto-detection thing going on? If a new kind of assembly came along, would the compiler be able to convert C code to that without being updated to do so?

And thanks for the answers, this stuff is interesting but really confusing.
>>
>>56281618
That looks like it's just an image of the next page, rotated, cropped, and then they apply a filter to the end to make it look curved. The 0,0 is where your finger is and they must calculate the angle somehow, probably with the height of your finger inside some bounding frame or something.

Didn't the SNES SFX thing do a lot of 3D looking effects that were really just sprite rotation and scaling?
>>
>>56282642
Kernel driver in C
>>
>>56282671
>would the compiler be able to convert C code to that without being updated to do so
No.
>>
>>56282656
def God():
return 'Nothing happens...'

def Pray():
print ('Calling God...')
return God()

print (Pray())
>>
>>56282671
>Is there some kind of auto-detection thing going on?
No

>If a new kind of assembly came along, would the compiler be able to convert C code to that without being updated to do so?
No
>>
>>56282699
*tips fedora*
>>
>>56282626
in some languages you can have parametrics/generics that exist at runtime
>>
>>56282700
>No
No
>>
>>56282704
Other than IO there is nothing I can think of that would require that. Also, this could be implemented just as a tagged union.
>>
>>56282595
>>56282626
>>56282704
How do you propose that this is implemented without breaking the "spirit of C" and fucking up C's simple ABI?
>>
>>56282718
?
>>
>>56282727
By ignoring it entirely and enforcing C89 compliance forever.
>>
Someone audit my sores code

/* 
Enter the wavelength in meters
to figure out what type of wave it is
*/

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
double wavelength;

cout << "Enter the wavelength in meters: ";
cin >> wavelength;

if (wavelength >= 1E-2)
cout << "That is a Radio Wave " << wavelength;
else if (wavelength < 1E-2 && wavelength >= 1E-3)
cout << "That is a Microwave " << wavelength;
else if (wavelength < 1E-3 && wavelength >= 7E-7)
cout << "That is an Infrared Wave " << wavelength;
else if (wavelength < 7E-7 && wavelength >= 4E-7)
cout << "That is Visible Light " << wavelength;
else if (wavelength < 4E-7 && wavelength >= 1E-8)
cout << "Ultraviolet " << wavelength;
else if (wavelength < 1E-8 && wavelength >= 1E-11)
cout << "X-Ray " << wavelength;
else
cout << "Gamma Rays";

return 0;
}
>>
>>56282727
There is no ABI defined in the C standard. Moreover it does not break any spirit.

Anyhow, it could be done like templates where the symbols would not be exposed.
>>
>>56282727
Did you not see the part where I said "aside from runtime specialisation"?
>>
>>56282748
/* 
Enter the wavelength in meters
to figure out what type of wave it is
*/

#include <iostream>

int main()
{
double wavelength;

std::cout << "Enter the wavelength in meters: ";
std::cin >> wavelength;

if (wavelength >= 1E-2)
std::cout << "That is a Radio Wave " << wavelength;
else if (wavelength < 1E-2 && wavelength >= 1E-3)
std::cout << "That is a Microwave " << wavelength;
else if (wavelength < 1E-3 && wavelength >= 7E-7)
std::cout << "That is an Infrared Wave " << wavelength;
else if (wavelength < 7E-7 && wavelength >= 4E-7)
std::cout << "That is Visible Light " << wavelength;
else if (wavelength < 4E-7 && wavelength >= 1E-8)
std::cout << "Ultraviolet " << wavelength;
else if (wavelength < 1E-8 && wavelength >= 1E-11)
std::cout << "X-Ray " << wavelength;
else
std::cout << "Gamma Rays";

return 0;
}
>>
>>56282755
>There is no ABI defined in the C standard
Yes, but C never adds features which force people to change it. It's one of the massive advantages that C has over C++.
>Anyhow, it could be done like templates where the symbols would not be exposed
They also don't like adding features which cause a shitload of object code to be generated.

>>56282782
What are you going to name all of the symbols from all of these specialisations?
>>
>>56282791
what benefit does using std :: cout over just cout << offer in the context of what I was programming
>>
>>56282671
No, what happens is that when someone creates a new architecture, someone typically writes a compiler because it makes it easier to write more complicated code on that architecture.
>>
>>56282799
>What are you going to name all of the symbols from all of these specialisations?
Whatever _generic does
>>
>>56282809
nothing
>>
>>56282813
The compiler doesn't generate new symbols. It just replaces it with a symbol that the user defines.
>>
>>56282823
Then why did you change D;
>>
>>56282799
>Yes, but C never adds features which force people to change it.
I fear that this is wrong.

>They also don't like adding features which cause a shitload of object code to be generated.
You do not need to generate any shitload of objects.
>>
>>56282833
>I fear that this is wrong.
How?
>>
>>56282830
nothing better to do (._.)
>>
>>56282829
Use something like

myfunc<T>(...)
myfunc@T
>>
>>56282849
Okay!

>_<
>>
>>56282859
That breaks the ABI.
>>
>>56282847
i live in constant fear
>>
>>56282847
Easily
>>
>>56282864
Just like adding a new header to the standard! Or maybe removing gets!
>>
>>56282862
Something would need to change
>>
>>56282878
>Just like adding a new header to the standard! Or maybe removing gets!
Those don't change the ABI.
Also, we can all agree that gets was horrible and was only a trap for new programmers.

>>56282880
>Something would need to change
Then it is unacceptable.
>>
>>56282878
meant for >>56282862
>>
>>56282595

It's not a macro. It's a compile time expression and thus, all branches of _Generic have to be valid.

http://en.cppreference.com/w/c/language/generic
>>
>>56282906
>Those don't change the ABI.
They clearly do, maybe you have a different ABI in your system that is not affected by it, but they clearly do things that break the ABI.
>>
>>56282906
>any change is unacceptable
>>
File: 3.png (24KB, 297x143px) Image search: [Google]
3.png
24KB, 297x143px
JUST
>>
>>56282924
ABI != API
I'm specifically referring to how functions are called and what symbols you use to call them.
Why do you think so many other languages can call C functions so easily, but not C++ functions?

>>56282931
The standard is very careful not to break old shit without a good reason.
>>
Books for C#? The wiki only recommends Apress Accelerated C# 2010, but I'm wondering if this is outdated or I could find something better.

Any recommendations?
>>
>>56282950
>ABI != API
I know that.

>I'm specifically referring to how functions are called and what symbols you use to call them.
I know that as well.

Why are you telling me things that I already know?
>>
how can I generate for example a**b for 2 < a < 100 and 2 < b < 100 using one line in Python

The way i did my list comprehensions just gives me an 'unhashable type' error.
>>
>>56282970
Because you seem to think that adding a new header or removing a function changes it.
>>
>>56282979
It clearly does, any objections?
>>
>>56282992
>It clearly does
I get the feeling that you're just pretending to be trolling at this point to save face.
>>
>>56282956
M$ Visual C# Step by Step, and the Wrox's Professional C#
>>
>>56283007
I knew you would say something like this.
No I am not trolling, I even explained to you before why I disagree with your claim.
>>
>>56283015
No you didn't.
Please explain how adding a new header changes this:
https://en.wikipedia.org/wiki/Calling_convention
>>
>>56282971
what do you mean?

2 ** 3
2 ** 4
.....
2 ** 99

3 ** 2
3 ** 3
....
etc

?
>>
>>56283010
Thanks, I'll check them out.
>>
File: TGydFdU.png (9KB, 401x121px) Image search: [Google]
TGydFdU.png
9KB, 401x121px
Shit's actually starting to come together now...
>>
>>56282971
I'm on a phone, so forgive me.
[a**b for a in range (2,100) for b in range (2,100)]
>>
#include <stdio.h>
int main()
{
char string[256];
gets(string);
puts("You said... ");
puts(string);
}

I'm really liking C so far, it's very simple
>>
>>56283021
>No you didn't.
I clearly did, please see 56282924
Since the standard does not specify an ABI, there might as well exist an ABI that contains informations that most common ABIs do not, such as included headers and break when a new <one> is added. As for gets, its removal means that a user should be able to define it, meaning that it would cause problems in an abi where libraries get statically compiled and the final program adopts the standard library (from the libraries linked) with the most functions. (as the C library would be forced not to include a gets symbol but since more functions would be added it would adopt that one)

>https://en.wikipedia.org/wiki/Calling_convention
Calling convention != ABI, the former is only a part of the later.

>>56282950
>The standard is very careful not to break old shit without a good reason.
It did break realloc (behaviour changed between C89 and next standards, causing many programs to use IDB/UB) and POSIX (POSIX defined [u]intN_t to be of at least N bit. Since the C standard changed it, the POSIX standard had to force CHAR_BITS == 8 to avoid issues) for no good reason
>>
>>56283074
post your $PS1
>>
>>56283074
>polysex
>>
>>56283107
Does your compiler not warn you?
>>
>>56283074
???
Post github
>>
File: hww.png (15KB, 979x514px) Image search: [Google]
hww.png
15KB, 979x514px
>>56283116
About what?
>>
>>56283138
>Microsoft (R)

Captcha is "tratorria"
>even captcha knows
>>
>>56283138
>windows
>microsoft C/C++ compiler
You really should move to a better OS.
As for the compiler, it's really shitty, please move to gcc or clang. Any compiler would warn you about the use of gets. Also the MS compiler will teach you some very bad habits.
>>
>>56283109
${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}

>>56283135
https://github.com/nv-vn/Malfoy
>>
>>56283150
What is wrong with my current set up? I've used Windows all my life, I don't know anything about Linux
>>
>>56283156
>all those constructors of type
why?
>>
>>56283156
This is really nice, I am jealous of you. My lisp is nothing like that yet and I don't know OCaml ;_;
>>
>>56283156
Why your github name isn't invoke?
silly doggo
>>
File: hww2.png (24KB, 979x514px) Image search: [Google]
hww2.png
24KB, 979x514px
>>56283150
>>56283160
This works too, I don't even need to say how big the string is going to be like my book said
>>
>>56283156
What would you suggest for someone wanting to start learning Idris and Ocaml?
>>
File: riYkjFt.png (25KB, 723x412px) Image search: [Google]
riYkjFt.png
25KB, 723x412px
Anyone care to explain why this behaves this way?

My only theory is that the method allocates memory for the return whether or not it's actually used by the caller in any way, where as the delegate does not.

But that's a completely wild stab in the dark.
>>
>>56283267
>= i => i <=
>>
>>56283276
*tips fedora*
>>
File: 1319396458001.jpg (12KB, 177x278px) Image search: [Google]
1319396458001.jpg
12KB, 177x278px
>>56283276
>>
>>56283138
Lmao you made a Hello World program! Congrats!
>>
>>56283330
Thanks I think I'm gonna stick with it and get better
>>
>>56283330
Are you fucking retarded?
That's clearly not hello world, it repeats user input.

Do you not even understand hello world? Wow
>>
>>56283343
>>56283346
Lmao
>>
>>56283169
because im a dumdum and can't into good type inference. the only time i've implemented HM before was a few years back and i basically copied it out of a book so i ended up having to relearn all of it (poorly)
>>56283174
don't be jealous, this has taken me way too long to get to this point and i had to ask people for a lot of advice along the way.
>>56283187
woof &^(
>>56283245
learn OCaml first cause it's weird starting out in a pure functional language (IMO). also, to get the most out of Idris it helps to get a good feel for the limitations of OCaml's type system first, so I suggest experimenting with a lot of the recent changes to the type system (GADTs, and open types in particular, and things like polymorphic variants, the object system, and first-class modules are also quite powerful). that way, you'll reach a point where you can kind of be in the right mind-set to start writing more powerful type-level proofs with Idris

as for learning the two languages, i pretty much learned (the cores of) both languages from their official tutorials, but you kind of have to look around a lot more to get to the more advanced topics. for OCaml real world ocaml is great for actually making use of the language and using features well. the Jane Street blog is really helpful with some of the newer additions to the language. for Idris, i don't really recall how i learned it but i didn't really know Haskell very well at the time and i think i honestly found it easier than the Haskell books that i had tried reading
>>
>>56283346
>it repeats user input

Holy fuck, this guys a genius!!
>>
>>56283361
Do you happen to know Rose and/or Lucy?
>>
Jeg foler meg dårlig at mannen min kan ikke drikke så mye vin som meg uten å kaste opp. Hva kan jeg gjore for å hjelpe ham?

Jeg tror at jeg har drukket for mye alkohol i kveld.
>>
>>56283361
Thank you! Is there any irc that you frequent? I am asking because I would really like to talk to you more.
>>
>>56283381
David?
>>
>>56283381
yes :3
>>
>>56283108
>I clearly did, please see 56282924
You merely stated something there.
>there might as well exist an ABI that contains informations that most common ABIs do not, such as included headers and break when a new <one> is added
Such an implementation is ridiculous and wouldn't exist.
There is nothing special about "including headers". It's literally a copy-paste of one file into another.
There is absolutely no difference for a compiler if I do
int printf(const char *restrict, ...);
int fprintf(FILE *restruct, const char *restrict, ...);
// and so on for all of stdio.h

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

vs
#include <stdio.h>

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

yet with your stupid example, the ABI would somehow be different.

>It did break realloc (behaviour changed between C89 and next standards, causing many programs to use IDB/UB)
It just appears that realloc was changed to allow implementation that support 0-length allocations. But I guess that would break programs that expected it to free the pointer.
>>
Du må lære seg Scheme, Haskell eller Idris, enten du vil eller ikke

Jeg kan ikke gjore CAPTCHAer i dag
>>
>>56283402
kinda on rizon#code a lot of the time but i haven't really been watching it lately. ill show up on rizon#λ when i remember too (but that's not very often). mostly i just use telegram. if you've got an account im @nv_vn
>>
>>56283408
I am even more jealous now ;_;
>>
>>56283365
Compared to >>56283330 maybe
>>
>>56283438
who is Rose and Lucy?
>>
File: wanna.png (10KB, 390x413px) Image search: [Google]
wanna.png
10KB, 390x413px
>>56283443
>>
>>56283409
>Such an implementation is ridiculous and wouldn't exist.
What's stopping it?

>There is nothing special about "including headers". It's literally a copy-paste of one file into another.
Sure, but what is stopping it from being included into an ABI? Nothing.

>yet with your stupid example, the ABI would somehow be different.
Nothing wrong with my example friend, I simply wanted it to be easy to understand for a baka like you.
>>
HVILKE PROGRAMMERINGSSPRÅK BRUKER DERE
>>
>>56283437
What's your IRC nick? Do you accept pms?
>>
>>56283452
LUCY ER EN STOR DRITTSEKK
>>
>>56283480
>What's stopping it?
Practicality.
I'm pretty sure the standard isn't too hung up about implementations that don't even exist and aren't even feasible.
>>
NEW THREAD BAKAS

>>56283506
>>
>>56283502
>Practicality.
Maybe
But it's a valid ABI, thus making your previous claims incorrect.

>and aren't even feasible
This is wrong.
>>
>>56283497
just nv. and yeah i accept PMs
>>
>>56283541
nv

Jeg liker deg

Kan jeg lage barn med deg?
>>
>>56283552
<3
>Kan jeg lage barn med deg?
ja lol
>>
>>56283569
De skal hete Emily ('ML-ey') og Haskell.
>>
>>56283138

MSVC only fully supports C89, despite two standards for C having been created since then -- C99 and C11. If you had used C99 or C11, your compiler would likely warn you that gets is deprecated (as of C99) or no longer exists (as of C11). There's a reason it's deprecated too -- gets() does not know how large of a buffer it is being passed, and therefore, a user can always produce a string that will overflow that buffer.

>>56283160

Even if you're going to use Windows, there is a better compiler setup. It's called MinGW-w64. It's a port of GCC, which is used on practically every platform other than Windows, not just Linux. There's also Clang, although its support on Windows is not the greatest compared to other platforms. Personally, the only compiler I can recommend any Windows user ever use is the MinGW toolchain and its variants.

The following are two distributions of MinGW-w64. Pick one and install it. Then cease using MSVC immediately. Also, cease the use of the gets() function entirely. If you the function isn't passed the length of the buffer as an argument, it cannot be trusted to figure that information out itself.

https://sourceforge.net/p/msys2/wiki/Home/
http://tdm-gcc.tdragon.net/
>>
>>56283595
Pappa, hvor er mamma?
>>
>>56283595
>he doesn't use Visual Studio while developing on Windows
What's it like missing out on the best IDE in existence (and the only reason to ever program on Windows in the first place)?
>>
>>56283626
You realise you can use Visual Studio and GCC right?
>>
>>56283652
It breaks the debugger though, which is 90% of the reason to use Visual Studio in the first place (the other being Intellisense)
Thread posts: 319
Thread images: 31


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