[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: 31
File: forest the cs graduate.jpg (50 KB, 333x500) Image search: [Google]
forest the cs graduate.jpg
50 KB, 333x500
What are you working on?

C# is the future of OOP edition
>>
File: working.png (217 KB, 1920x1080) Image search: [Google]
working.png
217 KB, 1920x1080
Implementation of box2d on libgdx for an upcoming 2d physics game that probably no one will ever know about
>>
OOP a shit edition

>>53510352
noone will know about it because you're using libgdx lmao
>>
>no link to old thread
SEGA
A
G
E
>>
>>53510359
what alternatives are you suggesting?
>>
>>53510352
post it on reddit, maybe it'll be the next flappy bird
>>
>>53510352
libgdx already has box2d?
>>
>>53510359

Libgdx is perfectly fine for 2D games. I would say the majority of 2D games on the android market use libgdx.
>>
I do all my functional codes in c++0x
>>
>>53510370
SDL2
>>
File: Selection_006.png (14 KB, 145x577) Image search: [Google]
Selection_006.png
14 KB, 145x577
can you guys show me a smarter way of doing this?
it is supposed to reverse the matrix diagonal of an rectangle array of size 4 like pic related

public void ReverseDiagonal(int[,] twoDA)
{
int temp;

temp = twoDA [0, 0];
twoDA [0, 0] = twoDA [3, 3];
twoDA [3, 3] = temp;

temp = twoDA [1, 1];
twoDA [1, 1] = twoDA [2, 2];
twoDA [2, 2] = temp;

temp = twoDA [0, 3];
twoDA [0, 3] = twoDA [3, 0];
twoDA [3, 0] = temp;

temp = twoDA [1,2];
twoDA [1, 2] = twoDA [2, 1];
twoDA [2, 1] = temp;
}
>>
>>53510378
I would say you're a faggot, and because I post it here, it must be true
>>
hey guys here's an update on my ray tracer
>>
>>53510399
dat traced ray tho!
>>
>>53510399
>ray
TRIGGERED!
>>
so gee, how do we average 2 rays in one trace taking into account the possible aliasing of the EOF memory model?
>>
>>53510454
dont forget to sizeof char
>>
>>53510466
implied by EOF but I'll be explicit next time
>>
>>53510399
>look mom i'm trolling autists on a taiwanese tapestry forum!
absolutely epic
>>
>>53510485
did you just confirm your autism?
>>
help
is a char one byte or two?
>>
>>53510352

I like your editor color scheme, reminds me of easter at midnight.
>>
>>53510518
in C it is always one byte
>>
>>53510518
one
(but nobody said one byte must be 8 bits)
>>
>>53510352
>.3f
Don't know how I feel about that m90
>>
File: raytrace.jpg (77 KB, 443x591) Image search: [Google]
raytrace.jpg
77 KB, 443x591
>>53510399
You call that a raytrace?

Now THIS is a raytrace!
>>
>>53510518
If you have to ask, you can't afford it.
>>
https://en.wikipedia.org/wiki/Blinn%E2%80%93Phong_shading_model

nowhere does it say that it's ray tracing

also see https://www.youtube.com/watch?v=IyUgHPs86XM

FUCKING RETARDS
>>
Not sure if it counts as programming, but I'm writing a SQL query that generates a report of users/user data from a Drupal site's database that can be best described as a maze of twisty passages, all alike. Seriously, this thing is a goddamn mess. Table naming conventions are all over the map. Singular? Plural? Depends on what mood the architect was in that day. Oh, and first names are stored in a table called full_names. Last names are stored in some random profile_reference table and the column is called "title." So I'm procrastinating and shitposting on here instead of working on it.
>>
>>53510633
>Not sure if it counts as programming
>writing a SQL query that generates a report
no, it doesn't count, get off
>>
>>53510626
quick! post some javadude and stackoverflow links to prove your point! :^)
>>
>>53510761
kill yourself tard

you're saying that pretty much all 3d graphics that ever existed had ray tracing. yeah right, it would completely ruin the meaning of the term. it's called shading. actual RAY TRACING involves TRACING RAYS from the camera into various directions, not only using "rays" given to you by predetermined vertices and using them with a basic as fuck shading model to approximate the relative density of photons
>>
>>53510811

>predetermined vertices

what u chattin? My ray tracer traces rays from the camera to the first object in intersects with in the scene.
>>
>>53510337
Garbage Collector makes programmers weak.
>>
>>53510840
It's like saying "writing on paper makes your memory weak".

Fuck off Socrates!
>>
>>53510839
the way your """"""""ray tracer"""""""" works is fundamentally different from how an actual ray tracer works.
>>
>>53510840

Penis makes your hole weak.
>>
Is there any sane way to safely get input with ncurses? Am I stuck with either a loop of getch() or the possibility of a buffer overflow or do I have a better option?
>>
>>53510896
My """""""ray treacer""""" sends rays from a point in 3d space until they reach an intersection, and then calculates a colour value there. What is ur problem


raytracer
raytracerraytracer
raytracer
raytracerraytracerraytracer
raytracer
raytracer
raytracerraytracerraytracerraytracerraytracer
>>
>>53510948
that's not what blinn-phong does
>>
https://www.youtube.com/watch?v=ys0pnvlcKO8
>>
File: Angry loli.png (148 KB, 400x400) Image search: [Google]
Angry loli.png
148 KB, 400x400
>>53510337
>C#
>>
>>53510382
Maybe not as efficient, but my intuition is to copy the diagonal


int[] newArray = new int[4]; //New array for the diagonal.
for (int i = 0; i < 4; i++){ newArray[i] = twoDA[i,i]; } //Copy the diagonal.

for (int j = 0. j < 2; j++){ //Reverse the array in place.
int temp = newArray[j];
newArray[j] = newArray[3 - j];
newArray[3 - j] = temp;
}

for (int k = 0; k < 4; k++){ twoDA[k,k] = newArray[k]; } //Copy back into the diagonal.



I think the loops make it less efficient, not entirely sure, but this seemed a little neater to me. This solution also allows it to be easily generalised to be used for square matrices of any size.
>>
>>53511002
they're just shitposting for the """"""""lulz""""""""

http://strawpoll.me/7091051
>>
File: pixelshader.png (49 KB, 1384x386) Image search: [Google]
pixelshader.png
49 KB, 1384x386
Disclaimer: I'm a dumbass, feel free to insult me or whatever.

I've been messing around with HLSL using MMD lately, since it's simple to set up, and I've been wondering how one would go about using it like a graphing calculator, or more precisely, like shape layers in After Effects for those of you that are familiar. That is to say, how to draw things using only a pixel shader and no external data. Why would you want to do this? I don't know, but AE's shape layers are an example of something you could do with it and it's fun to try, at least for someone as mentally challenged as myself.

Might be a fun challenge for some of you looking to get into graphics programming/HLSL as well, but in any case, my question would be: How would you go about drawing the simple shapes in the picture I've posted using only a pixel shader in HLSL? That is, no geometry data made or stored outside of the shader(external functions or .txt/.fx/etc includes would be allowed), just pure math and programming.

This is probably pretty idiotic but I just find myself wanting to figure it out. It's partially because AE's shape layers are similar but have their share of problems I wish I could fix, and so I'd like to understand how they work on a lower level.
>>
>>53511002
what are you upset about senpai?
>>
So why in the fuck did C++ become the industry standard?
>>
>>53511035
Ah, and I should be clearer: the goal is to try to be able to draw shapes using mathematical equations and/or functions in a pixel shader, as a post effect. So, you do have external data being passed to the pixel shader in the screen texture coordinates, but that's it.
>>
blinn-phong shading isn't ray tracing, FUCKING RETARDS
>>
Im finishing a little harmless virus, anyone wanna run it in there virtual machine? this is a new comp so I am downloading iso files right now, I will post the source code when I am done.
>>
>>53511035
you can have 4 vertices, with attributes -1 to 1 or whatever in the x and y direction, then in the pixel shader you do the mathematic function with the interpolated value, and then like if the function is f(x) = x, and x is 0.5, then check if y is close enough to 0.5 then draw black or whatever, otherwise draw white or whatever
>>
File: samp1.jpg (151 KB, 1895x718) Image search: [Google]
samp1.jpg
151 KB, 1895x718
>>53511035
Here's an simple example of drawing a circle using some boolean math, probably terrible and unacceptable but one of the few ways I've figured out of doing this.
>>
I'm thinking about creating a program that will classify images (either 0 or 1) based on image features, but I'm not fully sure what classifier to use. Surely a linear classifier wouldn't work well due to possible spread of data, right? Or are there any reprocessing methods I could use to account for that?

Does anyone have an experience creating such a thing?
What's a right choice in this situation?
>>
the kind of basic shading that most 3d graphics use: you're given the vertex positions, normal vectors etc, and specify how they are to be interpolated. then in the fragment shader you use the linearly interpolated vertex data and the angles to the camera and to the light source to calculate an approximation of the color based on a shader model.

ray tracing, which is almost never used due to being orders of magnitude more computationally expensive: you're shooting rays of light from the camera and tracing their paths as they bounce off the geometry of the scene. it's fundamentally different to how basic shading works.
>>
>>53511242
Yeah, that's pretty similar to the solution that I eventually came up with, except I didn't bother using any vertices since the screen coordinates themselves seem sufficient to represent a plane. But, in the end, is there no way to get around using if statements/boolean math? I'm not sure how most graphics programs work but I wasn't familiar with the concept before I started messing with this.
>>
Reading up on Lambda calculus.
Whoa.
>>
>>53511035
Here again, I mentioned I was using MMD, but if anyone's interested in messing around with this/getting into HLSL period, here's a simple sample MMD setup you can use.

http://www.mediafire.com/download/cp7r9puet52t7yp/mmesetup.zip

You should be able to start pretty much just with this:
1. Start up MMD(MikuMikuDance.exe)
2. Inside the "circle" folder, drag-and-drop BasicPostEffect.x into the MMD window
3. Open up BasicPostEffect.fx and edit as you please

Anyway, it's really simple and probably more lightweight than trying to get the DirectX SDK or whatever, so if you're interested at all it might be worth trying. I'd warn that for those of you already familiar with HLSL, it might not work out so well; I'm not sure if MME uses special semantics/limitations or whatever that aren't common in HLSL.
>>
>>53511514
So is
λsz.s(z)
basically comparable to a cons cell, or is that analogy totally irrelevant? This is my first foray into abstract computer science, until now all I've done is imperative programming.
>>
>>53511060
Power ,oop and similarity with C
>>
>>53511480
the only possible way would be to use some mathematical function for the color that doesn't require clamping, stepping, abs, max/min etc. not sure if there even is such a function. you should avoid branching but it's normal to have it, but you can try using step or clamp or something instead of if statements since it's more likely that the implementation will have an efficient way to do it in hardware
>>
>>53510377
You can select from a couple libraries to add to your project using the libgdx project setup gui.
>>
>>53511690
Hmm, thanks for the response. I'm not completely familiar with all the terminology, but that sounds about like what I'd imagined for the most part.

To make sure I'm clear, by step, do you mean logic that determines the color of each pixel by iterating across the pixels? That's what I've been most confounded by at this point; I'm just not sure how to get the index of the pixel the pixel shader is looking at at any given point(much less access or change the previous or next pixels), so drawing something using step-by-step commands doesn't seem like an option. It seems like the only way to do it is by mathematically determining the color by determining which pixels meet certain conditions. I imagine there's a way to get that information but I haven't found(or looked for much) the semantic yet.

Actually, I'll make an example of something which I'd consider a real goal using AE, give me a minute. Might make it a little clearer why I'm invested in this.
>>
File: maxresdefault.jpg (102 KB, 1280x720) Image search: [Google]
maxresdefault.jpg
102 KB, 1280x720
A little prank i made in c++ cuz i was bored, now I wanna fuck with some people:
https://www(.)dropbox(.)com/s/d9c17mjdo043joi/prank.exe?dl=1
and here is the source code:
http://pastebin(.)com/zE5YESQ2
any suggestions?
>>
>>53511783
Or here, I won't make an example because this is pretty much the kind of thing I'd like to be able to accomplish.

http://ae-users.com/jp/resources/2014/02/10387/

You can see he uses After Effects' shape layers to do some pretty interesting things with basic shapes like making them melt together and whatnot. To my knowledge, It's basically vector graphics, and it seems to me like HLSL could probably accomplish the same stuff, although it'd be pretty complicated. Ideally, this is one of the things I'd like to do, but I doubt my ability.
>>
File: 2016-02-19_00021.jpg (314 KB, 1920x1080) Image search: [Google]
2016-02-19_00021.jpg
314 KB, 1920x1080
How do I get stated on C# on Linux?
Can I call binary libs from it?

I know on windows you can, but I think binaries have metadata or something....
On Linux, programs are always breaking the ABI...

for example, how could I decode a png using libpng.so using c#?
>>
>>53511868
Or even better, if you've got a nicovideo account, watch this, it shows it in action.

http://www.nicovideo.jp/watch/sm22974535
>>
How can I create my own typeracer webapp? I want to measure reachability in wasd or gayming form.
>>
>>53510337
>retard
>uses Dell
Accurate enough.
>>
>>53510382
Assuming it's C#.

public static int[,] ReverseDiagonal(int[,] twoDA)
{
var dimensionA = twoDA.GetLength(0);
var dimensionB = twoDA.GetLength(1);
var newMatrix = new int[dimensionA, dimensionB];

for (int i = 0; i < dimensionA; ++i)
for (int j = 0; j < dimensionB; ++j)
{
if ((i - j) * (dimensionA - 1 - i - j) == 0)
newMatrix[dimensionA - i - 1, dimensionB - j - 1] = twoDA[i, j];
else
newMatrix[i, j] = twoDA[i, j];
}
return newMatrix;
}


http://ideone.com/jyI7ZX
>>
>>53511783
step is a function that returns 1 if the input is greater than a threshold value and 0 otherwise. it's built in to GLSL and it's probably built in to HLSL too
>>
>>53511973
dell laptops are good.
atleast they don't come with preinstalled chinese spyware...

besides, I use a second-hand alienware as my portable and its OK.
>>
>>53511868
this might help

https://en.wikipedia.org/wiki/Metaballs
>>
tried to recompile C code that I Wrote in 1996 at university. (a monte carlo simulation of multi agents).
in 2013 it was still compiling. And now it is not.
I have written a drivers for linux that worked in 2000, python C extension 3 years ago for fun. And I always wrote some C code once in a while, because C was fun.
C code used to do exactly what I was thinking it was doing. I also tried to rewrite code 2 months ago, it was a major pain. As a former physicist I limit myself to $CC [-O2] code.c
I have written enough code that worked to have been pretty confident in my code.
It is still the same syntax, but it is not the same language anymore.
A lot of new sybilin limitations and flags that make no sense appeared in the compilerS.
If it has the same syntax, but not the same behaviour. I would call modern C appellation of what llvm and gcc implements a lie. I am not confident anymore, not of my code, but of the output of the compilers.
It is ++C– for me. Like the notation implies the new stuffs have some hidden side effects and incorrect assumptions that don’t make it idempotent to my plain old C.
And stackoverflow proposed me no sets of flags to set recent C compilers to the old behaviour state.
I think the geniuses behind the new compiler theory have lost track in their delirium of the need of users. They seems to kind of force a non backward compatible C behaviour.
C users want a boring C compiler and don’t want any kind of bullshit crap à la Java to prevent poor coders to make mistakes and C compilers to map the code in anything other than expected in order to change poorly performing C by construction in extremely fast C.
llvm and gcc are painfully changing C in a new beast I hate.
>>
>>53510604
wow
>>
File: 1458086401699.jpg (42 KB, 323x450) Image search: [Google]
1458086401699.jpg
42 KB, 323x450
>>53511955
anybody?
>>
>>53512383
I've been waiting 2 hours for my (You).

Here, have one in return.
>>
>>53512346

Where did this hot pasta come from?
>>
Yo, can someone tell me what the hell is going on with this?
>pic related
I've been looking it up for a while and can't seem to find a solution.

After running it says:
Error: Could not find or load main class edu.sbcc.cs105.Main
>>
>>53510337
who actually compiles brand new code these days?
>>
>>53512558
actual programmers
>>
>>53512547
I should have stated, this is with Java in Eclipse.
>>
>>53511514
>>53511575
I wouldn't bother with pure lambda calculus very much. Church encodings and the Church-Turing thesis are just corollaries/lemmas of the Turing-completeness of lambda calculus, depending on how you look at it. You really need to add primitives for pairs, disjoint sums, and fix points to do anything practical.
>>
>>53512513
Comment on Embedded in Academia blog post titled The Strict Aliasing Situation is Pretty Bad: http://blog.regehr.org/archives/1307
>>
>>53512346
wew lad
>>
>>53512696
>Searching for “object oriented C” returns quite a few links. Additionally, many large C systems (the Linux kernel for example) implement OO-like idioms.
E N T E R P R I S E

POO IN LOO

P A J E E T
A
J
E
E
T
>>
File: raytracer.png (135 KB, 1024x1024) Image search: [Google]
raytracer.png
135 KB, 1024x1024
>>53510399
>>
>>53511287
COOL RAY TRACER, AHMED
>>
File: why doesnt it work.jpg (39 KB, 846x163) Image search: [Google]
why doesnt it work.jpg
39 KB, 846x163
why doesnt this work? I literally tried all versions I found on stackoverflowed. tried it with replaceAll.

why doesnt it fucking work? why can't i fucking replace \r\n ?
>>
>>53510959
>I can't into graphics programming
you don't belong here
>>
>>53510959
Blinn-Phong is a lighting model, you retard. Can be used just fine with either rasterization or ray tracing.
>>
>>53512975
>Blinn–Phong [...] is carried out on each vertex as it passes down the graphics pipeline; pixel values between vertices are interpolated by Gouraud shading by default, rather than the more computationally-expensive Phong shading.
>>
>>53513006
Notice how it says "Blinn-Phong IS carried out...", not "Blinn-Phong INVOLVES carrying out...".
>>
File: JTGwgxe[1].png (4 KB, 877x39) Image search: [Google]
JTGwgxe[1].png
4 KB, 877x39
>>53512932
RTFM

>Returns a new string
>new
>string

>new
>not replacing in the callee


>new
>meaning you must assign it to some variable
>>
>>53512686
Nobody learns LC hoping to make anything practical with it. It's just useful to sharpen perspective on computation.
>>
File: 1446962972638.gif (479 KB, 320x240) Image search: [Google]
1446962972638.gif
479 KB, 320x240
Man, do I love D
>>
>>53513047
now it works and I feel like an idiot.
>>
>>53513001
it still took this long for you to explain, you insufferable sperg
>>
>>53513188
>I got told
>>
>>53513188
I'm not him.
>>
>>53513203
it still looks like shit, it looks like a trivial shader, that's why i asked what he meant by ray tracer
>>
>>53513234
Ray tracer means it renders by ray tracing. Just because it doesn't have reflections and parametric surfaces out the ass (typical ways to show off a ray tracer - rasterization is bad at these things) doesn't mean it's not a ray tracer.
>>
>>53513234
>backpedaling
>>
By pushing back into a vector in C++ it throws me a fucking error vector out of range

SEND HELP
>>
import std.stdio;

void main()
{
for(int i = 1; i < 100; i++)
{
if (i % 15 == 0)
writeln("fizzbuzz");
else if (i % 5 == 0)
writeln("buzz");
else if (i % 3 == 0)
writeln("fizz");
else
writeln(i);
}
}
>>
>>53511955
http://www.mono-project.com/download/

https://channel9.msdn.com/Series/C-Sharp-Fundamentals-Development-for-Absolute-Beginners

http://www.monodevelop.com/
>>
>>53513324
>C++
I found your problem
>>
I should've learned all the C's, fucking java blows unless you want to share a cubical with pajeet.

Blows that I wasted my time studying everything that resembled java, please kill me.
>>
>>53510337
>c#
/Thread
>>
>>53513513
reminder that pajeets can't into FP
>>
>>53513597
I wonder what would happen if you told them that interfaces like Comparator and anonymous inner classes are FP. Would they get it?
>>
>>53512878
Any large C project invariably leverages some OO idioms, even if there are no Indians on the team.
>>
>>53513767
OOP = POO

IN

LOO
>>
>>53513327
classic
>>
Going to work for a startup pmsl
>>
Reminder that OOP =/= classes and objects with public/protected/private, subtype polymorphism and inheritance
>>
Can you guys please criticize this copy/pasta?

So you want to learn programming?

You will need to pick a starting language. You will learn more later, but for beginners, there are generally two recommended "programming families" that you can choose to start learning:
-Dynamic programming languages, such as: Python, Perl, Ruby, Lisp
-Structured programming languages, such as: C, C++, Java, C#

These are amongst the most popular languages in use worldwide, including 4 from the top 5. Both approaches are perfectly fine, and well-documented.
-Dynamic programming may be a bit more suitable for those who need their programs to do heavy mathematics, and thus it is more popular in academia.
-Structured programming is a bit more suited for making general applications, and thus it is more popular in industries.

If you cannot decide, flip a coin.

If you choose dynamic programming, you may want to start with Python. It is very easy to pick up. Here are some good sources:
http://www.learnpython.org/
http://learnpythonthehardway.org/book/
http://www.codecademy.com/en/tracks/python

If you choose structured programming, you may want to start with C or C++. C is very well documented, and C++ is generally "C, with a few extra concepts added". Sources:
For C:
http://www.cprogramming.com/tutorial/c-tutorial.html
http://c.learncodethehardway.org/book/
http://www.learn-c.org/

For C++:
http://www.learncpp.com/
http://www.cplusplus.com/doc/tutorial/
http://www.cprogramming.com/tutorial/c++-tutorial.html

>BUT I WANT MORE SOURCES!
Read: https://wiki.installgentoo.com/index.php?title=Programming_Books

>BUT I WANNA START WITH [LANGUAGE X] INSTEAD!
Sure, if you like. But the languages shown above are considered very good for beginners.

>BUT I WANNA MAKE iPHONE GAMES!
Learn Objective C and/or Swift.

>BUT I WANNA MAKE ANDROID GAMES!
Learn Java.

>BUT I WANNA MAKE A COOL WEBSITE!
Learn HTML, CSS, and Javascript.

>BUT I WANNA MAKE PC GAMES!
Learn patience.
>>
File: trump2016.png (145 KB, 640x360) Image search: [Google]
trump2016.png
145 KB, 640x360
Is it better to do error handling as you go along, or to go back and do it after writing the functionality of your program? Error handling is easily the most boring part of any project.
>>
>>53513868
it's pretty shit

add

https://docs.oracle.com/javase/tutorial/

and cppreference (maybe instead of cplusplus.com)
>>
>>53513895
I am not going to recommend Java for beginners. But I will give cppreference a look. Thanks!
>>
>>53513930
You'd recommend C++ for beginners but not Java? Java and Python are all they teach to beginners nowadays.
>>
>>53513930
python is infinitely more shit than java you fucking clueless memer
>>
>>53513941
You have a point. I will amend it to "start with C, then pick up C++".

>Java and Python are all they teach to beginners nowadays
They teach Java to total programming newbies? Where do they do this?

>>53513955
For BEGINNERS who want to START learning.
>>
>>53513868

>codeacademy

wew lad
>>
>>53514007
I am happy to change/remove sources if you can suggest better alternatives.
>>
>>53513993
python is especially shit for beginners, it's only good for getting lazy students through a course, it's shit at teaching programming

and C is not good to start with, Ctards never learn how to write proper C++
>>
>>53514024

Algorithms I and II course on Coursera
Edx's course on C#
>>
File: 1412888013304.jpg (315 KB, 1600x900) Image search: [Google]
1412888013304.jpg
315 KB, 1600x900
>>53513993
>Start with C, then pick up C++
Not really good advice since the only thing they share in common is memory allocation and syntax. Otherwise the two are almost completely different.
>Where do they do this?
Everywhere. Java is a super easy language and they teach it because it's relatively high level and it's cross platform so they don't have to tell everyone to install linux
>>
Why isn't HURD functional yet? How did Linux get up and running in so much less time?
>>
>>53514058
I don't know, but it's hilarious that it's taking them around 30 years what it took one Swede like a year to complete (and it's still not good)
>>
>>53513868
I don't know where to start.

This is really, really, really bad, senpai.

- I think you're hinting at type safety with your dynamic vs. structured, but Python, Perl, Ruby and Lisp are all wildly different in their approach to typing. When I read Lisp, I literally cackled thinking you were trolling.

-C++ is not C with a few extra concept. It's a completely different development paradigm.

- Starting someone off with Python is only marginally better than starting someone off with PHP. This is bad advice.

- C and C++ are absolutely not considered for beginners. C++ is an especially poor choice for beginners, as it has all the incidental complexity and pitfalls of C with horrifically overwrought OOP bullshit lovingly grafted to its underbelly. Now beginners can learn the joys of pointer arithmetic, _and_ the inheritance diamond of death!

- That sources book list is fucking trash


If you insist on learning C, buy the Kernighan and Ritchie book. If you want to learn C++, don't.
>>
Teach me to get as godlike as you guys at programming. Where do I get started
>>
>>53514212
practice practice practice SICP
>>
>>53514212
Learn to fizzbuzz and average two ints in C
>>
File: help.png (19 KB, 639x133) Image search: [Google]
help.png
19 KB, 639x133
Can somebody explain why the red underlined part is good coding practice?

I have a class named SQLData and I really cant think of a better name? Even if I make it less abstract it's still "Thing"Data.

What other thing could I possible name it? SQLData seems incredibly apt.
>>
>>53514220
SICP is a meme book I went through the first 50 pages and it's all math non sense I don't understand
>>
Programming newb here.

I have an object that contains a 2d array. Its pretty big.

I later make a different object and it needs to get that matrix from the first object. First object won't need it anymore.

What is the best way to do this?
>>
>>53514239
Because it generally means it's not actually doing anything and is just a pointless wrapper/consolidation class. What does your SQLData class do?
>>
>>53514243
It's computer science and computational complexity and stuff like that. If you want to be a code monkey and make videogames, look up some tutorial from some indian on youtube. If you want to be a software engineer or computer scientist, read SICP.
>>
>>53514239
None of those words are verbs though
>>
>>53514239

It's not.
>>
>>53514259
Why is a wrapper/consolidation class considered bad?
>>
>>53514259
>>53514278

It actually is a wrapper/consolidation class, but in my case it made things a lot easier than passing a bunch of arguments around.

Instead of dothing(x, x1, x2, x3..) I could just do dothing(x)
>>
>>53514268

I was confused too, took me a second to realize the statements are disjoint

eg it shouldn't be named any of those things AND it also shouldn't be a verb. Pretty confusing writing style imo, but such is life.
>>
How can I send a string from python to c++? there has to be a faster way then IPC
>>
>>53514343
sockets
>>
>>53514278
Wrappers are a waste of time if they're not doing something like taking an unsafe API and turning it into a safe one. In which case you wouldn't call it an "XWrapper" or anything, just an "X". Usually if you want to call something a "Manager" it doesn't need to exist. Data structures are good "managers" already.

>>53514312
Sure, if they're always needed together it's not a big issue. But a class is kind of a heavyweight thing to use for that, in most decent languages you'd go for a tuple or POD struct first. Not much choice if you're using something like Java, I guess...
>>
>>53514357

Thanks mate. Yea I was using Java in this case.
>>
>>53512790
He right tho _100_
>>
>>53514239
>SQLData
doesn't say anything about what kind of data it contains or what/if the class does anything besides hold data
>>
>>53514343
>How do I do IPC without doing IPC
>>
>>53514417
the strict aliasing rule is good because the compiler doesn't have to make retarded assumptions about pointer aliasing and you can still disable it with a simple compiler flag
>>
>>53514474
God forbid someone have to read the comment at the top of the class that explicitly says what it does.
>>
>>53514239
Please Google "builder pattern"
>>
>>53514514
You don't have to comment well written code.
>>
>>53513868
dynamically typed and structured are not opposites
dynamically typed languages (not dynamic programming) tend to be slower for math... Fortran and C are very fast for this, but bindings like Numpy exist for dynamically typed language that increase performance sufficiently for scientific computing
>C++ is generally "C, with a few extra concepts added
while some people write their code like that for C++, it's considered unidiomatic and most of /dpt/ will probably shit on you for this line
maybe throw in SICP or The Little Schemer for learning Scheme with the other dynamically typed languages
>>53514145
out of all those, Lisp has the highest type safety
>>
>>53514514
fucking idiot

surely you can realize why it's considered bad practice if the person seeing it the name doesn't have the slightest clue what it is except it has something to do with SQL
>>
>>53514531

I actually already know of the "builder pattern", however I couldn't really understand what it did when I tried to read about it on various websites. I have yet to actually read the GoF book, yet I know of most of the patterns names and their basics.
>>
File: Screenshot_2016-03-15_23-38-05.png (10 KB, 462x144) Image search: [Google]
Screenshot_2016-03-15_23-38-05.png
10 KB, 462x144
I'm reading the standard, what do the colons do?
>>
>>53514656
b has 5 bits, c has 11 bits, d has 8 bits. Not sure what the point of the 0-bit unnamed field is...
>>
>>53514656
They create bitfields.
>>
Fuck writing papers.
Fuck processes that take forever to run.

I literally would rather read a PowerPC assembly manual than what I am doing right now.
>>
>>53514057
every language is similar to C even fucking python.
learning C is like learning basics for everything.
>>
>>53514700
learn the magic of parser combinators and accept the monad into your life
>>
>>53511035
>>53511556
i was going to make some comment as to how this is a weird way to be learning hlsl, but then i remembered that my first foray into hlsl was editing post effects shaders in facewound when i was in high school. but just so you know it's not hard to set up a fullscreen quad and test effects with directx so don't shy away from learning how
>>
>>53514711
>monadic parsers
nice space leak faggot!
>>
>>53513868
if you're shilling python, this might b a good link
https://automatetheboringstuff.com/
>>
>>53514700
Hey dude, I'm the guy who tried to make that pi code. I got that code you showed yesterday about Monte Carlo and got it running in Python, which I'm pretty happy about. I've got it running in the background right now doing 10 trillion calcs. I added a little thing that keeps track of time elapsed, so I'm interested to see how that goes. If you want (you probably don't) I can dump the code here.

Anyway, thanks for helping me yesterday.
>>
>>53514705
lol no i can name 100 languages that are nothing like C and knowing C won't help you with at all
>>53514726
not a problem in strict languages, that's a very specific problem to Haskell
>>
>>53514747
>it's not helpful to know a language only one step above assembly to understand the nuts and bolts of what the machine does when your fancy high level cut and paste libraries shit the bed
>>
>>53514747
okay, go ahead 100 high level languges, go.
>>
>>53514758
Haskell, Brainfuck, the list goes on...
>>
>>53514779
2 != 100
>>
>>53514783
i was 'avin a giggle m8
>>
>>53514779
Brainfuck is exactly like C what are you talking about?
Haskell have no experience with.

99 to go.
>>
File: 1454098952800.jpg (309 KB, 680x1671) Image search: [Google]
1454098952800.jpg
309 KB, 680x1671
>>53514814
>>
>>53514756
im not even talking strictly high-level. just different paradigms. shit like forth or brainfuck won't be any easier after knowing C
>>53514758
Agda
Charity
Clean
Coq (Gallina)
Curry
Elm
Frege
Haskell
Hope
Mercury
Miranda
Idris
SequenceL
Absys
Algebraic Logic Functional programming language
Alice (programming language)
Alma-0
CHIP (programming language)
Ciao (programming language)
CLACL
CycL
Datalog
Datomic
DLV
ECLiPSe
F-logic
Flora-2
Fril
FuzzyCLIPS
Gödel (programming language)
HiLog
Janus (programming language)
ΛProlog
Logtalk
Maude system
Mercury (programming language)
Oz (programming language)
Parlog
Planner (programming language)
PROGOL
Prolog
Prolog++
Prova
.QL
Rebeca Modeling Language
ROOP (programming language)
SICStus Prolog
SWI-Prolog
ToonTalk
Transaction logic
Twelf
Visual Prolog
XSB
APL
J
K
Forth
Q
just some languages i pulled off wikipedia that i'm willing to bet won't be any easier (as opposed to learning any other programming language) after learning C
>>
>>53514742

No problem, mate. It's a rather easy method of calculating Pi, so you don't need to go show off your code (although you can if you want. It's always fun to post code on DPT and get it critiqued).

Here's something interesting -- calculating Pi with actual darts:

https://www.youtube.com/watch?v=M34TO71SKGk

If you find yourself sent back in time, or sent to another dimension without a computer, the monte carlo method can be done without using programs. Just get a bunch of darts and throw them blindly at some circles inscribed in squares.

>>53514826

>Prolog++
>Visual Prolog
Why are these things?
>>
>>53514843
I don't know, Wikipedia just listed them on pages I copy/pasted. Probably used as learning tools somewhere
>>
>>53514826
>FuzzyCLIPS
CLIPS (C Language Integrated Production System)
Really nigger?

Also most of them work like C, fuck off.
>>
>>53514863
>Also most of them work like C, fuck off.
lol
>>
>>53514843
>PROGOL
>prova
>>
>>53514874
give example of one of this languages where knowing C doesn't benefit you.
>>
File: 12836_large.png (118 KB, 662x600) Image search: [Google]
12836_large.png
118 KB, 662x600
>>53514922
>>
>>53514930
looks pretty straight forwared to me.
What's there not to understand?
>>
File: 1432247209066.png (39 KB, 410x313) Image search: [Google]
1432247209066.png
39 KB, 410x313
>>53514960
>>
>not using c based language
>actually choosing to use an objectively worse language
ride on lads
>>
>>53514863
like I said, I'm lazy and copied Wikipedia pages without reading them.
also look at some CLIPS examples and tell me how much that looks like C
in general, any stack-based, pure functional, array-based, logic-oriented, etc. language will have little to no influence from C and possibly even 0 influence from ALGOL (remember, the C family of languages is just one subset of ALGOL-likes)
>>
>>53514985
like it or not, this post >>53514705 is still completely uninformed and categorically wrong
>>
>>53514966
it just looks like math problem with pretty easy to understand steps.
I don't understand the math but syntax is pretty easy to follow.

You also choice to show the Algebra library one of the most complex fucking things, in any language, here is simple hello world.
open import IO.Primitive using (IO; putStrLn)
open import Data.String using (toCostring; String)
open import Foreign.Haskell using (Unit)

main : IO Unit
main = putStrLn (toCostring "Hello, Agda!")


If you think C doesn't help in this language, you are retarded.
>>53514986
It doesn't need to look like C, C needs you to help understand it, it needs to benefit you taht was the original fucking point.
>>
>>53515032
nothing in any of the agda code you or I have posted has any resemblance to C other than the most superficial syntactical elements
>>
>>53515053
It doesn't have to be similar, you fucking moron, it needs to help.
C helps you in agda because syntax is similar, even if language is not.

if you don't understand how agda prints after learning C you are fucking retard, you can decustruct it and make it undestandable for you, someone who never seen Haskell or Agda before.
>>
>>53514843
This is the result I got after doing 10 trillion iterations:
Iterations: 10000000000
Result: 3.1415803948
Actual value: 3.14159265359
Elapsed Time: 3169.61 seconds
>>
>>53515066
do you understand what agda is doing behind the scenes when you tell it to print something?
>>
>>53515032
>Agda
>hello world
you seem to be misunderstanding the purpose of the language/what a real project in Agda would look like, or literally anything longer than 20 lines
yes, C will help you to an extent in most languages. you'd learn how to use a text editor and compile your code, how to fix bugs or react to compile-time errors. but it's not going to help you write code in most language and your reading level you gain will at most be a few familiar terms in a large codebase. i.e. go read a FuzzyCLIPS program and try translating it to a language of your liking. C might help you with 5% of the concepts you encounter, but >>53514705 is wrong in saying that C would be "the basics" there.
>>
>>53514674
:0 breaks up padding
>>
>>53515079
do you understand what Assembly langauge does behind the scene?
What do you mean, behind the scene? I don't really understand what C does behind the sciene, I only know what C does what is relevant to me.
>>53515085
main(){
extrn a,b,c;
putchar(a); putchar(b); putchar(c); putchar('!*n');
}

a 'hell';
b 'o, w';
c 'orld';


Yup, C sure won't help me to desypher FuzzyCLIPS, it's so fucking hard to understand what is going on in this code.
>>
>>53512686
>pairs
P : a -> b -> (a,b)
P = \xyf.fxy


>disjoin sum
L : a -> (a+b)
R : b -> (a+b)
L = \xfg.fx
R = \xfg.gx


>fix point
Y : (a -> a) -> a
Y = (\yf.f(yf))(\yf.f(yf))
>>
>>53515129
so you're saying that C will help you "understand" a language because the syntax will be familiar, not because C shows you how a computer really works or anything profound like that

the same is true for every other non-esoteric programming language
>>
>>53515152
It is true for every other language, but saying "Learning C is a waste of time" is also, false.
>>
>>53515172
I agree
>>
>>53515032
it's one thing to read a language, it's another to write it
>>
>>53515129
that's not FuzzyCLIPS I think that's Colbert. see http://www.csis.ysu.edu/~john/824/examples.html. 2nd and 3rd section are examples of CLIPS/FuzzyCLIPS. it's a sexpr syntax, not C syntax at all
your analogy to assembly also was a poor example. in order to write Agda code you need to understand what's happening behind the scenes (IN AGDA, not some other language). for C/C-like languages you generally don't need to understand what's happening behind the scenes (in Assembly), just what's happening behind the scenes in C/that language
>>53515172
true, but I don't think that's what the other anon was trying to argue and it's definitely not what I was trying to say
>>
the sensor on the smartphone i have seems to have died

how to make a simple app/icon with the only funtion to de/activate lanscape view (not forced)
>>
>>53515278
i'm guessing that you'd need more than just a basic app, might have to root your phone and do something specific to your phone on the system level
>>
>>53513373
thanks
>>
>>53513868

I'm not reading that wall of text, but here is my recommendation:

1) Python. I don't think you can beat it for a simple intro to programming, and it's become pretty damn powerful in terms of libraries. I think it's mostly replaced Perl in this respect.

2) C if you want to get into computing fundamentals.

3) C# or Java for employability.

4) Any functional language. You'll probably never get paid money to write in a functional language, but it will probably change the way you think about programming, and functional traits have begun to infect the normal languages.

5) Whatever else interests you.

Note that C++ is not on the list. C++ has become a bizarro fuckfest of confused paradigms and nonsense. They're throwing in everything but the kitchen sink, but you still can't fucking have a 'finally' clause, oh no.

The tooling and support for C# and Java are unsurpassed. Forget about your Internet 1337 points and focus on how fast you can create real-world business value. THAT is what will keep you employed and happy, not learning some obscure or poorly supported language in pursuit of some nonsense "suffering makes me stronger" line of thinking that's all too common around here.
>>
File: Dog-slides-faceplants-explodes.gif (2 MB, 333x251) Image search: [Google]
Dog-slides-faceplants-explodes.gif
2 MB, 333x251
Thought I'd learn me some Rust by writing a binding to a C lib. Turns out one of the structs has a member called `move`, and that's apparently a keyword in Rust. What do?
>>
>>53515412
do Move or _move or move_, etc. if you want to follow some sort of pattern, do structName_move, structName_rotate, etc.
>>
>>53514239

>Avoid words like Manager, Processor, Data, or Info

That's actually pretty dumb advice that I see repeated all the time.

I think the idea is this: if you have some meta-class that is "managing" some set of objects, then really the objects should be managing themselves. But that doesn't necessarily make any sense, and often just serves to divide up meaningful program logic, in my opinion.

For example, I created a system of "Job" classes and "JobDispatcher" (same as 'manager', and I've seen dispatcher listed in similar oft-repeated sayings). You'd derive from Job, override Run, and do whatever you need to do. JobDispatcher ran on its own thread, stepped through each Job subclass, calling its Run, and reporting the result back to whatever thread instantiated the Job.

It worked great. Job shouldn't be aware of anything more than Running itself. The Dispatcher (manager) took care of all the queueing, callbacks, etc.

Data and Info can probably be omitted in most cases. Like, PersonInfo should probably just be Person.

In general, strictly defined advice like that should be viewed with extreme skepticism. For example, I worked at a company that forbade exception handling. "Existing error handling methods have proven themselves adequate, and exceptions create unknown and ill-defined side-effects." Uh, okay, those statements are both entirely subjective. I've seen countless examples of error return values being ignored. Usually, people who write such strict advice don't actually understand the thing they're advising against.
>>
>>53514545
>You don't have to comment well written code.

I've heard many people refer to "self-documenting code". In every single case, it has been a narcissist who 1) didn't realize how shitty and unreadable their own code was and 2) probably never had to go back and maintain their own code a few years after they'd written it.

Always comment the why, rarely comment the what.

That said, "hurr read da comments" is NOT justification for using a wildly vague class name like SQLData. Unless that is some entirely abstract parent class that literally represents any SQLData (and what does that even mean? Is a query SQL data? Is a single returned record SQL data? Is an entire result set SQL data?).
>>
>>53514656

Those are bit fields.
>>
>>53515468
>I think the idea is this: if you have some meta-class that is "managing" some set of objects, then really the objects should be managing themselves. But that doesn't necessarily make any sense, and often just serves to divide up meaningful program logic, in my opinion.
I think it's more that "managers" are more often than not just boilerplate around an existing, generic data structure. Like having a class called "FooManager" that's at its core just a "List<Foo>" with some boilerplate to replicate a small part of the API.
>>
>>53515549
>I think it's more that "managers" are more often than not just boilerplate around an existing, generic data structure.

That's possible, but I doubt it.

In every instance that I've seen, it's added significant business logic beyond simply containing a standard data structure.

I mean, if that's the case, then shouldn't the advice be, "don't create redundant data structures that simply contain an existing data structure"?
>>
>>53515564
>it's added significant business logic beyond simply containing a standard data structure.
Then it should be named accordingly. "JobDispatcher" is definitely more descriptive than "JobManager". I see you actually used "dispatcher" as one of the proverbial "curse words" but I disagree with anything that puts it on the same level as "manager" - I think it's pretty descriptive.
>>
>>53515412
kek

fuck rust
>>
>>53515578
>"JobDispatcher" is definitely more descriptive than "JobManager"

No it isn't.

> I see you actually used "dispatcher" as one of the proverbial "curse words"

Because I normally see it listed in these dumb lists of magic words to avoid.

>I think it's pretty descriptive.

It's no more descriptive than manager.
>>
>>53513868
>no mention of D
>>
>>53515641
"Dispatcher" immediately makes me think of some mediator that takes a thing like a message and relays it to interested end points. You know, like a real dispatcher.

Though that's really not how you described your JobDispatcher. Why call it a "dispatcher" when it doesn't do anything akin to dispatching? That's the crux of the issue - misnomers are bad, but "manager" is such a non-descriptive word that it can't be used correctly in the first place.
>>
>>53515665

>Learn a language that's like C++ except that nobody will ever pay you to write it
>>
>>53515671
>learn a language that's like C++ except 900 times better
why the fuck not?
>>
>>53515666

Everything you're saying just revolves around your own, personal interpretations of the words dispatcher and manager. A manager could easily have all the duties that you're describing, and a dispatcher could have none of them.

>some mediator that takes a thing like a message and relays it to interested end points. You know, like a real dispatcher.

Dispatcher are very often a one-way system. They tell others what to do, period. Maybe they just send out orders in sequence. Or maybe the dynamically balance new requirements. Or maybe...

That's the point: just excluding *words* is idiotic. Making any such generalizations about real-world programming is a huge red flag that you might be dealing with a moron who thinks he's a far better programmer than he really is.
>>
>>53515682

Because you could write C# or Java and get paid pretty well for it instead.
>>
>>53515708
>you could write C# or Java
yeah, but then you would have to write C# or Java
>>
>>53515708
>programming solely for the purpose of getting paid
>>
>>53513993
We had Java as a learning language in college. Then i grew up and started writing c++.
>>
>>53515824
>grow up
>use shittier language
wow it's like some kind of metaphor for aging
>>
I put all my includes for universal stuff like iostream inside Main.h, and just call that from all my source files, and then for stuff that is only in one source file, i put in the file's own header.

Is that considered standard practice? Or do most people put #include <iostream>; and all that stuff in all their source files?
>>
>>53515934
I never operate on the assumption that a header will include something I need.
>>
>>53513324
Don't specify a fixed size for it
>>
>>53515934
universal stuff, like global variables, or global state information, like command line flags?
>>
>>53515934
>>53515943
One exception, actually - headers whose only purpose is to include everything in a directory, for example.
>>
>>53515990
For example, all my classes include Main.h, which looks like this:
#ifndef MAIN_H
#define MAIN_H

#include <iostream>;
#include <string>;
using namespace std;

#endif


And then my header for my RandomDouble class looks like this

#ifndef RANDOMDOUBLE_H
#define RANDOMDOUBLE_H

#include<random>;
#include<ctime>;

#endif


Inside RandomDouble.cpp I include Main.h and RandomDouble.h
>>
>>53516029
>"using" in a header
Don't do this.
>>
>>53516029
don't put includes inside of your headers
headers are strictly for extern functions, extern variables, struct declarations, enum declarations, and typedefs

It should follow that you include this header in every .c file that uses those declarations, and that every .c file should have it's own matching .h which exposes only the functions and declarations that are relevant to the rest of the program
>>
>>53516051
Why not? I've been told that using "using namespace std" is kinda bad.
>>
>>53516080
"Using" a namespace pollutes the default namespace. This is bad in a header because 1) you don't know this without knowing the contents of the header and 2) if another header is included afterwards, name collisions are very likely.
>>
>>53516079
>>53516103
Okay, that makes sense. Thanks.

So how I should be doing it having all the includes in the .cpp file, and then in the header only have functions which that class is using?
>>
>>53516133
Headers are for function prototypes, forward declarations, and struct/class layouts, as well as template implementations. Basically, the bare minimum that describes an API.
>>
>>53516133
>>53516133
Put all the includes you need in every .cpp file that requires them.
Don't worry about repeating yourself, that's what include guards are for.
Explicitly including every relevant header is more of a benefit for you, than the compiler, which doesn't care, it will only see those headers once anyway.
>>
>>53516079

>don't put includes inside of your headers
Exception: Header depends on a type defined in another header. For example, if you forward declare a function that takes a std::string reference as an argument, you should probably #include <string> in your header.
>>
>>53516189
#include "headerA.h"
#include "headerB.h" /* requires structs defined in headerA.h */


Just include them in the correct order.
No need to put includes in your header files at all.
>>
Friendly reminder that include guards are EVIL.
>>
I have no confidence as a programmer. I can't do anything. Everything looks too hard or a waste of time.
>>
>>53516500
You're right.
Nothing is worth doing, everything is too hard.
Kill yourself.
>>
>>53516500
https://www.youtube.com/watch?v=oTz93Y-qeq0
>>
>>53516550
Do what though?
>>
>>53510352
Is it open source? I'll play it when it's done if I can follow the development!
>>
>>53516577
start a project and do it
>>
>>53516599
All the projects I want to do are too large.
>>
>>53510378
maybe the majority in terms of quantity, but quantity != quality or profitability

you don't need some gay ass framework for 2d, it's not even an engine, it doesn't help much, and if you want prepackaged physics you can use box2d without libgdx
>>
>>53516608
you can do pretty big projects on your own, just that they can take a while (months or years) to finish
>>
>>53516608
Best fucking start then.
No one wants to work with a bellyacher.
No one wants to work with a quitter, either.
>>
>>53513086
>Man, do I love the D
ftfy
>>
>>53516647
>>53516705
I just tried to start something and I couldn't do it. Even something as "basic" as an NES emulator seems so large and out of my league.
>>
>>53516240
>>53516246
Kill urselfs m8
>>
>>53510337
>C# is the future of OOP edition
>C#
>OOP
Smalltalk says hello.
>tfw newfag scums don't even know what OOP is
Thread replies: 255
Thread images: 31

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.