/dpt/ - Daily Programming Thread

What are you working on, Cred Forums?

Previous thread:

Other urls found in this thread:

wiki.c2.com/?AlanKaysDefinitionOfObjectOriented
rylev.github.io/words/blog/2013/10/03/erlang-is-the-most-object-oriented-language/
ghostbin.com/paste/toudj
gameprogrammingpatterns.com/
docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/how-to-initialize-objects-by-using-an-object-initializer
gamefromscratch.com/post/2015/12/15/GameDev-For-Complete-Beginners-A-New-Series-Using-LuaLove2D.aspx
en.wikipedia.org/wiki/Game_programming
cplusplus.com/doc/tutorial/introduction/
google.com/
danluu.com/dunning-kruger/
google.com/recaptcha/api/fallback?k=' key,
en.wikipedia.org/wiki/Analysis_paralysis#Software_development
reddit.com/r/todayilearned/comments/3i9cmh/til_that_telling_other_people_about_your_goals/cuekfpr/
httpie.org/
forum.nim-lang.org/t/1278
forum.nim-lang.org/t/3473/1#21720
rbt.asia/g/search/image/cmWJbiSqqtdBE36rER7khg/
nim-lang.org/docs/intern.html),
ideone.com/wXB4ny
Cred
en.cppreference.com/w/cpp/language/nullptr
twitter.com/NSFWRedditGif

c++ is the greatest language of all time

What's with this religion bullshit over the last few threads, OP?
Only religion allowed on g is unashamed orthodox weebism.

Is there anything like type constraints in C++?

For example, proc fn[T : int | float](a, b: T)

I enjoy writing java code

data List(T: Type) {
nil,
cons(T, Self)
}

A discriminated union. It can be more space-efficient than the tagged version by indicating `nil` with a normally illegal null tail pointer.

type List(T: Type) = (tag: Bool, (| !tag) ^ (T, List(T) | tag));

impl[T] List(T) {
pattern nil = (false, ());
pattern cons(x: T, xs: Self) = (true, (x, xs));
}

A tagged union. `T ^ U` is the exclusive disjunction of `T` and `U`. In this case, it's inhabited because `!tag && tag` is unsatisfiable. It can be more ABI-friendly than the discriminated version because the layout in memory is well-defined. Discriminated union memory layout is not well-defined to allow for optimizations like the one shown for the first example. User-defined patterns can still be checked for exhaustive matching.

>I want the player to be able to ctrl+F to search through all items he's seen in the game, and that will be much fewer operations if the members of class_B/game_item are altogether in a seperate container I can iterate through
you mean like a diary that records where the player saw an item so he can go back and get it when he needs it? sounds like it should be a data structure of its own with a pointer to both the tile and the item.

The inevitable spread from when "christian" forums decided to start infiltrating Cred Forums around 2010-2013.
It has already ruined /fit/ I'm pretty sure /k/ and I'm pretty sure Cred Forums is on the list now

>Is there anything like type constraints in C++?
No. All you get is SFINAE.

...

why do you say that? If I have a doubly-linked list of instances of items_class, then those instances will already have branch/floor/x/y coordinates as members. Why would I copy the same information into a data structure that is organized in the same way? The reason I already want the same item listed twice is for computational efficiency: for ctrl+F, I want to be able to iterate through a list of items, and for drawscreen and monster AI, I want to be able to iterate through a list of x,y coordinates.

>not recognizing the one true belief system
pleb

I'll do that. My biggest worry is that I'm gonna get to some point where I realize that everything I've written is incompatible with some larger good design practice, and I'm gonna have to scrap it all. I already have 1k LOC, and don't want to get to 5k in time to find out that it only works on Linux, or it relies too heavily on pointers to save the gamestate, or that it's a convoluted spaghetti mess. However, I guess that is the nature of being new, can't know what you don't know until you know you don't know it.

Yeah, if you have proper references, sounds like you'd only gain something if you keep an itemsSeenLog: List[Item], since from what I understand you can access an item's location from the item, right?
>want the same item listed twice
Are you talking actual data duplication (as in, no longer doing Single Source Of Truth), or just referencing the data from multiple directions?

How can I route the code-completion list displayed in Visual Studio over to an executable? Or even just capture the list items as they pop up?

I am not asking for help, just seeing if anyone can point me toward the right direction. Already asked this elsewhere, can't get any info. Trying to look through VS but it would help if I had a tip from a more seasoned user.

I hope you're referring to the Church of Emacs, user.

That's why it's a good thing to keep asking, and share your thoughts.
Just don't forget to remind yourself - aim for a balance between getting shit done and getting shit proper.
>it only works on Linux
Port and test early, set up automated testing if possible. This is if other platforms are important enough. Go for at least smoke tests, whatever's easiest to have automated.
>relies too heavily on pointers to save the gamestate
Yeah, dunno what you're thinking about saving the game state. What do other projects in this class do?

I found out Windows 7 has a built in C# compiler, does anyone have any tweaks they make using C#?

It's just a women programmer wearing her programming hijab :)

Oh yeah, I now realize what I was missing. I will not have a itemsSeenLog, I'll just add a boolean "seen_by_player" member in the item class.

I'm not in a class, just been playing a lot of roguelikes and trying to write one. It's more work than I thought, mostly because I'm having to learn so much. My previous programming experience was just writing simple image editors in Matlab for uni.

its called intellisense

Thanks. Not sure why I didn't realize the entire code-complete process is handled through Intellisense. The more you know...

Ask again in ~2 years.

That's probably going to be hard as fuck, easiest way I can think of it to create your own code completion list using the Roslyn compiler by analysing the code tree yourself.

>>most of what i've found has dead results
>Look harder. Here's the basic idea: you pick a plane and use it to split space into two subsections: all the space behind the plane, and all the space in front of it; then, for each subspace, you pick another plane and repeat the process; keep doing this recursively until you reach some limit that satisfies you. When you're done, you're left with a binary tree of planes. You then take your polygons, and one by one, you "push" them through this tree: you check which side of the root plane the polygon is on. If it's behind, you push it through the (e.g.) left subtree. If it's in front, you push it through the right subtree. If it's on both sides (i.e. the plane splits it), you split the polygon into two, and push each one through the corresponding tree. Eventually you reach the leaf nodes, so you leave your polygons there. To draw it back-to-front, you start with the root plane and check which side the camera is on. You know that all the polygons on the opposite side have to be drawn before all the polygons on the same side as the camera, because any ray of light from the camera to the polygons on the other side would have to at least cross the plane to get to there, and it would sooner hit a polygon on the same side of the plane. So you draw the child node for the opposite side, then the child node for the camera side. The same logic them applies recursively until you reach the leaves, at which point you just render the polygons stored there. As for picking the planes in the first place, you have one for every polygon.

I kind of understood that. So you go left to right in the bsp tree.

What I am confused is what exactly a leaf node holds: a line? a polygon? a pixel?

How does the program cut it up into leaf nodes? How does it decide what the starting point is and what the final leaf is?

Without the diary structure you'd need to loop through the entire map every time to you want to show the player where the loot he has seen is located, and test whether he has seen that loot.
With the diary you have what you need and only what you need right there. You can sort it and to b-searches on it there, and you can put other important things like quest objectives in that same structure. It's good encapsulation and good semantics, the hero has-a diary.
And don't worry so much about memory use, especially for something so small as pointers. Memory exists to make your life easier.

I think we are on the same page. I planned on having 1 variable be a list of items, then also having map tiles point to the item. I thought for some reason user was saying I should have items included in a 3rd location.

>be me
>making a program in C
>compile without error
>test run
>wtf.png
>it behave really weird
>spend 7 hours checking whats wrong with the code
>turns out there is 2 .c files containing int data_index; and I forgot to set it to static, and the linker just connect them together

Stop using global variables, idiot.

I too have had problems in C. Mainly when I call a function that is in another C file without be being declared there.

if youre using global variables then youre a retard and should stop using c

>using a language that allows globals

>programming at all

Or maybe it's you who is retarded who knows nothing about his design requirements?
Global variable is fine if it's used for it's intended purpose: global state.

>inb4 hur dur all global state is bad
Or maybe you're just an idiot who's never done any real programming before.

Can someone explain what message passing is? I saw it while searching for Nim, which supports it, I read the wiki page but it looks identical to polymorphism.

Building a function that performs the Newton's method for approximating squares. Can't seem to get the a to continue updating past two iterations.
Where am I being a dumbass?
void newtons_method() {

int i = 0;
double long a = 1.0;
double long b = 3.5;

while (i < 100) {

b = (a - (func(a) / func_prime(a)));
a = b;
cout

approximating roots*

wiki.c2.com/?AlanKaysDefinitionOfObjectOriented

rylev.github.io/words/blog/2013/10/03/erlang-is-the-most-object-oriented-language/

Do you mean it crashes? Post expected outcome and actual outcome

Ackshually b = 3.5 might as well be nan since you never use that value

P(n) is now at : 3.5
P(n) is now at: 3
P(n) is now at : 2.5
P(n) is now at: 3
P(n) is now at : 2.5
P(n) is now at: 3
...
so 'a' starts at 1,
becomes 3.5,
by the 2nd iter, 'a' should equal ~2.60714, but it starts bouncing as you can see.
here are the funcs being called:
double long func(int x) {
return (x * x) - 6;
}

double long func_prime(int x) {
return 2 * x;
}

Is that supposed to happen?

Don't you have to declare that shit extern?

Accckkchully I know it but it was for debugging and I didn't change it back before I posted.

You might want to not use a func that works on ints if you want more precise results. Just sayin'

Fuck I'm a retard, now it's working, thanks, user.

You're welcome user

Hey guys. I have a dillema:
I am a developer and have been with my first company for 5 years now.
I worked on many different projects and had to use different technologies some of which are: C, C#, Javascript, TSQL, Java.
As you can guess I am now OK with all of them but really a master of none. When it comes to programming in general I would say I am very good and a fast learner.
In my company I am a one-man show since software development is not our core bussines. That is why I recently reached out to a few other companies where I would be surrounded with developers and learn more and quicker.

One of the companies is offering me a role of Javascript engineer... That would of course include Angular and similar frameworks.

The only problem is the salary. The new company is offering 20% less pay than the current one. This is kinda reasonable since I effectively only have a year of experience with the technology that they need me for, but on the other hand, overall I am an experienced developer and have brought a number of projects to completion.

On my current salary I can save 10% per month no problem.

So my question is: is it worth it to change my lifestile to spend less in order to try out a potentially better company?

There is a significant probability that my new salary could reach my current salary in about a year or a bit more.

I wanted to ask on /advice but the question is software based so i'm posting here.

it greatly bothers people like you

go back there

Dis nigga being a disingenuous and insensitive fag here because no one is arguing that.

If programming socks make you better at programming, why aren't there more female programmers? Surely they should be super powered from decades of wearing programming socks?

>retard thinks the prayers are for prevention
>not that the prayers are to get the sinning faggot kids into heaven
nigger needs to stop being edgy

Ask if the starting salary is negotiable.

That's basically a strawman of an amalgamation of gun owners and Christians, but so vague there's no opponent that's going to want to point it out. For liberals, debate means monologue.

I wouldn't take any life advices from the internet and especially 4cham.

If you care more about improving then you go to the place where you can improve.
But if you are thinking about some creative position you might be trying to bite more than you can chew.

>female brains is still inferior
>t. Neckbeard virgin misogyny.

Nice strawman.

Why grant the vote to females if they are just going to vote guns and booze away?

Will do probably

Normally I would not go to the internet woth this, but I am really struggling.
Just wanted to see how do you guys value learning over money.

New position won't be something crazy creative, there is a UX team for that.

Learn to generic:
#include
using namespace std;

template
FLOAT newton_method(FLOAT x0, Functor f, Functor_Prime f_prime, int iteration_count = 100){
while (iteration_count) {
x0 = (x0 - (f(x0) / f_prime(x0)));
cout

The blood of the innocent is needed for the conversion of sinners.

Cred Forums has never been your super secret fedora hideout.

>>>/reddit/

I don't see work as a place to learn but you should take opportunities that present themselves.

If risk isn't high only thing stopping you is fear.

why aren't you using D this very moment

Not as fast as C++, not as convenient as [every POOlang which isn't Java]

what's a good book to learn concurrency, preferably language-agnostic?

So I have only done object oriented programming and want to do a basic web project, but my shit Java doc only explains Tomcat and I am pretty sure is not what I want. I consider C# or C++ too, where do I start?/ I took JS classes and holy fuck JacaScript and HTML is a mess...

it's dead

Is it at all possible to disable playback controls somehow when streaming youtube video inside an app?

>putting this in a global variable because I don't know how else I can get the instance of that object
on a scale from 0 to 10, how wrong is that ?
0 is wrong, 10 is wrongest.

global variables are evil, but sometimes they're the least evil option

post your code

Friendly reminder goto is perfectly fine in modern languages.

desu there must be some other way, but the frontend of this ERP is very badly documented. And all these modules and objects and shit... I just feel like whatever I do I'm shooting myself in the foot.

ghostbin.com/paste/toudj

Can someone tell me how/why func1 is going terribly wrong with auto return type detection?

#include
#include
using namespace std;
#include

int main()
{
using F = boost::multiprecision::cpp_dec_float_50;
cout.precision(numeric_limits::max_digits10);
cout

If you don't know any better it's some kind of solution so it's not wrong.

Question should be how bad is that.

not him but would you mind explaining the syntax you used in main for your Functor and Functor_Prime args? I'm not familiar with it but it looks to be extremely useful.

>t.genericlet

he's using lambdas user. please dont template if you're going to only ever have the one parameter, you're just uglifying your code and increasing compilation times.

Are there any tools for designing text-based UIs? Or do I just have to like create a bunch of spaces with a monospace font in a word processor and work from there?

Because you're using boost. Who knows what black template magic is happening in the background.

ncurses

it's okay, I can't into templates yet anyway and I'm not planning on trying until my basic skills are much stronger, I just didn't think we had any lambda style functionality in c++, so this is good news to me

yeah it's a c++11 feature. good on you for waiting till you master the basics too

is this still relevant today, or is there a better, updated book?

>Be God
>Be about to cast Timmy into hell to be tortured for eternity.
>Soccer mom in America prays to me for 8 seconds and convinces me to send him to the good place forever

lmfao.
what a brainlet worldview

Don’t use OOP in 2018.

This.
DOD > OOP

mike acton pls go

Never heard of him but he seems pretty neat. More of a Jon Blow fan.

You can't reuse the Functor type for the 2nd lambda as each lambda is it's own anonymous struct type (with its own operator()). An alternative is to use std::function but that's can lead to more overhead and it's more annoying to call.

#include
#include
using namespace std;

template
FLOAT newton_method(FLOAT x0, function f, function f_prime, int iteration_count = 100){
while (iteration_count) {
x0 = (x0 - (f(x0) / f_prime(x0)));
cout

>What are you working on, Cred Forums?
AI-powered virus that replaces Anime with pictures of frogs.

stupid frogposter go back to

smart frogposter

Wow. That's very edgy. I didn't expect that from him.

Works fine in visual studio. Must be a gcc problem.

gameprogrammingpatterns.com/

I think he means lambdas are C++11

punch that straw

Not that guy but isn't it more appropriate to explain your view rather than mocking the opposition?
It's certainly more in line with the idea that prayer is for the sinners moral standing not to prevent their deaths.

>What I am confused is what exactly a leaf node holds: a line? a polygon? a pixel?
Every node has a plane that divides the parent's space (or subspace) into two. The leaf nodes also contain polygons.

>How does the program cut it up into leaf nodes?
Leaf nodes are just those nodes of the tree that have no children. They are the point at which you stop subdividing.

>How does it decide what the starting point is and what the final leaf is?
Typically, you will have a level made out of many convex solids, so every face of every solid has a plane associated with it. In principle, you can pick any of them as a starting point. Then you have solids on one side of it, and solids on the other side, so for each subspace, you pick another plane from a solid contained therein and repeat the process. Eventually you run out, because you will have subdivided the entire level into convex subspaces that have no solids in them, but which are the spaces between your solids. Naturally, you stop at this point. Then you can push the polygons through the tree, and be confident that all the polygons that end up in the leaves can't possibly obscure eachother, so they can be rendered in any order.

In practice, if you want to write a good BSP builder, you will typically try to pick your planes so that the number of splits (remember that you have to split a polygon if it's on both sides of a plane) is minimized. There are simple heuristics that can be applied here. For example, pick planes from big solids first, because they will have big polygons, and picking them last and pushing them from the tree increases the chances that one of the planes splits them. Small polygons aren't as likely to be split. If you want to use the BSP tree to accelerate game logic, you will probably also want the tree to be balanced. Industry-strength heuristics for doing this stuff are difficult, but once you understand the basics, you can always read more on this stuff.

I have been sick for the last 3 days, hopefully I can go back to writing and learning data structures from tomorrow

I'll pray for your health

Is it worth caching results from a mysql db if the table has like 500 rows?

thank you.

>If programming socks make you better at programming, why aren't there more female programmers?
>Surely they should be super powered from decades of wearing programming socks?
It's like wearing great running shoes but never actually running. You have to program while wearing them to become a good programmer.

I'm reading through pic related right now, what language would be good to use for typing up quick and simple implementations of the algorithms while also correctly demonstrating the strengths or weaknesses of each algorithm.

in other words, I'd like to be able to type up these algorithms to better understand how they work, but I don't have time to be reframing n-queens and creating custom classes/structs for this purpose on every single algorithm/agent type

or rather is there some simpler toy problem that can be quickly and easily implemented over and over again?

>t.brainlet

>muh sogyny
He wasn't making judgments about female brains, user. He was merely pointing out that they are, apparently, unsuitable for programming. This is probably a good thing. I don't want an autistic programmer girlfriend.

that image has to be poes law...


Right?

Getting "comfy" is a bad way to get mentally sharp. Programming socks are really "I'm mentally getting ready to spend the next 2 hours making hot cocoa and posting on my favorite forums"

Nope. She's real, and she even has a cake as her github profile pic. (Which kinda makes me wonder if you're right.)

for quick and simple implementations, literally any language. You are not posting to ask a serious question, you are posting to show off the book you are reading.

>What are you working on
managed to work out callbacks on WWW IEnumerator functions. Can make this fucking IO helper work in Unity now.

what's the discord?

>pls respond
>I am in need of an excuse to tip even harder

Is it possible in C# to add an item to a list in which arguments that are not given are automatically interpreted as null or 0? Adding another null in a list.Add whenever I add another variable in a class I use for a list is bothersome.

Do you mean something like this?
list.add(new Human{name=null});

the fuck is that syntax

docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/how-to-initialize-objects-by-using-an-object-initializer

you can go fuck yourself, I'm legit struggling with this book and I just wanted some suggestions on what I can do to better understand it without having to spend days trying to encode a sample problem correctly just so I can then try to implement an algorithm that I don't understand very well, correctly, in order to finally see some sample output that I have to try to decipher to see if I did anything correctly. I just wanted any advice on how to make any part of that process faster or at the very least more informative

>literally any language
okay, what's your favorite fucking language then?

Do it, faggot. Tell /dpt/ what your favorite language is. I fucking dare you.

does anybody have experience with pic related?

c# is gay

for quick and simple implementations, literally any lanuage. Pick one that you like the sound of and jump in with two feet.

what's a straight language?

FORTRAN

they're all gay
buncha 0s and 1s, and you always end up with some of the 1s touching
so they're all gay

>none of my study friends are interested in spatial data structures and voxel rendering
why life?

>I'm not in a class
Not what I meant, but now I can see how it can be misread. By
>What do other projects in this class do?
I meant
>What do other projects in this class of projects (i.e. games, and maybe roguelikes) in the ecosystem do?
In short, I'm hoping you're having a skim at what other projects similar to your own do from time to time, so you don't have to reinvent too many wheels.

An even lazier way is to use C++14's generic lambdas and auto

auto newton_method = [] (auto x0, auto f, auto f_prime, int iteration_count = 20) {
while (iteration_count) {
x0 = (x0 - (f(x0) / f_prime(x0)));
cout

If you post obviously incorrect code without disclaimers, you can't expect to not be called out on it.

Matlab

It's annoying that auto lambdas are a thing but auto functions are only a gcc thing.

God outsources a lot of his omniscience to humans, instead of using his own resources to determine if a kid was good enough to enter heaven he just uses the number and quality of prayers people send him using the heuristic that if a lot of people want you to go to heaven, you were probably good.

Haskell

I see all this talk about how setting pointers to null after deleting them is bad practice but I don't know how else you'd be able to avoid accessing invalid memory in a program like a game where you're regularly adding/removing objects. Is it fine to do assuming you're using something older than C++11?

>talk about how setting pointers to null after deleting them is bad practice
Never heard anyone claiming this.

>how else you'd be able to avoid accessing invalid memory in a program like a game where you're regularly adding/removing objects.
Why would you need to set anything to null? Presumably, you'd just delete the object and them remove it from the collection it was a part of, never to be seen again.

Dangling pointers aren't a problem for the pointer you're actively deleting, but they are a huge problem for other pointers in other parts of the program. This is why garbage collection and C++ smart pointers exist.

What if I'm a dumb bitch but I want to write code for a video game? How and where do I go to become less dumb and understand what I'm doing? I really, really want to know but I'm a brainlet when it comes to figuring shit out.

Send help please.

gamefromscratch.com/post/2015/12/15/GameDev-For-Complete-Beginners-A-New-Series-Using-LuaLove2D.aspx

>learning game development using lua

en.wikipedia.org/wiki/Game_programming

cplusplus.com/doc/tutorial/introduction/

google.com/

We could be all day here argueing about languages.
But I find just making something in anything will learn him more then muh perfect gamedev language.

Do you have some idea you want to implement? It's pretty difficult to learn if you don't have a specific thing to focus on.

When it comes to getting comfy, the programming plug is a must-have alongside your standard-issue programming socks.

You already accomplished an important step.
The best programmers know that they're dumb bitches even after years of experience.
Beware of self-proclaimed masters.

>Will learn him

this is a very nice post

Pick an engine and learn the language it uses, what type of game do you want to make? After you've learned how one engine works the second one is easier, so only focus on short term for now.

Oh, I see. Well, actually most of the games in the genre are open source, so 90% of the existing games are just forks of code from the 1980's. If I wanted to I could just take one of those source codes and tweak it, but I wanted to make it myself as a hobby. So, I'm not going to look too hard at what other games do codewise, although I am imitating them gameplaywise. I did a little more reading, and I guess the best way to savegame for a simple game like this is to just write the data as text into a .txt. I'll have to have functions for writing the data into the .txt in a way that a function can legibly read it when I load a game.

>But I find just making something in anything will learn him more then muh perfect gamedev language.
Making something in anything is better than making nothing, but making games in Lua is as close as you can get to making games but still not learning anything of value. There's a reason why people use it as a scripting language instead of writing engines in it.

Assuming I haven't changed anything am I legally allowed to distribute a WPF application made in VS Community 2017 using the default fonts and UI stuff?

>The best programmers know that they're dumb bitches even after years of experience.
So let me get this straight: you've been at it for years but you're still dumb and incompetent, and you think that having realized this means that you're a good programmer?

Love2D is actually pretty similar to using something like Monogame/XNA in terms of basic entry level gamedev. Its certainly closer to using a framework than a game engine like Godot or Unity. Whether that is a good thing or not is personal preference and goal related I guess.

Ever heard of the Dunning-Kruger effect?

Is it bad that I've done this guy's homework for fun?
#include
#include
#include

int main(void){
uint64_t n, l, r;
scanf("%llu %llu %llu", &n, &l, &r);

char tree[64];

int tree_size;
for(tree_size = 0; n; n >>= 1)
tree[tree_size++] = n&1;

uint64_t offset, step = 1 >= 1){
if(tree[i] != 1)
continue;

for(offset = (step >> 1) - 1; offset < l; offset += step)
;

for( ; offset < r; offset += step)
sum++;
}

printf("%d", sum);
}

>Dunning-Kruger

How many people actually follow links and check citations?
danluu.com/dunning-kruger/

"""The pop-sci version of Dunning-Kruger is that, the less someone knows about a subject, the more they think they know. The actual claim Dunning and Kruger make is much weaker."""

"""In two of the four cases, there’s an obvious positive correlation between perceived skill and actual skill, which is the opposite of the pop-sci conception of Dunning-Kruger. """

>If I wanted to I could just take one of those source codes and tweak it
Not the direction I was going in. More of a:
- did they do hand-written code to save the game state,
- was that a text/binary format,
- do newer projects go for automatic de/serialization of the state graph
- are there certain patterns, tools, libraries, that make sense to use
E.g. you have meta-programming libraries in most languages that allow you to just have your data type definitions, sprinkle in a line or two of code, and have code generated that can de/serialize from some common format, e.g. (ugh) JSON.
I'm thinking about all of this from the perspective of "tweaking gameplay mechanics is fun, de/serialization is boring. Can I waste as little time/motivation as possible on the latter, without sacrificing too much?"
>guess the best way to savegame for a simple game like this is to just write the data as text into a .txt. I'll have to have functions for writing the data into the .txt in a way that a function can legibly read it when I load a game.
Hand-written code, text format, cool cool.
The text format'll help with debugging.

So you're telling me that you've been at it for years but you're still dumb and incompetent, and you think that having realized this means you've overcome Dunning-Kruger levels of incompetence, so now you're a good programmer?

Where's that guy working on the wojak detector. I could use a dumb brinletposter filter.

Sounds like someone's a Dunning-Kruger on the Dunning-Kruger effect.

I'm not telling you that. Peer-reviewed scientific data is

>I'm not telling you that. Peer-reviewed scientific data is
So you're so incredibly fucking dumb that you think finally realizing your incompetence makes you competent? Is this what you're telling me? Because that's quite literally what you just said.

#get c
#get image
#display
#return answer with number pad
translate={7:0,
8:1,
9:2,
4:3,
5:4,
6:5,
1:6,
2:7,
3:8}

answer=sorted([translate[int(x)] for x in text])
Form={'c':c,
'response': {'0':answer[0],
'1':answer[1],
'2':answer[2]}
}
poster = requests.post('google.com/recaptcha/api/fallback?k=' key,
headers=user_agent(),
data=Form)
Why doesn't this work? Am I literally retarded? I don't get it.
Random guesses work, why not manual input?

What the fuck are you on about. Yes, chances are my sense of personal incompetence means I'm competent. That's what the fucking effect is.

Man, this one requires thinking.
Fuck that.

>chances are my sense of personal incompetence means I'm competent
Morons actually believe this... holy shit. user, either you are able to accurately judge your level of competence (i.e. you are definitely as incompetent as it seems to you), or you are not able to judge your level of competence (i.e. you are probably incompetent). Pick one.

...

>or you are not able to judge your level of competence (i.e. you are probably incompetent)
So you're disputing the dunning-kruger effect?

>implying that's not what he's saying
>implying he didn't outright confirm it

>So you're disputing the dunning-kruger effect?
What I said isn't even incompatible with their actual results. What their study shows is that incompetent people aren't good at judging their own level of competence, and as you get more competent, you know more about the field, so you know better where you stand.

So I actually have Imposter Syndrome. Whatever, you get my point. Stop being obtuse

>So I actually have Imposter Syndrome. Whatever, you get my point
No. You're actually just incompetent. That's all. There is zero evidence here that you're able to program, but every post of yours highlights your low IQ.

Nice opinion.

...

>implying
Just look at all your posts literally saying that you're competent because you think you're incompetent, and then tell me again how it's just my opinion that you're a retard. Non-retards avoid drawing retarded conclusions like that.

I'm not averse to doing a moderate amount of heavy lifting, learning wise. That's part of the reason for this project, is to learn, I already got a good start into C++, vim, some simple bash scripts. The thing that is troublesome is when I get that 'analysis paralysis' as you called it, and I'm not sure where to go to find an answer. But, I have a pretty clear path set out for at least the next few days now. Thanks for the advice, I'll probably keep posting even if I don't run into any big problems.

He's disputing your interpretation of the Dunning-Kruger effect.
The Dunning-Kruger effect is basically when someone believes that they're well-versed in a subject when they actually know bugger all.
What you seem to be trying to do is invoke something akin to a reverse-Dunning-Kruger effect, in that thinking you're not well-versed in a subject makes you an expert.

What you need to do is not only be humble enough to realise that you're not an expert, but also be able to identify which areas your knowledge and expertise are lacking and improve on those areas.

/thread.

try Python, shit was designed with brainlets in mind.

It requires thinking if you don't want to create a tree structure with 2^50 branches, wherein the left branch pointer always being equal to the right branch pointer.
Which is what my initial implementation did.

>when I get that 'analysis paralysis' as you called it,
Well-recognized term in the industry, actually:
en.wikipedia.org/wiki/Analysis_paralysis#Software_development
>and I'm not sure where to go to find an answer.
Post here, some game forums, maybe the StackExchange ecosystem.
>I'll probably keep posting even if I don't run into any big problems.
Even if it's not to help you solve an issue, it may have other positive outcomes, e.g.:
- pride in the progress that you're showing to others (and them stroking your ego) increasing your motivation. Note the opposite effect is also possible (discussion of this borderline pseudo-science from both sides: reddit.com/r/todayilearned/comments/3i9cmh/til_that_telling_other_people_about_your_goals/cuekfpr/ )
- alternatively, others occasionally providing alternative viewpoints (poor man's code review), though it helps to have a thick skin when peeps start shitposting
- this might encourage/inspire others
- might even find other people doing stuff in the same or related domains
- etc.
This goes not only for Cred Forums, but other communities.

Hey Cred Forums I have some time off and was thinking to make a two-player 'code battle' like TUI game.
I'm not that great with IPC, but the idea should be as follows:

- Game is started (./game)
- Two processes (player one's program P1 and player two's program P2) are started, so that there is no language constraint, as long as the program can run
- The game is turn-based, so first P1 receives the game state (JSON), decides on an action, and returns this to the game process
- Then P2 receives the (updated) game state, also decides on an action and sends it to the game process
- This repeats until one of two players wins.

I'm thinking of writing the game in python, calling two subprocesses, and communicating with them through pipes.
Would you guys know any better ideas or will this work fine?

Forgot to close code tag properly, fixed:

---
Hey Cred Forums I have some time off and was thinking to make a two-player 'code battle' like TUI game.
I'm not that great with IPC, but the idea should be as follows:

- Game is started game)
- Two processes (player one's program P1 and player two's program P2) are started, so that there is no language constraint, as long as the program can run
- The game is turn-based, so first P1 receives the game state (JSON), decides on an action, and returns this to the game process
- Then P2 receives the (updated) game state, also decides on an action and sends it to the game process
- This repeats until one of two players wins.

I'm thinking of writing the game in python, calling two subprocesses, and communicating with them through pipes.
Would you guys know any better ideas or will this work fine?

No but it's bad that you chose a language so poorly suited for the task.

Third time's the charm, budy.
Python'd work, but if it's that simple, you can do the glue in plain-ass shell, frankly.

dang

>y-you have to watch this ad! n-n-o s-skipping!
fuck you

Low level programming newfag here (only done web dev stuff before). I want to make a program that can send HTTP requests, and send and receive websocket data via socket.io. What language should I look into?

I've done a little bit of C++ before via Arduino, but I've spent hours trying to install CURL and still can't get it to work.

>What are you working on, Cred Forums?
Make an emulator for my own designed URISC architecture.
Now working on a simplified-pseudo-C compiler, and it become extremely confusing instantly.

A huge salute for everyone in the compiler making industries. This compiler can't even handle function, and takes 400MB memory to compile, and it doesn't even have any optimization at all.

Write in C.

Any good guides or books about making your own language? I'm not making anything advanced and it should run in another language in a game but I want to read up on it before diving in. It's a scripting language used in game to manipulate the objects in the game.

>I've spent hours trying to install CURL and still can't get it to work.
tf are you doing
literally
apt-get install curl
curl shit

don't tell me you're trying to do this in Windows
also, try httpie.org/

Why not lua? It's practically made for that shit.

>used in game to manipulate the objects in the game
If the in game interface is a CLI, then consider implement a rudimentary bash-like language or python-like language.
If there is no constrain of the interface, then you can create a scratch-like front end.

If the language is limited to in-game, then there is almost no point other than making yourself busy for a long time to "invent" a new programming language.

I'm using windows yes. Finally got it to work using vcpkg.

Nim or Rust for general purpose programming?
I'm not interested in low-level but they seem well made.

>general purpose programming
What's that?

Basically I want a multiplatform Swift.

If you want to dig in to your editor, try emacs

My condolences.
Even a shitty VM with a sane environment would make shit light years easier.

Scala.
Comes with goodies like
- horrible (Rust-tier) compilations times
- slow application startup times (it being more shit piled on top of the JVM)
- half the community is smug FP weenies
- decent SJW CoC presence
- occasional guest appearances by Java Pajeets that want to seem smarter
- Android story's in the shitter
- iOS one even more so
- probably missing something, comments welcome
I mean, what's not to love?

...

literally windows xp vms

>Nim or Rust for general purpose programming?
Nim is more expressive and concise, and it doesn't have Rust's obnoxious restrictions and borrow-checking autism. As a bonus, the community seems quite alright, as opposed to Rust's.

>probably missing something, comments welcome
They have 1 compiler, by which I mean they have 2 * 0.5compiler .

They still compile to C. Dropped.

>They still compile to C
Why is that a problem?

nlvm is on its way

>3*0.32 compilers
FTFY
And that's skipping the FP/SJW fork.

Crap, that's the backends.
Nvm, I'm retartet.

>low level
>socket.io
What?

nim is a language with meme level productivity
forum.nim-lang.org/t/1278

Rob Pike, pls go.

My language will make borrow checking great. You'll see...

Linear types will save systems programming

How do I access private associations in OOL?

Ools don't have access to private associations, silly. They live in barns.

It's impossible for any form of "borrow checking" to ever be great, user. "Great" borrow-checking is undecidable.

C will save systems programming.
C will save application programming.
C will save web programming.
Write in C.

Functional abstractions in Java 7.
private static class Differences extends Reducible {
private Reducible coll;
private T initial;
private Differ differ;

private static class State {
T lastItem;
U accum;

private State(T lastItem, U accum) {
this.lastItem = lastItem;
this.accum = accum;
}
}

public Differences(Reducible coll, T initial, Differ differ) {
this.coll = coll;
this.initial = initial;
this.differ = differ;
}

@Override
public U reduce(U accum, final Reducer r) {
return coll.reduce(new State(initial, accum), new Reducer() {
@Override
public State invoke(State accum, T x) {
return new State(x, r.invoke(accum.accum, differ.invoke(accum.lastItem, x)));
}
}).accum;
}
}

This is the worst one so far.

I don't think so, and even if that were the case, checking is surely decidable whereas automatic proving may be semi-decidable or undecidable at worst.

C is the reason systems programming needs to be saved

holy fuck, why, no, get it out of here.

is mov ax, 1 faster than mov rax, 1?

nim is a language with
- cuck license defenders
- that unironically believe the Invisible Hand will protect their bananus from the thick shaft of oligopolists and other free market failure modes

forum.nim-lang.org/t/3473/1#21720

Probably not

Why are lambdas in c++ so ugly?

I don't know what you guys are sperging about. If you go to the forums, you see that it's 99.9% technical.

why arent you using java 8

>(You)
>(You)
sameguy here
just shitposting a bit, BSD/GPL usually is decent flamebait.

>why arent you using java 8
Compatibility with old Androidshit.

Ah, the advantages of Google's "open" "source" ecosystem.

This one dude goes on a rant out of nowhere... and you read this much into it?

If it isn't the muslims shill OP from last summer:
rbt.asia/g/search/image/cmWJbiSqqtdBE36rER7khg/

Aren't you a bit early this year, Ahmed?

Alright I took the bait, well played.

Not his only one, he's the resident cuck license defender. I see him every time I end up there for whatever reason.

They are here too, having a non-restrictive entry to an internet community does that.

Oh yeah, no argument.
Thankfully there's more shitposters here to give them the mockery they ask for (but don't deserve).
We should be working together with the lads tho.
Full-on Stallman or full-on cuck are both extremes with their weak points when it comes to sustaining and growing software users' freedoms without shafting the devs too much.
That and pushover/commie license infighting mainly helps the common enemy - MS is probably popping champagne bottles.

Yes, it's called static typing.

Fuck off, KevinGolding,

That's literally just overloading.

>Yes, it's called static typing.
You mean you're so fucking stupid you don't know what a C++ template type parameter is? I guess that's to be expected from a C++ programmer.

So, DrRacket is the best IDE/"environment" for going through SICP, right? There ain't no way I'm going to use mit-scheme for it.

See

...

...

It means they don't have a reasonable compiler backend, yet and most likely leak semantics.
If done intentionally, it's a design flaw.
Good. Then it can finally become what Python should have been.

This. Given Nim or Crystal get production ready they will ravage golang.

>most likely leak semantics.
no. you can say the same thing for compiling to llvm ir

Also in their run to 1.0(which is coming soon(TM)) they are cleaning up a fuckton of stdlib bugs and crashes. IIRC the biggest segfaults in the compiler have been cleaned up last year.

That's just a declaration, there's no telling that the definitions are the same for T = Int and T = Float. Overloading technically works either way. Though, I suppose, so would templates, because of specialization.

int initialize(int per_row, int matrix[][per_row]);
Is this fine to do such thing in C? It does compile, I just don't know if it's safe

...

>C
Translation: it does the wrong thing, you are shooting yourself in the foot and not even realizing it. goto fail.

>no. you can say the same thing for compiling to llvm ir
In theory. In reality, compiling to C is just the hello world equivalent of compilers, whereas people that build llvm backends put in more efforts, like a custom IR.

Yeah, that is safe. What you've got is just a pointer to an array.
"int matrix[ ]" = "int (*matrix)"

If you'd have populated the left most index you'd have an array of pointers pointing to arrays.

It is all pointers, do not fear.

Only if you're using C99. matrix is a value of a variably modified type.

Either wait for craftinginterpreters.com (half way there) to be finished or buy interpreterbook.com if you're busy.

I'd generally go more with:
int initialize(int per_row, int **matrix);

How do I make gcc eat my chinese letters?

>That's just a declaration, there's no telling that the definitions are the same for T = Int and T = Float
His question sets the context. It's pretty clear what he's asking: if there's a way to control what sort of template type arguments are valid. I think this is known as "concepts" in Sepples town.

I'm curious, have you ever tried writing a short little nim program, compiling it to c, and then looking at the .c file that it creates and leaves right there for you to inspect?

>people that build llvm backends put in more efforts, like a custom IR.
Are you retarded or something? The entire point of LLVM is that you compile your program into LLVM IR, which is really just an uglier C. There isn't any inherent difference between compiling to one or the other. In fact, compiling to C is slightly more complex.

What would be the most valid way for passing a two dimensional array in C89?

Thats an option too, thanks

Cast it to a regular pointer and manually calculate indices.

Made c# backround program that checks for:
Windows Update
Update Orchestrator
Background Intelligent Transfer Service
Delivery Optimization Service
every 5 secs and stops them. First time doing anything in C# and without visual studio. It was bit annoying since msdn isnt very clear about imports but it works. Also figured out how to schedule it using task scheduler as admin on startup

No. Doesn't matter. It is an amateurish thing to do and an amateurish thing to defend.
Compiler devs either stop doing it at some point (even Hasklel) or perish, like Vala. Otherwise, you might as well "transpile" to JS.
>Are you retarded or something? The entire point of LLVM is that you compile your program into LLVM IR, which is really just an uglier C.
>t. brainlet
>There isn't any inherent difference between compiling to one or the other.
Except one has a loss of semantics like aliasing etc involved.
>In fact, compiling to C is slightly more complex.
If you don't do it correctly.

>she just keeps screeching how it "feels" amateurish to her
Nobody cares. Compilation is fast, and so is the executable. Now crawl back to .

So basicly
int initialize(int per_row, int *matrix);
...
initialize(10, (int*) array);

?

If I'm not mistaken, the question never mentioned templates. I guess this is what happens when you wank over memelangs too much.

>I don't care about proper compiler engineering.
Nobody cares. Your meme language will die anyway. And no, it doesn't compile fast. Now crawl back to .

Spotted the retard who has never developed real time software.

yep

It's one thing to have a level of intelligence so low that you can't figure out what's being asked because your mind can't recognize trivial patterns. It's a whole different things to try to respond while not understanding what's being asked. Why are C++ monkeys so retarded?

>she continues sperging autistically
>she still can't offer any concrete arguments against compilation to C
Off you go.

Bismillah she is covering her hair so kaffirs like you don't look at her inshallah

the best you can do at present is static_assert with further hacks.
template
void fn(T x)
{
static_assert(is_integral_v);
}

Luv ya

I come from C++ and C# (mainly directx and opengl), and am trying to learn JS for WebGL. I got the hang of it already but I still don't know the best practices for structuring large JS projects yet. Stuff like how/what to separate to different files, whether to try use 'objects' or a more functional approach, etc

Do you guys recommend any 3d engines in WebGL that are particularly well written or a good book for large JS project design patterns?

>still can't refute an answer

>she still can't offer any concrete arguments against compilation to C
I just did faggot. But if you are too retarded to understand the implications, it's the UTF16BE of compiler construction.
No idea why you bring up Rust repeatedly, it's like you like getting cucked or something.
You on the other hand are clearly a JS transpiling code artisan and belong to
>>>

>Otherwise, you might as well "transpile" to JS.
haha jokes on you, the nim compiler already supports this

[that's the joke.png]

>she

it's never too early to make Cred Forums halal again, kafir.

>putting genders

>i just screeched autistically again
>that proves me right
No point talking to animals. Come back when you have some solid arguments explaining why compiling to C is this huge practical downside that warrants your angry sperging.

ok brainlet

>crawl back to .
huh, I didn't even know that subreddit existed

really makes you think

after 8 months of searching for a job after graduating with my computer science degree, i finally got offered a position with a health insurance place doing enterprise java for 14/hour

i live in michigan so the market isnt great but im very happy that the search is finally over

How did you find the job/how did you search? tell me your secrets. I'm to brainlet to figure out on my own.

in c++, does return by reference make a duplicate of the object (consume more memory) or does it basically work like a pointer but without the pointer getting destroyed after you call the function?

Basically I have a vector of objects, and I need find and return one of these objects in the vector based on its id, but I don't want to create duplicates of the same object because these objects can have a lot of data in them. I'd rather just return a pointer to the object and manipulate it from there. But when I return a pointer, some values in the object's members get corrupted.

Would returning by reference eat up more memory than return a pointer?
I can return a pointer and use it, but I have to some hacky bs that I don't like.

You guys realize this whole shitposting debacle is all but moot because of , right?

i just used indeed and made a list of all the relevant keywords (computer science, java, c++, c#, programming, programmer, developer, software, etc) and searched everyday

my unis job site was fucking useless

In all the months I've seen anything related to Nim, I haven't seen anything about loss of semantics.
C++ also started like Nim(Cfront iirc), OCaml also had a C backend, you have Chicken Scheme(not really known tho so who cares huh).
Nim's compiler isn't just a +1 on a hello world compiler exercise (nim-lang.org/docs/intern.html), it does a lot of things right.

Even with all the `semantics loss` compiling to C(llvm backend is on it's way though) advantages outweighed all of the negatives.
Just look at Crystal with all it's platform and compile time issues and Nim where you don't have to worry about it.

FYI Nim also compiles to C++/ObjC

template
void fn(T a, T b)
{
//
}

Refute what, you tard? He wasn't asking about overloading. He was asking about constraints on type parameters.

never mind.
I'm just going to return the index of the object in the vector.

If you return via a reference, it's essentially a pointer assumbing the reference points to a valid variable that exists in member (i.e. a properly allocated class member). If you return a reference to an object on the scope then there's no guarantee and it's going to bite you in the ass.

I'm also doing the same, on a different site though.
I guess I gotta keep it up till I find something, I've been trying since september.

...

You can override that shit by passing a second argument manually.

Better to use static assert or a using declaration.

>responding to a butthurt sperg who makes vague assertions but can't provide practical examples
Never change, /dpt/. You're delightfully easy to bait.

What do you mean exactly? Care to elaborate?

Dumbass

New thread: :^)

Gotta procrastinate somehow innit

#include

template
void fn(T a, T b)
{
//
}

struct Foo{};

void foo()
{
fn(Foo{}, Foo{});
}

I love C++. It's so powerful that even the syntax reflects it. When you see someone writing that, you just know they have to be smart. C++ lets you do amazing things, like workarounds to constrain type parameters. It makes me feel empowered.

ideone.com/wXB4ny

Oh shit, I didn't realize that's what you were doing.
The = after typename in threw me off.
Yeah, that's a solution. Gives you a really shitty compile error though, I'd still prefer a static assert personally.

Well, you just said it yourself. All those that matter HAD a C backend.
Crystals problem come from another issue, not having enough competent compiler devs in the first place; that is what one of the devs said here a couple of days ago.
Feeding LLVM correctly isn't a light feat.

Look, when I said compiling to C is like UTF16 you should have done the math at last. Compiling to assembly is UTF8 and feeding a compiler pipeline directly is like UTF32. Not a great analogy, but if you can't comprehend the meaning of that, you're a mong. It's really a if you have to ask thing.

Yeah my bad, I do agree though that it's both ugly to write and produces nasty error messages.

>she continues to sperg about UTF16
>still not a single practical example to demonstrate why compiling to C is a huge downside

>she

Original newton's method guy, thanks for learnin' me some stuff.

Newton? Is that you?

>[captures](arguments){code};

How else would you do it?

#include
using std::string;

string cut(int i){
if(i==0)
return "0";
if(i==1)
return "1";
string s=cut(n/2);
return s+string(i%2)+s;
}

int count(int n, int l, int r){
string s=cut(i);
int num = 0;
for(int i=l-1; i

Cred Forums-science.wikia.com/wiki/Computer_Science_and_Engineering#Game_Development

the point is not to do
>ptr = 0;
or
>ptr = NULL;
but
>ptr = nullptr;

en.cppreference.com/w/cpp/language/nullptr