[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: 332
Thread images: 29

File: cppmap3.jpg (3MB, 3840x2555px) Image search: [Google]
cppmap3.jpg
3MB, 3840x2555px
What are you working on, /g/?

Old thread: >>59110597
>>
sml or ocaml?
>>
Reposting because I'm an attention whore. Rate my fizzbuzz:
    DECLARE N INTEGER
DECLARE F INTEGER
DECLARE B INTEGER
N = 0
F = 0
B = 0
FB: IF (F = 3) THEN PRINT("FIZZ");
UNLESS (B = 5)
INWHICHCASE PRINT("FIZZBUZZ");
ELSE UNLESS (B = 5)
INWHICHCASE PRINT("BUZZ");
PRINT(N)
DON'T UNLESS (F = 3) F = -1;
DON'T UNLESS (B = 5) B = -1;
F += 1;
B += 1;
N += 1;
DO UNLESS (N = MAX);
REPEATFROM FB;
>>
>>59116218
All programming is trash.
>>
In this thread, we continue discussing why Scheme is superior to every other vermin-tier language. Scheme brothers, unite.
>>
>Procedural: My code is completely unmaintainable spaghetti, but at least it gets shit done.
>Object-oriented: I have thousands of lines of code that don't do anything, but at least it looks nice.
>Functional: Nobody can read my code and it doesn't get anything done, but at least I get to feel smug about it.

does this sound about right, /g/?
>>
>>59116253
t. mac toddler
>>
Dataflow programming is the future
>>
>>59116278
>FP is somehow not a subset of either procedural or POO
not even close.
>>
>>59116278
b r a i n l e t
>>
Please, post a working version of code.
The purpose is to read some lines, and after the EOF, print those, which are more than 30 chars long.

#include <stdio.h>

#define ARRAYMAXLIMIT 2000
#define INPUTMAXLIMIT 500
#define CHECK 30

int inputline(char line[], int lim);
void copy(char to[], char from[], pos);


main ()
{
int len;//lenght of array
int lim;
char line[INPUTMAXLIMIT];
char overall[ARRAYMAXLIMIT];

while ((len = inputline(line, INPUTMAXLIMIT)) > 0) {
if (len > CHECK)
copy(overall, line, len);
}
printf("%s", overall);
return 0;
}


int inputline(char s[], int lim)
{
int i, c;

for (i=0; i<lim-1 && (c=getchar()) != EOF && c!='\n'; ++i)
s[i] = c;
if (c=='\n') {
s[i] = c;
++i;
}
s[i] = '\0';
return i;
}

void copy(char to[], char from[], int pos)
{
int i;

i = 0;
while ((to[i] = from[i+pos]) != '\0') {
++i;
}
}

>>
File: Screenshot_2017-02-25_14-15-36.png (83KB, 1076x797px) Image search: [Google]
Screenshot_2017-02-25_14-15-36.png
83KB, 1076x797px
Oh god I have no idea what I'm doing, someone please tell me how to lex
>>
I'm trying to parse strings in a file and cleanse punctuation:

for (i=0; wordcheck[i]; i++)
{
wordcheck[i] = tolower(wordcheck[i]);
wordcheck[i] = strtok(wordcheck[i], ",.?");
}
fseek(fp1,0,SEEK_SET);




when I implemented the code
tolower
everything worked perfectly fine, however when I use strtok it produces compiler warnings and crashes when executed:

main.c
main.c(86) : warning C4047: 'function' : 'char *'
indirection from 'char'
main.c(86) : warning C4024: 'strtok' : different t
actual parameter 1
main.c(86) : warning C4047: '=' : 'char' differs i
ion from 'char *'
>>
11th for Typed Racked is pretty fucking neat.
>>
>>59116365
is the type system actually good though?
>>
>>59116218

float Q_rsqrt_distance(glm::vec3 vector1,glm::vec3 vector2){

// remove this and it will not be reliable{
float value = abs(
(vector1.x-vector2.x) * (vector1.x-vector2.x)+
(vector1.y-vector2.y) * (vector1.z-vector2.y)+
(vector1.z-vector2.z) * (vector1.z-vector2.z)
);
if(value <= 0.0f){
printf("value: %f\n",value);
}
// }
return Q_rsqrt(
abs(
(vector1.x-vector2.x) * (vector1.x-vector2.x)+
(vector1.y-vector2.y) * (vector1.z-vector2.y)+
(vector1.z-vector2.z) * (vector1.z-vector2.z)));
}


C++11 compiled with g++
.x,.y,.z are floats
>>
>>59116338
Don't use that language to do it. Use something higher level.
>>
File: FB_IMG_1488049973515.jpg (184KB, 1080x1080px) Image search: [Google]
FB_IMG_1488049973515.jpg
184KB, 1080x1080px
Anyone here know if this riddle is based on coding?
>>
>>59116434
???????
>>
>>59116276
Scheme is truly a language for the white man.
>>
>>59116321
First of all, I would suggest reading up on fseek() instead of caching all those lines. You can skip back and forward like that easily.
>>
>>59116365
>>59116398
It's a good type system, but not practical because few libraries use it. It's the same problem as with Typed Clojure, except Clojure has more libraries.
>>
>>59116536
I really want to accomplish the task with the knowledge I've been given and nothing more than that, otherwise there is not point in exercises and it would have been better to switch to Python to do this.
I want to learn.
>>
what do haskellfags think of how functional programming will be remember as nothing more than a way to save space in java?
>>
>>59116577
Racket is still fairly new, they only just got their package manager ironed out a few months ago, right? Most of the newer libraries I've seen use typed racket and I'm pretty sure most of the built in libraries use it.
>>
>>59116608
>that English
>java
I don't even know which "country" this post was made from
>>
>>59116404
Why do you calculate value twice?

Also make sure to compile that with -O3, I think gcc will vectorize the whole thing for you.
>>
>>59116652
triggered
>>
>>59116321
Here, my friend, is a working version of code.
(do ((l (read-line t nil 'eof) (read-line t nil 'eof)))
((eq l 'eof))
(when (> (length l) 30)
(print l)))
>>
>>59116697
kys, my friend.
>>
Another fucking SPA web app that I make for a living.
>>
C is the best thing ever to happen to humans
C is love
C is life
>>
>>59116620
Racket (formerly PLT Scheme) is pretty old. It just never took off as a practical language. A package manager might help but I wouldn't bet money on it.
>>
>>59116747
Fair enough, it is about as old as python/java. Seems to me that it's only just started to really take off in the past 7 years
>>
>>59116620
Came out 1994.

The fact that the packages aren't called 'Rackages' (or some similar pun) is a constant disappointment to me.
>>
Do any of you guys take amphetamine?
>>
>>59116792
I did at the time. Didn't help programming, desu
>>
>>59116782
>The fact that the packages aren't called 'Rackages' (or some similar pun) is a constant disappointment to me.
You are disgusting.
>>
File: scientist-having-headache.jpg (11KB, 250x250px) Image search: [Google]
scientist-having-headache.jpg
11KB, 250x250px
>studying for 8086asm exam
>its a write a matrix function question
>>
>>59116818
You fucking love it.
>>
Where do I buy an APL keyboard?
>>
>>59116352
Anybody got any ideas for this one?
>>
>>59116839
floating point?
>>
>>59116792
nah, we take spironolactone
>>
>>59116817
I'm planning on buying some this summer, and using it to aid me in learning programming. Tips?
>>
File: 1484836659147.png (178KB, 500x500px) Image search: [Google]
1484836659147.png
178KB, 500x500px
Is there an algorithm for creating an infinite amount of PNGs? If so, would it technically be able to produce screenshots of anime which haven't even been created yet?
>>
>>59116890
>Tips?
Don't.
>>
>>59116892
https://en.wikipedia.org/wiki/Infinite_monkey_theorem
>>
>>59116885
>spironolactone
>is a medication that is primarily used to treat fluid build-up due to heart failure, liver scarring, or kidney disease.
wat? is it a nootropic also?
>>
>>59116890
Just use high dosages of caffeine. It's pretty good for beginner programmers.
>>
File: 1483494811350.gif (314KB, 512x384px) Image search: [Google]
1483494811350.gif
314KB, 512x384px
>>59116907
look at this guy
>>
>>59116902
Time isn't an issue for me.
>>
>>59116890
It won't help. You'll want to go outside and smash someone's face, you won't learn anything.
>>
>>59116892
Not only that, but it would make every single frame of every anime anyone could ever make, as well as pornographic versions of every single anime.
>>
>>59116940
What about microdosing
>>
>>59116958
> microdosing amphetamine
It doesn't work like that. If you don't take it all, you're probably dead.
>>
>>59116942
Now I just have to finish my time machine written in Haskell and I'm all set.
>>
File: aika_face.png (55KB, 161x284px) Image search: [Google]
aika_face.png
55KB, 161x284px
What's a stable way of implementing the hyperbolic cotangent in C++ for small increments of the argument? Is 1/tanh(x) better? Or cosh(x)/sinh(x)?
>>
>>59116792
I used to, did help with programming (concentration, not motivation) but eventually quit because it really cranks up my anxiety levels.
>>
I'm learning Python and coming from Ruby I can't say it has been a pleasure so far. Either way here's something that confuses me a bit:

def double_first(n):
n[0] = n[0] * 2

numbers = [1, 2, 3, 4]
double_first(numbers)
print numbers


Here a list is passed as the argument to the function. But when the function uses a parameter, it is just the same object??? The code above outputs [2,2,3,4], meaning that the function modifies the original array despite it being the parameter "n" being modified.
>>
>>59117071
You pass a reference to a list in to the function. It's the same object but a different reference to it.
>>
>>59116892
(number of colors that exist)^(amount of pixels) = number of possibilities

you could do it with nested for loops :-)
>>
>>59117094
ok that seems like something to keep in mind as not to accidentally modify an object when you pass it into a function
>>
>>59116321
#include <tcl.h>

int main(int argc, char const *argv[])
{
Tcl_Interp* tcl_interp = Tcl_CreateInterp();
return Tcl_Eval(tcl_interp,"\
puts [join [lmap s [split [read stdin] \\n] {\
if {[string length $s] <= 30} continue else {lindex $s}\
}] \\n]\
");
}
>>
>>59116278
>Procedural: My code is completely unmaintainable spaghetti, but at least it gets shit done.
Assuming you've just started learning, yes.

>Object-oriented: I have thousands of lines of code that don't do anything, but at least it looks nice.
Yes

>Functional: Nobody can read my code and it doesn't get anything done, but at least I get to feel smug about it.
Yes

>Back to procedural
Eventually you realise that modules with free functions is a superior programming model to OO, and you just write procedural code but with better structure than before.
>>
>>59117016
>C++
Didn't read past this point.
>>
>>59117118
>FP is somehow not a subset of either procedural or POO
opinion discarded.
>>
>>59116278
2 out of those 3 are unmaintainable. Doesn't matter if it takes 5 times the time to write it, if it takes 1/100th the time to maintain it.
>>
File: drugs for programming.png (274KB, 445x629px) Image search: [Google]
drugs for programming.png
274KB, 445x629px
>>59116908
>>
not entirely programming related but I need to set up PXE so I can boot and debug my own kernel in virtualbox.
how do I get started?
>>
>>59117160
is this some new reddit meme?
>>
File: IMG_4327.jpg (172KB, 1024x1024px) Image search: [Google]
IMG_4327.jpg
172KB, 1024x1024px
>>59117104
C-could I generate the best porn that will ever exist?

Asking for a friend...
>>
>>59116792
Used to. It does help temporarily but the price is too high.
>>
>>59117227

Yes.

We love it.
>>
Is there any reason for me to not focus on the entry level stuff like java and various C versions? The way I see it I'm rarely going to be able to choose what I use in a job so it makes sense I should be able to make things work even in languages that are a bit more difficult to manage.
>>
>>59117275
>various C versions
what did he mean by this?
>>
>>59117227
Yes, do you like it?

>>59117232
It would generate every possible image so yes, but since the best porn would be at least 4k resolution and 32-bit colour, you're looking at 3840*2160*32=265,420,800 possible images. Finding the one you want would be pretty difficult desu
>>
>>59116907
It's a fucking diuretic and antihypertensive that occasionally causes gynaecomastia.

Sensible traps take actual hormones, not that shit.
>>
Switch and case statements are the devil.

What do you want? A jump table? A branch chain? Neither somehow? Well, leave that to the optimizer! Semantically encoding assembly instructions is for the dogs! C is an APPLICATION PROGRAMMING LANGUAGE, nerd.

"I don't care that your case values are sequential and that you are running this in a tight loop, I'm not gonna generate a jump table!" -- GCC v4.9+
>>
>>59117044
Chew nicotine gum.

If you want something stronger, get that oromucosal nicotine spray and put half a dozen spritzes under your tongue. Hits you like a hammer.
>>
>>59117337
Isn't it
>32^(3840*2160)
?
>>
>>59117375
Yes, my mistake
>>
>>59117375
>>59117393
(2^32)^(3840*2160)
>>
>>59117342
Inline assembly rang, it says you never called it.
>>
File: 146669968445.jpg (3MB, 1920x1883px) Image search: [Google]
146669968445.jpg
3MB, 1920x1883px
>>59116218
Please don't disrespect my heritage by culturally appropriating our national icon and attaching it to such an awful programming language
>>
>>59117454
Is that our national icon? I thought it was Michael Palin or something.
>>
>>59117401
Maintaining a port-specific file for each combination of compiler and architecture doesn't sound all too fun.
>>
>>59117475
It's Britannia you uncultured fuck
>>
In C++, how do I return a pointer to an object from a function (the object being created in the function body) without returning a dangling reference?
>>
>>59116218

laravel site. Is taking forever to learn the framework properly. On my own, so feel like I have to learn all the information in the world.
>>
>>59117507
>In C++
that's where i stopped reading, buddy
>>
>>59117454
Your heritage has been disrespected left and right, and this is what you object to?
>>
>>59117522
>implying i haven't objected to anything else
>>
>>59117486
Didn't you like my 'call'ing pun? :(
>>
>>59117507
>object
Stopped reading right here.
>>
>>59117507
return a shared_ptr.
>>
I'm kind of stuck right now and some help would be appreciated.
I'm trying to create a prompt that only pops up if a variable has a certain value, and if it doesn't have that value then the prompt doesn't show up.

 
var tax = prompt("Do you pay state tax? (yes/no)")
if (tax == "yes") {
var stateTax = prompt("How much?")
if (stateTax >100 || <0) {
alert ("incorrect value");
}
}

so basically if you answer yes to the tax question, I want another prompt that shows up asking how much the tax is. Any guidance would be appreciated.
>>
>>59117522
You'll find the British don't really care when their heritage is disrespected.

It comes from not being a histrionic infant nation :)
>>
>>59117550
>You'll find the British don't really care when their heritage is disrespected.
Yes. Because they don't have any.
>>
>>59117547
Well, you can't use or like that. It needs to be
if (stateTax > 100 || stateTax < 0) {
>>
>>59117589
thanks, I fixed that part but it still doesn't load.
I don't think I'm properly implementing the second prompt, but I'm not sure how to fix it.
>>
>>59117573
Exactly. They have several millennia of being overrun by whoever happens to come along, and still give no fucks. Most of their heritage consists of painting themselves blue and running screaming down the nearest hill.

On the other hand, that's far preferable to being a 250 year old pubescent mess that screams bloody murder as soon as someone burns a flag.
>>
>>59117615
>On the other hand, that's far preferable to being a 250 year old pubescent mess that screams bloody murder as soon as someone burns a flag.
True.
>>
Would taking a tool like https://github.com/tabulapdf/tabula-java, and building a front-end similar to https://www.youtube2mp3.cc/ in order to make money be legal under the GPL? Is it ethical?
>>
>>59117610
Just tried your snippet on my machine, it seems to be working. You are comparing a string to a number though. You could change line three to this:
var stateTax = Number(prompt("How much?"));
>>
>>59117610
>;
missing semicolons?
>>
>>59117659
That tool is MIT but yet. There's nothing in the GPL that prevents you from making money selling software.
>>
>>59117516
>>59117545
Thanks for sharing
>>
>>59116733
C is the reason why there are so many bugs in Linux kernel
C is has shitty async sypport
C is from the 80's, holds us back to the 80's
C is full of undefined and unspecified behaviors

C stands for cancer and needs to die
>>
>>59117698
>C is from the 80s
I'm not a fan, but honestly.
>>
>>59117226
>PXE
scratch that, a boot floppy image is probably easier
now how do I mount a floppy image file in msys2 so I can copy my kernel to it?
>>
>>59117698
>C is from the 80's means bad
>computers are based on telegraph tech
>this fag doesn't know
>because he can't C anything
>>
Currently learning C# in Unity~
>>
>>59117659
It's legal. The ethics you'll have to judge for yourself.
>>
>
--target=x86_64-w64-mingw32

who the hell came up with this retarded bullshit?
>>
Asking again because I don't think I got any responses last time. I'm doing babbys first CS course with java right now, should I try doing the projects in another language as well just for the experience?
>>
>>59117941
me
>>
>>59117953
well fuck you then.
>>
>>59117589
>>59117672
>>59117681
thanks guys I was able to fix it. It was just a typo somewhere and I was using or incorrectly.
>>
>>59117947
Yeah, try learning a language that is very different than java. See what programming under an entirely different paradigm is like. See how languages that descended from Pascal are like compared to languages descended from lisps. See what other C-family langauges are like. Maybe get really wild and do something in Prolog
>>
>>59117947
>java
stopped reading right there.
>>
>>59118011
>.
Stopped reading right there
>>
>>59118004
What Pascal languages would you recommend? I already have a tiny bit of experience in python from seventh grade, and some C++ from personal time so those would be easy enough for something close.
>>59118011
niceme.me
>>
def generate_X_y():
X = []
y = []
for i in range(10000):
X.append([1, 50 + randint(1, randint(40,60)), 2*randint(1, 90), 1.4*randint(1, 10), 3**randint(1,3)])
if X[i][1]*X[i][4]/2.0<X[i][2] + X[i][3]:
y.append([0])
else:
y.append([1])
return scale_and_normalize(X), y

logistic regression on the above data set - X is training set matrix, y is output

i use the same routine to generate both a training and a test set
i use my own framework i made to learn

on this particular set my classifier just minimizes the error by calling everything a positive example - a problem
>>
File: PLchart.png (548KB, 2520x1554px) Image search: [Google]
PLchart.png
548KB, 2520x1554px
>>59118091
I'm partial to Ada myself.
>>
>>59117947
If you are new to programming I would just recommend that you focus on getting good at Java. Really hammer in the beginning concepts. Don't worry about learning a new language or paradigm yet, mastering the basics are the most important part.
>>
>>59118192
Looking at that chart, I hadn't realized ICON was so far removed from most other languages.
>>
I've edited my code just a bit. It should collect all the lines into a whole[], with '\0' of line[] being replaced by first char of next line[] in while loop.
I really want to do it without any extra things, just those I may get from 1st and 2nd chapters of K&R.
Still does not work though, most likely the problem is in copy().

#include <stdio.h>
#define MAXLIMIT 1000

int inputline(char line[], int lim);
void copy(char to[], char from[], int pos);


int main(void)
{
char line[MAXLIMIT];
char whole[MAXLIMIT];
int len;
int offset;

offset = 0;
while ((len=inputline(line, MAXLIMIT)) > 0){
offset += len;
printf("\n\tdebugging %s", line); //debugging, print gotten line
copy(whole, line, offset);
}
printf("%s", whole);
return 0;
}

int inputline(char line[], int lim)
{
int c, i;

for (i=0; i<lim-1 && (c=getchar()) != EOF && c!='\n'; ++i)
line[i] = c;
if (c=='\n') {
line[i] = c;
++i;
}
line[i]='\0';
printf("\n\tdebugging %3d", i); //debugging, print iterator position (which is line's length - 1)
return i;
}

void copy(char to[], char from[], int pos)
{
int i;

i=0; //next two lines are to be sure if while has started
to[i+pos] = from[i];
++i;
while((to[i+pos] = from[i]) != '\0')
++i;
}

>>
>>59118091
Ada is top notch and I hear Delphi is good (but most people say Ada is better designed, which it probably is)
>>
>learning more and different languages matters and has significant benefits

someone explain why i shouldn't regard people who think that as bad at programming and/or not getting it
>>
>>59118502
9/10.
>>
>>59118515
i think you are someone who does the same things in different languages thinking he's actually learning anything of value and not just repeating things you already know how to do
>>
>>59118502
Different languages are all slightly different expressions of computation. I think to truely study and understand computation one should look at things from as many different angles as possible.
>>
>>59118557
yeah, there are some things to be learnt
i just think your time will be better spent learning something else in 95% of the time
>>
>>59118556
3/10.
>>
why are some classes in java returning a new instance and some return an updated version?
LocalDate for example.
wtf oracle
>>
does anyone know how to use this?
>>>https://github.com/Microsoft/MIEngine/
>>
Programming newfag here. Some anons here recommended I read "How to Design Programs: An Introduction to Programming and Computing by Matthias Felleisen & Robert Bruce" in one of these threads for better understanding core concepts & general working knowledge of programming. I finally have some spare cash and am about to purchase a copy, I just wanted to double-check here first to see if anyone has any other suggestions or if it's a solid book to read and I should go ahead and buy it.

I chose C++ as my first language and am working (slowly) through Programming Principles and Practice using C++ by Bjarne Stroustrup, and regularly post stupid beginner questions in these threads, if anyone is curious.
>>
Daily Reminder

OOP is the only way to program
>>
>>59118877
this
>>
>>59118851
my suggestion is try to find the book for free
>>
>>59118877
One day you'll understand what is fp.
>>
>>59116218
>he programs for free
>>
>>59118851
Here you go. The second edition is a great improvement over the first:

http://www.ccs.neu.edu/home/matthias/HtDP2e/

Don't use C++ as your first language; that way lies only pain.
>>
File: 37faff7b0851f401ded7f9851b844452.jpg (572KB, 811x1200px) Image search: [Google]
37faff7b0851f401ded7f9851b844452.jpg
572KB, 811x1200px
>>59116218
What's the difference between SSL_get_error and ERR_get_error in OpenSSL?
I believe the former belongs to libssl and the latter to libcrypto, is this correct?
Do I also need to call ERR_clear_error before subsequent SSL_* calls or only for ERR_* calls?
>>
>>59118930
>fp
stopped reading there
>>
>>59119052
You didn't miss much
>>
>>59119052
FYI, if you read up until 'fp', you read his whole post.
>>
>>59119052
>there
stopped reading right there
>>
>>59118945
It's best to learn it first, so that you can acquire Stockholm syndrome and blindly defend it
>>
Any tips on how to deal with macro pollution?

I want to name a method DrawText but i can't because fucking d2d1.h that i need to include has a macro predefined that replaces DrawText with something else.
This kind of shit keeps happening all the time when working with Microsoft APIs.
>>
>>59119015
I'm currently stumbling through OpenSSL, so take this with a grain of salt

I think you are right in thinking SSL goes to libssl and ERR goes to libcrypto. What are you working on? Have you managed to get AES working?
>>
<$> <*> *> >> >=> <=<

Am I missing something, or did the Haskell devs pick arbitrary symbols as operators?
>>
>>59119144
I'm writing an IRC client/bot, pretty sure I have established an encrypted connection since I can see the TLS negotiation in wireshark and my SASL authentication works like a charm.
The code's here: https://github.com/ez3chi3l/tallis.git
Still not sure if I am doing full-depth cert chain verification or hostname validation, or if not, how to do so.
>>
>>59119190
no

>monads
>>=
>>
>=>

>applicatives
<*>
*>

>functor
<$>
$>
>>
>>59119230
why the hell are you writing an IRC bot in C??
>>
>>59119245
But why does $ represent functors?
>>
>>59119255
http://strictlypositive.org/Idiom.pdf
>>
File: 1477836894134.png (194KB, 498x430px) Image search: [Google]
1477836894134.png
194KB, 498x430px
>>59119253
THAT'S WHAT THEY ALL SAY BUT FUCK EM
>>
Alright I'm serious. As someone who is bad with languages, what's the simplest but most effective way to get into programming? Any website? Which language to start with? Etc
>>
>>59119255
>>59119275
⊛ = <*>
in fact try this
https://hackage.haskell.org/package/base-unicode-symbols
>>
File: 1462666496179.jpg (57KB, 637x685px) Image search: [Google]
1462666496179.jpg
57KB, 637x685px
Is anime a function?
>>
>>59119322
>simplest but most effective way to get into programming
lol
>>
>>59119347
a mental illness actually
>>
>>59118929
I like having an actual book to bring with me to places, but that's a fair point- I should read a bit of it online to see if it's something that I'd be interested in reading.
>>59119015
Cool, thanks for the link. I'll probably end up buying it either way, I'm a bookfag and enjoy having a physical copy, but I bookmarked that shit nonetheless.

As for C++- it's too late for me, I'm already balls-deep in vectors and Tokens, go on without me boys.
>>
>>59119322
It's got nothing to do with languages. Syntax will come from necessity. There is no "simple and effective" way. You hack shit together, read, program, and repeat for years, and you will start to know enough to get what you want done whether it be a job or a hobby. Pick a language, probably something procedural so you get an idea of how computers actually work by the hardware, and you learn how to implement concepts in it, you write functions and reinvent the wheel, you figure out something you want to write and you try it.
>>
>>59119322
lpthw by zed shaw
not because of its contents so much, but it teaches you to use the terminal and have a text editor and not use some bullshit ide

and then online courses uploaded by universities for free on the internet
>>59119347
no
>>
>>59119377

>>59118945
I meant to reply to this. I have autism.
>>
File: Black_Sun_2.svg.png (80KB, 1024x1024px) Image search: [Google]
Black_Sun_2.svg.png
80KB, 1024x1024px
>>59119323
>>59119275
It's a bit far fetched, but then again: it's Haskell.
>>
>>59119376
A function is a mental illness?
>>59119392
Why?
>>
>>59116276
>Scheme, the dialect that was given up by his creator to create CL.
>>
>>59119415
qed
>>
>>59119347
No, just a mistake.
>>
>>59119322
Lose your sanity. This is the only way.
>>
>>59119377
i was the same with paper books, but i got used to ebooks after i started learning programming
now i read and even write almost everything on my laptop
>>
>>59119377
I was mainly linking that because I don't think you can buy hard copies of the second edition, and the second edition is admirably improved over the first.
>>
>>59119415
i don't know what the math definition of a function is, but my gut feeling tells me anime is not a function
>>59119447
>le programming is arcane mystic art for austists (hehe we call ourselves autists, so cool)
>>
File: solve (7).png (771KB, 1366x768px) Image search: [Google]
solve (7).png
771KB, 1366x768px
>>59119347
Anime is math
>>
>>59119456
Yeah about that, I don't actually have a laptop, otherwise I'd probably do the same. Though I just got my tax return, so I've been looking through the ThinkPad threads and am considering buying a relatively cheap one, so that might change soon.
>>59119462
I did not know that. That's odd that they'd bother making a second edition and not publish a physical copy. In that case, would you recommend against buying the first edition at this point? Is it too outdated?
>>
>>59119323
What's a good font for this?
>>
>>59119475
Keep projecting.
>>
>>59119538
i don't know
>>
>>59119530
>In that case, would you recommend against buying the first edition at this point? Is it too outdated?
I have been trying to persuade to just read the second edition online for a few weeks now.
>>
>>59119557
programming is ez
>>
File: 1471976744998.gif (420KB, 616x338px) Image search: [Google]
1471976744998.gif
420KB, 616x338px
>>59119322
In my experience most people learn through immersion, typically they are obsessed with problem solving, and so they end up going on these long and perilous journeys to find the solutions to a given problem such as implementing a particular feature etc.
So the point here is that necessity is the mother of invention; I know programming looks cool and many feel inspired to do it by that alone, but it is at its core a utilitarian effort. So definitely come up with some ideas, don't try to come up with just easy ideas though. Do this, start one ambitious and difficult project, and at the same time one small project. You will inevitably finish the small project first, when you do, start another, and another and another, until the big project is finished. Then do this for each language you want to learn.
This way you will solve a diverse set of small implementation-related problems while at the same time grinding on a larger software design problem.
As for what language to learn first, in my humble opinion it does not matter, the faster you learn your first language the faster you can start on the second one.
Just don't skip the big ones, it pays to know C++ and python and javascript regardless of occupation or domain of expertise.
>>
>>59119538
Fira Code
>>
>>59119379
>>59119392
>>59119447

Welp. Alright. I was originally a Comp sci major but the department at my university is so outdated, mostly dominated by adjunct professors copying out of a textbook that I lost interest after the semesters and never went back. Figure it'd be easier to teach myself Python or C.
>>
they key to enjoy programming is start very simple small projects and build more complex ones as you go
>>
>>59119849
and wear skirts
>>
>>59119877
Anime is necessary but traps are heresy.
>>
>>59119877
This, and get a toy that vibrates whenever your code bugs out
>>
Can anyone tell me why the code I wrote here doesn't strip the punctuation out of the string "wordcheck"?

            int len = strlen(wordcheck);
int p = 0;
printf("%d, %s", len, wordcheck);
for (i=0; wordcheck[i]; i++)
{
if (! ispunct(wordcheck[i]))
{
wordcheck[p] = wordcheck[i];
p++;
printf("%p", p);
}
}
>>
>>59119943
cute
>>
>>59119943
Wouldn't that just make you degenerates want to write extremely buggy code?
>>
>>59120058
>wordcheck
has no punctuation
>>
>>59116892
Yea, haskell can do it (or any language with lazy evaluation)
>>
>>59120108
I can promise you that wordcheck has, it produces the following output

Unix. 
Later
C.
Not
systems,
>>
>>59120167
Did you terminate the string after you stripped the punctuation?
>>
>>59120072
only occasionally

i'd prefer running other anon's code so it's like they're doing it to me tho
>>
File: tokenized.png (29KB, 658x380px) Image search: [Google]
tokenized.png
29KB, 658x380px
In any statically typed language(with the ability to create new types), with no context, it is impossible to tell the difference between an identifier and a type. As I have started to write my tokenizer, should I group words based on keywords vs. non-keywords, or group them based on known keywords in categories, and treat types as identifiers to look up later?
>>
>>59120232
>it is impossible to tell the difference between an identifier and a type
false
>>
>>59117698
>C is has shitty async sypport
Name a systems language that has good async support

I'll wait
>>
>>59120232
You know the type based on its use in the syntax. What?
>>
All programming languages suck.
>>
>>59120232
do what haskell does

lowercase = variable
Uppercase = type
>>
>>59120301
>He doesn't know of the Ravenscar Profile ™®©
>>
>>59120289
>>59120303
If you were to take a single "word" from the source, and it were a struct in C, and had no context whatsoever, you couldn't tell if it were an identifier or type name.
>>
>>59120336
Why does that matter?
>>
>>59120232
>it is impossible to tell the difference between an identifier and a type
Nope.

Consider making a syntactic distinction between variable names and type names. For example, as another Anon has pointed out, in Haskell, types must start with a capital but variables must start with lowercase.
>>
>>59120353
It's just a small choice in how I was going to create tokens.
>>
>>59120181
Should I even need to do that? Should ispunct handle this for me?

I added

wordcheck[len - 1] = '\0';


under p++; and it just unbelievably fucked things up

It looks like there's no point using ispunct and I'm better just checking the last character using OR operands.
>>
>>59120391
Only move the \0 after you've got all the punctuation out of there. Otherwise you're making the string that you're still reading from end earlier.
>>
>>59120232
https://en.wikipedia.org/wiki/The_lexer_hack
>>
>>59120232
Why do you need to distinguish identifiers from types by its id? Why not make it part of the grammar?

class const
{
str herp
str derp
}

const saysomething(const str herp, const str derp)
{
const x = new const();
x.herp = herp;
x.derp = derp;

return x;
}


Even though the class is called const and const being a reserved keyword, it's still possible to distinguish which is meant at any given position with proper grammar rules.
>>
>>59120449
This makes the tokenizer more complicated. Right now what I'm going to do is have a list of keywords, and return a token with a keyword as the type, otherwise return a "word" or a value.
>>
>>59120476
I seriously hope you're not hard-coding the syntax of your language into the tokenizer itself, you fool.
>>
>>59120391
>>59120181
Thanks for the massive elif chain you prick
>>
File: 1483207498521.png (158KB, 666x607px) Image search: [Google]
1483207498521.png
158KB, 666x607px
>tfw too dumb for Rust
>>
>>59120476
Sounds unmaintainable
>>
>>59120498
Nope, just some basic checks to make parsing easier.
>>
>>59120498
You should "hardcode" keywords into the lexer, though.
Pushing that shit off to the parser seems pretty stupid.
for (int i = 0; i < 10; ++i)
ident ( ident ident = num ; ident < num ; inc ident )
>>
>>59120501
what? you can do this with a single extra line.
>>
>>59120517
the fucking borrower
>>
>>59120428
>>59120555
I couldn't work it out sorry
>>
File: dunecat.jpg (30KB, 439x392px) Image search: [Google]
dunecat.jpg
30KB, 439x392px
Employed Haskell programmer reporting in
>>
What's the best method for getting console input in C++? I usually do
string etc_string;
getline(cin, etc_string);
//parse etc_string
And have a specific parser depending on what I need to do/the string is.
>>
>>59116892

Neither does such an algorithm exist, nor can such an algorithm exist. A .png image has a maximum height and width of 4,294,967,295 pixels each. Any of those pixels may be a maximum of 281,474,976,710,656 colors and 65,536 alpha channels, for a total of 18,446,744,073,709,551,616 possible values per pixel.

Though the resulting number of possible .png images is exceptionally large, it is nonetheless finite.
>>
>>59120630
>Neither does such an algorithm exist, nor can such an algorithm exist.

I find this opinion interesting, as I was considering posting a version of his idea in Haskell.
>>
>>59120630
>nor can such an algorithm exist
prove it.
>>
>>59116892
well if you have a 20x20 pic greyscale pic that's 400 pixels, 256 values/pixel, so that's
256*256.... = 256^400

good luck
>>
>>59120623
You are my second favourite /dpt/ poster after akari-bbs anon
>>
File: screenshot 1.png (278KB, 1280x800px) Image search: [Google]
screenshot 1.png
278KB, 1280x800px
New chrome extension is working well
>>
>>59120707
lol
>>
>>59120705
>favourite
i think you meant "favorite" there, "mate"
>>
>>59120707
Brilliant!
>>
>>59120628
string input;
std::cin >> input;
>>
File: vomit.jpg (90KB, 650x650px) Image search: [Google]
vomit.jpg
90KB, 650x650px
>>59120731
How do people defend this language?
>>
>>59120555
I got it eventually thanks
>>
>>59120731
>>59120765
I forgot
std::string

Or just use
using namespace std;
>>
>>59120731
That reads until
iswhitespace(c)
is true, >>59120628 's reads until a newline.
good for space seperated data bot nothing else
>>
>>59120652

I do not know of any image formats that allow theoretically infinite numbers of colors and infinite dimensions. A format COULD exist using Variable Length Quantity encoding, but inevitably, one would run into the limits of the filesystem to be able to store large enough files, and of the word size of the instruction set in question to be able to hold the entire file in memory. With 128-bit RISC-V and a custom motherboard filled with some rather dense RAM, along with a customized filesystem on an array of hard disks, we could get pretty large though.

>>59120692

I just did. Finite dimensions * finite colors = finite number of possible .pngs.
>>
>>59120330
Other languages should be embarrassed of themselves, tbqh
>>
>>59120813
So I can just create all pngs instead of an infinite amount?
>>
File: 1453303517244.png (48KB, 336x280px) Image search: [Google]
1453303517244.png
48KB, 336x280px
I want to write a compiler for a C-like programming language.
I'm seriously considering using Haskell for it. Am I going to regret it?
What sort of bullshit will I get into when writing a non-trivial Haskell program?
I already have a somewhat basic understanding of Haskell.
>>
>>59120863
I'm currently writing my compiler in c++ and don't regret it too much.
>>
How do I make a type which is similar to this, but S can't contain itself while R can.
data TSR = T String | S [TSR] | R [TSR]
>>
File: 1486331158993.jpg (21KB, 314x400px) Image search: [Google]
1486331158993.jpg
21KB, 314x400px
id = [A-Z][a-zA-Z0-9-_]*

type = id

method = return_type method_name '(' parameters ')' '{' commands '}'

return_type = type
return_type = null

method_name = id

parameters = parameter ',' parameters
parameters = null

parameter = type id

commands = command ';' commands
commands = null

command = definement
command = initialization
command = assignment
command = invocation
command = return

definement = type id

initialization = type id '=' expression

assignment = id '=' expression

invocation = type invocation_body invocation_tail

invocation_body = '.' method_name '(' arguments ')'

invocation_tail = invocation_body
invocation_tail = null

return = 'return'
return = 'return' expression

arguments = expression ',' arguments
arguments = null

expression = 'true'
expression = 'false'
expression = 'null'
expression = [0-9]+
expression = [0-9]+\.[0-9]+
expression = '\'.*\''
expression = id
expression = invocation


Rate my syntax.
>>
someone teach me to program
>>
>>59116218
I'm been working with those books Humble Bundle keeps putting out.

Working through the lex & yacc one now. It's mostly pretty good, except it uses K&R C so it's probably outdated as hell
>>
>>59120887
>C++
Disgusting.
>>
>>59120813
>I do not know of any image formats...
It's true that the file format might be an issue, but you could certainly create an infinite collection of infinitely large images (using your own format spec) in Haskell.

You would simply have to take precautions to only attempt to display a finite area of an infinite image (which makes sense, considering you can only really use finite 'views' into codata).
>>
>>59120783
So what's the third option?
>>
>>59120831
Very easily.
>>
>>59120932
Only if you sit on my knee and wear thigh highs, anon.
>>
>>59120936
I personally think that c++ is an overrated thing to scream about, and that you really aren't going to change hearts and minds by just yelling about it.
>>
>>59120963
>overrated
stopped reading right there.
>>
>>59120961
I am 230 pounds I am pretty fat and muscular I don't think you'd like it
>>
>>59120908
data TSR = T String | S [TR] | R [TSR]
data TR = T String | S [TR] | R [TSR]


wat
>>
>>59120979
It's not his knee he really wants you to sit on.
>>
>>59120950
getline is what you want for unix-style data

unless it's whitespace-seperated, then the istream's
operator >>()
automatically parses it for you.
>>
>>59120985
so it's a trap?
>>
>>59120979
oh, nevermind, it might be better I do that part then, I'm more than 100 pounds lighter than you
>>
>>59120980
I've done something like this but it's complaining about multiple declaration of T, S and R
>>
>tfw to smart to use anything but Rust
>>
>>59120932
https://docs.oracle.com/javase/tutorial/
https://docs.python.org/3/tutorial/

either one is good for starting out, and then once you get the hang of programming without having to worry about memory management, it's a good time to branch into C/C++, and also a functional language, probably either Scheme(whatever the updated version is called) or Haskell. Functional languages aren't that useful in production code imo, but you still learn things that make you think differently
>>
>>59121001
Yes, and so is xe.
>>
>>59121035
which one of those will make me money the fastest

I am a brainlet
>>
File: FxyEY62.png (42KB, 846x592px) Image search: [Google]
FxyEY62.png
42KB, 846x592px
>tfw too smart for C++
>tfw learn Rust
>tfw too smart for employment
>>
Question: why would anyone use Go over D? D has most of the advantages that Go markets as its selling points, including faster compile times, GC, reasonably simple to use, outputs binaries instead of jars, etc etc. But unlike Go it isn't horribly crippled in terms of features.
>>
>>59121069
Nice filename, plebbitor.
>>
>>59121076
t. pythonista
>>
>>59121066
Python or Java.
>>
>>59121072
Simplicity is a feature.
>>
>>59121072
D is unstable, not production ready. Go is Google's language.
>>
somebody PLEASE post ruby's programming socks
>>
>>59121093
Are you sure you arent mistaken?
>>
>>59121069
>tfw too smart
>too
You had one job.
>>
What are some neat /compsci/ books to read?
>>
>>59121066
I first learned on Java.

People say Python is easier. idk just pick one there's plenty of jerbs out there on both
>>
>>59121130
Sams Teach Yourself Java in 24 Hours
>>
>>59120831

Correct. Although that would take a long amount of time, and you would break a LOT of laws. And if you were able to view all of these images, you might even be able to learn a bit about the universe... and an even greater amount about some parallel universes. In theory, you could fit every page of a VERY thick book into one .png image (although it would not display on Windows due to the limitations of GDI), so you'd have unfettered access to every story ever told and that ever would be told. In theory, it could also hold the entire length of a movie. An 8K UHD movie has dimensions of 7680 pixels × 4320 lines. Assuming of course that each line means one pixel, and that the entire movie was captured in 60 fps, we could produce a single vertical strip containing all of the frames of a movie at a low cost of only 259,200 pixels per second of movie time. With the current limitations of the .png file format, this would make for 16,570 seconds, or 4 hours, 36 minutes, and 10 seconds. There wouldn't be sound, but you'd have some very crisp subtitles to read as you infinitely scroll the image. If you were to encode in multiple columns, you'd have access to a much longer movie, however. There could be a total of 559,240 of such columns, stacked together. Using time length of 16,570 seconds per column, we find that we can encode a whopping 9,266,606,800 seconds of 8K UHD video with subtitles inside one .png image. This is approximately 293.8 years of content... in 48-bit color.
>>
>>59121143
No
>>
>>59121156
>Correct. Although that would take a long amount of time, and you would break a LOT of laws. And if you were able to view all of these images, you might even be able to learn a bit about the universe... and an even greater amount about some parallel universes.

Too bad that the majority is false information
>>
>>59121156
ill hack u fagget
>>
>>59121156
>Although that would take a long amount of time
I am working on this with some friends who are into physics.
>and you would break a LOT of laws
That isn't a concern.
>>
>>59121130
The Little/Seasoned/Reasoned Schemer
>>
>>59121189
What's even worse, is that you have no way of knowing what is correct or incorrect
>>
>>59121156
It would have been easier to just go with 'P(R^2)'.
>>
>>59121202
What's even worse than that, is that the information could be correct but just not in the way you're expecting.

You might've been expecting an image of an apple but what you got was an RSA encrypted version of an apple
>>
>>59121066
learn Scheme in 10 min and Forth in 20
Then you'll be prepared to solve pretty much anything.

Then learn Scala as that's popular now
>>
>>59121202

But if you had a proof of P=NP, you might be able to verify if it was correct, and indeed, it would probably fit inside of a single .png image. If it doesn't, well, it would take the entire lifetimes of more than 3 college professors explaining it in 8K UHD video.

>>59121219

It's a lot nicer to put things in terms of more... human-understandable figures.
>>
Anyone know any good examples of ordering the components of a transformation matrix?
I've got all the components I need (translation, xyz rotation, projection, scaling) but I don't know how I should arrange them.
>>
>>59121324
wikipedia

just make sure you know if your system wants row-major or column-major
>>
>>59121317
>It's a lot nicer to put things in terms of more... human-understandable figures.
You'd take nice over easy? Not typical of /dpt/.

Also, my version would be in black and white.
>>
does anyone know what i need to do to block "data:text/html" urls from doing anything?
>>
Why isn't there a anime girls list with more languages on it. It's all scripting languages and a few systems languages in for shits and giggles.

I need to know what my Rust and Common Lisp anime girls are!!! :'(
>>
>>59121363
Where?
>>
File: 1475296277247.jpg (17KB, 319x240px) Image search: [Google]
1475296277247.jpg
17KB, 319x240px
>>59121342
>this will prevent the question from receiving a real answer because people ignore posts with replies
>>
>>59121374
Lain = Lisp
>>
>>59120908
>but S can't contain itself while R can
what does that mean exactly
>>
>>59121381
from pop-ups and shit (chrome specifically). i can write up the solution, but i want to gather info first
>>
>>59120908
R [R ...] should be possible
S [S ...] shouldn't be
>>
>>59121470
You're breaking the html standard
Use an adblocker instead
>>
>>59121350

Black and white would reduce the overall file size due to the reduced number of bits per pixel, but it would do nothing about the overall amount of frames of information that you could contain, as the dimensional restrictions would remain the same. As such, you could similarly contain 293.8 years of greyscale or black/white footage in 8K UHD. Of course, with so few colors, you might consider reducing the size of the frames to only 4K UHD, giving you four times the amount of frames, for a grand total of over a millenia of footage.
>>
new-ish thread
>>59116220
>>59116220
>>59116220
>>
>>59121481
meant for >>59121419
>>
>>59121488
Dumbass
>>
>>59121486
I love how you've just gone on a huge tangent there.

I was just pointing out that with my set product version, no colour data is encoded.
>>
>>59121512

I got bored, and it's a nice distraction from the work ahead of me.
>>
>>59121512
i showed your mum a huge tangent
>>
310
>>
>>59121542
Feel free to post more unrelated meanderings.

>>59121542
I shoved my cos into your mum's tan.
>>
New thread:
>>59121588
>>59121588
>>59121588
>>
>>59121594
You idiot.
>>
>>59121606
The other thread is invalid.
>>
Does C++ have the low level ability of C?
>>
C or C++, lads?
>>
>>59121636
yes

>>59121641
c++
>>
>>59121616
The other thread actually has replies :)
>>
>>59121695
It's all samefag
>>
>>59121740
>23 / 2 / 22 / 2
>>
>>59121796
I was talking about the animu one. The Intel one will have 200+ replies and you can still see the animu alive.
>>
>>59121806
Gross. I'm in the Intel thread.
>>
Which thread is the real one?
>>
>>59121877
Whichever one has more replies/is older.
>>
>>59121911
That's wrong, you stupid redditor. It's the oldest _valid_ thread, as in, posted after the bump limit of the old thread.
>>
>>59121963
I don't go to reddit, but you seem to have a chip on your shoulder about this.
>>
>>59121983
Not following bump limits properly leads to thread wars.
>>
Bruh, I just want to post progress but dont want to post in the thread that's gonna die. I'll just wait until you all sort this out
>>
>>59122003
Also conversations like this, apparently. I'm not sure which is worse.
>>
>>59116672

So I can print it and debug

Also it doesn't work without that extra block
>>
>>59120232
>In any statically typed language
>>59120336
>and it were a struct in C
>any
>in C tho
ask me how I know you're a retard
Thread posts: 332
Thread images: 29


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