/dpt/ - Daily Programming Thread

Jaxon Brown
Jaxon Brown

What are you working on, Cred Forums?

Previous thread: credforums.com/thread/64780884/technology

Other urls found in this thread:

credforums.com/thread/64780884/technology
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/
credforums.com/thread/64768572/technology
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/
credforums.com/thread/64792121/technology
forum.nim-lang.org/t/1278
forum.nim-lang.org/t/3473/1#21720
rbt.asia/g/search/image/cmWJbiSqqtdBE36rER7khg/
credforums.com/thread/64793394/technology
nim-lang.org/docs/intern.html),
credforums.com/thread/64794002/technology
ideone.com/wXB4ny
Cred Forums-science.wikia.com/wiki/Computer_Science_and_Engineering#Game_Development
en.cppreference.com/w/cpp/language/nullptr

Lucas James
Lucas James

c++ is the greatest language of all time

Jonathan Lee
Jonathan Lee

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

Noah Anderson
Noah Anderson

Is there anything like type constraints in C++?

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

Andrew Williams
Andrew Williams

I enjoy writing java code

David Young
David Young

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.

Henry Martin
Henry Martin

credforums.com/thread/64780884/technology
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.

Leo Scott
Leo Scott

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

Easton Johnson
Easton Johnson

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

Zachary Russell
Zachary Russell

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.

Jackson Taylor
Jackson Taylor

not recognizing the one true belief system
pleb

Landon Lee
Landon Lee

credforums.com/thread/64780884/technology
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.

Kevin Jenkins
Kevin Jenkins

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?

Jack Morgan
Jack Morgan

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.

Zachary Davis
Zachary Davis

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

Liam Perry
Liam Perry

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?

Gabriel Perez
Gabriel Perez

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

Juan Parker
Juan Parker

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

Jaxson Jackson
Jaxson Jackson

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.

Zachary Campbell
Zachary Campbell

its called intellisense

Adam Miller
Adam Miller

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

Julian Davis
Julian Davis

Ask again in ~2 years.

Hunter Price
Hunter Price

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.

Angel Fisher
Angel Fisher

credforums.com/thread/64780884/technology
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.

Joseph Ward
Joseph Ward

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?

Juan James
Juan James

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.

Jackson Cox
Jackson Cox

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.

Jacob Myers
Jacob Myers

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

Wyatt Morales
Wyatt Morales

Stop using global variables, idiot.

Nolan Wood
Nolan Wood

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

Jace Morris
Jace Morris

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

Jacob Gray
Jacob Gray

using a language that allows globals

Bentley Anderson
Bentley Anderson

programming at all

William Thompson
William Thompson

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.

Juan Phillips
Juan Phillips

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.

Chase Fisher
Chase Fisher

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 << " P(n) is now at: " << a << endl;
i++;
}
}

Noah Wright
Noah Wright

approximating roots*

Jordan Walker
Jordan Walker

wiki.c2.com/?AlanKaysDefinitionOfObjectOriented

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

Christopher Jenkins
Christopher Jenkins

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

Daniel Barnes
Daniel Barnes

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

Julian Harris
Julian Harris

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;
}

Colton Cook
Colton Cook

Is that supposed to happen?

Don't you have to declare that shit extern?

Julian Davis
Julian Davis

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

Tyler Adams
Tyler Adams

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

Nicholas Reed
Nicholas Reed

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

Ryan Diaz
Ryan Diaz

You're welcome user

Luke Reed
Luke Reed

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.

John Powell
John Powell

it greatly bothers people like you

go back there

Angel Walker
Angel Walker

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

William Turner
William Turner

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?

Henry Anderson
Henry Anderson

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

Lincoln Smith
Lincoln Smith

Ask if the starting salary is negotiable.

Adrian Clark
Adrian Clark

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.

Evan Miller
Evan Miller

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.

Ryder Bennett
Ryder Bennett

female brains is still inferior
t. Neckbeard virgin misogyny.

Thomas Ortiz
Thomas Ortiz

Nice strawman.

Aaron Foster
Aaron Foster

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

Nolan Price
Nolan Price

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.

Jack Wright
Jack Wright

Learn to generic:

#include <iostream>
using namespace std;

template<typename FLOAT, typename Functor, typename Functor_Prime>
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 << " P(n) is now at: " << x0 << endl;
--iteration_count;
}
return x0;
}

int main()
{
newton_method(3.5, [](double a){ return a*a-2; }, [](double a){ return 2*a; });
}

Also why are you using long doubles? And why are you calling them double long?

Dylan Bennett
Dylan Bennett

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

Jeremiah Long
Jeremiah Long

Cred Forums has never been your super secret fedora hideout.

>>>/reddit/

Nicholas Young
Nicholas Young

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.

Brandon Watson
Brandon Watson

why aren't you using D this very moment

Ethan Bailey
Ethan Bailey

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

Tyler Williams
Tyler Williams

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

Cameron White
Cameron White

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

Luis Johnson
Luis Johnson

it's dead

Isaac Perez
Isaac Perez

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

Nicholas Sanders
Nicholas Sanders

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.

Adrian Ward
Adrian Ward

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

post your code

Lucas Adams
Lucas Adams

Friendly reminder goto is perfectly fine in modern languages.

Chase Walker
Chase Walker

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

Joshua Lopez
Joshua Lopez

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

#include <iostream>
#include <limits>
using namespace std;
#include <boost/multiprecision/cpp_dec_float.hpp>

int main()
{
using F = boost::multiprecision::cpp_dec_float_50;
cout.precision(numeric_limits<F>::max_digits10);
cout<<F{3.5}<<endl;
auto func1 = [](F a) { return 2*a; };
auto func2 = [](F a) -> F { return 2*a; };
cout<<2*F{3.5}<<endl;
cout<<func1(F{3.5})<<endl;
cout<<func2(F{3.5})<<endl;
}

output is:
3.5
7
0
7

If I set F = float/double/long double; it works just fine.

Leo Ramirez
Leo Ramirez

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.

Grayson Gray
Grayson Gray

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

Matthew James
Matthew James

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.

Joshua Cruz
Joshua Cruz

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?

Anthony Scott
Anthony Scott

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

Jacob Morales
Jacob Morales

ncurses

Sebastian Sullivan
Sebastian Sullivan

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

Landon Campbell
Landon Campbell

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

Matthew Ward
Matthew Ward

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

Jeremiah Baker
Jeremiah Baker

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

Samuel Barnes
Samuel Barnes

Don’t use OOP in 2018.

Landon Wright
Landon Wright

This.
DOD > OOP

Mason Turner
Mason Turner

mike acton pls go

Austin Watson
Austin Watson

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

Sebastian Lewis
Sebastian Lewis

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 <iostream>
#include <functional>
using namespace std;

template<typename FLOAT>
FLOAT newton_method(FLOAT x0, function<FLOAT(FLOAT)> f, function<FLOAT(FLOAT)> f_prime, int iteration_count = 100){
while (iteration_count) {
x0 = (x0 - (f(x0) / f_prime(x0)));
cout << " P(n) is now at: " << x0 << endl;
--iteration_count;
}
return x0;
}

int main()
{
newton_method<double>(3.5, [](double a){ return a*a-2; }, [](double a){ return 2*a; });
}

You need the <double> in newton_method<double> or it's not going to be able to deduce the template since you need to convert the lambda's into std::function<>.

Templates are one of the few ways to pass lambda expressions.

Templates have been around since C++98

Benjamin Harris
Benjamin Harris

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

Luis Sullivan
Luis Sullivan

stupid frogposter go back to /r/catalog#s=ibbit

Charles Morgan
Charles Morgan

smart frogposter

Juan Nelson
Juan Nelson

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

Andrew Carter
Andrew Carter

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

Logan Bell
Logan Bell

gameprogrammingpatterns.com/

Luis Martin
Luis Martin

I think he means lambdas are C++11

Jaxon Taylor
Jaxon Taylor

punch that straw

Gavin Walker
Gavin Walker

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.

Josiah Brooks
Josiah Brooks

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.

Christian Bell
Christian Bell

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

Adam Nguyen
Adam Nguyen

I'll pray for your health

Leo Martin
Leo Martin

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

Aaron Hernandez
Aaron Hernandez

thank you.

Jacob Wood
Jacob Wood

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.

Jace Perez
Jace Perez

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

Levi Wood
Levi Wood

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.

Joshua Wright
Joshua Wright

that image has to be poes law...

Right?

Luke Young
Luke Young

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"

Eli Bailey
Eli Bailey

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

Xavier Anderson
Xavier Anderson

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.

Carter Bennett
Carter Bennett

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

Benjamin Peterson
Benjamin Peterson

what's the discord?

Wyatt Roberts
Wyatt Roberts

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

Jaxon Adams
Jaxon Adams

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.

Julian Rivera
Julian Rivera

Do you mean something like this?

list.add(new Human{name=null});

Nicholas Gonzalez
Nicholas Gonzalez

the fuck is that syntax

Adam Hill
Adam Hill

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

Hunter Martinez
Hunter Martinez

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?

Josiah Torres
Josiah Torres

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

Dominic Long
Dominic Long

does anybody have experience with pic related?

Nicholas Gomez
Nicholas Gomez

c# is gay

Jaxson Reyes
Jaxson Reyes

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

Landon Lee
Landon Lee

what's a straight language?

Parker Thompson
Parker Thompson

FORTRAN

Christopher Reed
Christopher Reed

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

Luis Allen
Luis Allen

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

Kayden Myers
Kayden Myers

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.

Andrew Carter
Andrew Carter

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 << " P(n) is now at: " << x0 << endl;
--iteration_count;
}
return x0;
};

Tyler Ross
Tyler Ross

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

Liam Reed
Liam Reed

Matlab

Brody Fisher
Brody Fisher

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

Thomas Torres
Thomas Torres

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.

Carson Reyes
Carson Reyes

Haskell

Cooper Jones
Cooper Jones

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?

Cameron Hill
Cameron Hill

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.

Gabriel Powell
Gabriel Powell

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.

William Edwards
William Edwards

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.

Ryder Green
Ryder Green

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

Juan Gray
Juan Gray

learning game development using lua

Joshua Campbell
Joshua Campbell

en.wikipedia.org/wiki/Game_programming

cplusplus.com/doc/tutorial/introduction/

google.com/

Colton Gonzalez
Colton Gonzalez

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.

Thomas Campbell
Thomas Campbell

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.

Robert Baker
Robert Baker

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

Luis Ward
Luis Ward

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.

Ryder Campbell
Ryder Campbell

Will learn him

Parker Reyes
Parker Reyes

this is a very nice post

Ian Lopez
Ian Lopez

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.

Andrew Reed
Andrew Reed

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.

Gavin Lee
Gavin Lee

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.

Oliver Lee
Oliver Lee

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?

Angel Howard
Angel Howard

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?

Gabriel Green
Gabriel Green

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.

Alexander Rivera
Alexander Rivera

Ever heard of the Dunning-Kruger effect?

Luke Butler
Luke Butler

Is it bad that I've done this guy's credforums.com/thread/64768572/technology credforums.com/thread/64768572/technology homework for fun?

#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>

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 << tree_size;

l--;
int i, sum = 0;
for(i = 0; i < tree_size; i++, step >>= 1){
if(tree[i] != 1)
continue;

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

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

printf("%d", sum);
}

Easton Anderson
Easton Anderson

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

Kevin Fisher
Kevin Fisher

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.

Connor Green
Connor Green

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?

Ryan Gonzalez
Ryan Gonzalez

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

Jaxson James
Jaxson James

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

Jayden Gonzalez
Jayden Gonzalez

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

Hunter Murphy
Hunter Murphy

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.

Anthony Reed
Anthony Reed

#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?

Brayden Williams
Brayden Williams

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.

Hunter Stewart
Hunter Stewart

Man, this one requires thinking.
Fuck that.

Owen Wood
Owen Wood

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.

Leo Kelly
Leo Kelly

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?

Zachary Sanchez
Zachary Sanchez

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

Isaiah Rivera
Isaiah Rivera

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.

Jayden Nelson
Jayden Nelson

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

Jackson Bailey
Jackson Bailey

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.

Carson Hughes
Carson Hughes

Nice opinion.

Ayden Robinson
Ayden Robinson

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.

Joseph Bennett
Joseph Bennett

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.

Carson Carter
Carson Carter

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.

Xavier Davis
Xavier Davis

/thread.

Nathaniel Moore
Nathaniel Moore

try Python, shit was designed with brainlets in mind.

Nathaniel Brown
Nathaniel Brown

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.

Leo Rivera
Leo Rivera

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.

Oliver Harris
Oliver Harris

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?

Brandon Campbell
Brandon Campbell

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?

Evan Brown
Evan Brown

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

Kayden Morales
Kayden Morales

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.

Gavin Miller
Gavin Miller

dang

Nicholas Williams
Nicholas Williams

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

Parker Mitchell
Parker Mitchell

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.

Brayden Wright
Brayden Wright

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.

Asher Cruz
Asher Cruz

Write in C.

Leo Thomas
Leo Thomas

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.

Jordan Turner
Jordan Turner

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/

Zachary Wilson
Zachary Wilson

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

Jonathan Wright
Jonathan Wright

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.

Jose Price
Jose Price

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

Camden Jenkins
Camden Jenkins

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

Joseph Davis
Joseph Davis

general purpose programming
What's that?

Nathaniel Johnson
Nathaniel Johnson

Basically I want a multiplatform Swift.

Robert Howard
Robert Howard

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

Landon Price
Landon Price

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

Luke Moore
Luke Moore

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?

Mason Allen
Mason Allen

credforums.com/thread/64792121/technology

Ryan Phillips
Ryan Phillips

literally windows xp vms

Dominic Clark
Dominic Clark

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.

Jack Myers
Jack Myers

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

Noah Ortiz
Noah Ortiz

They still compile to C. Dropped.

Ian Cooper
Ian Cooper

They still compile to C
Why is that a problem?

Caleb Morris
Caleb Morris

nlvm is on its way

Julian Turner
Julian Turner

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

Tyler Hughes
Tyler Hughes

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

James Anderson
James Anderson

low level
socket.io
What?

Jaxson Adams
Jaxson Adams

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

Parker Green
Parker Green

Rob Pike, pls go.

Dominic Harris
Dominic Harris

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

James Nguyen
James Nguyen

Linear types will save systems programming

Samuel James
Samuel James

How do I access private associations in OOL?

Lucas Rodriguez
Lucas Rodriguez

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

Juan Gray
Juan Gray

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

Robert Ortiz
Robert Ortiz

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

Jordan Smith
Jordan Smith

Functional abstractions in Java 7.

    private static class Differences<T, D> extends Reducible<D> {
private Reducible<T> coll;
private T initial;
private Differ<T, D> differ;

private static class State<T, U> {
T lastItem;
U accum;

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

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

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


This is the worst one so far.

James Powell
James Powell

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.

Jackson Gonzalez
Jackson Gonzalez

C is the reason systems programming needs to be saved

Jace Rivera
Jace Rivera

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

Parker Brooks
Parker Brooks

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

William James
William James

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

Parker Watson
Parker Watson

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

Easton Perez
Easton Perez

Probably not

Jeremiah Walker
Jeremiah Walker

Why are lambdas in c++ so ugly?

Daniel Young
Daniel Young

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

Connor Green
Connor Green

why arent you using java 8

Grayson Bailey
Grayson Bailey

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

Levi Sullivan
Levi Sullivan

why arent you using java 8
Compatibility with old Androidshit.

Christian Sanders
Christian Sanders

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

Luis Evans
Luis Evans

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

Nathan Carter
Nathan Carter

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?

Kevin Nguyen
Kevin Nguyen

Alright I took the bait, well played.

Dominic Peterson
Dominic Peterson

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

Michael Lee
Michael Lee

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

Anthony Howard
Anthony Howard

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.

Grayson Taylor
Grayson Taylor

Yes, it's called static typing.

Nathan Reed
Nathan Reed

Fuck off, KevinGolding,

Logan Richardson
Logan Richardson

That's literally just overloading.

Levi Smith
Levi Smith

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.

Ethan Hernandez
Ethan Hernandez

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.

Kayden Myers
Kayden Myers

See

Jack Ramirez
Jack Ramirez

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.

Ethan Collins
Ethan Collins

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

Juan Reyes
Juan Reyes

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

Tyler Morris
Tyler Morris

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.

Zachary Flores
Zachary Flores

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.

Chase Phillips
Chase Phillips

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

Aaron Robinson
Aaron Robinson

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

Zachary Reed
Zachary Reed

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.

Jeremiah Hernandez
Jeremiah Hernandez

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.

Zachary Cooper
Zachary Cooper

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

Ayden Johnson
Ayden Johnson

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

Liam Scott
Liam Scott

I'd generally go more with:

int initialize(int per_row, int **matrix);

Zachary Green
Zachary Green

How do I make gcc eat my chinese letters?

Wyatt Cook
Wyatt Cook

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.

Lucas Lee
Lucas Lee

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?

Adrian Cooper
Adrian Cooper

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.

Liam Sanchez
Liam Sanchez

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

Thats an option too, thanks

Carson Butler
Carson Butler

Cast it to a regular pointer and manually calculate indices.

Brody Collins
Brody Collins

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

Thomas Powell
Thomas Powell

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.

Brandon Perry
Brandon Perry

she just keeps screeching how it "feels" amateurish to her
Nobody cares. Compilation is fast, and so is the executable. Now crawl back to /r/catalog#s=rust.

Samuel Peterson
Samuel Peterson

So basicly

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

?

Henry Rivera
Henry Rivera

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

Connor Barnes
Connor Barnes

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 /r/catalog#s=coffeescript.

Parker Thompson
Parker Thompson

Spotted the retard who has never developed real time software.

David Ramirez
David Ramirez

yep

Logan Watson
Logan Watson

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?

Isaiah Wright
Isaiah Wright

she continues sperging autistically
she still can't offer any concrete arguments against compilation to C
/r/catalog#s=rust
Off you go.

Parker Morgan
Parker Morgan

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

Aaron Evans
Aaron Evans

the best you can do at present is static_assert with further hacks.

template <typename T>
void fn(T x)
{
static_assert(is_integral_v<T>);
}

John Jenkins
John Jenkins

Luv ya

Carter Bennett
Carter Bennett

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?

Jeremiah Baker
Jeremiah Baker

still can't refute an answer

Hunter Morris
Hunter Morris

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
credforums.com/thread/64793394/technology

Ryder Bell
Ryder Bell

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

Liam Bennett
Liam Bennett

[that's the joke.png]

Jace Gutierrez
Jace Gutierrez

she

William Clark
William Clark

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

Matthew Diaz
Matthew Diaz

putting genders

Joshua Johnson
Joshua Johnson

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.

Ian Collins
Ian Collins

ok brainlet

Jordan Phillips
Jordan Phillips

crawl back to /r/catalog#s=coffeescript.
huh, I didn't even know that subreddit existed

really makes you think

Gavin Scott
Gavin Scott

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

Connor Hill
Connor Hill

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

Robert Watson
Robert Watson

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.

Blake Gutierrez
Blake Gutierrez

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

Jason Sanders
Jason Sanders

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

Jeremiah Walker
Jeremiah Walker

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

Austin Nguyen
Austin Nguyen

template <typename T, typename = std::enable_if<std::is_floating_point<T>{} || std::is_integral<T>{}>::type * = nullptr>
void fn(T a, T b)
{
//
}

Ryan Gomez
Ryan Gomez

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

Christian Brown
Christian Brown

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

Levi Ward
Levi Ward

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.

Jayden Howard
Jayden Howard

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.

Cooper Peterson
Cooper Peterson

credforums.com/thread/64794002/technology
credforums.com/thread/64794002/technology
credforums.com/thread/64794002/technology
credforums.com/thread/64794002/technology

Caleb Brown
Caleb Brown

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

Better to use static assert or a using declaration.

Ian Bailey
Ian Bailey

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

Tyler Lopez
Tyler Lopez

What do you mean exactly? Care to elaborate?

Daniel Brooks
Daniel Brooks

Dumbass

Asher Sullivan
Asher Sullivan

New thread: credforums.com/thread/64794002/technology

:^)

Landon Hughes
Landon Hughes

Gotta procrastinate somehow innit

Levi Hernandez
Levi Hernandez

#include <type_traits>

template <typename T, typename = std::enable_if_t<std::is_floating_point_v<T> || std::is_integral_v<T>>>
void fn(T a, T b)
{
//
}

struct Foo{};

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

Kevin Cox
Kevin Cox

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.

Camden Scott
Camden Scott

ideone.com/wXB4ny

Robert Rodriguez
Robert Rodriguez

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.

Lincoln James
Lincoln James

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.

Carter Cooper
Carter Cooper

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

Josiah Nguyen
Josiah Nguyen

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

Parker Garcia
Parker Garcia

she

Easton Cruz
Easton Cruz

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

Sebastian Ramirez
Sebastian Ramirez

Newton? Is that you?

Gavin Hughes
Gavin Hughes

[captures](arguments){code};

How else would you do it?

Levi Allen
Levi Allen

#include<string>
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<r; i++){
if(s[i]=="i"s;) num++;
}
return num;
}

Jayden Mitchell
Jayden Mitchell

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

Disable AdBlock to view this page

Disable AdBlock to view this page

Confirm your age

This website may contain content of an adult nature. If you are under the age of 18, if such content offends you or if it is illegal to view such content in your community, please EXIT.

Enter Exit

About Privacy

We use cookies to personalize content and ads, to provide social media features and to analyze our traffic. We also share information about your use of our site with our advertising and analytics partners.

Accept Exit