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

File: time for an injection!.jpg (248KB, 1920x1080px) Image search: [Google]
time for an injection!.jpg
248KB, 1920x1080px
old thread: >>61556266

What are you working on, /g/?
[Bonus] Daily Programming Challenge!
How would you protect your program execution from attempts to inject arbitrary data into resident memory?
>>
>Created before the bump limit
>Doesn't follow OP format
Delete this invalid thread.
>>
>>61560889
Too soon and picture unrelated to programming.

Sage and report.
>>
>>61560889
>to inject arbitrary data into resident memory?
You dont have this problem with functional languages who are run-time safe.
>>
>>61560883
there's nothing wrong with arbitary limits
the computer's memory is not infinite

>1 The implementation shall be able to translate and execute at least one program that contains at least one instance of every one of the following limits:
>[...]
>— 4095 characters in a logical source line
>>
File: 1498244916373.png (121KB, 250x418px) Image search: [Google]
1498244916373.png
121KB, 250x418px
>>61560906
>injection
>unrelated to programming
>>
>>61560954
>the computer's memory is not infinite
Doesn't mean you have to read the entire file into a buffer.
>>
>>61560889
i was thinking keep a master checksum of every bit of data allocated to my program and then recalculating after any modifications, but what if they overwrite my checksum?
>>
>>61561024
Pretty sure you meant to post in this thread:

>>61560918
>>61560918
>>61560918
>>
>>61561038
fuck off with your facebook shit
>>
>>61560889

>How would you protect your program execution from attempts to inject arbitrary data into resident memory?
By not being a dumbass about how I handle user input.
>>
>>61561161
What if you're writing a game and you're trying to prevent cheating by simple means, like memory editing?
>>
>>61560906
Anime is always related to programming.
>>
>>61561190
Well, if it's single player, you don't give a fuck.

If it's single player and you have microtransactions for easymode, burn in a fire.

If it's not single player, do sanity tests server-side. "Is the player moving faster than the max speed given his situation?" Is he accelerating in the XZ axis despite not being on the ground?"
>>
>>61561190
you can detect dll injections / memory access on windows somehow
>>
>>61561244

This right here. For single player, the user has a right to cheat if they so feel like it... the only person screwed is themselves. For multiplayer, use the server. If it's hotseat multiplayer, the other guy in the room knows what's up.
>>
>>61561190
>>61561244
I few years ago I downloaded some WoW cheating program which allowed me to run extremely fast. I just ran through the jungle with no one around but they detected it.

I wondered how they specifically managed to catch me. So what do they check every frame that every player is not flying or running faster than they should be?
>>
File: b_1_q_0_p_0.png (86KB, 275x266px) Image search: [Google]
b_1_q_0_p_0.png
86KB, 275x266px
>program crashes with library error on Linux Mint
>it runs fine on windows
windev here I come I guess

kill me
>>
>>61561503
>everyone sees you running extremely fast
>hmmm i wonder if he's cheating??
>>
>>61561504
Youre probably missing a random devlib
>>
>>61561539
It was a low population server, I haven't come across anybody else and only used it for about 3 minutes out of curiosity.
>>
>>61561570
maybe the server does sanity checks on clients doing things that shouldn't be possible, like running 9999999 speed or something
>>
>>61561541
all the libraries came with the source code
it was already set up for qtcreator all I did on either system was load it into qtcreator
I think openJDK was fucking me somehow, because the program calls java for graphics and a console

what's weird is it was working fin on linux for a solid while, and then it just started having errors after I added some stuff to the code. Now, mind you, it gets through all of my code without error. it seems my additions somehow caused other parts unrelated of the code to behave differently and lead to the library error
>>
>>61561503
Yeah that's one way. You don't technically do it every frame, just every time a packet comes in. Not even necessarily every time a packet comes in. You could do it on random packet receive events. WoW also has code injection detection too because some of the gameplay (herb picking; grinding; mining; excessive addon usage) is indistinguishable from using bots. But that should have been rectified by changing the gameplay desu.

Were you banned immediately? My understanding is that blizz bans in waves because they're shady assholes. Banning people in waves rather than immediately makes them more likely to buy the game again.
>>
>>61561616
Fuck QT, get off that pajeet shit.
>>
>>61561633
i have no choice in the matter
>>
File: discord_bot.jpg (695KB, 1903x3074px) Image search: [Google]
discord_bot.jpg
695KB, 1903x3074px
Please rate my D code /g/-kun. I'm writing a discord bot.
>>
>>61561539
Wow's a big fucking game. Even on a server with 3k people online, you could run around like desolace or the eastern coast of arathi highlands no problem. And in modern you can really cheat in the old content without people seeing since the old content is so empty.

Also you could cheat in an instanced dungeon and no one could see because you're the only one in it.
>>
>>61561633
Provide a decent alternative to QML.
>>
>>61561503

>Player reports being at position (x1, y1) at t1, and being at position (x2,y2) at t2.
>Server side sanity check: Is this possible?
>No
>Autoban
>>
>>61561627
>Were you banned immediately?
Since this happened about a decade ago my memory of it is foggy. I was either disconnected from the server and banned, or the ban took effect after I logged out.
Either way it happened within about an hour. It was a short ban though, I believe 24 hours or some shit.

>Banning people in waves rather than immediately makes them more likely to buy the game again.
The fuck?
>>
File: 1500896680978.png (87KB, 601x223px) Image search: [Google]
1500896680978.png
87KB, 601x223px
>>61561671
don't understand shit, but looks promissing
>>
File: old_hag_langs.png (173KB, 600x355px) Image search: [Google]
old_hag_langs.png
173KB, 600x355px
>>61561504
Ricers ladies and gentlemen.
>hurr install gnetoo xDddxD
>>
>>61561699
I get that they do sanity checks, what I'm wondering is how exactly they do it and how frequently.
>>
>>61561671
try to subdivide your code into simpler more understandable functions, will really help you read your own code in a year, each function should have ~20 lines max
>>
>>61561671
Use selective imports.
dont brace one if / else statements.
Could probably de-pajeet your params length checks into a final switch.

Other than that it looks okay for the most part.
>>
>>61561633
>Fuck QT,
why tho?
Clang static analyser, GDB, CMake, Visual Studio keybinds, optional Vim keybinds... etc.
I can't think of anything it could possibly be missing
>>
>>61561627
>>61561598
its pretty lenient, you can get away with a certain ammount of speedhacking because the game doesn't want to punish players that are just lagging and not speedhacking.
The game wouldn't be popular if everyone with a bad connection got rubberbanded or booted.
That being said the detection isn't always accurate and it would often boot you if you charged right as the same time you got stunned. It would detect that you were moving while stunned and boot you. But other times you could see lagging players or hacked players moving around while stunned for the entire duration of the stun. The games pretty messy.
a quick google search says that the charge bug was still in the game in may 2016 lmao: https://eu.battle.net/forums/en/wow/topic/17611273110

bugs been in the game so long people started trying to time their spells to disconnect warriors on purpose. What a joke of a game
>>
>>61561776
Its a bloated, buggy piece of shit.
>>
>>61561776
Qt != QtCreator
>>
>>61561756
I factored a bunch of the static checks out into helper templates but I hit a compiler bug so for now it has to stay in.
>>
>>61561708
It creates this idea that you won't get necessarily banned, they just "caught you" at a later point in the future. So you just "got unlucky" or you were in the clear until you somehow "messed up" and need to try again, even though they immediately knew.

My understanding of this comes from a defcon panel about hacking videogames which alleges this.

But if it was a decade ago it was probably before blizz got bought out by activision.
>>
>>61561788
ah, I see, yeah fuck QT5
>>61561787
shoo
QTCreator a best
>>
Is "Where's Waldo?" decidable?
>>
>>61561779
Oh kek. I wish I knew that when I played. Woulda been fun to turn hammer of justice into the hammer of warrior banishment.
>>
>>61561793
>I hit a compiler bug
report that shit nibba
>>
>>61561697

Nana and IUP are the only acceptable GUI libraries.
Poco, Boost and STL for the common stuff
>>
>>61561766
>dont brace one if / else statements
this depends on what style guides hes following
some require braces around all if-s and else-s
>>
>>61561793
What compiler you on, and what was the bug?
>>
>>61561854
I made some cursory attempts to reduce it to a test case but I couldn't so I gave up.
>>
>>61561754

That would be a question to ask a Blizzard employee, who would promptly tell you to fuck off.
>>
>>61561857
Nana is complete garbage that gets stomped by QML, I'll look into IUP though, haven't heard of it before.
>>
>>61561793
try out the different D compilers, there are a whole bunch dmd,ldc etc... to see if it really is compiler specific
>>
>>61561854
>tfw the only compiler bug I've ever submitted was marked as resolved in the latest version, and I was told to stop using debian
>>
>>61561917
kek
>>
>>61561876
Well if youd look at the code, hes using it inconsistently for variables.
>>
>>61561882
2.073.1 I think. It doesn't matter though because I updated to 2.075 which broke vibe.d, which my project depends on.

>>61561916
I don't have LDC/GDC installed. Maybe I'll try building with one of them eventually.
>>
File: 1468540941275.jpg (122KB, 845x740px) Image search: [Google]
1468540941275.jpg
122KB, 845x740px
>>61561916
>D has more compilers than programmers
>>
>>61561946
>I updated to 2.075 which broke vibe.d, which my project depends on.
Im taking a break from Vibe.d desu, ive had enough of diet templates for a lifetime.
>>
>>61561930
I'm not saying he shouldn't be consistent, he definitely should
I'm just saying what he should be consistent -to- is ambiguous to us, and telling him to always un-brace single statement if-s and else-s is not necessarily good advice
>>
>>61561961
What's wrong with diet templates compared to jade or some other template language?
>>
I'm new at C++ and I'm having an idiotic problem. I have a map of objects to vectors of objects. (It's modelling a digraph: the keys are the nodes, the values - vectors of nodes - are the immediate descendant, so to speak, of the key node.) Now I want to iterate over this map and potentially change some of the fields of those objects.
Thing is, it turns out keys in maps are immutable. Wat do? I literally have no idea what the best approach would be.

As a simple example, imagine iterating over all the keys (i.e. nodes in the graph) and flipping a "traversed" flag on them to true. That sounds simple enough, but I don't know how to go about it.
>>
>>61561949
Theres only three main ones. But GDC is basically irrelevant because LDC is for when your reference is good and you want your final compile for more optimizations.
>>
>>61561949
>Oracle has more lawyers than programmers
>>
>>61561980
3 compilers, 2 programmers total.
Marvellous.
>>
>>61561978
Map it to a different key? I don't get what your problem is.
>>
>>61561977
Painfully slow to compile even when caching stripped down d code is awkward
The forced indention got old.
and for the life of me, i could not figure out why string interpolation would not work. I just want them to re-do it completely, and not base it off pug/jade.
>>
>>61562001
>Never import in a function
>Global variables like alias Response
Not trying to be rude, but you've obviously never used D.
>>
>>61562003
And then delete the old one? That seems messy. I could do it though.
>>
>>61562019
caching,*
>>
>>61561794
I see. If they get banned in batches though a group of cheaters would tell each other that they were also banned during the same time.

It would make the most sense to have a script that bans random people at random times once they've been added to a list.
>>
>>61561978
make a vector aff all key
for example
vector<objects> mykeys = mymap.getkeys();
for (int i = 0; i < mykeys.size(); i++) {
vector<objects> = temp;
temp = mymap.get(mykeys[i]);
//do stuff with temp
}

should get every value from every key
>>
>>61562001
local imports are a feature and encouraged idio in D
There are no globals in D, only module-scoped ones.
>>
>>61562025
Yeah, or you can wait until C++17 is officially released and use http://en.cppreference.com/w/cpp/container/map/extract.
>>
>>61561978
>>61562046
fug, wait

 vector<objects> = temp;

should be
vector<objects> temp;
>>
>>61562046
>>61562069
I don't think std::map has a getkeys() method though
>>
>>61562094
std::vector<std::string> extract_keys(std::map<std::string,std::string> const& input_map) {
std::vector<std::string> retval;
for (auto const& element : input_map) {
retval.push_back(element.first);
}
return retval;
}


and

std::vector<std::string> extract_values(std::map<std::string, std::string> const& input_map) {
std::vector<std::string> retval;
for (auto const& element : input_map) {
retval.push_back(element.second);
}
return retval;
}
>>
>>61562094
make a better map then
you can even use a std::map as a base and add that function
how hard could it be? kek

alternatively, there are implementations of maps in C++ that -do- have that as a function
>>
>>61562051
Also, won't that fuck up the iterator? Will I need like a separate map to put my new elements into? If I delete the element from the old one it should be fine in memory usage, but it's still really messy and will have a whole ton of not-really-necessary copying.

Is there really no better way in C++11?

Would using a vector<pair<>> instead be a horrible idea?
>>
File: C vs C++.jpg (409KB, 1400x1265px) Image search: [Google]
C vs C++.jpg
409KB, 1400x1265px
defend this
>>
>>61562038
It causes them to blame the person they bought the cheat from. So they'll try again with a different bot vendor. It's also grandstanding for optics with the honest playerbase.
>>
>>61562124
>Also, won't that fuck up the iterator?
Only if you're modify the map while iterating over it.
>>
>>61562131
One is simple and concise, the other one is convoluted and bloated.
>>
>>61562131
One is a big book and the other is a booklet.
>>
I'm trying to make a snake game.

can I just make a list of snake fragment objects where each fragment has the position of the fragment it is attached to in the last tick?
>>
>>61562046
>just make a bunch of unnecessary copies temporary vectors
please stop giving advice
>>
>>61562116
Element.first will still be const though, won't it?

>>61562145
...which I will, since you advised me to make a new element and delete the old one
>>
>>61562209
>...which I will, since you advised me to make a new element and delete the old one
These operations do not involve looping. If you are however looping you'll have to re-retrieve the iterators after the operation.
>>
>>61562238
Fug. I did say in my first post that I was looping and modifying practically every key (such as marking it as "traversed"), so I'm basically fucked. Yay!
>>
>>61562131

>Programming language initially designed as an extension of another programming language has a larger book than said programming language
Does it really need defending? This should be obvious.
>>
>>61561892
But someone who is not a Blizzard employee could make educated guesses. If there is a set of possibilities with good solutions there is a good chance that one of them is used by Blizzard.
>>
File: 1501013694361.webm (3MB, 754x688px) Image search: [Google]
1501013694361.webm
3MB, 754x688px
>>61562204
>>
>>61562267
the C section in the C++ book is bigger than all of K&R
>>
>>61562263
>I did say in my first post that I was looping and modifying practically every key
I missed that bit but I feel like there's a better way to do whatever you're trying to do.
>>
File: 1395534797824.gif (465KB, 500x281px) Image search: [Google]
1395534797824.gif
465KB, 500x281px
Why do in C/C++ what can be done in vanilla javascript?
>>
>>61562345
>immutable strings
what did she mean by this?
>>
>>61562322
I know, hence my question.

But in a stroke of unprecedented genius I decided that maybe using POINTERS to the objects as keys would be a good idea. This let's me modify the objects' fields while keeping my map intact. I think this is exactly what I was looking for.
>>
>>61562360
>nuclear weapon launch systems will one day be running in node
>>
>>61562389
>C and C++ will one day be unknown arcane magic known only by the old wizards
>>
File: s.png (174KB, 1680x1050px) Image search: [Google]
s.png
174KB, 1680x1050px
>>61560889
>What are you working on, /g/?

Exploring the deepest, darkest corners of Racket.
>>
File: W_A_I_f_U.jpg (116KB, 1280x720px) Image search: [Google]
W_A_I_f_U.jpg
116KB, 1280x720px
>>61560889

didn't ship new Rust code since one year

driving my LEGO trains via bluetooth with Ruby

did statistics of a FPS multiplayer console log to identify people using aimbot and wallhack. Postgres and Ruby

still laughing at people involved with Golang or Python
>>
I made a program that calculates the sum of natural numbers up to n in brain-flak

I started doing products (factorials) but haven't gotten far yet
>>
Sorry for a stupid question but it's late night and I can't think properly.
>If pshared is nonzero, then the semaphore is shared between processes, and should be located in a region of shared memory (see shm_open(3), mmap(2), and shmget(2)).
(Since a child created by fork(2) inherits its parent's memory mappings, it can also access the semaphore.) Any process that can access the shared memory region can operate on the semaphore using sem_post(3), sem_wait(3), and so on.
Does it mean when I sem_init() and then fork() the child will inherit the semaphore or do I need to put it in shared memory?
>>
File: saruman.jpg (44KB, 900x381px) Image search: [Google]
saruman.jpg
44KB, 900x381px
>>61562453
>>
>>61562268
https://www.youtube.com/watch?v=hABj_mrP-no&feature=youtu.be
>>
>>61562521
BTW what I'm trying to do is send signals from parent to child. I only need the semaphore to let the parent wait till the child is ready to receive them.
>>
>>61562521
Yes
>>
File: teleport.webm (922KB, 800x608px) Image search: [Google]
teleport.webm
922KB, 800x608px
>>61560889
>What are you working on, /g/?
Adding support for collision detection and resolution for arbitrary shapes (assuming they can be broken into a finite number of aabbs).

I got the collision detection working correctly, but the collision resolution is still the original implementation and needs to be updated.

What you see here is the collision resolver placing the player too high; it would be correct height if the block were full-sized. But, the collision detector works correctly, so the player falls a bit, then the resolver puts him midair.
>>
>>61562588
Yes what?
>>
>>61562453
>implying C++ isn't common knowledge and won't always be common knowledge
C might go the way of Fortran and ASM, but C++ has a good many decades ahead of it.
>>
>>61562761
>C++ has a good many decades ahead of it.
fug I hope not
>>
>>61562488
>"laughing at people involved with Golang or Python"
>uses Ruby (toylang) to play with toys
>>
I'm starting to see why people write OOP.
It's because they think they need to write code in this way.

For context all this does is get the locs and set the uniforms of a predefined list of glsl uniforms.
I looked at this project because I just wanted to add another variable but I'm gonna have to add it in a bunch of places. And then I'll have to compile it with gradle.
This is just dumb. I'd rather write my own app now.
>>
File: Screenshot_20170726-010735~01.png (234KB, 736x1496px) Image search: [Google]
Screenshot_20170726-010735~01.png
234KB, 736x1496px
>>61562807
It feels like I forget to post related images more than I remember them.
>>
>>61562714
>aabbs
Why aabbs and not just do convex hulls like a normal person?
>>
>>61562830
Why not just do
rotationLoc, 1
gyrolistener.rotation,0


Your formatting is real funky and wasteful
>>
>>61562761
>but C++ has a good many decades ahead of it.
not if a saner language emerges
>>
Ok. I'm done being a neet. I was working in some help desk shit for a while but I've been laid off since December. And my neet bucks have run out.
Where do I start to get into programming. Boot camps look like scams, idek which moocs to check out. Are things like bento or codecademy any good?
Idc if it's a book or a site, but I'll take any recommendation for where to start.
>>
>>61562868
It's not my code. Also I believe this wasn't written with 80char width in mind. I cropped the indentation.
>>
>>61561998
>2 programmers
Why would you spout disinfo?
>>
>>61562854
because he's cloning minecraft obviously
>>
>>61562893
But she's accepting arbitrary shapes.
>>
>>61562888
Ok, I was exaggerating just to be nice.
There is just the one.
>>
>>61562881
>Where do I start to get into programming
read a book or three on it
>>
>>61562921
Why do you continue spouting disinfo?
>>
>>61562881
Just put out CVs and fuck making a project. Just say the right buzzwords in an interview. Hack it till you make it
>>
>>61562919
>she
>>
>>61562830
>this is the kind of code written by anti-OOP retards
really makes you think
>>
>>61562781
I agree, but lets just face the facts. ML, Ocaml, Fortran, C, ASM, will all soon be completely dead. We're going to die while C++ and Java are still in mainstream popularity. This is the consequences of a world where /v/ideogame permavirgins are the people who most often want to become programmers. Every year, people care less and less about the quality of their code, and more and more about "features".

>>61562870
Basically every other language other than Java is saner than C++. The only people getting into programming anymore are /v/irgins, and /v/irgins are just going to keep using Unity, Unreal, and Source. They're too busy bitching about things they shouldn't care about on Twitter and YouTube, like women in tech or not enough women in tech, or why transgender bathrooms should or shouldn't be included in their game. They don't have time to learn more langs or write their own engine.
>>
>>61562854
Because AABB is simple and cheap. Because it's not a physics simulation. Because everything in the game will be an AABB or a union thereof. So I don't have to calculate slope effects.

>>61562919
Arbitrary shapes formed from finite unions of AABBs.
>>
>>61562929
Sure. Got any book recommendations?

>>61562936
Will do. I've been trying to switch lanes from support to something else for a while.
>>
>>61562953
>ASM will all soon be completely dead
By definition, this literally can't happen.
God damn, you're so fucking stupid. I can't even be bothered reading the rest of your post, because I know it's just going to be fucking retarded.
>>
Why does my compiler give me stack overflow when I store a recursive anonymous function in a Hashtable? How do I solve my issue using Ocaml?
>>
To all of you often asking about some ideas for cool programming project. Why don't you just type "algorithms" in Google scholar, find a cool paper and implement them?
>>
>>61562970
I read Jumping into C++, it's a good starter book that covers alot of bases fairly quickly, if a bit rough on the edges, but follow it up with either Structure and Interpretation of Computer Programs (free online), or some other book that will broaden your understanding
K&R "The C programming Language" is a classic, for example
>>
>>61562990
>By definition, this literally can't happen.
Why is that, exactly?

>>61563009
Because algorithms aren't video games and they want video games.
>>
>>61562949
You can't read? This is oop code.
>>
>>61563009
I want to implement Cholesky decomposition in C
>>
>>61563009
because that's boring not cool
>>
>>61563009
why do that when I can write my 20th fizzbuzz in a memelang?
>>
>>61563019
>You can't read?
nope
>>
File: 1501024651730.jpg (380KB, 1080x1920px) Image search: [Google]
1501024651730.jpg
380KB, 1080x1920px
>>61563029
plus, who would care if you implemented some obscure algorithm?
>>
>>61563049
Don't you think it's a bit bold to call others retarded then?
>>
>>61563018
>Why is that, exactly?
What the fuck do you think a CPU runs? High level code and magic?
Assembly is by definition, the (human readable) instruction set that a CPU runs. It cannot die; the CPU has to fucking accept something.
Also, there is no "ASM". There are various assembly languages that various CPUs accept.
If you designed a weird CPU that accepted Python or some shit, Python would by definition become "ASM".
>>
>>61563017
Thank you. I'll check that all out.
>>
>>61562990
>By definition, this literally can't happen.
only machine language is completely unkillable

ASM is a layer of abstraction upon machine language
theres nothing really stopping ASM from going away
>>
>>61563009
Because they don't want to risk learning anything.
>>
>>61563076
>If you designed a weird CPU that accepted Python
honestly surprised this isnt a thing yet
>>
>>61563095
Lisp machine is sort of that.
>>
>>61561697
>>61561857
Tcl/Tk
>>
>>61563076
>Assembly is by definition, the (human readable) instruction set that a CPU runs.
we don't need that human readable for tho, now do we?
a compiler could compile straight down to machine code, skipping the assembly
assembly is unnecessary
>>
>>61563090
>layer of abstraction
Retards need to stop throwing that stupid word around for fucking everything.
ASM is not an "abstraction" of machine code. It's just an alternate way of representing it. There is a 1-1 mapping between assembly instructions and machine code instructions. Talking about machine code and assembly being distinct things is just not helpful.
>>
>>61563076
Holy shit, you're retarded. Assembly is not machine code, you smoothbrained inbred. Assembly is ran through an assembler (a type of compiler) that converts it to machine code.

If your CPU accepted raw Python, Python would not be it's ASM. Python would be it's machine code. You need an assembler for it to be assembly.

https://en.wikipedia.org/wiki/Assembly_language
Read this before trying to ride your high-horse, dipshit.
>>
>>61563120
The Mt. Stupid truly hurts.
>>
>>61563127
See >>61563123
>>
>>61563018
because the languages you complain about complile into assembler
and if everyone turns into a shit programmer because they like videogames then we'll end up with shit videogames
the whole idiocracy argument holds no merit, as long as there are talented people in the world they will make things ten times as good as all the rest of the idiots using unity and people are going to prefer their products
>>
>>61563095
>picoJava
>aJile
>Jazelle
So.... Java is ASM?
>>
>>61563123
>There is a 1-1 mapping between assembly instructions and machine code instructions.
That's objectively false. You've never written ASM, have you?
>>
>>61563076
Pixie bum dust and fairy magic
>>
>>61563151
The burden of proof is on you. Hard mode: Macros aren't instructions.
>>
>>61563123
giving series of byte instructions names is abstraction

the fact that it's 1-1 means nothing
I remain unconvinced that ASM won't be forgotten within 50 years as some weird archaic language
>>
>>61563134
Read the wikipedia article I linked. It contradicts you within the first sentence.

>>61563137
>because the languages you complain about compiler into assembler
No, they don't. They compile into bytecode, IR, or are interpreted. You don't know what the fuck you're talking about.
>>
>>61563120
>skipping the assembly
Why do you butt into discussions you know nothing about? Compilers usually don't compile to asm first. They compile into an IR which then becomes machine code generally. Which the CPU then processes further to microcode.

Programming 101 come on.
>>
>>61562131
>implying you will know C++ from reading just that one book
>implying Bjarne can write for educated adults

somebody just fucking end C++ already
>>
>>61563164
The burden of proof isn't on me because I didn't make the initial assertion. I gave you a citation that agrees with me though. That's good enough for most.
>>
>>61563151
Nah he's right if you amend his statement to assembly instructions of a particular format with all extraneous whitespace and comments removed, with all memory address labels renamed with some incremental naming system.
>>
>>61562369
It's me again!

Turns out changing my map to use pointers as keys broke literally everything else in my program. At one point, if I dereference an iterator into one of my objects, then use that object's address as a key to insert stuff on the next line, everything breaks immediately. But if I store it as an iterator, then on the next line do
my_map[&*the_iterator] = stuff
, then most things work, except I still get a segfault a bit later.
>>
>>61563167
C++ compiles into assembly
>>
File: 1415548266529.gif (2MB, 516x283px) Image search: [Google]
1415548266529.gif
2MB, 516x283px
Ignore anyone recommending C, C++, or Lisp (ala SICP). An ideal starting language is something like Python (or maybe Javascript if you're specifically getting into web development).

This is coming from someone who cut his programming teeth on SICP, and even happens to be currently using C++ in a personal project (NES emulator).
>>
>>61563202
C++ can transpile to ASM, as can JavaScript or any other language, but they usually don't. Most implementations of C++ compile into IR and then that turns into machine code for the target system.
>>
>>61563217
>An ideal starting language is something like Python (or maybe Javascript if you're specifically getting into web development).
Literally the opposite side of the coin for bad beginner info
>>
>>61563168
>>61563233
gcc compiles to actual asm which is piped to gas.
t.once wrote a gcc backend
>>
>>61563217
The only ideal thing about Python for beginners is the fact that it's designed in a way where you can experiment with most paradigms without learning a new syntax. Other than that, while it's a good language, it's not that great for beginners.
>>
>>61563217
>An ideal starting language is something like Python
it's like starting to learn math with a calculator.... just wrong!

first just learn fucking C to the point where you understand the key elements of the base language, fuck the libs
>>
>>61563167
>No, they don't. They compile into bytecode, IR, or are interpreted. You don't know what the fuck you're talking about.
$gcc -help
....
-S Compile only; do not assemble or link.
....
$ gcc -o pascal.asm pascal.c -S
$ cat pascal.asm
.file "pascal.c"
.section .rodata
.align 8
.LC0:
.string "Please pass the number of rows to print\nSyntax: %s <number literal>\n"
.align 8
....

Are you sure anon? There may be an IR before assembly, but GCC's target is assembly.
>>
>>61563242
That's horrible if true. Hardly believe it. Pretty much disqualifies it as a serious project.
>>
>>61563233
>Most implementations of C++ compile into IR and then that turns into machine code for the target system.
yes, compiling to assembly
are you fucking retarded?
>>
File: CmkrzRkUcAEaSrd.jpg (91KB, 745x735px) Image search: [Google]
CmkrzRkUcAEaSrd.jpg
91KB, 745x735px
>asm is going to die even though you need it for real low level shit, debugging, reverse engineering
Really gets my noggin jogging
>>
File: Brazilian Crime.jpg (95KB, 997x665px) Image search: [Google]
Brazilian Crime.jpg
95KB, 997x665px
I am going ballsdeep into a payroll program.

Considering going with django and mysql, i dont know shit about programming other than some Excel Macros.

How badly am i fucking this up?
>>
>>61563242
I'm aware, but nobody sober uses GCC anymore. LLVM compiles to LLVM IR which then is transpiled into a target language.

>>61563284
What did you expect? It's a Stallmanix® product.

>>61563300
Oh, you're trolling.
>>
Quick assembly question
I'm reading that with
CMP r1, r2

The NZVC = 0101 iff r1 = r2.
If r1 = 3 and r2 = 3, then r1-r1=0.
So how is there a carry-out?
>>
>>61562953
do you think code is only used to make video games?
>>
>>61563301
You don't need it for any of those though. You can do all of those with C and C++.
>>
>>61563333
whoops, meant to write r1-r2
>>
>>61563330
do you think you're smart by using 'IR' like it's relevant to anything? all compilers have immediate phases and it's completely irrelevant in discussing the input and output of said compiler
>>
>>61563364
Can C load a GDT?
>inb4 with a library that uses ASM
>>
>>61563242
>>61563330
https://gcc.gnu.org/onlinedocs/gccint/RTL.html
Then what's this?
>>
>>61563284
Assembly is surjective to machine code, so why would it be a problem?
>>
>>61563284
>>61563395
It compiles to a Lisp-esque intermediate representation called RTL which is handed off from the frontend to the backend. The backend optimizes then pattern matches it to asm snippets.
I haven't played with LLVM, but I knew a guy who used to sing its praises weekly.
>>
>>61563378
>IR is completely irrelevant to compiler input and output
IR is literally the bridge between a compiler's front and backend. It's not just an intermediate *phase*, like a tokenizer or code generation. It's an intermediate *state* like an AST. Please swallow my dick to it's base.

>>61563395
An IR which should be compiled directly into machine code for the target CPU.
>>
>>61563458
>An IR which should be compiled directly into machine code for the target CPU.
It is. It's compiled to assembly which is compiled to machine code.

Again, the assembly->machine code map is surjective.
>>
>>61563458
phase or state, the internal workings of a compiler make no difference to its inputs and outputs so they're completely irrelevant to the discussion. A tokenizer phase can produce tokens which can also be then a 'state'. It's a meaningless distinction.
>>
>>61563478
Reread. I said 'directly'.
>>
>>61563487
>The process itself and the output it produces are the same thing.
Wut
>>
>>61563489
It might as well be direct because it's surjective you retard. There's only one valid program per assembly file, and every possible program is covered by assembly. Consult https://en.wikipedia.org/wiki/Injective_function brainlet.
>>
File: 1418081126229.gif (3MB, 1280x720px) Image search: [Google]
1418081126229.gif
3MB, 1280x720px
>>61560889
Thank you for posting a mudslime and nigger free /dpt/
>>
>>61563496
the X phase of a program produces X state of the program. Arguing over using phase, process or state is meaningless in this case. Much like aruging over the distinction between machine code and assembly. This just sounds like some wiki warrior trying to sound smart by repeating things he's read online
>>
File: required texts.jpg (585KB, 2048x1536px) Image search: [Google]
required texts.jpg
585KB, 2048x1536px
>>61562131
I also think Fabien Sanglard is a cool guy
>>
>>61563505
>surjective
Stop abusing this term, you math illiterate dumbass. Every language implementation causes it's sourcecode to be surjective to it's fucking compiled code. Do you put the same C code into the same C code compiler and get different fucking machine code sometimes? If ASM was truly 1-to-1 with machine code, it wouldn't just be surjective, it'd be both surjective and injective.

>>61563532
None of the words you just said made any fucking sense. Read what you said and try to rationalize it to yourself. "Processes produce results therefore there is no distinction between processes and results therefore machine code is assembly."
>>
>>61562761
>C might go the way of Fortran and ASM
ASM is on the up and up, though
>>
>>61563589
>Every language implementation causes it's sourcecode to be surjective to it's fucking compiled code
Not only is this false, but this is not the same thing as
>Assembly is surjective to all possible machine code
Of course you can make a surjection out of any mapping if you restrict the codomain to the image of the domain you retard.

ASM doesn't need to be bijective retard. It needs to be Surjective. Surjective means that you make zero meaningful choices while compiling it, and there is a mapping to every possible program.

There are NO programs that you cannot write in assembly.

>Do you put the same C code into the same C code compiler and get different fucking machine code sometimes
Yes. It's called an "optimization setting."
>>
>>61563598
That's just due to the internet of things fad. It'll die out soon enough.
>>
>>61563598
Only for the web but even its still wildly experimental.
>>
>>61563589
how about you read what I said? I didn't say they were the same, I said the distinction in this case is meaningless. You're arguing over meaningless semantics in both cases.
>>
>>61563631
>Yes. It's called an "optimization setting."
The not's not the same implementation of C, you dipshit. Those are different backends. Do disassemblers existing now prove you wrong?
>>
How difficult is it to make a basic imageboard from scratch?
>>
>>61563217
Learning a statically typed language first is so much nicer than a dynamically typed language. I feel like it doesn't trap you into only feeling safe with dynamically typed languages.
>>
>>61563631
>There are NO programs that you cannot write in assembly.
Holy shit, that's hilarious. I didn't even notice you said that when I first read your post. Write a non surjective assembler in assembly.
>>
>>61563658
depends.
if its just a replica of a chan site, easy
if youre trying to do something innovative, hard
>>
>>61563642
No? It's actually exactly what I'm saying, because disassemblers don't change the program at all, whereas assembly -> C transpilers do.

You really are a brainlet.
>Yes. It's called an "optimization setting."
>The not's not the same implementation of C, you dipshit
So if I make a program that when presented with a choice in compilation, say whether to inline a function, chooses at random, then I've just made infinitely many implementations of C? You really are a brainlet.
>>
>>61563689
What if I just want ability to post images and reply? No fancy embedding or fancy text options.
>>
>>61563658
Anyone can make an image-board, good luck keeping people around.
>>
>>61563694
>because disassemblers don't change the program at all, whereas assembly -> C transpilers do.
How exactly do they do that?

>then I've just made infinitely many implementations of C?
You've not created infinitely many, but you've created quite a lot. Just like a hash function with a different seed is considered a new hash function.
>>
>>61563717
>>61563689
Can it be made in any language?
>>
>>61563745
Technically no, but in effect, yeah.
>>
>>61563745
>Can it be made in any language?
As long as it can talk to JS, but most anything can.
Heres a fellow anon's BBS
https://github.com/microsounds/akari-bbs
>>
>>61563713
>no fancy text options
Then how will people Be Me?
>>
File: 2wqertyujg.jpg (20KB, 1044x1044px) Image search: [Google]
2wqertyujg.jpg
20KB, 1044x1044px
Do you use Atom»?
>>
>>61563756
>As long as it can talk to JS
Why would an imageboard need to talk to JS?
>>
File: 1499839752598.jpg (45KB, 683x384px) Image search: [Google]
1499839752598.jpg
45KB, 683x384px
>get through first round of interview just fine
>called back in front of second round
>it's in a skype call with a non-native English speaker that can't understand anything I say
>answer everything correctly and try and explain it three different ways so he'll understand
>he still doesn't
>English speaker tells me after he thinks I did fine, but the other guy wasn't convinced
>>
>>61563776
Hiding posts/threads comes to mind
>>
>>61563776
If you want quick reply, you need javascript enabled.
>>
>>61563776
I mean if you want a super barebones HTML BBS then sure, but anything atleast on par with 4chan will require JS. But thankfully we have a 1001 languages that can compile to it.
>>
>>61563789
Don't have to do that with JS
>>
>>61563743
>How exactly do they do that
By being surjective. A compiled program is an equivalence class for assembly.
>You've not created infinitely many, but you've created quite a lot. Just like a hash function with a different seed is considered a new hash function.
No, I've created infinitely many retard. I can submit programs of unbounded length to a compiler, which means that the number of random choices that can be made are unbounded brainlet. Therefore, by your logic, I've created a compiler that can compile to infinitely many implementations of C.
>>
Lets say you did an imageboard and wanted to put in a cooldown per post or wanted to stop the same reply being spammed by bots, could that be done with javascript?
>>
>>61563789
>>61563800
>>61563811

Neither of you have ever written a damn thing for the web, have you? The language doesn't need to talk to JavaScript to serve a js file.
>>
File: 1407610731848.gif (3MB, 360x202px) Image search: [Google]
1407610731848.gif
3MB, 360x202px
>>61563782
Thanks Diversity quota!
>>
>>61563847
>Can X thing on the web be done it JS
Yes, thats literally its use.
>>
>>61563824
>No, I've created infinitely many retard.
Computer hardware is not capable of that. Machine code and ASM are different things. You've been throughly BTFO.
>>
>>61563863
I rather use javascript than a language like PHP that suffers from all kinds of malicious interjections.
>>
>>61563847
>>61563863
That can't be done in client-side JS, like the kind your browser reads. Someone could write a plugin for the browser that bypasses it and then any idiot would be able to spam. Bots don't give a fuck about your client code when sending requests.
>>
>>61563865
>Computer hardware is not capable of that
that's completely irrelevant in a theoretical dicussion involving the term 'infinite', dumbass, everything in the real world is finite
>>
>>61563865
>computer hardware is not capable of that
>i know nothing about computers
Learn what a memory mapper is retard. Here's one used in the NES:
https://en.wikipedia.org/wiki/Memory_management_controller
How do you think 8 bit machines had more than 2K ram? Or do you think that 8 bit machines were limited to 2k ram?
>machine code and asm are different things
Yes but asm is surjective to machine code, so machine code is (a) an equivalence class for asm and (b) every possible program can be written, so it literally does not matter that they're different.
>>
>>61563824
>No, I've created infinitely many retard.
>>61563913
>everything in the real world is finite

Lol, you accidentally agreed with me twice in a row. Machine code still isn't assembly.
>>
>>61563936
(a) not me (b) finite but UNBOUNDED.

Learn the difference between unbounded and infinite please.
>>
>>61563925
>actually arguing computers are capable of infinitely many anythings
Keep trying.
>>
>>61563883
Any language is susceptible to injection if you're dumb enough.
>>
>>61563953
learn the difference between unbounded and infinite brainlet.
>>
>>61563950
The word used was infinite. Don't say infinite if you don't mean infinite.
>>
>>61563967
But in PHP has so many corner cases that allow for injection that you have to put unnecessary effort into securing your website. And all that effort isn't worth it considering that PHP is just not a well designed language.
>>
>>61563973
Learn english.
>can compile to infinitely many things
Unbounded means infinite possibilities.
>>
>>61563992
I am always so paranoid when webshitting, everything feels like a house of cards that can blow up any second
>>
>>61563992
seriously when is the designer of the no-prepared-statement mysql module going to be thrown from a helicopter?
>>
can a Makefile do simple generic shit like compile every .cpp then link every .o?
>>
>>61563992
parameterizing queries or sanitizing input isn't any harder on php than other languages.
>>
>>61563936
not the same person, and being unable to discern context is a telltale sign of autism
>>
>>61564025
NO
THAT'S EXPLICITLY FORBIDDEN

of course it can my dude
>>
>>61564025
lol

that's what they are for
>>
>>61564025
That's literally all Makefiles are for
>>
>>61564025
Yes. There's a generic makefile floating around that will compile all cpp files in a directory (I don't have it and I don't know how to write one) but I end up accidentally dirtying my directories with responses code to anons anyway, and I don't want random shitposts being linked into my projects so I just do:
OBJ = foo.o bar.o (and so on)

%.o : %.c
gcc -c $< -o $@ -std=c99

main : $(OBJ)
gcc -o main $(OBJ) -std=c99
>>
>>61564048
>>61564045
>>61564037
I know what makefiles are for but how do you make it generic without feeding it anything except maybe the name of th executable?
>>
Hello /g/. Card game dev here, I'm wondering if I should continue to go through with my project. The idea is to create a sort of generic protocol for implementing TCG games like MTG or Hearthstone through a Scheme API with a simple GUI frontend. The game rules are completely customizable, so one could theoretically write up some rules, and then make cards for them and have a fully functioning networked game like MTGO. Also, if someone were to implement MTG or a large portion of it, the custom card community could build custom sets and try out interesting abilities.
I've been busy lately and barely have a UI so obviously there's a long way to go. Even after I have all the networking written out and the Scheme API implemented, I then have to implement an interesting card game and a bunch of cards for it and try to advertise the platform to /g/ and /tg/, which I'm not sure if anyone would really be willing to use it.

What do you think /g/, is it an idea worth pursuing?
>>
>>61564093
and in pure makefile of course
>>
>>61564123
Dream big but take little steps to get there. I'd start with blackjack as a proof of concept, then move up to a minimalist version of dominion.

Keep going.
>>
>>61564123
>Scheme API
noice

what dialect?
>>
>>61564123
i think /tg/ and possibly /qst/ would love it assuming it was user-friendly and you could quickly prototype and test-iterate.
>>
>>61564174
I think I'm going to use Chibi Scheme since it looks easy to embed. I plan to use some well established standard like R5RS because I don't want to have my client be the canonical client, I'd like for others to be able to create better clients once the protocol and API gets established.

As for prototypibility, I'll have to devise a library of commonly used card game patterns and make the interface easy to understand. I'm not entirely sure how that'd look right now, but the last thing I want is obtuse implementations due to a bad API
>>
>>61564257
sounds like the smart route

what is the program itself in?
>>
>>61564093
>>61564130
>>61564084
ok, I think I made some progress
>>
>>61560889
>How would you protect your program execution from attempts to inject arbitrary data into resident memory?
Not my program's but the OS' job.
>>
>>61562166
The book or the language?
>>
File: 61e.gif (476KB, 495x495px) Image search: [Google]
61e.gif
476KB, 495x495px
Could use help with the C problem, I just can't get it.

> Design and test a function that reads the first word from a line of input into an array and discards the rest of the line. It should skip over leading whitespace. Define a word as a sequence of characters with no blanks, tabs, or newlines in it.
>>
>>61562457
That's an interesting esoteric programming language, anon.
>>
>>61563062
>that image
What qualifications do you need to wash dishes?
>>
>>61560889
>How would you protect your program execution from attempts to inject arbitrary data into resident memory?
sanity checks and keeping three copies of everything
>>
>>61564313
>C
Enjoy your buffer overflows.
>>
>>61564313
nigger, this is easy as fuck
>>
>>61564319
>>>/pol/134930292
>>
>>61564331
Yeah I just don't understand it, i've been trying though
>>
>>61564257
Also make sure you're debugging tools are good. Make sure you can pause the simulation and go into a repl. The best way to do this is with call/cc

(define jmp '())
(define repl-mode? #f)
(define (repl)
(if (not repl-mode?)
(let ((oldjmp jmp))
(call/cc (lambda (cont)
(set! jmp cont)))
(if (not repl-mode?)
(oldjmp #f))))
;repl code here
)

(define (game-loop)
(if repl-mode?
(let ((oldjmp jmp))
(call/cc (lambda (cont)
(set! jmp cont)))
(if repl-mode?
(oldjmp #f))))
;game loop code here
)

This SHOULD work but any other schemefags in the thread pls correct me.
>>
>>61563217
I recommend C++ because it teaches good programming right off the start. When I was learning it I knew exactly what was happening in terms of memory when I a declared an integer variable.

Instead of muh magical variables that don't have a type in its declaration and the user doesn't understand what hes doing when he creates a variable. These shitty languages are the main reason new programmers are so shit, because they are cutting corners and building on top of a shakey foundation.
>>
Novice here, having trouble w/ some code

#include <stdio.h>

/* declare a sequence of constants */
enum colors { RED=1,YELLOW,GREEN,BROWN,BLUE,PINK,BLACK };

/* declare a custom type, of the enum colors type */
typedef enum colors COLORS;

/*declare a custom type of unsigned short int type */
typedef unsigned short int USHRT;


int main()
{
/*declare variables of the custom data types */
USHRT num = 16;
COLORS fingers = (COLORS) BROWN + PINK;

/* display the variable values */


/* display the value in the variable */
printf("values: %d %d\n", fingers, num);

return 0;
}

Returns invalid conversion from type int to COLORS... reading a book that says this is supposed to work. What do?
>>
>>61564365
the idea that when you learn programming you're some sort of pseudo-infant who will pick up bad practices they can't unlearn later in life is a meme that needs to die
>>
>>61564358
I'm planning on abusing call/cc for GUI interactions (e.g. you call something like (prompt "Discard a card?" '(yes no)) and it goes into a continuation until the user respond through the UI). I didn't think about debugging tools but you're right, I definitely need to think about that.
>>
>>61564370
???
works on my computer

compiles without errors
this is the equivalent code
#include <stdio.h>

/* declare a sequence of constants */
#define RED 1
#define YELLOW 2
#define GREEN 3
#define BROWN 4
#define BLUE 5
#define PINK 6
#define BLACK 7

int main()
{
/*declare variables of the custom data types */
unsigned short int num = 16;
int fingers = BROWN + PINK;

/* display the value in the variable */
printf("values: %d %d\n", fingers, num);

return 0;
}
>>
>>61564370
Change
COLORS fingers = (COLORS) BROWN + PINK;


to [COLORS fingers = (COLORS) (BROWN + PINK);
>>
>>61564313

if you can't even solve this then you should give up on programming

I'm totally serious
>>
>>61564313
>>61564483
>if you can't even solve this then you should give up on programming

kinda true.

For reals, anon, let's see you write this function in pseudocode. If you put in real effort, I'll give you some help.
>>
>>61564413
call/cc for callbacks huh. Never thought about using call/cc like that.

I mostly use libraries that use call/cc desu.

So something like this?

(define-syntax wait-for-response (syntax-rules ()
((_ response) (... standard coroutine stuff ...))))
(define (choose-discard card)
(if (wait-for-response (make-truefalse-alert-box (sprintf "Do you wish to discard ~A" (card 'tostring))))
(card 'to-graveyard)))
>>
>>61564390
you can unlearn bad practices, but human nature makes people pick sides and refuse to acknowledge the faults in how they learned something
>>
>>61564475
Works ty

>>61564422
The code u provided worked for me aswell. But my original does not.

I don't understand why it does for you and doesn't for me though.
>>
>>61564545
>I don't understand why it does for you and doesn't for me though.
well then post the fucking error the compiler threw
>>
File: Untitled.png (12KB, 360x502px) Image search: [Google]
Untitled.png
12KB, 360x502px
>>61564508
I thought programming is something i'd be interested in, I take a 6 week summer class and have come to realize that it may not be for me.

I've never felt more stupid in my life.
>>
>>61564589
You either commit and get better or you stay a pleb. Thats what separates the artisans from the actual programmers. Programming is not some magical birth perk some people only have.
>>
File: owl.jpg (65KB, 500x407px) Image search: [Google]
owl.jpg
65KB, 500x407px
>>61564589
>>
>>61564589
I've been programming for 15 years, anon.

I feel stupid every day, at some point.
>>
>>61564634
nice

what's your job?
>>
>>61564652
...computer programmer
>>
>>61564616
>>61564621
>>61564634
I get the concept that it takes practice, just like any other skill.

But this class is only 6 weeks and it's essentially just "Here's the concept, now solve this issue without being told how to use the concept"

I'm not one for blaming a professor, I don't , but I blame the fact that all of C is being packed into a 6 week course and I thought I would be able to handle it.
>>
>>61564666

6 weeks is more than enough to learn C
>>
>>61564658
nice

what stack do you use?
>>
>>61564666
Youre learning a shit way from a shit class and probably shit teacher.
C may be small but its atleast a summer class.
>>
>>61564676
>>61564695
You think it's enough time? The way the prof makes it seem is that it should be a full semester course, for fucks sake the guy hasn't even explained what #include <stdio.h> is, but says don't worry it's not important to the class.
>>
>>61564390
When I went to college I was expecting all of my peers to be really technical and good at programming. I soon realized that out of my entire class only one other person knew any programming.

They proceeded to cram everything into a 2 hour programming class twice a week and taught Python while cutting corners every step of the way. The end result was nobody having a clue how to program and just copy-pasting shit from the internet.

My high school programming classes taught me the fundamentals with C++, and college programming was a total joke.
>>
>>61564695
I'm in the middle of a clusterfuck.

I have to mess with fucking everything on any given day,

Java, Python, C#, Ruby, Actionscript/MXML(!!!)

PHP, Node, JS

MySQL, SQL Server, Postgres

Apache, IIS, Rails
>>
>>61564413
Oh fuck my repl code that I posted didn't work. Here I fixed it.
(define jmp '())
(define repl-mode? #f)
(define (repl)
(if (not repl-mode?)
(let ((oldjmp jmp))
(call/cc (lambda (cont)
(set! jmp cont)))
(if (not repl-mode?)
(oldjmp #f))))
;repl code here
(repl))

(define (game-loop)
(if repl-mode?
(let ((oldjmp jmp))
(call/cc (lambda (cont)
(set! jmp cont)))
(if repl-mode?
(oldjmp #f))))
;game loop code here
(game-loop))

(define (start-loop)
(call/cc (lambda (cont) (set! jmp cont)))
(if repl-mode?
(repl)
(game-loop)))
>>
>>61564742
This is normal. I'd estimate that the majority of people graduating from my school with a BCS had no idea how to program outside of toy academic examples.
>>
>>61564563
C:\Users\johnb\Documents\programming\C\enumtype.c: In function 'int main()':
C:\Users\johnb\Documents\programming\C\enumtype.c:17:34: error: invalid conversion from 'int' to 'COLORS {aka colors}' [-fpermissive]
COLORS fingers = (COLORS) BROWN + PINK;
~~~~~~~~~~~~~~~^~~~~~
[Finished in 0.1s with exit code 1]
[shell_cmd: g++ "C:\Users\johnb\Documents\programming\C\enumtype.c" -o "C:\Users\johnb\Documents\programming\C/enumtype" && "C:\Users\johnb\Documents\programming\C/enumtype"]
[dir: C:\Users\johnb\Documents\programming\C]
[path: C:\mingw64\bin;%JAVA_HOME%\bin;"C:\Users\johnb\AppData\Local\Microsoft\WindowsApps;C:\Program Files\mingw-w64\x86_64-7.1.0-win32-seh-rt_v5-rev0\mingw64";]

good point pal
>>
>>61564798
>using the C++ compiler to compile C code
>>
>>61564732
Yeah I know what you mean. My history prof forgot to tell us who won WW2. Gee I guess I'll never find out now.
>>
>>61564798
Install Pelles C.
>>
>>61564732
>for fucks sake the guy hasn't even explained what #include <stdio.h> is, but says don't worry it's not important to the class.
Ah yes, the original "ill explain using namespace std in a future video".

It includes source files which house things you use. When using printf your compiler needs to know where the source for that function is.
>>
Why do Rust strings not have a reverse method
It's so trivial to implement
>>
>>61564742
>>61564786
I was surprised by this, too.

I came in to college with 27 hours from AP tests, mostly from programming.

But I still had to take intro to CS. Final project was to implement bubble sort. Sophomore year of highschool we were doing self balancing trees and shit.
>>
>>61564370

Fingers as %d

Maybe you need a more idiomatic way to print this
>>
>>61564842
>It's so trivial to implement

but is it efficient?
>>
>>61564842
Because Rust unironically still doesnt even have proper strings.
>>
>>61564813
>>61564831
Thanks dudes
>>
>>61564862
I have no idea but to reverse strings you usually do some bullshit like x = x.chars().rev().collect() why not just wrap an x.reverse() around that
>>
>>61564666
>>61564732
You can learn C in a week -- it's a really small language. What takes a full semester is the background needed to understand what C is really doing (i.e. how computers work).
>>
>>61564864
???
>>
New thread:

>>61560918
>>61560918
>>61560918
>>
new proper in a sec lads
>>
real new
>>61564958
>>61564958
>>61564958
>>
>>61564798
Enums aren't really for arithmetic. They're meant to be their own type.
>>
>>61565105
You're right. The way to do it "cleanly" would be to overload operators (which I generally don't recommend).

Otherwise, you're just going to end up with a bunch of casting.

I explained this to an anon the other day. If you had like rgb color objects, you *might* want to overload so you could do stuff like

purple = red + blue;
Thread posts: 317
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.