[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 33
File: rwh_cover.jpg (95 KB, 500x656) Image search: [Google]
rwh_cover.jpg
95 KB, 500x656
Pajeet gets triggered edition

Old: >>54944744
>>
TRIGGERED
>>
>>54951352
>haskell
>real world haskell
good joke m8
>>
>>54951352
First for C
>>
Rust is the only good language.
>>
>>54951361
>>54951419
POO
>>
>>54951409
>>54951449
>>54951481
>>54951496
I'm doing a game in monogame. I haven't written any C# before and I know a little bit of Java (took maybe two courses in it, so I know OOP stuff, but no language details really).

Anything to be aware of?
>>
>>54951515
Also I could optionally switch to F# now. But that doesn't seem like a priority since I'm likely only gonna do C# for this and perhaps small things in the future.
>>
reminder
>>
>>54951535
I don't think I've ever seen any serious discussion about Perl
>>
>>54951547
It all happened before you were born.
Perl is quite literally the Python of the 1990s.
>>
>>54951555
Probably because all of the programmers moved on and everyone realized that it's a write-only language.

But hey, Perl6 is out now :^)
>>
>>54951515
>Anything to be aware of?

It can be broken in subtle ways. I'd use love2d if I were you.
>>
>>54951555
Except Python isn't nearly as shit
>>
>>54951562
Does anyone use Perl 6?
>>
>>54951567
not as shit as perl but still really, really, REALLY shit
>>
>>54951602
Why?

>inb4 whitespace meme
>>
Any good learning material for C# ?
>>
I wish it was easier to deploy new media formats and whatnot on the web.

FLIF, for instance, is an amazing image format: FOSS, supports lossy and lossless encoding, transparency, animation. Encodes all types of images about as well as or better than specialized formats like PNG and JPEG. Highly advanced progressive rendering: you can use prefixes of the full-resolution image instead of generating thumbnails, and it loads entire animations from low to high quality, rather than from start to finish, so a half-loaded throbber / progress indicator will play the entire loop in reduced quality, rather than pausing at the first unloaded frame.

But getting a format standardized + supported in all browsers is a huge pain, and is nearly impossible if you aren't Google, Apple, or Microsoft.

Why isn't there a principled way of doing essentially PolyFills? Something like the server sending a hash of the decoder, hash of decoded output, and record of number of steps to decode and peak memory usage in some standard virtual machine. Then the client can verify the decoder, verify the correct decoded output, can cut off the decoding process if it runs for longer or uses more memory than it claims, and the client can refuse to decode things that request absurd amounts of CPU time or memory.
>>
>>54951419
It's used.

You just have to be competent and aware of its type system.

You should be aware of your chosen language's type system anyway.
>>
>>54951675
You can decode FLIF in (ASM.)JS for now

I agree, it's cool
>>
File: [tilting increases].png (27 KB, 500x500) Image search: [Google]
[tilting increases].png
27 KB, 500x500
>>54951676
>You just have to be competent and aware of its type system.
>>
>>54951675

I'm still waiting for people to care about apng.
>>
>>54951702
FLIF essentially obsoletes APNG, but I'd still take APNG if that's all we can get.
>>
>>54951702
Hi there!

You seem to have made a bit of a mistake in your post. Luckily, the users of 4chan are always willing to help you clear this problem right up! You appear to have used a tripcode when posting, but your identity has nothing at all to do with the conversation! Whoops! You should always remember to stop using your tripcode when the thread it was used for is gone, unless another one is started! Posting with a tripcode when it isn't necessary is poor form. You should always try to post anonymously, unless your identity is absolutely vital to the post that you're making!

Now, there's no need to thank me - I'm just doing my bit to help you get used to the anonymous image-board culture!
>>
>>54951715
>>54951702
How computation intensive is it?
>>
>>54951715

If we wait a few hundred years, then maybe it will have eclipsed GIF.

>>54951720

Thanks.
>>
>>54951735
Hi there!

You seem to have made a bit of a mistake in your post. Luckily, the users of 4chan are always willing to help you clear this problem right up! You appear to have used a tripcode when posting, but your identity has nothing at all to do with the conversation! Whoops! You should always remember to stop using your tripcode when the thread it was used for is gone, unless another one is started! Posting with a tripcode when it isn't necessary is poor form. You should always try to post anonymously, unless your identity is absolutely vital to the post that you're making!

Now, there's no need to thank me - I'm just doing my bit to help you get used to the anonymous image-board culture!
>>
tbqh I would use ocaml over F# if it had good parallel programming
>>
>>54951692
I'm right, you know.
>>
>>54951762
competent people don't use haskell
>>
>>54951746

Thanks.
>>
>>54951822
Competent people use what is ideal for the task.

Some people use Haskell, but only a few. Quit being a farquad.
>>
>>54951833
some people literally eat shit, but only a few.

just because a language exists doesn't mean you have to use it.
>>
>>54951762
Of course you are right, you should be aware of type system of any language you use to be good at it.

When people joke about Haskell being useless in the real world, it is generally in response to Haskell programmers who refuse to recognize that the language has drawbacks. It isn't the right tool for every job.

Sometimes you need to be fully aware of how much memory your program uses. Haskell makes reasoning about this difficult. Sometimes you have to mutate a byte array. Even if you don't need to, sometimes stateful mutation is the most intuitive way to write something. Haskell makes this ugly. Sometimes you need to reach below the abstractions you generally use to get all the performance you can out a hot loop. Haskell makes this retarded (see: Haskell entries on the shootout).
>>
when you printf a bool as "%d" it can have values that are not 0 or 1

what are the caveats when using bools? in which situations does a true bool not get implicitly converted to 1?
>>
>C#
>Java
>Cannot even explicitly destroy objects
HAHAHAHA how do you retards even consider these viable languages to program in?
>>
>>54951939
I'm guessing your bool is actually just a byte. Values other than 0 or 1 are invalid, afaik.
>>
>>54951939
Sounds like you want a char.
>>
>>54951352
Does anyone have a PDF for Advanced computer architectures: a design space approach by D. Sima (Deszo) T. J Fountain (Terry J.); Peter Kacsuk?
>>
>>54951952
>C
>C++
>Can leak memory
HAHAHAHAHAHA how do you retards even consider these viable languages to program in?
>>
>>54951958
> Kacsuk
> Cock Suck
>>
>>54951852
Any sane person would use C for the examples you give, yes. Now, try computing a byte array across 16 cores.

Machines have 8GB of RAM nowadays, and four or more cores, so we can write concise code in a functional language that doesn't needlessly hog resources. It's the future.
>>
>>54951968
Java and C# can also leak memory.
>>
>>54951955
the bool i'm printing is part of a struct array. maybe %d is reading 4 bytes while the bool is only 1 byte so it includes 3 erroneous bytes in the value?
>>
>>54951958
>>54951973

That name is unfortunate.
>>
>>54951983
Make a copy of your code and remove things until you have the smallest example that shows the weird behavior you are noticing. Then post that.
>>
Anyone know a book on monogame?
What should I be reading? Should I read a C# book if I'm sortof experienced in C++?
>>
>>54951979
I wasn't defending java or C#.
>>
>>54951968
The difference is that in these languages you can extremely easily free those resources explicitly, unless of course you're retarded.
>>
>>54952003
(You)
>>
>>54951968
You can soft-leak memory (read: still have pointers to it, but will not read it again for the life of the program) in any language. The bigger issue is that you can trivially dereference invalid pointers in those languages.
>>
>>54951983
>>54951998
>>54951939
never mind i was printing uninitialized bools so it was UB
>>
>>54951983
If you're worried do
bool b=true;
printf("MyBool as int %d",b&000000FF);
>>
>>54952040
Use warnings.
>>
>>54951983
Are you using stdbool.h? You can't printf bools directly because there is no format specifier for a byte (except char, but that's not going to work.)

Just do printf("%s", bool_var ? "true" : "false") or something
>>
File: 1386214247466.jpg (65 KB, 714x682) Image search: [Google]
1386214247466.jpg
65 KB, 714x682
Is it bad practice to have a reference to a parent object in a child object in C#?
Say that I'm working on a graph theory based application.
I want packets (objects traveling around the graph) to be able to get a node from an ID, so it would have to leap "upstream" twice: Once from the packet to the packet controller, and then from the packet controller to the graph controller class.

Is storing a reference to the graph logic in the packet controller, and then sending that reference to each individual packet bad practice?

I don't know why, but it feels like it is.
>>
>>54952066
you ask for a banana, but get a monkey holding a banana and the whole jungle surrounding it
>>
>>54952003

Everybody must be retarded, considering how often these issues happen.
>>
>>54952085
Well yeah but it's just a reference, does it really matter? It's not like it's storing a copy or anything.
>>
>>54952097
If you can really think of no other way then it's fine, but yeah it can be considered as less than optimal practice (not going to say "bad" because I'm not sure if you have an alternative)
>>
>>54952094
most people aren't particularly bright
>>
>>54952097
Pretty sure he's talking about what you have to consider when you break encapsulation.

I hate OOP fags.
>>
>>54951602
Python isn't shit, it's just not a language meant for heavy performance needs. It can be used to write almost anything, with fast development time.

Sure the actual program will be terrible compared to being written in other languages but that's not the point of python...
>>
>>54952066
look for an alternative solution
>>
>>54952106
Well I mean the alternative would be just storing a reference to the actual array of nodes but that hardly seems better
ho hum

>>54952111
But anon, OOP is fun
>>
>>54952094
>Everybody must be retarded
No they're just taught bad ways of doing things. You should allocate memory a bunch of memory which you use your own allocate scheme for. Not new/delete everywhere. If you make your own allocator you will have a far too many places where things can go wrong and your errors are fairly unhelpful.

If you have a potentially massive memory footprint you can write your own dynamic allocator.
>>
>>54952146

Memory arenas are the future.
>>
>>54952146
this

new/delete or malloc/free everywhere can also lead to memory fragmentation especially for long-running applications
>>
>>54951531
>I have limited knowledge of a vaguely similar OOP language on a completely different platform
>I could also do it in a functional language on. That same platform I know nothing about
Yeah, I'm betting this one never gets past "New > Project"
>>
>>54951578
Notice you you didn't get a reply. That's your answer.
>>
File: 1462941846529.gif (3 MB, 240x180) Image search: [Google]
1462941846529.gif
3 MB, 240x180
>>54952132
>python isn't shit
>Sure the actual program will be terrible
>>
>>54952183
This.

I just want a language that lets me support them neatly. I don't want to do sizeof(type) all the time.
But they're so neat becuase if I have an issue I can just print all the allocations/deallocations to a file & pass a __line__ and __file__ to the function. Gets me where the dereference happened for instance.

There's just so much you can do just because you've actually made it yours.
>>54952194
Funny. I'm just not involved with that end of it. And i want to explore Monogame/XNA because people have said it's good. I really want to learn why people think what they think.

I'm a little interested in functional programming. That's why I suggested F# (because I saw it in my New>Project I've already done actually). But I'm not entirely sure if its appropriate. I just have no visibility into this space so I can't really tell. For instance this Java vs C# is news to me. Don't really see any differences aside from that Java seems to be very verbose and C# is a little bit more terse (but still more verbose than how I write C or C++).
>>
>>54951615
please
>>
>>54951847
>I'm too dumb to appreciate provable design
Wait - if you're here, then who's installing unpatched WordPress plugins on DreamHost right now?
>>
>>54952242
>I just want a language that lets me support them neatly.

Time to start writing your own lang.
>>
>>54952251

Haskell isn't the only purely functional language.
>>
What are you working on?

I'm making a terminal spreadsheet program.
>>
>>54952132
>Fast development time
Accumulate technical debt at the speed of typing!

I'd say Python is good for "rapid prototyping", not fast development time. If you've ever had to work with a >10k line Python codebase that doesn't use type annotations, you'll know what I'm talking about.
>>
>>54952257
I'm putting my hopes in this man:
https://www.youtube.com/watch?v=TH9VCN6UkyQ
His heart is in the right place and he knows more than me.
>>
>>54952251
haskell isn't any more provable than any sensible design in any sensible programming language
>>
Could any of you make me a script that'd ping google and alert me when the ping reaches it?
It's raining a lot where I live and I'm having trouble with my internet. The script would help me knowing when the internet is back, like now.

Would really, really appreciate this.
>>
Why is linear algebra important for programming?
>>
>>54952279
vidya gaymz
>>
>>54952290
Even if you dev for the next Nintendo console which won't have any 3D graphics at all?
>>
File: maxresdefault.jpg (120 KB, 1440x1080) Image search: [Google]
maxresdefault.jpg
120 KB, 1440x1080
I don't get it: why would anyone willingly code in Java?
>>
>>54952279
3D graphics is literally applied linear algebra.
>>
>>54951829
v
>>
>>54952303
yes
>>
>>54952273
>I don't understand what "provable" means
I guess ITT isn't really heavy on the math, huh?
>>
>>54952279
Because lots of linear algebra happens in programming. Games especially.
There's no math required in programming beyond preschool math really. It's just that you mostly do math stuff because all computers do is math. They take some input (keypresses or whatever). Put that into functions or put that through a set of (sequential) operations and outputs other numbers (pixel colors for instance).

This is the best way to think of it imo.
>>54952303
2D has linear algebra. But really it's just vector math/trig. So it's probably stuff you can either figure out on the fly or stuff you already know.
>>
>>54952272

When people first started shitposting about Jai, I was apprehensive, but it seems like Blowlang might actually be somewhat promising.

I would be lying if I said I wasn't at least a little excited to see how it turns out.
>>
>>54952305
I/O is impure and should be used with great care and with explicit error handling
>>
>>54952305
It's like a complex epic compared to a one-page short story.
>>
>>54952314
explain yourself. are you talking about some hypothetical compiler proofs or what the fuck?
>>
>>54952279
http://aix1.uottawa.ca/~jkhoury/app.htm
You don't need it to be a code monkey though
>>
>>54952347
Pajeet, if I only had the time and you weren't so hopelessly in over your head.

If you're truly interested, here: https://wiki.haskell.org/Applications_and_libraries/Theorem_provers
>>
>>54952385
>Tools for formal reasoning, written in Haskell.
they're implementations written in haskell, doesn't mean there's anything special about haskell as a language
>>
>>54952305
Why is the main thing in Java to create an object for input?
>>
File: 255.png (4 KB, 222x211) Image search: [Google]
255.png
4 KB, 222x211
Got a quick question about memory allocation. I'm used to languages that deal with the heap automatically, like C# and Python, but I'm diving a bit into C now.

Say I want a program that sums an arbitrary long list on numbers from the user, and stores them in an array.
This is trivial in GC languages because you just create an array of size n and the memory is automatically allocated and safe.

In C, do I have to allocate it myself every time? First time I tried to do a program like this where it read an input from a user and stored n integers in an array, it compiled and ran perfectly well. Did I just get lucky that I didn't get a segmentation fault?

tl;dr - Do you always have to allocate memory when dealing with arrays of arbitrary length, or is it enough to just initialize them with length n?
>>
>>54952412
>they're just libraries whose function is entirely predicated on the intrinsic nature of the paradigm, type system and provable nature of the language itself

lmao I wish I had a way to explain or illustrate how completely retarded and self-conscious you sound right now. Like, it's obvious that you're far out of your element and know absolutely nothing about what you tried to shitpost on, and instead of taking your medicine like a good little code monkey, you doubled-down on your ignorance three times. You basically telegraphed that you've probably never taken an advanced math class or CS class for that matter and that you don't really understand much of anything about the fundamentals of the discipline.

$10 says you're the same dipshit that posts "how do I use maven?" every day on SO.
>>
>>54952027
False. Educate yourself.
>>
>>54952509
stay delusional jackass
>>
>>54952482
The difference between GC and explicit memory allocation systems in that scenario is that in an explicit system you have to choose when to free.
That's it. If you want to always have that bit of memory stick around you never free, and there's nothing really wrong with that unless it's absolutely massive maybe.

You can also have it stick around and decide that "I'm in a section of the program where i will no longer take input for the rest of the program, free the input array" is a good strategy.
>Do you always have to allocate memory when dealing with arrays of arbitrary length, or is it enough to just initialize them with length n?
Sounds like you're comparing a static vs a dynamic array. If you're gonna have to take X amount of elements as input you need X space. If n is the upper bound of possible inputs a static array of n elements will suffice.

My recommendation would be to write a list struct which allows you to use it as a C++ vector or whatever. You're not that extremely constrained you care about the small overhead for the vector struct.
>>
File: output2016-06-06_22-52-49.png (14 KB, 500x500) Image search: [Google]
output2016-06-06_22-52-49.png
14 KB, 500x500
writing a ray tracer for a graphics programming class
>>
>>54952482
>Do you always have to allocate memory when dealing with arrays of arbitrary length, or is it enough to just initialize them with length n?

That really depends on stack size and the length of the list.

For the length n part, C99 thankfully saved us. VLAs are the goat.
>>
if you had Account objects in Java with a few fields like username,passwd,etc whats the best way to read/write them to disk? over the years I made many solutions to this problem before.. plain txts w/ bufferedreader, dbs, raw data streams, json... just wondering if theres a new better way?
>>
This question is more math/statistics but I figure this is where I should ask.

Let's say I have a group of ten people, and groups of 3 work together for X amount of time to complete a task Y times, the only recorded stats are how long it took the group to complete as a whole, how many times they did Y, and who was working in the team. Over a long period of time, I should be able to calculate what an expected contribution of an individual is, right? I imagine that this creates a P VS NP problem though...

Anyone have any idea of what I should look for in statistics/programming books to solve this?
>>
>>54951615
>>54952245
C# Step by Step (Newest ed.)
Professional C#
>>
>>54952561

Nah, I had static arrays in mind. Here's some code examples. I apologize for any style violations.
int n, i;
scanf("%d", &n);
int numbers[n];
for (i = 0; i < n; i++)
scanf("%d", &numbers[i]);
return 0;

Versus
int *p;
int count, i, n, sum;
scanf("%d", &count);
p = malloc(count * sizeof(int));
if (p == NULL)
{
printf("\nUh oh, malloc failed");
exit(1);
}
for (i = 0; i < count; i++)
{
scanf("%d", &n);
p[i] = n;
}
>>
>>54952656
>C# Step by Step (Newest ed.)
This one?
https://ptgmedia.pearsoncmg.com/images/9781509301041/samplepages/9781509301041.pdf
>>
>>54951968
>I want to program without knowing what I'm doing
>>
>>54952269

Exactly, it's a fucking scripting language.

It may have been meant for 10k+ line projects years ago but not in 2016
>>
>>54952675
Either is fine.
>>
>>54952675

In the first example, the values will be on the stack. In the latter they will be on the heap.

The bonus of the first example is that it will make C89 users very angry.
>>
>>54952698
That one uncomplete, didn't find it for free online, the one older version is what I did read.
>>
>>54952705
>I am too much of a cuck to know what's possible in programming language design
>>
>>54952751
Yeah just noticed it's only 84 pages. This one is 824 pages.
https://mitseu.files.wordpress.com/2014/08/microsoft_visual_c-sharp__2013_step_by_step.pdf
>>
>>54952749
>>54952731

Great, thanks.
This clears things up a bit for me.
>>
File: php-logo.png (93 KB, 1280x678) Image search: [Google]
php-logo.png
93 KB, 1280x678
>>54951352
I'm starting to make a website for fun. How can I make an html form with the content of the page inside a textarea and with a button for saving edits? This seems fairly trivial for somebody who knows the basics of PHP and will be very handy for me.
>>
>>54952806
>>>/g/wdg
>>
>>54952769
You don't recognize the fact that there's an optimal memory usage situation for any program and an automatic process can't hold all the information unless you give it to it. Which is essentially avoiding the GC altogether or using it in an intentional implicit way to emulate non-GC code.

It's not a good idea if you care about that stuff.

But sure, if you want to be the cause for why I can't open programs way way faster than I did on windows 95 that's fine. I just won't use your programs. Go cuck some other user.
>>
>>54952675
The first one can crash if you put in too big a number because it blows the stack
>>
>>54952818
>I have no clue about programming languages
>that means I'm an expert about the topic
/dpt/ - dumb pretentious teens.
>>
>>54952806

Depends on how you want to store it. Use GLOBALS if you want something really simple and non-persistent.
Set up a database connection if you want persistent information, but it's a bit of a hassle to set up if you don't know what you're doing.
>>
>>54952837
kys
>>
>>54952837
>doesn't even argue
It's not that complicated. It's just true by the nature of things.

If there's a generalized language to write a program it's impossible to do better than a human with intent (and perfect programming practice/skill).

That said crappy programmers may very well be helped by GC. But there's good reasons people complain about it.
>>
>>54952839
>Depends on how you want to store it.
What is want to do is editing the current page, so I don't need to store anything don't I?
>>
>>54952873

>What is want to do is editing the current page
You're in dangerous territory, anon. Tread lightly.
>>
>>54952539
It is provably impossible for a language to eliminate "soft" memory leaks (AKA free memory immediately when it will never again be used by the program)

Proof:
> let maybe_leak = allocate(foo)
> let use_foo = bool(run_program(arbitrary_code, current_time))
> if use_foo:
>> use(*maybe_leak)

The program given above allocates something, runs some code based on the current time, and if it returns true, it uses the thing allocated earlier. If the program returns false, it never uses the thing allocated earlier.

It is impossible in the general case to prove that arbitrary_code returns false for every current_time.

There exist some values of arbitrary_code that will return false for every current_time.

Therefore, there exist cases where maybe_leak will never be used after allocation, yet no algorithm will be able to free it as soon as it is no longer used.
>>
I know Java and have made a few Android apps.

I want to get into the indie game development field.

Where do I start? Should I go with Unity?
>>
>>54952925
>>>/vg/agdg
>>
I wanted to learn C++ in middle school so I could make games, then I wanted to learn Java as a high school freshman so I could make/fix plugins for my friend's Minecraft server.
I used some basic programming concepts to make Java simulations in Physics C this year (though much more than my teacher actually intended) and am looking to teach myself C. Does anyone know what would be good resource with which to do so? The books on installgentoo seem to be more geared to manuals of the C language, and what I really need to learn is programming itself.
>>
>>54952925
well libgdx is java, so go with that
>>
>>54952928

>>>/lgbt/
>>
>>54952934
libgdx is SHIT

everything is shit for that matter, you're fucked

>>54952938
kill yourself
>>
>>54952925
>Java
libgdx?
>>54952938
That's kinda unfair anon. There's some good devs there.
>>
>>54952806
Any of you have an idea for my little issue?
>>
>>54952934

I've heard it's outdated? It is good for modern games? I mean simple games, the kind the people play on the subway
>>
>>54952094
You're right.
I don't get these problems though, my resources are always freed properly and I rarely ever get memory errors.
So yes, everyone else must be retarded except for me.
>>
>>54952863
>If there's a generalized language to write a program it's impossible to do better than a human with intent (and perfect programming practice/skill).

It's a time trade-off you doofus. Managing your memory allocations perfectly by hand, especially if you're being cucked by a sad mockery of a programming language like C++ which has a dozen other footguns to go along with it, takes loads more programmer time than just letting the GC do its thing.
>>
>>54952806
>>54952952
textarea will not do what you want.

Look into "contentEditable": https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Editable_content
>>
libgdx is only """"good"""" for being a lazy smug mexican/indian/millennial piece of shit that thinks learning opengl is beneath him, and thinks his lazy flappy bird-tier 2d games will make it big and get more than 100-1000 downloads (actually comparing it to flappy bird would be a compliment because flappy bird was actually successful but of course these retards won't replicate the success of flappy bird)
>>
>>54952966
>So yes, everyone else must be retarded except for me.

You are very special. I appreciate you.
>>
>>54952974
Sorry, I mean the source code of the page.
>>
>>54952958
not at all dude
it easily supports HTML5/iOS/Android/Desktop

But I guess Unity might be easier
>>
>>54952675
In the second example, because you're using dynamic memory allocation, you need to free p by the end of the program.
>>
look at the people who post in the libgdx forum they're a bunch of pathetic stupid noobs
>>
>>54953003
Kind of like /dpt/
>>
>>54952998

Well thanks, will look into it
>>
>>54952975
what
libgdx is in the same vein as monogame, SFML, etc.

it's a lower level than engines like Unity/Unreal, but higher than opengl/directx
>>
>>54953014
>monogame, SFML, etc.
those are shit too
>>
>>54952993
Look into innerHTML: https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML
>>
>>54953014

So basically, you are saying Unity is easier to learn?
>>
>>54952966
Test some >1000 line C program you've written with AFL and Valgrind and I bet you'll find a mistake.
>>
>>54953024
it is easier yea
>>
>>54953024
you should suck a bunch of cocks at least it will be more fun than your "easy" indie game career
>>
>>54953037
Heh! He thinks I write anything other than fizzbuzzes all day! What a schmuck! Haha!
>>
>>54953044

You sound butthurt

Sorry you weren't able to finish college
>>
Thoughts on Idris?
>>
>>54953070
you sound delusional

but go ahead and fuck off to your circlejerk of underperformers over at >>>/vg/agdg
>>
>>54953075
M E M E
E M E M
M E M E
E M E M
>>
>>54953077

>being this mad

Thanks for the laugh
>>
>>54953090
stay delusional nathaniel
>>
>>54953090
The only person who seems mad here is you my friend
>>
>>54953024
just learn whatever you can, it doesn't matter what you learn as long as you pay attention to the core concepts and get out of your comfort zone. If you stick with it enough you'll end up learning the hard stuff one way or the other

protip: this isn't limited to game programming
>>
>>54953106

Thanks, an actual intelligent person in this thread.
>>
File: uw1BYvh.jpg (245 KB, 1378x778) Image search: [Google]
uw1BYvh.jpg
245 KB, 1378x778
>>54953134
go make some friends in >>>/vg/agdg
>>
>>54952593

>VLAs are the goat
VLAs are shit, subject to possible stack overflow (if you could guarantee an upper bound on the amount of stack memory needed, you could just use fixed width arrays), and waste a register just keeping track of their length.

Thank goodness we don't have that crap in C++, and C11 isn't required to implement them.
>>
>>54953218

Yes, let's just use alloca instead.
>>
File: linaface.png (95 KB, 512x512) Image search: [Google]
linaface.png
95 KB, 512x512
made a thing
>>
>>54953267
If you like algorithmic art, give allrgb a try. Really fun one. This one's mine: https://allrgb.com/images/hamiltonian-1.png
>>
>>54953225

Using alloca would have the same problems. What I'm saying is that if you don't know the size at compile time, don't use the stack at all. Use malloc/new. That is what the heap is for in the first place.
>>
File: Lena aint looking too good.png (138 KB, 512x512) Image search: [Google]
Lena aint looking too good.png
138 KB, 512x512
>>54953345
nice, will have a look. Just started playing with image processing. Fun shit
>>
i tried to write a simple code to find prime number less than 20, it works except it counts 4 as a prime number
wtf? is this because of some int division bullshit?
int c;
int i = 3;
int prime = 1;

void setup() {
pinMode(13, OUTPUT);
}

void loop() {
for(c = 2; c < i/2; ++c) {
if(i % c == 0) {
prime = 0;
break;
}
}
if(prime) {
c = 1;
while (c <= i) {
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
delay(500);
c = c + 1;
}
delay(3000);
}
prime = 1;
i = i + 1;
if(i > 20){
i = 3;
}
}
>>
>>54953267

What's the effect here?

>>54953358

NEVER!
>>
File: infull.png (331 KB, 400x855) Image search: [Google]
infull.png
331 KB, 400x855
>>54953420
code takes an image and 2 arguments, # of corruptions and threshold, picks random points then computes the colour distance between neighbouring points, if the 2 pixes have a colour distance lower than the threshold the neighbouring pixel takes on the same colour continues doing this recursively. Theres a bit of randomness thrown in too hence the brownian motion looking paths
>>
>>54952930
Anyone?
>>
>>54953624
Programming is easy
>>
>>54953624
>I really need to learn is programming itself
C programming a Modern Approach is perfect for you, that book seriously teached me how to program (I've used a few languages before but everythin seemed like magic), also this books: Understanding and using C Pointers, and 21st century C.
>>
>>54953460

Trying to tinker with something like this, but GDI doesn't much like it.
>>
>>54953673
Thank you anon
>>
>>54953707
i knocked up the code using Pillow, it is unforgivably sloppy but it seems to work well
>>
I'm making a small 2D game with SDL. What is the best way to make my own 2D maps? I'd rather not use any other libraries. I made my own small tile map engine, but it is very limited. What do I use?
>>
>>54953784

I imagine pillow is a bit more forgiving than good old GDI.
>>
>>54953820
Make your own map maker
>>
>>54953867
I will but I'd like someone to give me some abstract ideas on how to do it.
>>
>>54953867
How will the maps and collision work, not the Maker. (incase it was unclear)
>>
>>54953820
Look up tiled map editor

Comes with tons of 3rd party libraries
>>
>>54952509
no program larger than fizz buzz is realistically provable in any language, functional or otherwise
>>
>>54953899
1. As I said, I don't want to use 3rd party libraires
2. I need to know how they work (someone just throw some abstract ideas at me)
>>
>>54952066
Create operations on the container and not on the nodes.
>>
>>54953955
>Move all of your logic into one class!
do you not OOP or what
>>
>>54953968
Ok then, but how else do you do node operations that require knowledge of node surroundings if you can't store references inside the node?
>>
>>54953992
You don't, you store the references
there's nothing wrong with doing that but there is definitely something wrong with putting all your code in in class just because you're averse to references.
>>
Hello all,

i want to become a VBA pro for my current enterprise. where can i get some VBA books. im specially interested in excel macros.

note : i already write macros and know my why around basic c/java/c++ . i want to have a book to read.

thanks

>inb4 youtube tutorial with pajeet.
>>
File: 1282613150782.jpg (78 KB, 522x399) Image search: [Google]
1282613150782.jpg
78 KB, 522x399
I thought DBs were these fucking esoteric super-complex things but it turns out SQL is the easiest thing in the world.
I really like it.
>mfw
>>
God damn, GDI is so fucking unpredictable.
>>
>>54951535
Python has its merits. It's easier to write than fondling a passed out drunk and comes with so many damn extra modules that if you need something done, somebody else already has something for it.

It has drawbacks, but for automating jobs no one wants. It's pretty straightforward.
But honestly, if you're good with a better language, there's little reason to use it.
>>
>>54953412
It's because your loop terminates before checking that 2 is a multiple of 4.
>>
>>54951352
>Real world Haskell
>not a picture of a unicorn
>>
File: 1459581215924.png (11 KB, 420x420) Image search: [Google]
1459581215924.png
11 KB, 420x420
Well /dpt/, Emacs or Vim?
>>
>>54954414
Sublime Text
>>
File: 1.jpg (84 KB, 1010x1201) Image search: [Google]
1.jpg
84 KB, 1010x1201
I worked really really hard on this image for another thread but no one appreciated it so I will share it here. This is my anime persona. The Man With Seven Dereferences. He fights for the programmer and knows a deadly killing technique where a program still compiles but is soon destroyed from within via memory leaks.

>>54954025
Database design is a fucking pain. There's the famous line about how SQL is one of the few languages in which the programmer thinks more than he types and in my experience that's true.
>>
So uh, I have a question

I know how to program, but at times I feel like I really don't, and I wonder if what I'm looking for has a name or even exists

Basically, I learned to program in C++ in a very practical way, just going down to town and never really stopping to ask questions, making due with what I knew how to use and building stuff that worked but was not exactly uh, very well thought out ? Sometimes it feels like I'm just doing stuff out of immediate necessity, without a clear plan or pattern, and I feel dissatisfied, like the code I did is just immature and naive. I sometimes feel like I'm an impostor pretending to be a programmer just because I know the languages and the frameworks we use to work, but I lack... I don't know, the fundamentals ? Like, when and why to use each type of data structure, how to write a parser, stuff like that.

What do you say /g/, what kind of book should I look into to learn these sort of things ? Theoretical, good practices,...
>>
File: fn.png (52 KB, 512x512) Image search: [Google]
fn.png
52 KB, 512x512
Well, it's not what I intended, but it's interesting.
>>
>>54954577
Girl's pretty. Hat's fucked.
>>
>>54953394
Lol i've dealt with that girl image too on computer vision classes few years ago.
It's some free startup resource for every graphic course? Is she like hello world of computer vision?
>>
>>54954590
https://en.wikipedia.org/wiki/Lenna
>>
File: fn.png (290 KB, 400x855) Image search: [Google]
fn.png
290 KB, 400x855
I FINK I'M BLOODY DOIN IT, CHAPS!
>>
>decide I want to fix up some old code
>try to find it, can't
>look through my backed up system images
>can't find it in any of them, the remaining one used fsarchiver
>you can't mount an fsarchiver backup
>create a directory
>you can't restore filesystem fsarchives to a directory, only to a block device
>create a 100GB file, losetup /dev/loop8 the_file
>restore the fsarchive to /dev/loop8
>in the meantime, I'm going to watch some old episodes of Stargate
>open Chromium, go to Amazon Video. "Your web browser is missing a digital rights component. "
>try to figure out why it is working with Netflix, but not Amazon Video
>give up, install Google Chrome
>fsarchive finishes restoring
>find . -name "*mycode*"
>it wasn't in the backup, realize it is on an old hard drive
>insert drive into external hard drive dock, press power button
>nothing happens
>take off headphones, check power cables
>still nothing
>find a known-good drive
>still nothing
>fuck, I guess it is broken, I'll have to get a new one
>sit back down
>sit on headphones
>>
>>54954575
lots of people have imposter syndrome at work (google that)

anyway you want to read a algorithms/data structure book, I recommend Algorithms by sedgewick
then read up on The Pragmatic Programmer
then Design Patterns

for compiler shit, you can read the dragon book (but rarely would anyone read up on compilers tbqh)

finally learn functional programming to expand your horizon
>>
>>54954607
the original cropped porn post
>>
File: lenna-so0308derberg-1972_620.jpg (602 KB, 620x1129) Image search: [Google]
lenna-so0308derberg-1972_620.jpg
602 KB, 620x1129
>>54954607
>>
File: fn.png (131 KB, 400x855) Image search: [Google]
fn.png
131 KB, 400x855
Ooh, wowee. Abstract art.
>>
>>54954626

Thanks, will look into those
>>
>>54954626

Forgot to ask, anything that would teach me about the "cost" of actions ? I kind of want to get into optimization but I never have any idea of how it works or what action is preferable to another etc
>>
>>54954645
>>54954668
This isn't a fucking art board you cunts
>>
>>54954388
underrated post
>>
>>54954623
>doesn't just grep for something memorable
dude why am i even reading this?
>>
File: lispfags on suicide watch.png (13 KB, 530x291) Image search: [Google]
lispfags on suicide watch.png
13 KB, 530x291
>>54954732
>inb4 imageboard

pic unrelated
>>
>>54954732

Image manipulation is programming, though.
>>
>>54954750
And this is why D doesn't provide a dedicated list type. Also the image name is garbage, Lisp doesn't dictate how a list is mapped into memory. An implementation might as well treat it like an array.
>>
File: moot.jpg (85 KB, 1024x512) Image search: [Google]
moot.jpg
85 KB, 1024x512
>>54954623
Who Are You Quoting?
>>
>>54954741
I knew what the file was called, I used find. I just didn't realize I hadn't migrated it from my old computer.
>>
>>54954726
in the first book there is a part that will bring you through the analysis of algorithms, there is this other book as well
http://aofa.cs.princeton.edu/home/


for a more in depth look, you can of course read on Knuth's books (TAOCP)
>>
>>54954820

Thanks again
>>
File: this article is real and true.png (329 KB, 711x610) Image search: [Google]
this article is real and true.png
329 KB, 711x610
>ywn be free from CAPITALIST, PROPRIETARY software
Why live?
>>
If I have a vector v:
#(1 2 3)

and I want to reference it in a circular manner, so that
(vector-ref v 4)
returns 2, it's easy enough to implement it in a recursive manner:
(define (vector-refr v n)
(let ((vlen (vector-length v)))
(if (> n (- vlen 1))
(vector-refr v (- n vlen))
(vector-ref v n))))


But is this the fastest way to do it? Is there some kind of arithmetic I'm overlooking that gets rid of the need to iterate?
>>
>>54954891
Just use modulo with the list length on n.
>>
>>54954891
>>54954901
(define (vector-refr v n)
(vector-ref v (modulo n (vector-length v))))
>>
>>54954750
100,000+ elements is definitely a lot
linkedlists are still useful in functional languages when you don't work with very large data
>>
>>54954901
>>54954909
Thanks. I need to brush up on my middle school math.
>>
>>54954925
>100000
>a lot

>functional languages
>don't have to deal with a lot of data
>>
>>54954621
nice!
>>
>>54954935
well i released commercial software that didn't deal with 200,000+ elements in a single array
>>
>>54954925
linked lists are never useful, you can use an arraylist instead
>>
>>54954976
not with immutable data
>>
>>54955011
Did you even understand the graph that you were commenting on?

>>54954976
You do realize that an arraylist is just an array, right?
>>
>>54954958

The first hour and a half was me realizing that GDI would never play nice with recursion.

Oh well.
>>
You know what almost never comes up in this threads ? Ruby
>>
File: huh.png (3 KB, 400x855) Image search: [Google]
huh.png
3 KB, 400x855
>>54954732
suck it.
>>54955096
have some pixelated lenna
>>
File: smhfam.gif (1001 KB, 640x480) Image search: [Google]
smhfam.gif
1001 KB, 640x480
SOMEBODY HELP
I tried to port something i made to windows phone on Qt it works but how do make the app stay on the phone?
It only runs the app on the moment and then it's gone
>>
>>54955011
fuck off with these retarded memes

>>54955045
arrays are what you should be using in >99.9% of cases. and an arraylist has the same interface as a linked list so you really have no excuse to use linked list
>>
>>54954820
>>54954626
Do you consider these books over 'Introduction to Algorithms'? The latter has like 1300 pages so I feel overwhelmed by it but it has been adviced by couple of anons.
>>
>>54952971
>It's a time trade-off
Yeah I know. That's what I said. Users time vs your time.

It's not that complicated.
Also managing memory isn't hard when:
>>54952146
>>54952183
>>54952187
>>54952242

Yes. Sure C++ doesn't actually help you very much, but that doesn't mean you can't help yourself. It's really not more than a day worth of code at most to do a good memory arena with debug features.
>>
>>54954925
>100,000+ elements is definitely a lot
A million elements wouldn't be a lot.
Not unless you're dealing with massive structs like maybe 512byte structs
>>
>>54955280
Introduction to Algorithms is a great book, imo it beats every other book I've seen in terms of teaching understanding of how to design efficient algorithms and data structures. Also you don't have to read it in its entirety, the part until 'selected topics' is ~750 pages and out of those you can only choose the chapters that interest you the most
>>
>Reading libc manual on memory
>There is no point in freeing blocks at the end of a program, because all of the program's space is given back to the system when the program terminates

So does this mean I can safely exit a program anywhere without checking for and freeing allocated memory?
>>
File: cpama.jpg (7 KB, 220x276) Image search: [Google]
cpama.jpg
7 KB, 220x276
started reading pic related the other day, I love how short the chapters are, and i feel like im really getting whats being discussed, I was wondering if there was something I should look to read after this if I was to feel confident in C before moving onto learning another language?
>>
Is ncurses a comfy library?

I kinda like it, less overengineered than most GUI libraries.
>>
>>54955919
>>
>>54955945
>I kinda like it, less overengineered than most GUI libraries.

That's because it's a TUI library, lad.
>>
>>54955901
Yes. I don't know who's teaching anyone anything else. There's no "memory leaks" once your program have terminated. There's often memory checks that are done there because if you free all the memory during the program run you will know you had a leak.

But your users will appreciate if you don't do unnecessary work during program termination. I'm sure you've been annoyed at programs taking forever to shut down. That's mainly C++ programs calling all the destrutors.
>>
>>54955945
SDL2 is the comfiest one I know.
>>
Guys, tell me about Prolog. Anything, literally any story you have about it, short, long, funny boring, I don't care. I wanna get in the right mindset since I have to learn that language.
Thread replies: 255
Thread images: 33

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.