[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: 368
Thread images: 35

File: dpt_flat.png (102KB, 1000x1071px) Image search: [Google]
dpt_flat.png
102KB, 1000x1071px
Old thread: >>57325190

What are you working on /g/?
>>
>>57333561
first for C
>>
I'm learning C++.
i've got the basics.
>if, for, while, do, try/catch.
>returns, breaks, continue, goto
>int,char,string,unsigned, etc..

Can you guys give me some pointers to what to learn in order from basic to advanced?

I've read books but +100 pages on single topics make me feel lost. it'll be nice to know what topics are the best to learn first.
>>
>>57333623
fuck off pajeet
>>
>>57333623
pointers
>>
>>57333561
improved >>57333589
 
#include <stdint.h>

int8_t largest(uint16_t n) {
uint8_t length = 1, highest = n % 10;

while ((n /= 10) > 0) {
++length;
if (n % 10 > highest) highest = n % 10;
}

if (length != 4) return -1;
return highest;
}
>>
>>57333623
Speaking of this... I'm trying to make software for Windows, but written in C++. Does Visual Studio support C++? Seems like it defaults to C#, but the problem is I need the interface designer in Visual Studio like what Android Studio has.

Is there a way to design the interface and still use C++? It's obviously all just code regardless, but I need something to design it in and it seems like Visual Studio is the only way.
>>
>>57333669
Isn't the express version c++ only?

Dunno about the community edition.
>>
>>57333669
there is an interface designer but it's more finnicky. they are the .rc files.

just make an MFC application and look at the .rc file in the resources folder, there you can add forms and stuff.
>>
>>57333755
shit, sorry im kinda drunk now.

I meant, make an empty CLR and add a UI windows form in the UI node.

you need to configure your project then. like this:
http://stackoverflow.com/questions/32404247/cant-find-windows-forms-application-for-c

if you get errors in the designer just close the myform.h file and open it again
>>
posted in the wrong thread

college pajeet in training here, learning java for CS-101

this project involves taking in an expression from the user using Scanner in the format
> 2 + 5
>% 14 3
>13 ^ 2
That sort of thing. The problem is that I need to catch and reject inputs that have too many or too few tokens in the input. I've hamfisted it to where it rejects inputs of too few tokens, but I cannot for the life of my retarded self come up with a way to catch an input with too many tokens.

Can I get some suggestions on this, please?
>>
>>57334001

Read an entire line, parse the string.
>>
>>57333623
0x04af8c53
0x8cef939b
0x938fbac7
>>
>>57334001
Use a string tokenizer (or just regex) to break up the expression then count how many tokens you have.
>>
I finished a MOOC on C in a month last summer, because I got bored with a Java course on the last stretch of 20 or so exercises.
Since then I've done nothing besides fiddling with and dropping a CLI RPN calculator that should show an arbitrary amount of lines from its stack and print over its previous input. I'm a bit unmotivated.
>>
>>57334286
>2001 + 15
>still using 32 bit addresses
>>
import os
import shutil

def move(src, dest):
shutil.move(src, dest)

SCAN_DIR = "/Users/max/Desktop/dispatch/"

IMG_EXT = ('.png', '.jpg', '.gif')
IMG_PATH = "/Users/max/Pictures/"

VID_EXT = ('.webm', '.mp4', '.mkv')
VID_PATH = "/Users/max/Movies"

DOC_EXT = ('.pdf', '.html')
DOC_PATH = "/Users/max/Documents/"

PROG_EXT = ('.c')
PROG_PATH = "/Users/max/Etc/"

ETC_PATH = "/Users/max/Etc/"

for file in os.listdir(SCAN_DIR):
if file.endswith(IMG_EXT):
move(SCAN_DIR+file, IMG_PATH+file)
print("Moved " + file + " to " + IMG_PATH + file)
elif file.endswith(VID_EXT):
move(SCAN_DIR + file, VID_PATH + file)
print("Moved " + file + " to " + VID_PATH + file)
elif file.endswith(PROG_EXT):
move(SCAN_DIR + file, PROG_PATH + file)
print("Moved " + file + " to " + PROG_PATH + file)
elif file.endswith(DOC_EXT):
move(SCAN_DIR + file, DOC_PATH + file)
print("Moved " + file + " to " + DOC_PATH + file)
elif file.endswith('.DS_Store'):
print("FUCK YOU MOTHERFUCKER DIEEE")
else:
move(SCAN_DIR + file, ETC_PATH + file)
print("Unknown file type moved to" + ETC_PATH + file)


Hard-coded a python script to scan a folder on my desktop that I drag shit into. Going to create a more robust application and gui where I can create rules based on file types. Might even make a a gui. Does /g/ design first or just start writing shitty code like this.
>>
>>57334256
>>57334301
Oh shit, I think I finally got it working.

Thanks a ton, guys.
>>
So how exactly would something like google's doodle work for determining how straight of a line you draw?
>>
File: hqdefault.jpg (18KB, 480x360px) Image search: [Google]
hqdefault.jpg
18KB, 480x360px
>>57334477
>>57334488
>>57334499
>>
>>57334499
my initial thought is to find the two ends of the drawn line, then draw an imaginary straight line between them, and find out what percent of the drawn line is inside of the imaginary line.
>>
File: 97.jpg (70KB, 396x1076px) Image search: [Google]
97.jpg
70KB, 396x1076px
>mfw Visual Studio opens faster than Visual Studio Code
Electron was a mistake
>>
>>57333666
The simplest solution is always the best one.
int largest(const int n)
{
unsigned len = log10(n) + 1;
char num[len];
sprintf(num, "%d", n);
unsigned i, largest = 0;
for (i = 0; i < len; i++)
if (num[i] - '0' > largest)
largest = num[i] - '0';
return largest;
}
>>
>>57333666
>>57334737
gets(4).chars.map(&:to_i).max
>>
>>57334737
>The simplest solution is always the best one.
No.
>>
>>57334737
>The simplest solution is always the best one.
Usually, the simplest solution has the worst runtime.
>>
>>57334823
It's also easier to maintain, and in the grand scheme of things, processor time is much cheaper than developer time.
>>
>>57334838
>It's also easier to maintain
Hello to rewrites when things scale up.
>>
>>57334838
That's a fucking retarded attitude to have.
Algorithmic time-complexity is extremely fucking important. In this case, it's a simple O(n) problem, but in the face of O(2^n), your CPU doesn't mean jack shit.
>>
>>57334842
By the time you would need to scale up, it's no longer your problem.
You've either been promoted or you sold your company and your shitty crufty codebase to a larger company for mad dosh.
Let them hire pajeets to figure it out.
>>
>>57334838
>pajeet detected
>>
File: 1455794981356.jpg (45KB, 433x378px) Image search: [Google]
1455794981356.jpg
45KB, 433x378px
>>57334859
>Let them hire pajeets to figure it out
>implying pajeet can do that
>>
I'm a C# pajeet, I'm now porting my C# knowledge into C++.NET.

it feels good when you have no idea what are you're doing but it werks.
>>
File: fuckfuckfuck.png (242KB, 1366x741px) Image search: [Google]
fuckfuckfuck.png
242KB, 1366x741px
working on a map converter that converts quake 3 maps to source engine maps as i mentioned on >>57307977

the only language i'm good at is php at the moment so i made a little script that reads quake 3 maps line by line and converts it to source engine's map format, vmf.

still trying to figure out how i can convert vertical and horizontal shifts of textures since those values in both map formats are pretty fucking different.

any of you /g/rus have any idea?
>>
>>57334896
>into C++.NET

Why?
>>
What's the common pitfalls to using std::threads and copy constructors together in C++? Because everything is good until the method that I'm threading (which takes in a deep copy of a class) tries to call another method, at which point it promptly crashes.
>>
>>57335010
>What's the common pitfalls to using std::threads and copy constructors together in C++?
std::thread doesn't have a copy constructor.
A common pitfall is that std::threads don't join or detach when they leave scope.
You have to write a RAII class for that.

>Because everything is good until the method that I'm threading (which takes in a deep copy of a class) tries to call another method, at which point it promptly crashes.
It's hard to tell what's wrong without the code.
>>
I recently heard of devdocs.io and I love it.
Of course you can disable all that web programming shit that's there by default.
>>
>>57334819
>micro-optimizing homework
>ISHIGGYDIGGY
>>
>>57335199
i wish I could view all those docs in texinfo format and not with my web browser.
>>
>>57335256
Most documentation is available as html. So it makes sense to use that.
I think you can pull devdocs from github and run all the scrapers locally.
I don't know how they store the results, but I guess it's just a bunch of directories with html file in them.
You could write a script to translate them to texinfo.
>>
>>57335247
>doesn't know the meaning of "micro-optimization"
>>
>>57335169
>Std::threads don't join or detach when they leave scope
Are you sure? I was able to use detach() successfully, it was the fact that I was then trying to free something malloc'd earlier that was only shallow copied and not deep copied.
Basically want to write a series of images but since the write time for the images is so long, I wanted to have threads do the writing separate from the main AND have to deep copy the class that holds the image chunks so i can delete the image chunks later.
>>
How do you stay motivated?

It's so depressing. I've tried so hard to get into programming. I always have these ideas I'd like to make reality, but once I look at the mountain of work ahead of me I end up getting discouraged.

Should I just go to HTML instead and call it a day?
>>
>>57333623
Just read Stroustroup, line by line, chapter by chapter. Until you collapse.

Also stick with "pre-modern" C++ at first. All that auto/lambda/move semantics faggotry will only get you even more mixed up.
>>
>>57335401
>I was able to use detach() successfully
They don't detach or join implicitly by the destructor.
Some people use std:threads under the assumption that they join implicitly.
That's the pitfall I was talking about.

>Basically want to write a series of images but since the write time for the images is so long, I wanted to have threads do the writing separate from the main AND have to deep copy the class that holds the image chunks so i can delete the image chunks later.
Does your main thread need that image after you decide you want to write it to disk? If not, moving a unique_ptr into the writer thread might work just fine.
Do you spin off one thread per image or do you have one writer thread that you communicate with and pass new images to?
Do you keep the images completely in memory or do you only process them in chunks?
>>
>>57335427
>Just read Stroustroup
Fuck no. From a technical standpoint his books may be fine, but they are didactically bad .
>>
>>57333561
Where do I find open-source projects that need some help?
>>
>>57335673
https://www.openhub.net/p/linux
>>
>>57335673
https://trac.sagemath.org/query?status=needs_info&status=needs_review&status=needs_work&status=new&order=priority&col=id&col=summary&col=status&col=type&col=priority&col=milestone&col=component&keywords=%7Ebeginner&report=38
>>
piu piu
>>
Just read sicp everyone
>>
>>57335453
The main thread constantly writes over a single image, then i want to pass a copy of the image (once I've finished writing that image) to a thread that then writes in to disk, if that makes sense.
So the main thread creates a write thread whenever there is a image to write atm, I wanted to get the basic concept done before looking at further control/thread pooling, etc.
I am keeping the whole image in memory, not chunks.
>>
Are signals important for programming/programmers

As in knowing about signal theory

Has anyone here had such a course
>>
>>57335930
Are you planning on doing any DSP?

If yes, then signal theory is important.

If no, and you're only planning on doing no brainer web dev, then no, you don't need signal theory (although it's nice to know about anyway).

>Has anyone here had such a course
Yes, it's obligatory for CS students at the university I did my degree.
>>
File: umarusee.jpg (113KB, 1280x720px) Image search: [Google]
umarusee.jpg
113KB, 1280x720px
/dpt/-chan, daisuki~

Ask your much beloved programming literate anything (IAMA)

>>57335673
http://up-for-grabs.net/
https://www.codetriage.com/
http://www.firsttimersonly.com/
https://openhatch.org/
https://www.codemontage.com/
https://www.bountysource.com/
https://bountify.co/
http://www.docsdoctor.org/
http://issuehub.io/
http://www.pullrequestroulette.com/
contribhub.org (seems offline for the moment)

>>57335404
Nobody should start to undertake a large project. You start with a small trivial project, and you should never expect it to get large. If you do, you'll just overdesign and generally think it is more important than it likely is at that stage. Or worse, you might be scared away by the sheer size of the work you envision. So start small, and think about the details. Don't think about some big picture and fancy design. If it doesn't solve some fairly immediate need, it's almost certainly over-designed. And don't expect people to jump in and help you. That's not how these things work. You need to get something half-way useful first, and then others will say "hey, that almost works for me", and they'll get involved in the project.

>>57333561
Thank you for using an anime image.
>>
>>57335947
Good response

I'm not planning anything I'm just learning CS and programming as a plan b
>>
>>57335974
>>57335673
forgot https://www.freecodecamp.com/
>>
File: images.duckduckgo.com.jpg (41KB, 600x939px) Image search: [Google]
images.duckduckgo.com.jpg
41KB, 600x939px
>>57335974
>Ask your much beloved programming literate anything (IAMA)
how do i into php?
>>
>>57335974
>>>/a/
>>
>>57336007
>php
Please, don't.

http://hacklang.org/
>>
File: image.jpg (13KB, 200x200px) Image search: [Google]
image.jpg
13KB, 200x200px
>>57336050
>http://hacklang.org/
ebin troll
>>
>>57335404
It's hard to say, for me I have to get chained in order to don't give up, like doing some courses or technical school. Try coding something that u like(games or ur hobbies). Since I've started learning php I've been programming an web app to track my reading based on my browser history(get this information with a java script)
>>
>>57336007
it's a good start to web dev. First u need to know html+css+js, then go to some books like head first

I like this book to start with : Learning PHP, MySQL & JavaScript: With JQuery, CSS & HTML5
>>
hiro is really shitting up the site on mobile
>>
>>57336007
Don't do it, you have too much to live for!
>>
I'm doing something fun with randomly generated cellular automata rules, and I know how to make a way for a computer to tell what is and isn't an interesting pattern (which saves me a lot of time looking at random noise), but how do I use a modulus in such a way that if the value goes lower than zero it will loop back around?

I don't want -5%64 to give me -5, I want it to give me 59, it would make things so much easier.
>>
Going to do some academic research that involves teaching programming basics to blind kids with some simple logo turtle lookalike using arduino/raspberry pi. My teacher told me to use python.
what are some good python books?
>>
>>57336491
add n (the n in x modulo n) number if it's <0
>>
>>57336491
>>57336545
eg -5 + 64 = 59

alt.

((x % n) + n) % n
>>
>>57336557
Tested it, and it works fine!
Good timing too, I just ran a test and found that my cellular automata isn't actually looping around the edges as it should, but this will let me simplify my code a lot and likely fix the bug inadvertently.
>>
RIP spoopy
>>
File: ass.png (142KB, 1273x649px) Image search: [Google]
ass.png
142KB, 1273x649px
>>57333561
Working on a chat bot.

Image tangentially related.
>>
File: Capture.png (8KB, 508x473px) Image search: [Google]
Capture.png
8KB, 508x473px
Alright, the cellular automata now has edge looping, like it's supposed to.

What I still don't understand though is that the very first time I ran the code when I had fixed all the major bugs, I saw a truly strange cellular automata.
Black tendrils licked from the edge, then started growing until the entire thing was shrouded in darkness.
I don't think I changed the system at all until just now, but I must have generated a hundred patterns since and not seen anything like that.
>>
>>57336673
cyber cthulu has awoken?
>>
>>57336673
show a recording
>>
File: Screenshot 2016-11-01 11.08.38.png (52KB, 395x282px) Image search: [Google]
Screenshot 2016-11-01 11.08.38.png
52KB, 395x282px
>>57336646
>tfw the bot roasts you
>>
Hold on, there's still one major bug with the cellular automata!
If I start from a blank screen, exactly half the time something should happen, and the only thing that would be able to happen is for every cell to turn black, in which case the only thing that could happen is for every cell to turn white again (if the random rules specify it).
It also appears that cells can affect each other at a distance.
I'm guessing what's happening is that as the cells update, they update in response to the mid-iteration map, rather than the map of the previous iteration.
But I wrote
boolean[][] tempMap = map;
for (int x = 0; x < map.length; x++){
for (int y = 0; y < map[0].length; y++){
tempMap[x][y] = rules[surroundingsID(x, y)];
}
}
map = tempMap;

specfically so that wouldn't happen.
Maybe I just don't understand Java.

>>57336722
I don't have the rule set.
I'll set it to print the rules, just in case I see something crazy again.
>>
>>57336491
>>57336673
are you using comonads
>>
>>57335404
It's weird; it's really easy to stay motivated in the learning aspect if you have a job that wants you to program because they need you to solve problems, but I can't really do anything just for myself these days since nowadays there are at least 3 or 4 competing services for things I'd think about making for myself; it's kind of ridiculous. I really wish I had the free time of a NEET or a college student again just to bulk up my portfolio with pet projects.
>>
>>57336770
Alright, I fixed it, but this new code is horrific and I still don't understand why what I did before didn't work.
I'm using arrays to copy every value and it takes up so much space, there's like a third of a page of just copying data.
>>
File: 48884445_p0_master1200.jpg (172KB, 650x866px) Image search: [Google]
48884445_p0_master1200.jpg
172KB, 650x866px
>>57335974
Say senpai, where will you go when 4chan will be closed?
>>
File: witch.jpg (331KB, 1061x1500px) Image search: [Google]
witch.jpg
331KB, 1061x1500px
>>57336917
back into my grave.
>>
>>57335974
>Nobody should start to undertake a large project. You start with a small trivial project, and you should never expect it to get large. If you do, you'll just overdesign and generally think it is more important than it likely is at that stage. Or worse, you might be scared away by the sheer size of the work you envision. So start small, and think about the details. Don't think about some big picture and fancy design. If it doesn't solve some fairly immediate need, it's almost certainly over-designed. And don't expect people to jump in and help you. That's not how these things work. You need to get something half-way useful first, and then others will say "hey, that almost works for me", and they'll get involved in the project.

True and wise words.
>>
Trying to get through the pythonic jungle of missing libraries, making funny images.

>>57334286
kek
>>
File: pointers.png (87KB, 795x597px) Image search: [Google]
pointers.png
87KB, 795x597px
>>57336968
>kek
how dare you take amusement like that

that joke has been told so many times here
>>
>>57336981
This joke never gets old.
>>
Not quite programming, but I figured you guys might know:

How do I open a file in mpc from the command line? I am trying to pipe a url to mpc and it just opens mpc without opening the file.

I can pipe to clip.exe and paste into mpc's "open" option, but I'm trying to remove this intermediate paste step.
>>
>>57336981
Java doesn't even have pointers
>>
>>57334803

You can even skip the mapping, ASCII-order of single digits is natural order:

p gets(4).chars.max
>>
>>57337007
>>>/g/sqt
>>
>>57337131
You don't know either huh
>>
File: pointers.png (18KB, 360x299px) Image search: [Google]
pointers.png
18KB, 360x299px
>>57334286
>>57336981

Hello, newfriends!
>>
>>57337149
That joke has been told many times before this comic even existed, youngfag.
>>
>>57337146
This is CLI operations 101, but I'm going to be an ass because you asked in the wrong place.
>>
File: 343.jpg (52KB, 500x500px) Image search: [Google]
343.jpg
52KB, 500x500px
Why doesn't /g/ have homepage threads anymore??
>>
>>57337224
nobody here cares about you
>>
if( op.image.isAnime() == true)
{
reply("fuck you for watching anime degenerate weeaboo\n>>>/a/");
}
>>
>>57337224
I seen one not so long ago, anon.
>>
>>57337250
>if( op
POO
>>
>i good programmer
>i not need smart pointer
>smart pointer make slow
>work with raw pointer
>>
still learning C and SFML. I asked here if I should learn SDL instead but only got inane replies.
>>
File: m.png (194KB, 478x380px) Image search: [Google]
m.png
194KB, 478x380px
Why haven't you got a gf yet, lads?
>>
>>57337260
if
(
op.image.isAnime ==
true
)
{
reply("wtf are you going to do about it bitch");
}
>>
>>57337281
Girls think i'm creepy.
>>
>>57337250
>>57337286
> == true
>>
>>57337286
IN THE LOO
>>
>>57337296
maybe he's real anal
>>
>>57337281
The only dating I'm apparently being able to do is being intimidating - not in the good sense.
>>57337289
this.
>>
>>57337296
>reply in scope
>>
>>57337307
Maybe he just learned about boolean logic this week.
>>
>>57337327
I've been typing that for at least two weeks m8
>>
>>57337289
>>57337319
Maybe you just think girls think you're creepy and you don't really try desu.
>>
>>57337327
That's it, === true

You forced my hand.
>>
>>57337321
>side effects
>>
>>57337335
==== true when?
>>
>>57337333
This is what copy paste programming. Not understanding your code.
>>
>>57337361
I've never copypasted brah

fite me 1v1 irl ill rekt u
>>
>>57337334
Well not anymore, i'm not.
Trying is what made girls think me creepy.
>>
>>57337369
>if (op.image.isAnime == true)
>if (1 == true)
>if (1 == 1)
>if (1)

>if (op.image.isAnime) //true
>if (1)
>>
>>57337334
I have been told upright several times. Apparently they could sense my desperation.
But I have to admit, I haven't tried again yet.
>>
>>57337388
> both evaluate to the same thing
> both probably has the same assembly
Glad we agree
>>
>>57337409
but they have different readability

you can save literal bytes and time in the long run by having efficient code

the isAnime property is already asking the question, == true is asking it again
>>
File: download.png (25KB, 1310x614px) Image search: [Google]
download.png
25KB, 1310x614px
Working on a hompage, learning how to code in HTML.

Not sure how to make it look pretty doe.
>>
We just had the first snow of the year. It snowed outside my window for like 2 minutes.
>>
>>57337422
>reddit
>/pol/
>learning to code in HTML
I'm not surprised at this point, honestly.
>>
>>57337422
>>>/g/wdg
>>
>>57337422
>>>/g/wdg
>>
>>57337419
> if this function returns true, do this
> if this function, do this
Which one is more readable?
>>
>>57337422
>>>/reddit/
>>
>>57337457
They're both "if returns true", you're just adding fluff.
>>
>>57337434
HTML is a good skill to have.
>>
File: download.png (39KB, 1310x614px) Image search: [Google]
download.png
39KB, 1310x614px
>>57337437
>>57337439
Literally a dead thread.

Nothing wrong with posting web dev stuff here, lads. Calm your autism.

I plan to add functionality to it one day, but JS is a bit too complicated for me atm.
>>
File: snake.png (6KB, 801x635px) Image search: [Google]
snake.png
6KB, 801x635px
>>57333561

newfag here

just finished making a snake game in python. Any advice on what i should make next to improve my skills?
>>
op.image.isAnime && reply("you're a faggot");
>>
>>57337457]
Noob.
Why do you think the function is named like it is?
>>
>>57337457
>if (op's image is anime is true)
>if (op's image is anime)
>>
>>57337473
>>>/g/wdg
>>
>>57337473
>JS is a bit too complicated for me
>this combined with the rest of what we know about you

Literally end your life.

>>57337476
>Any advice on what i should make next to improve my skills?
What do you want to do?

Everyone should know how to work with data, whether that's from a public API or a local database.

Combine this with your game in some way for more motivation; maybe an apple appears every time someone tweets a particular hashtag or something.
>>
>>57337476
you mean your python game?
>>
>>57337463
> implying fluff is bad
This is the type of guy who writes one liners in python in a professional environment

>>57337484
>>57337494
Ain't nothing wrong with being explicit
>>
>>57337519
If by "guy" you're referring to me, then no.

I'll abuse ternary and regex to no end though.
>>
>>57337498
I've already said, anon. There's nothing wrong with posting web dev stuff here.

Besides, what's the point of dividing discussion? /dpt/ is uncomfy slow anyways.
>>
>>57337519
I'd never want to review your code.
>>
>>57337528
>There's nothing wrong with posting web dev stuff here.
It isn't programming. It isn't even webdev; they'd chase you out just the same.
>/dpt/ is uncomfy slow anyways
You are not here to do anything related to programming. You want to be praised for picking up the simplest skill imaginable in the field. Crawl on back to your containment board.
>>
>>57337571
>containment board
/d/?
>>
>>57337563
>op.image.isAnime == true
>Oh noooooooo. The horror! The humanity! Why does it need to end like this?

This is you
>>
What's the difference between a custom allocator and pre-allocating memory at program startup?
>>
File: fds.jpg (19KB, 306x306px) Image search: [Google]
fds.jpg
19KB, 306x306px
>>57337571
You're not my dad.
>>
>>57337528
>There's nothing wrong with posting web dev stuff here.

There's nothing wrong with it if you're actually doing programming, not basic HTML.

If you have a website with a significant back-end that does some interesting things, then feel free to discuss it here.

If you're copy/pasting HTML in the most basic sense, why bother posting it here? It feels like a cry for attention when you're doing the artistic equivalent of scribbling patterns in the margin.
>>
>>57337586
>if (op.image.isAnime)
>Oh noooooooo. This is too simple and goes against the college textbooks and teachings I acquired! Why does this bad habit need to end like this?
>>
reply("You're a " . (op.image.isAnime ? "faggot" : "cool guy"));
>>
>>57337590
Ignore them, you can post HTML here if you want to.

Some autists get triggered by it, but it doesn't matter. Good look with learning web development, anon.
>>
>>57337590
If I was your dead I'd have aborted you the moment I had the chance to. Even if it would have been a postnatal process.
>>
>>57337601
You still didn't give me one single argument why isAnime == true is bad that didn't get utterly btfo by "compiler optimization"
>>
File: 1459487588767.jpg (78KB, 340x314px) Image search: [Google]
1459487588767.jpg
78KB, 340x314px
>>57337612
>Samefagging because your anus ruptured as a result of being told that no one wants to see you copy-paste the most basic HTML exercises
>>
>>57337611
reply("You're a " . (op.image.isAnime ? "faggot" : (op.isFaggot) ? "still a faggot" : "cool guy"));
>>
>>57337587
Are they both executed at run-time?
>>
>>57337612
Thanks, lad. What HTML/CSS books would you recommend?
>>
>>57337514
>>57337505

i should've been more specific. I was thinking more like simple 2d games and programs with graphics
>>
>>57337628
I did already, and you conveniently ignored it.

I said you're asking the same question twice.
If the property was just anime instead, it would be fine.

>isAnime? yes!
>isAnime is true? yes!

Continue living your fantasy.
>>
And the daily basic common sense awards goes to...
>>57337494

Maybe aliens will finally care about us?
>>
>>57337623
Killing babies isn't something to joke about, autismo.
>>
>>57337645
I wasn't joking, retard. If killing babies means getting rid of people like you I'd personally do it in a second.
>>
>>57337635
None. You can pick most of it from sites like w3schools and codecademy.
>>
>>57337635
Pressing F12 in your browser.
>>
>>57337651
Well, you're a bit edgy desu.
>>
>>57337656
I don't have F12 on my chromebook, what do?
>>
>>57337662
A moment of silence
>>
>>57337640
And being explicit in calls is somehow bad?
>>
>>57337659
You can't be edgy enough against dumb people. Otherwise they don't get the hint and don't XOR themselves.
>>
>>57337687
Are you female?
>>
>>57337687
Making senses is better than being explicit.
>>
>>57337687
If you wanted to be explicit you'd also be type checking.

1 as an integer evaluates to true.
Some languages also interpret any non-zero value as true.

What are you doing to handle those?
>>
>>57337717
Define true

t. C programmer
>>
>>57337729
Not false :^)
>>
So, I got laid on Halloween. I'm no longer able to call myself part of this thread. I have ascended, fellow coders.
>>
File: jg.jpg (14KB, 229x220px) Image search: [Google]
jg.jpg
14KB, 229x220px
Ok, I've moved onto JS now, it isn't as bad as I thought, I just made this.

Press F12 and paste the following into the console:

var t = document.getElementsByClassName("thread")[0].id;
var p = localStorage["4chan-track-g-" + t.substring(1)];
var b = document.getElementsByClassName("bottomCtrl")[0];
var lp = p.split(">>");
lp = lp[lp.length - 1];
lp = lp.substring(0, t.length - 1);
b = b.getElementsByTagName("input");
document.getElementById("p" + lp).getElementsByClassName("desktop")[0].childNodes[0].checked = true;
b[4].click()


What do you think, lads?
>>
>>57337687
import this
>>
>>57337743
>ascended
Get out, you non-virgin!
>>
>>57337743
Disgusting. You're now a filthy reproducing primate. You really should kill yourself miserable subhuman.
>>
>>57337744
Small readability suggestion, but some may go against it. I'm not saying use it just acknowledge it:

var t = document.getElementsByClassName("thread")[0].id,
p = localStorage["4chan-track-g-" + t.substring(1)],
b = document.getElementsByClassName("bottomCtrl")[0],
lp = p.split(">>");


Also what is the purpose of lp? You don't seem to use p again so reuse it instead of lp.
>>
>>57337744
Pretty neat.

You should still kys though.
>>
>>57337744
"You must wait longer before deleting this post."
What did it mean by this
>>
>>57337785
It pulls the tracked posts (yours) from the localStorage, marks them for deletion then submits.
>>
>>57337772
Please don't tell me you're serious.
>>
>>57337281
girls can't be programmed.
>>
>>57337801
What, the readability suggestion or questioning lp?

I already said there'd be flack.
>>
>>57337422
>literally nothing
are you 12?
also: >coding
fuck off underageb8
>>
>>57337772
Writing out var is better for readability, you can easily tell it's a newly declared variable, and the purpose of lp is so I don't have to write p.split(">>") over and over again.

>>57337792
It only marks you latest post because you can only delete one post at a time.

Perhaps it should mark second last post to avoid "you must wait longer before deleting."
>>
>>57337772
Your coding style is bad and you should feel bad.

Readability is adding an empty line between variable declaration block and "where the magic happens".

Readability is not making simple statements harder to parse while making the code more fragile.
>>
>>57337812
Everything you've done in your life was worthless.

>>57337817
Kys faggot web 1.0 was the best. His website is still beter than 99% of the bloated shit out there.
>>
>>57337825
p = localStorage["4chan-track-g-" + t.substring(1)].split(">>")
?
>>
>>57337838
You are hired
>>
>>57337698
Nah

>>57337703
Boy I'd sure hate to review your code

>>57337717
isAnime is a function that only returns bool
>>
>>57337854
KISS
>>
>>57337838
Fair point.

var t = document.getElementsByClassName("thread")[0].id;
var p = localStorage["4chan-track-g-" + t.substring(1)].split(">>");
var b = document.getElementsByClassName("bottomCtrl")[0];
p = p[p.length - 1];
p = p.substring(0, t.length - 1);
b = b.getElementsByTagName("input");
document.getElementById("p" + p).getElementsByClassName("desktop")[0].childNodes[0].checked = true;
b[4].click()


How can I make it even smaller?
>>
>>57337826
>Readability is adding an empty line between variable declaration block and "where the magic happens".
But I do add the line between var declarations and the rest.

If you were to use this (read my original post, I didn't say FUCKING USE IT just acknowledge it) you'd still visually format it the same way.

One disadvantage, as per >>57337825 is it's hard to distinguish between newly created vars and may otherwise be in the scope.

Functionally and space-saving wise you stand to gain nothing. However, it is possible to do it. Ignoring it is your initiative.

var a = 1,
b = 2;

//magic
>>
>>57337865
I ain't gay yo
>>
>>57337867
Removing whitespace

Also it seems you're just getting the last post if I'm reading it properly, thus:

var p = localStorage["4chan-track-g-" + t.substring(1)].split(">>").pop();


Should get the last post immediately, no need to calculate the array length minus 1.

Taking that a step further:
var p = localStorage["4chan-track-g-" + t.substring(1)].split(">>").pop().substring(0, t.length - 1);
>>
>>57337923
Welcome to JavaScript
>>
>>57336945
Upvoting this.
>>
>>57337875
No, I'm saying a newline would improve OP's readability.

Distinguishing is what I meant by harder to parse.

Also it takes more mental effort to modify / interpret, introduces more room for error (say, accidentally using a semicolon instead of a comma), etc. etc.
>>
>>57334488
>>57334488
Checked
No problemo anon
>>
>>57336945
More like plan ahead.

If you expect your code to large scale, start with that in mind even when it starts on the small scale.

If you have to dedicate classes/files/etc for a few lines of code "now" but that may expand to several hundred relevant lines later, then do it.

About a year ago I took on the task of breaking down a several thousand line program into smaller, in-time loaded files recursively.

It was a nightmare for me, but more so for the other devs because their monstrosity was being fixed. I'd start big, taking out entire functional portions of code from the main file before breaking those down further.
>>
>>57337923
So:

var t = document.getElementsByClassName("thread")[0].id, p = localStorage["4chan-track-g-" + t.substring(1)].split(">>").pop().substring(0, t.length - 1), b = document.getElementsByClassName("bottomCtrl")[0].getElementsByTagName("input");document.getElementById("p" + p).getElementsByClassName("desktop")[0].childNodes[0].checked = true; b[4].click()


Any smaller?
>>
File: lifeos.webm (910KB, 720x420px) Image search: [Google]
lifeos.webm
910KB, 720x420px
>>57333561
stupid things with vga text mode
>>
>>57333623
>Can you guys give me some pointers
&
>>
>>57337993
Whitespace nigga

Also while I didn't test this, setting .checked to 1 (integer) should auto-cast to a boolean.

var t=document.getElementsByClassName("thread")[0].id,p=localStorage["4chan-track-g-"+t.substring(1)].split(">>").pop().substring(0,t.length-1),b=document.getElementsByClassName("bottomCtrl")[0].getElementsByTagName("input");document.getElementById("p"+p).getElementsByClassName("desktop")[0].childNodes[0].checked=1;b[4].click()
>>
>>57338004
^
>>
Does anyone know any website or so where i can get some practice for programming, specifically a site that uses c++? I remember there being a plethora or java websites but almost no c++ ones?
>>
>>57338014
You can also save about 10 characters by making a new variable in reference to "document",
d=document


Can't say it's a good idea though, but space!
>>
Given F(X) = X + 1, what is the value of X?

You should be able to solve this.
>>
>>57338048
if (op.image.isAnime == true)

Duh, anybody knows that.
>>
>>57338048
F(X) - 1
>>
>>57338048
Not enough information.
>>
>>57338048
"fizzbuzz"
>>
>>57338061
>>57338048
x= F(X) -1
>>
>>57337228
Do people actually use pure functional programming for anything outside of pet projects?

I know that some companies use functional programming for specific tasks, particularly in finance or other cases requiring massive parallelization, but I'm not sure if they do it in a pure functional manner.
>>
>>57338048
Anything for which +1 is defined.
>>
>>57338130
Pure FP doesn't mean no side effects. It means no side effects that are observable to unrelated parts of the program. There's no practical value in defining purity to be anything more restrictive than that.
>>
>>57338048
unknow
>>
>>57338176
I running it without the click, and getting none.
Seems to check the box as intended. Post error.

In the meantime, another 4 characters saved by abolishing b which is only used once:
var d=document,t=d.getElementsByClassName("thread")[0].id,p=localStorage["4chan-track-g-"+t.substring(1)].match(/(\d+)":1}/)[1];d.getElementById("p"+p).getElementsByClassName("desktop")[0].childNodes[0].checked=1;d.getElementsByClassName("bottomCtrl")[0].getElementsByTagName("input")[4].click()
>>
>>57338048
f(x) is a function that defines a pattern for whatever number x, the function then transforms that to x+1.

x in itself isn't a number, but a variable that can be any number
>>
>>57338130
It's wise to segregate functions into pure functions and impure functions. Pure functions can be formally proven to be true and this remains true when you compose them together to form more complicated pure functions. By explicitly segregating these two types of functions, we can concentrate our debugging efforts on ensuring the correctness of impure functions when we've proven that the pure functions are correct.
>>
>>57338214
""""""""""""pure""""""""""
>>
Is Erlang's lightweight process stuff really that important of a selling point? I mean, couldn't I basically write my C code in a way that would accomplish the same thing? It sounds pretty similar to a kernel in the first place.
>>
>>57338232
Of course you can write C code to achieve anything you wish. The difference is that programmers have to explicitly how achieve your multi-processing. In Erlang, the language itself takes care of many operations and abstract them away from the programmer. This means the programmer can spend more time implementing business logic rather than computer resource bookkeeping.
>>
>>57338214
That's not really pure vs. impure. That's more generally safe vs. unsafe, where safe code is entirely machine verified but unsafe code requires the programmer to postulate (and be responsible for) its correctness. And unsafe code doesn't infect safe code.
>>
>>57338048
>Given F(X) = X + 1, what is the value of X?
F(X) - 1

what do I win?
>>
>>57338287
f(x) - x = 1

:^)
>>
>>57338232
>I mean, couldn't I basically write my C code in a way that would accomplish the same thing?
The same can be said for everything. If you want to understand what the difference is between C and other languages, you haven't been programming C for long enough
>>
>>57338296
>f(x) - x = 1
>f() = 1
>0 = 1

Where do I receive my gold medal?
>>
>>57338061
>>57338111
>>57338287
>>57338296
X is of string type and + is concatenation with implicit number->string conversion for the 1 so you are wrong
>>
>>57338302
at the edge of the universe, like everyone else
>>
>>57338302
Wouldn't f() just result to undefined?

That's why you can't unbalance equations, it doesn't magically become 0.
>>
>>57338048
Is this a silent protest that most comp sci programs require a minor in mathematics?
>>
>>57338320
No, you can't fucking go from
>f(x) - x
to
>f()
in the first place, whatever f() is even supposed to mean
>>
>>57338340
And if he meant to substitute 0 for x, surprise surprise, f(0) = 1 and thus you get 1 = 1.
>>
File: Screenshot_3.png (4KB, 658x79px) Image search: [Google]
Screenshot_3.png
4KB, 658x79px
guys I'm failing this class. Pls help. :(

This is what I have so far. I guess I can get to th end of string but dont know how to reverse.

 
int main()
{
int word;
cout << "Please Enter a Word" << endl;
cin << word << endl;
cout << "The word has this many letters: " + word << endl; //This needs to be fixed
return 0;
}

void q1_reverse(char *str, int n){ //pointer array

if(n==0) //Base case n==0
{
q1_reverse(); //Not sure
}
else
{
while(n==!0){
q1_reverse(str[n-1])

}

}
>>
>>57338304
Ah, but Haystack - Needle deletes the substring Needle from Haystack, so it is correct.
>>
>>57338048
You post this like once a day and every day more people take the bait.
>>
>>57338304
not in the language im using
>>
>>57338381
sounds like a meme language to me like hasklel
>>
>>57338374
>int word
>>
>>57338374
>int word;
>cout << "Please Enter a Word" << endl;
>cin << word << endl;

You are right at failing the class. At least when you screw up at McDonalds it wouldn't have such a big impact.
>>
>>57338414
#blacklivesmatter
>>
>>57338276
I've equated pure functions as safe (after you've verified it) and impure as unsafe. Now it's harder to verify that the impure functions are safe because the mathematical tools we have to model the state transition of impure functions can be prohibitive but it's possible to prove in some cases.
>>
>>57333669
Re-run your installer and download the the C++ shit. If you did the default install instead of "Choose what i want installed" or whatever, it probably didn't include C++. That's what happened with me.
>>
>>57338374
maybe you should have paid attention instead of relying on strangers to do trivial tasks.
>>
>>57338199
Nvm, my mistake.

Saved a lot more characters with querySelector too.

var d=document,t=d.querySelector(".thread").id,p=localStorage["4chan-track-g-"+t.substring(1)].match(/(\d+)":1}/)[1],b=d.querySelectorAll(".bottomCtrl input");d.querySelector("#p"+p+" .desktop").childNodes[0].checked=1;b[4].click()
>>
>>57338432
Purity is a necessary but not sufficient condition to be safe.
>>
>>57338424
#whitelivesmatter
There is enough white trash that's still better than black trash. And they often frequent fast food restaurants.
>>
>>57338432
>>57338448
And you don't need impure functions at all if you can postulate things to tell the type checker "just trust me", which you will need anyways.
>>
he's just protesting strong typing guys
>>
>>57333561
php
Variables and Literals
:(
>>
>>57338374
void q1_reverse(char *str, int n){    //pointer array

if(n==0) //Base case n==0
{
q1_reverse(); //Not sure
}
else
{
while(n==!0){
q1_reverse(str[n-1])

}

}

This code makes me sick to my head.
>>
>>57338438
var d=document;d.querySelector("#p"+localStorage["4chan-track-g-"+d.querySelector(".thread").id.substring(1)].match(/(\d+)":1}/)[1]+" .desktop").childNodes[0].checked=1;d.querySelectorAll(".bottomCtrl input")[4].click()
>>
>>57338495
Worth noting from when we started it was 414 bytes, this one is 219.
>>
File: 2015-05-28_00001.jpg (235KB, 1366x768px) Image search: [Google]
2015-05-28_00001.jpg
235KB, 1366x768px
So is Lisp worth learning?
I have some spare time and wanted to get into AI programming.
I'm afraid I might be too stupid for it though.
What's the best way to start /dpt/?
How have you started?
>>
>>57338536
Do you first understand the resources it takes for "good" AI and "acceptable" AI within a certain time frame?

Realistic expectations for AI is a good start.
>>
>>57338536
>So is Lisp worth learning?
Lisp is a meme language and will always be a meme language
>>
>>57338545
I don't understand.
>>
begin dup while tuck mod repeat drop
>>
File: dd_leper.jpg (185KB, 1024x575px) Image search: [Google]
dd_leper.jpg
185KB, 1024x575px
>>57333561
Fixing my disasm/analyzer.

I have sinned. In my greed I veered away from the EZ way, I thought that instead doing four small passes over the code which is being analyzed, I can do all in one big pass.

I forgot the first rule of optimization. And the second one, the most important of them all.

Now it's buggy and messy. And I'm redoing it the simple way.
>>
>>57338572
Consider if it takes 5 years to get the PERFECT action to perform for say, one loop.

I can write a tic-tac-toe AI that just picks from spots randomly with no tactics, it'd be "acceptable". I could code another one that weighs blocking the player and going for traps. This may take maybe a second or two (exaggeration) and still be "acceptable" for the player.

Now apply this to a chess AI, etc.
Unless you're talking about general purpose AI then ignore me.
>>
>>57338604
A good example musuo games (the things that spam enemies for players to kill).

Especially on older hardware where performance is a premium, it's not hard to imagine what each individual enemy is doing is very simple with little to no regard to the player or a way of forcing the player to change their strategy. An easier way would be more enemies and beefing them up to simulate a different degree of strength.

Keep in mind I don't do AI, but this is my concept of it. If I'm off the mark please correct me.
>>
How many of you implement Machine learning, AI, or algorithms by hand?

or do we all just use APIs?
>>
Why is Lisp so allegedly good for AI?
>>
>>57338662
are you suggesting the APIs use APIs?
>>
>>57338679
do those APIs use APIs?
>>
>>57338679
>>57338683
> /dpt/ humor
>>
>>57338694
import Laugh
>>
>>57338699
> input error no module "Laugh"
>>
>>57338495
var d=(q)=>document.querySelector(q);d("#p"+localStorage["4chan-track-g-"+d(".thread").id.substring(1)].match(/(\d+)":1}/)[1]+" input:first-child").checked=1;d("[value='Delete']").click()
>>
>>57338683
it's APIs all the way down
>>
>>57338604
>>57338658
I understand now.
There was a local AI hackathon which got me interested. The problem was the prisoner's dilemma and they had to design an AI to play that.

I literally don't know where to start with it though.
Python maybe?
All I know is Java and C++
>>
>>57338730
npm install left-pad
>>
>>57338724
welcome to fucking JavaScript
>>
>>57338753
ikr JS is so much harder than all the C languages put combined.
>>
File: anal beads.png (2MB, 2000x2000px) Image search: [Google]
anal beads.png
2MB, 2000x2000px
>>57338662
>How many of you implement Machine learning, AI, or algorithms by hand?
Not a single person here, competently.

There are divisions of hundreds of extremely talented programmers creating things like Watson Conversation. These things are simply out of reach of a single programmer, no matter how talented, due to the sheer amount of resources necessary to undertake a complex AI functionality.

In my life, I've used hammers for a few things. There were different hammers. Some large, some small, some had a specific texture on the head, and some even were made out of a particular metal to handle heat or shock in a certain way.

Did I spend years upon years of my life studying metallurgy and the processes to cast durable metal into a particular shape? Did I spend years upon years learning how to create a durable, non-slip, non-conductive rubber coating?

No, I did not do those things. I went to the store, and purchased a hammer. Oddly enough, no one jeered at me on the street for my lack of effort. Not a single person called me a filthy casual for my lack of self-manufacturing abilities.

Today, sometimes I need some text and sentiment analysis, or even human-like responses to my clients. I don't build that. I use the tools available to accomplish my goals.

#HumansUseTools
>>
>>57338724
>input:first-child

Would changing it "input > *" select all children then you can use [0]?
>>
>>57338730
Until they interface with LOGO code and you find the turtles.
>>
>>57338778
I'm not completely sure how "input *" evaluates, but "input > *" would be all immediate children with no recursion.
>>
File: FizzBuzz.png (13KB, 578x461px) Image search: [Google]
FizzBuzz.png
13KB, 578x461px
>>57338792
>>
>>57338773
Calm down, Kyubei

i get what youre saying, I'm just not comfortable using Persons A, B, and C work, glued it together and call it "my" work.
>>
>>57338805
And you shouldn't be, that's what attribution is for.
>>
>>57338778
Just realised, I can remove ":first-child" altogether because "querySelector" automatically selects the first child.

var d=(q)=>document.querySelector(q);d("#p"+localStorage["4chan-track-g-"+d(".thread").id.substring(1)].match(/(\d+)":1}/)[1]+" input").checked=1;d("[value='Delete']").click()
>>
Is there a hotkey for wrapping in code tags, like Ctrl+S is spoiler?
>>
>>57338778
input:first-child means "an input element which is the first child of its parent", not the first child element of an input
>>
>>57338822
Now if we could just get rid of that substring and just get the OP number immediately.

>>57338830
Whoops.
>>
>>57338814
that doesn't make me feel any better.
>>
>>57338834
why do you need a var for d?
just make it global and save 4 spaces.
>>
>>57338822
Bet you can't get it below 150 characters.
>>
>>57338662
I played a little with manually written GA

I also made some variation of GAs: divided whole pool them into separated "tribes", each tribe member could crossover only with other tribe member. Elitist selection was used inside each tribe. So basically it was several GAs running in parallel, but
each N iterations tribes collected together to find the very best and return back to the tribes.

It's fun in theory, but I found that my all implementations were no better than doing hill-climbing.

But anyway, doing simple and basic GA is VERY easy. The hard part is making it useful: you need good fitness function(fast to compute and little local maximums) and crossover/mutation
>>
>>57338866
Okay Satan
>>
>>57338873
whats GA?
>>
>>57338891
Google Analytics
>>
>>57338869
Anything is possible with JavaScript™
>>
>>57338830
type="submit"
is one character shorter
>>
>>57338878
seriously though, its no big deal, just be careful.
>>
>>57338822

d=(q)=>document.querySelector(q);d("#p"+localStorage["4chan-track-g-"+d(".thread").id.substr(1)].match(/(\d+)":1}/)[1]+" input").checked=1;d("[value=Delete]").click()


Struggling now desu.
>>
>>57338891
genetic algorithms
>>
>>57338974
see isn't it much lighter without that pesky var keyword?
>>
>>57338536
Lisp is worth learning for the profound enlightenment experience you will have when you finally get it; that experience will make you a better programmer for the rest of your days, even if you never actually use Lisp itself a lot.
>>
>>57338974
d("#delform").submit()
might replace
d("[value=Delete]").click()
>>
>>57339012
Confirmed with that post, the former works.

If we could shrink the selector, though.

d("form")[#] ?
>>
>>57339008
>use macros everywhere
>even when they're inappropriate
>>
>>57339012
Yeah, that works.

d=(q)=>document.querySelector(q);d("#p"+localStorage["4chan-track-g-"+d(".thread").id.substr(1)].match(/(\d+)":1}/)[1]+" input").checked=1;d("#delform").submit()


Only 11 characters to go for 150.
>>
>>57339030
well, isn't lisp a programmable programming language or not?
>>
>>57339051
>the only way to metaprogram is with macros
>>
>>57339044
That substring still triggers me.
>>
>>57339073
lisp macros are intelligent and the very definition of programming freedom.
>>
I already know C(++), rust, python, and R would there be any point in me picking up a lisp for my next lang or should I do something practical like java or C#?
>>
What exactly is the difference between a function and a macro in Lisp since it's interpreted and homoiconic?
>>
>>57339073
at least lisp macros aren't such a hack like C preprocessor
>>
>>57339111
just use monad transformers bro :&)
>>
>>57338536
First, you should know that Lisp has been endorsed by Richard M. Stallman (PhD). Second, do you already have an experience in programming or are you starting from scratch?

http://practicaltypography.com/why-racket-why-lisp.html
>>
>>57339111
#define FIVE_TIMES(x) 5 * x

int main() {
printf("%d\n", FIVE_TIMES(2 + 3));
return 0;
}


That feel when rust AST macros master race
>>
>>57339141
now do:
int x = 2;
FIVE_TIMES(++x);


:-)
>>
>>57339044
d("[name=res]").value
for
d(".thread").id.substr(1)
?

It's a hidden input in the delete form, might as well use it. It's also just the number so we don't need to process it.
>>
>>57339141
#define FIVE_TIMES(x) (5 * (x))
>>
what is metaprogramming and why should I care
>>
>>57339170
it's just programming at a higher level
>>
>>57339170
It's how shit languages let you do things they aren't powerful enough to do normally.
>>
>>57339184
what "powerful" language that actual software is written in doesn't have some form of metaprogramming

>inb4 assembly
>>
>>57339184
just because you don't call it metaprogramming doesn't mean it isn't

but using macros all the time is totally a hack
>>
>>57339184
it's the inverse actually, you can evolve the language as you want where another one would require dirty hacks.
>>57339197
>but using macros all the time is totally a hack
how so?
>>
>>57339196
All "practical" languages are garbage.

>>57339197
What's the line between programming and metaprogramming, then? Things that are normal programming in some languages are metaprogramming in others, e.g. generics in C compared to generics in C++.

>>57339209
Macros are dirty hacks you moron. Some are just less dirty than others. Lisp macros appear to be the nicest since the language is already dynamically typed and you're not losing anything by using them since you didn't have anything to lose in the first place.
>>
File: d5c.jpg (36KB, 625x626px) Image search: [Google]
d5c.jpg
36KB, 625x626px
>>57339249
>'all "practical languages are garbage'
>>
>>57339209
99% of the time you should be using a higher order function
>>
>>57339270
They are.
>>
>>57339152
And I think that's the smallest it can go.

d=(q)=>document.querySelector(q);d("#p"+localStorage["4chan-track-g-"+d("[name=res]").value].match(/(\d+)":1}/)[1]+" input").checked=1;d("#delform").submit()


7 off 150.
>>
>>57339249
>All "practical" languages are garbage.
What the fuck do you even mean by this

Like...what the fuck man
>>
>>57339008
> lisp...the profound enlightenment

Are you a /prog/rider?
>>
>>57339289

new
>>
>>57339288
All good languages are too academic at this point.
>>
>>57339249
how the fuck something with a well specified syntax and well specified semantics can be considered a hack?
>>
>>57339296
C was made by an academic
>>
>>57339296
what the fuck

A programming language is a tool. If it's practical to use, then it's a good tool.

What level of stuck-up-your-own-ass do you have to be to categorically say that a language being practical makes it bad?

Jesus fucking christ, you mongoloids are going to end my sanity one of these days.

Can't you just ask what a monad is or something?
>>
>>57339277
What do you even mean by practical languages? Anything that uses OO? The only language I'd confidently call garbage is Java.
>>
>half talking about conceptual programming and the application behind it
>half optimizing actual javascript to hell and back
>>
>>57339315
In fact, literally what have non-academics ever achieved in PLT?

>>57339318
>What do you even mean by practical languages? Anything that uses OO?
kek, nice joke anon
>>
>>57339297
So this method of doing generics isn't a hack?
void *id(void *x) {
return x;
}

int a = 100;
a = *id(&a);

It's well-specified.

>>57339315
>made by an academic
Not what I said.

>>57339317
I didn't say that, I said that all "practical" languages (i.e. abiding by the criteria of the first post) happen to be bad.

>>57339318
>what "powerful" language that actual software is written in
>>
>>57339318
Nice, PHP rides on.
>>
>>57339330
I'm trying to understand this insane mindset of yours.

Can you specify two practical languages that are "garbage", as well as the things you don't like about them?
>>
>>57339330
>undefined behavior
>not even a macro
lel, k, you definitively trolling
>>
>>57339284
See how much cleaner it is than the ~414 bytes you started with?
>>
>>57339342
C++ is just a pile of features that don't interact well shoved on top of one another.
Java claims that everything can and should be done with its interpretation of OOP.

>>57339348
What's undefined about that?
>>
File: erfe.png (9KB, 462x190px) Image search: [Google]
erfe.png
9KB, 462x190px
Can anyone help me figure out how I could write a function in C that checks to see if 2 tree data structures are reflections of each other? like in the picture?
>>
>>57339709

this value == that value
this left == that right (recur)
this right == that right (recur)
>>
>>57339731
>== true
>>
>>57339810
!= false is noticeably faster
>>
File: bg_20140628101253.jpg (49KB, 275x275px) Image search: [Google]
bg_20140628101253.jpg
49KB, 275x275px
>>57339342
>>57339362
Basically this. Languages that claim being "practical" are just hiding how things work to programmers, but this is retarded. Think about math with "abstraction".
>>
Question

Someone posted this in another thread
var t=document.getElementsByClassName("thread")[0].id,p=localStorage["4chan-track-g-"+t.substring(1)].split(">>").pop().substring(0,t.length-1),b=document.getElementsByClassName("bottomCtrl")[0].getElementsByTagName("input");document.getElementById("p"+p).getElementsByClassName("desktop")[0].childNodes[0].checked=1;b[4].click()


What does it do
>>
>>57340044
install a virus on any computer that copy/pastes it (resides on the clipboard when copied and exploits a bug in most major OSes to execute its payload during the pasting operation)
>>
>>57340093
>execute its payload during the pasting operation
Wrong. It's executed as root as soon as it's copied using a 0 day vulnerability.
>>
>>57339731
>>57339810
>>57339839
Got it, thanks.
>>
>>57338773
> >How many of you implement Machine learning, AI, or algorithms by hand?
>Not a single person here, competently.

I wrote a backpropagation implementation by hand. Though how competently developed it is you could debate all day.
>>
hiro found a 0 day exploit in the css then changed the style of the page to infect everyone, now your porn folders have porn in them
>>
>>57340241
not again!

>captcha: sale sold
>>
>>57340093
Good thing my right click is broken and I had to type it out
>>
This TTF exploit is packaged within a Microsoft Office file. Upon opening the file, the font will exploit a vulnerability in the Windows TTF subsystem located within the win32k.sys kernel-mode driver.

The attacker’s shellcode resides within the Font Program (fpgm) section of the TTF. The font program begins with a short sequence of instructions that quickly return. The remainder of the font program section is treated as unreachable code for the purposes of the font program and is ignored when initially parsing the font.

During exploitation, the attacker’s shellcode uses Asynchronous Procedure Calls (APC) to inject the second stage from kernel-mode into the user-mode process winlogon.exe (in XP) or lsass.exe (in other OSes). From the injected process, the attacker writes and executes a third stage (executable).

The third stage decodes an embedded DLL to, and runs it from, memory. This DLL is a full-featured remote access tool that connects back to the attacker.
>>
>>57340410
Good thing I'm running Linux and use OTF exclusively then
>>
>>57339362
I haven't read this whole argument, but I assume you're a fan of Haskell then?

What do you do for a job/are studying?
>>
>>57340487
What kernel version are you using?

:^)
>>
>>57340487
A critical vulnerability (CVE-2016-1019) exists in Adobe Flash Player 21.0.0.197 and earlier versions for Windows, Macintosh, Linux, and Chrome OS. Successful exploitation could cause a crash and potentially allow an attacker to take control of the affected system.

Magnitude EK recently updated its delivery chain. It added a profile gate, just like Angler EK, which collects the screen’s dimensions and color depth. The server responds with another profiling page, which tries to avoid sending exploits to users browsing from virtual machines or with certain antivirus programs installed, In our tests, Magnitude EK delivered the JSON double free exploit (CVE-2015-2419) and a small Flash loader that renders the new Flash exploit.

A memory corruption vulnerability exists in an undocumented ASnative API. The exploit causes the flash memory allocator to allocate buffers under the attacker’s control. The attacker can then create a ByteArray of length 0xFFFFFFFF such that it can read and write arbitrary memory, as seen in Figure 4. The exploit’s code layout and some of the functionalities are similar to the leaked HackingTeam exploits, in that it downloads malware from another server and executes it.
>>
File: 2.jpg (181KB, 515x698px) Image search: [Google]
2.jpg
181KB, 515x698px
Sooo
(https://www.redditgifts.com/exchanges/secret-santa-2016/)
Reddit has its secret-santa xmas presents exchange thing, we should do the same.
Let's send gift to anons! :D
Thread posts: 368
Thread images: 35


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