[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: 29
File: gillette.jpg (103 KB, 800x794) Image search: [Google]
gillette.jpg
103 KB, 800x794
Previous thread at >>51668809

What are you working on, /g/?
>>
FIRST FOR THANK GOD NO MORE FAGGOTS
>>
>>51675036
>>51675071
>>
>>51675104
I am a refugee girl (with a penis), does it work for me?
>>
>>51675126
Yeah use the blades to cut you tiny dick off
>>
Best book for a confident C programmer to learn/review C++? I know the basics of it.
>>
>>51675126
*allocates a hug*
*hugs you*
*unhugs you*
*de-allocates hug*
>>
>>51675145
C Programming
>>
>>51675164
This is probably a meme because C++ is stupid; I'm learning it just for employability mind you
>>
>>51675149
cute~
>>
>>51675104
Working on the google foobar challenge questions
>>
>>51675175
>object oriented programming
>enjoyable
>>
>>51675267
employ
not enjoy
>>
Drink at the pub at 3 pm reading some papers on object capabilities

Mark Miller and Jonathan Shapiro the GOAT
>>
>>51675285
oh fuck my bad

My condolences.
>>
>>51675295
thanks
>>
C++ isn't an oo language it's a multi paradigm language
>>
>>51675402
How did Scott Meyers put it? C++ is a federation of languages, or something like that.

Even moreso with the additional capabilities of C++11/14
>>
Why are there multiple ways to do very very basic things in C++?
I'm pretty new to it but
why have an iterator when you can just foreach with a reference?
>>
>>51675446
... there are lots of ways of programming the same thing in any language .. ?
>>
>>51675452
That is a very, extremely basic, language-level thing, though.
>>
>>51675104
Fuck that 5 blade shit.
Maybe if you like paying for $5 dull cartridges, razor bumps and cutting your face up by having to go against the grain.

DE is the only proper way to shave.
>>
>>51675446
How do you implement foreach for user made types?
>>
>>51675446
The reason C++ has both X and Y even though they do the same thing is because X came before Y and X couldn't be removed because of legacy support.

In the case of iterators and foreach, foreach is such simple syntactic sugar that it's hardly a "different way".
>>
>>51675468
Foreach? To some languages.

You do realise for(auto x : y) uses iterators right?
>>
>>51675446
- Cuz iterators came first, before ranged for.
- Iterators offer you more flexibility when you need to do more than just iterate forward once, like with a ranged for.
- Ranged for is just nice sugar on top of its anyway.
>>
>>51675497
I don't

>>51675499
Got it, makes sense

>>51675509
I do now!

>>51675512
Ah, thanks.
>>
>>51675563
template <typename l>
auto foreach(l&& fn)
{
while (iter++ != enditer)
fn(*iter);
}
>>
>>51675491
yes hipster faggot
spending 30x longer to shave and buying lots of satellite accessories for your new hobby is a much better use of your limited resources than simply shaving with a cartridge.
I bet you also
>bake from scratch
>own multiple mechanical watches
>grind and roast your own coffee beans every morning
>compile your own kernel
>etc etc etc

Wasting money and time on doing things in archaic ways does not make you a better person.
>>
Prelude> :type " " 
" " :: [Char]
Prelude> :type ' '
' ' :: Char
Explain this.
>>
>>51675653
The first is a string, which is a list of characters. The second is a character.
>>
>>51675606
baking from scratch is rewarding and fun anon
>>
>>51675665
A single character is a list of characters
>>
>>51675653
As in many languages (C/C++, Java), single quotes denotes a character literal, and double quotes denotes a string literal. Even a length 1 string is still technically a string. Strings are represented as arrays of characters in Haskell (any many other languages).
>>
File: 1440648860267.png (263 KB, 523x372) Image search: [Google]
1440648860267.png
263 KB, 523x372
>>51675606
But because I'm a do nothing hipster faggot I have nothing else but doing stuff the shit way just to be different. :(
>>
File: Pointy nose face.png (2 KB, 131x156) Image search: [Google]
Pointy nose face.png
2 KB, 131x156
>>51675693
The English language is weakly-typed.
>>
test.c: In function ‘main’:
test.c:11:2: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘double’ [-Wformat=]
printf("\n%d\n%f\n",5.0+5, num2);
^


Why does this error mark prtinf's 2nd argument value as "double" instead of a "float"?
>>
>>51675734
actually why does it even say 2nd argument, isn't it the first?
>>
>>51675606
>baking from scratch
I thought this meant something laborious like growing your own wheat and grinding it to make your own flour, but all it means is you didn't buy a premade cake mix.
Are there really people who can't be bothered to make their own cake batter?
>>
>>51675750
"\n%d\n%f\n" is the first argument
>>
>>51675769
I see. Why is it marking the other argument as type double though? Shouldn't that operation return a float type value?
>>
>>51675753
Apparently the same lazy neckbeards who would rather pay literally 50 times as much for blades for their razor, and copy live iso's to their HD instead of building a custom optimized kernel.
>>
>>51675734
because it's cast to whatever the compiler wants. double is more precise so that's probably default with your compiler. either way, why did you type 5.0?
>>
>>51675799
double will just be truncated to type float unless you specifically do "long float"
%lf
>>
>>51675799
5.0 is double

>>51675828
...
what?

and there is no long float
>>
>>51675806
>because it's cast to whatever the compiler wants. double is more precise so that's probably default with your compiler.

I see.

>either way, why did you type 5.0?

Going back to the basics with C and toying/trying to break some stuff for better understanding.

>>51675844
>5.0 is double

It is, I understand now.
>>
Would it be feasible to create a .NET CLR that runs on bare metal without an underlying OS?
>>
File: z3f1WiK.jpg (62 KB, 551x550) Image search: [Google]
z3f1WiK.jpg
62 KB, 551x550
>>51675873
>>
>>51675806
>because it's cast to whatever the compiler wants
no, 5.0 is defined as double by the standard.
>>
>>51675873
Good luck, from what I've read Microsoft tried doing something like that because they wanted to write a fully managed OS but couldn't pull it off
>>
>>51675892
Is it possible to for a constant to have a "float" value?
>>
>>51675491
you don't even need to buy more cartridges, just rub it the opposite way against the inside of the forearm to sharpen the blades
>>
>>51675873
>.NET
>no interpreter or windows environment
lel do you know what you're talking about?

>>51675844
>and there is no long float
wat? this compiles and prints the same thing to window.
#include <stdio.h>

int main(void)
{
double what_is = 42.0;

printf("Number: %f\n", what_is);
printf("Number: %lf\n", what_is);

return 0;
}


>>51675941
typecast
printf("%f\n", 5.0f);
//or alternatively...
printf("%f\n", (float)5.0);
>>
>>51675957
Bare metal managed language runtimes are a thing, m8
>>
>>51675946
and the joke of the pic is that these "refugee boys" aren't really boys nor refugees. they're lying about their age to leech welfare support. costs hundreds of dollars per "child" per day to "take care" of these fuckers
>>
>>51675957
I see no long float.

>printf("%f\n", 5.0f);
>//or alternatively...
>printf("%f\n", (float)5.0);
It will still be promoted to double
>>
>>51675992
You're right, do you know why?

test.c: In function ‘main’:
test.c:11:2: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘double’ [-Wformat=]
printf("\n%d\n%f\n",(float)5, num2);
^

>>
>>51675992
a double is a long float pretty much. double is represented by more bits than a float. i was just stating what %lf stood for in hopes that it would aid in remembering the conversion specifier.

typecasting will get rid of compiler warnings, at least. if you are doing math on a double and a float, you will get a precision warning. casting the double to float will rid you of the warning if you're in to that sort of thing.
>>
File: 4aX1VW1 (1).png (819 KB, 1282x722) Image search: [Google]
4aX1VW1 (1).png
819 KB, 1282x722
Do you idiots ever do anything useful or do you just argue semantics and syntax because it's a low hanging fruit?
>>
>>51676072
No one here has any idea what they're talking about, it's all CS101 kids who think skill equals the amount of languages you know.
>>
>>51676099
Or people who pretend to know C because /g/ says it's cool
>>
>>51675145
The book written by Bjarne Stroustrup.
>>
>>51676072
Yeah, sorry for the dumb questions. I'm learning C and I'm just a autistically curious individual.
>>
>>51676021
what compiler are you using? I get no warnings at all with -Wall on gcc

#include <stdio.h>

int main()
{
double my_number = 42.0;

printf("%f\n", (float)5);
printf("%f\n", (float)5.0);
printf("%lf\n", my_number);
printf("%f\n", (float)my_number);

return 0;
}
>>
>>51675446
C++ is notorious for allowing you to do everything in at least 2 ways.
You see, C++ is meant to be a "one size fits ALL" language with its ridiculous quantity of features. The palette of choices you get allow you to write code in tons of different styles and give you a very precise grip on the performance of your program. The reason that C++ is irreplaceable is because it's pretty much the fastest language out there for the level of abstraction and indirection it offers, also because of what I mentioned earlier and how it contains features for about every paradigm and style.
>>
>>51676136
I'm using gcc as well, I did not add the -Wall flag however.
>>
>>51676136
try with %d
>>
>>51676149
This. What the "C++ killer" languages don't realize is that it's extremely difficult to slim down C++ without either sacrificing some level of abstraction or some level of performance.
>>
>>51676160
well yes it won't work with %d because it wants an integer. is this what the problem is? typecast the 5 or 5.0 with (int) instead of (float) and it will compile without warnings.

#include <stdio.h>

int main()
{
double my_number = 42.0;

printf("%d\n", (int)5.0);
printf("%f\n", (float)5.0);
printf("%lf\n", my_number);
printf("%f\n", (float)my_number);

return 0;
}
>>
>>51676149
Also obviously this comes at the price of C++ being a very difficult language with a very thorough knowledge of its semantics and underlying functionality to be able to effectively write and reason about C++ code. This is why I urge new programmings to NOT LEARN C++ FIRST NO MATTER HOW MUCH YOU WANT TO MAKE YOUR VIDYA GAMES YES I UNDERSTAND THAT C++ IS THE INDUSTRY STANDARD BUT YOU ACTUALLY ARENT THE INDUSTRY.
Excuse me.
I think you should at least learn C before learning C++ so you understand memory and pointers, and so that you understand the motivation and semantics behind things like copying/moving/references/destructors.

>>51676169
You can't kill C++ in one language but C++ is definitely not perfect and a simpler language that is 90% as effective could probably be developed.
>>
>>51676192
I totally agree.
>>
>>51676072
There are some people, a few per thread. Most won't comment unless somebody starts by commenting on their area of expertise. With skill comes ability for restraint.
>>
>>51675497
http://www.drdobbs.com/custom-containers-iterators-for-stl-fri/184401929

Recall that iterators are templates, so they are compiled. Therefore all you need to do is add certain members to your class. If you all you want is a for_each loop, you do not need much.

>>51675145
man C++Intro
install it with
libstdc++-4.8-doc
or whatever is your disto's package.
>>
Anyone here employed?
What kind of questions do they ask during interviews so I can study up and not get blacklisted?
>>
I have a table with a lot of foreign keys. When I insert into this table, I want to check to make sure that the foreign keys exist, ie insert a row into the foreign key's table if one doesn't already exist.

Which is the better way to do this (or am i missing the best way?):
A) INSERT OR IGNORE into all of the foreign key tables every time I insert into the table
B) do a try/catch, catch a failed foreign key constraint and insert then

It takes about 10x longer to do the INSERT OR IGNORE (there are a lot of foreign keys), but the try/catch feels hacky and gross

>>'Time to insert with insert or ignore is is 2.3121321201324463'
>>'Time to insert with try/catch is is 0.20801186561584473' (plus an additional ~2 seconds if it catches, which it shouldn't very frequently, but will happen enough that I need to account for it programmatically)
>>
>>51676367
Don't complain on twitter that you can't solve fizzbuzz.

>>51676405
>try/catch feels hacky and gross
put your try/catch inside a function and abstract it out. Do the gross stuff once.
>>
>>51676367
Let's say you have an array of integers. Find all positions p (if they exists) so that the sum of elements from 0 to p is equal to the sum of elements from p + 1 to the end of the array. You have 5 minutes.
>>
Maybe (a->b)

How do I apply this function?
>>
>>51676447
w-what?
>>
>>51676450
Applicative!
>>
>>51676457
1, 2, 3, 6, -2, 10

p = 2, 5
>>
File: apple.jpg (56 KB, 400x600) Image search: [Google]
apple.jpg
56 KB, 400x600
I've been studying this code for a while now, trying to understand what it does so I can make some cool spirals like it myself

its good so far, its a kind of hexagonal spiral with multiple fractals coming off it, if you'd like to take a look at the code then head at http://openprocessing.org/sketch/198578

I cant wrap my head around this, tho
//A gives the spiral its number of "sides" (6)
//N is the variable that gives the spiral its number of loops
X[N+1] = L[N+1] * cos(A[N+1]) + X[N] ;
Y[N+1] = L[N+1] * sin(A[N+1]) + Y[N] ;


is the sine and cosine up there what makes the spiral grow in a clock-wise motion??
>>
>>51676447
array a = arrayofint();
array b;
int running_sum = 0;
foreach(a as i)
b.append(running_sum += i);
int final=running_sum.lastvalue();
array c;
running_sum = 0;
foreach(a as i)
c.append(final - (running_sum += 1);
print b.intersect(a);
>>
>>51676450
import Control.Applicative
foo = Just (\x -> x + 3)
foo <*> Just 4 = 7
foo <*> Just 5 = 8
foo <*> Nothing = Nothing
Nothing <*> _ = Nothing
>>
>>51676480
Why the fuck would anyone need to figure this out?
What is this for?
>>
>>51676480
misread it, nevermind
lmao
>>
>>51676486
*+=i, not += 1
>>
>>51676490
practice you dolt
a programmer doesn't do anything useful until they know shit
>>
>>51676486
*b.intersect(c)
>>
>>51676501
>*+=i
wew
>>
>>51676447
def find_pos (lst):
total = sum(lst)
acc = 0
pos = []

for i in range(len(lst)):
acc += lst[i]
total -= lst[i]

if acc == total:
pos.append(i)

return pos
>>
>>51676447
How long is this list expected to be? How large are the integers?
>>
>tfw thinking in code while I drift off to sleep
>churning out for loops & if statements at light speed
>last night involved making a parking algorithm for my car, and variable c represented how many degrees to the right to turn the steering wheel
>2 nights ago there was a translucent IDE layered over 2 anime characters who were coming up w/ an algorithm to find her lost brother
>speaking in a choppy English-C++ combo while the code gets written on my mind's eye

Anyone else?
>>
>>51676505
and what is this supposed to teach me?
>>
>>51676457
For an array A = [1, 2, 3] the answer is 1, since A[0] + A[1] = 1 + 2 = 3 = A[2]. Generalize to arbitrarily length arrays with arbitrary integers (but nothing stupid overflow crap tho, assume that you can sum elements as much as you want). This was one of the questions I remember well. Another is probably impossible to replicate: consisted of a pair of VMs and I had to transfer a bunch of files between them in an hour. Trouble is they had broken a _lot_ of stuff in the databases and the network intentionally.

>>51676490
They want to hear your though process. Not really useful in my opinion but you asked what you might face so here we are.
>>
>>51676486
>running_sum.lastvalue

NOT SO FAT CANADA AND BELGIUM
>>
1. Who saw the game awards?

2. After reading this: https://web.archive.org/web/20150206045601/http://tremor3d.com/2014/12/game-development-lua-c-pretty-kewl/ (could only find archived)

Is it possible for me to rework it to work in C with structs?
>>
>>51676534
Fired.

>>51676550
How do you like my code >>51676533
Would this get me a job (currently in highschool, no underage b&)
>>
>>51676545
Sometimes I'll end up daydreaming about how I could improve code I wrote several hours ago, but I don't start thinking about real life programmatically, that's just autistic.
>>
/g/uize, what's the recommended way to learn Winapi? I almost never see a single post regarding the windows api and it's obviously very important for low-level windows programming...

Anyway I need it to make some projects and I've been trying to use some of it by looking at stackoverflow, codeproject, MSDN but it seems really confusing and almost like a language of its own... Couldn't find any recent books on it either.

Any suggestions?
>>
>>51676556
>Is it possible for me to rework it to work in C with structs?
Most Lua interpreter libraries are written in C. Everything you do in C++ can be actually converted into C so yes it's very possible to do it in C, just if you're making a gigantic game that needs Lua I'd suggest you learn C++.
>>
>>51676588
Just write your programs in Qt
>>
>>51676593
i'd say it's as advanced as super mario bros. 1

>if you're making a gigantic game that needs Lua I'd suggest you learn C++

could you explain this some more?

also, what about the swift programming language that got released today?
>>
>>51676556
You won't be able to do it with that nice looking syntax in C.
>>
>>51676564
>How do you like my code
Looks correct.

>Would this get me a job (currently in highschool, no underage b&)
Not by itself (and certainly not this particular one since it was a lead role). A few more similar solved questions, some nice project to show and good social skills will though.
>>
>>51676635
Swift a shit.
Kidding, never used it, but it's tied to Apply so I don't think I'll be using it for a while.

In C++ they give you two things (primarily) that make it a lot easier to organize your code without giving you a headache
1) OOP (Yes, I hate OOP as much as the next fa/g/got but it greatly cleans up your code compared to C, especially for gamedev)
2) Memory management (from destructors to shared_ptr, memory management in C++ is still annoying but SO much easier than in C. In a big game with tons of components interacting, memory management can quickly become a nightmare. Especially if you're throwing strings around. C strings are shit.)
>>
>>51676612
>Just write your programs in Qt

Wouldn't it be a lot worse performance-wise and lack of functionality for a lot of things?

I was looking at sourcecode of a lot of programs and they all use Winapi.

Is there some major differences between the two?
>>
>>51676677
*Apple
>>
>>51676573
>that's just autistic
Makes sense. I guess my natural autistic mind turns on when I sleep, thus peacefully replacing my dumb, daytime mind that's been stained by socializing w/ other humans for so many years.

I should really go into isolation...yeah, that'd be nice...
>>
File: deepbunnyhole.jpg (100 KB, 600x1066) Image search: [Google]
deepbunnyhole.jpg
100 KB, 600x1066
Same as her.
>>
>>51676725
>NODE

WHAT A SURPRISE, A LITERAL SLUT LIKES NODE LMAO

GAS NODE

WE PHP7 NOW
>>
>>51676588
You are in for a world of pain if you want to use WinAPI without a toolkit. You will literally be reinventing the wheel if you have a semblance of knowledge about "the right way (TM)" to do it. The structure of the WinAPI developed during 3.1 and hasn't changed much since.
>>
>>51676635
You need to look at Love2D son. There's even an actual mario 1 clone already written in it (I know you just said 'advanced as').
>>
>>51676725
>ugly
>slut
>degenerate
>interested in: both
>nodejs
why am I not surprised?
>>
>>51676732
Php is not bad if you take templating away.
>>
>>51676677
>App-ly
Sounds like something you'd find on a Mac.
>>
>>51676742
>You will literally be reinventing the wheel if you have a semblance of knowledge about "the right way (TM)" to do it. The structure of the WinAPI developed during 3.1 and hasn't changed much since

I am interested in youknowwhat and reverse engineering memes though. Seems kind of necessary...

Anyway is there a nice way to learn all this stuff? Because just looking at sourcecode/MSDN/SO it looks very very confusing, especially considering I don't have 30 years of programming exp and all that.
>>
>>51676767
Wasn't sarcasm.

PHP7 is going to be amazing very soon. Php is literal God of webdev, has been around for ever and will be around forever, most used AND is only getting better now.
>>
>>51676759
Calling someone a degenerate means you're the real degenerate you filthy fucking degenerate.
>>
>>51676759
>why am I not surprised?

EGG PLANT IS PHALLIC

U MUST BE ARRESTED
>>
File: jelly.gif (3 MB, 309x301) Image search: [Google]
jelly.gif
3 MB, 309x301
lainchan λ 12467
>>
Okay, I'm done. I've finished 2 assignments today. My kernel now supports deleting directories, and I've got a program to communicate between two processes using el gamal with either the discrete logarithm problem or elliptic curves. My professor has recommended against generating my own elliptic curve function, and sent me some 43 page document full of NIST recommendations on choices of elliptic curves.

After my finals next week, I shall finally have a good 3 weeks to work on whatever the hell I want!
>>
>>51676588
Anyone can help suggest some resources for this?

Trying to figure it out from MSDN + sourcecodes is too hard ;_;"
>>
>>51677082

Use MSDN to figure out what a particular WinAPI function does.

Use Google/Stack Overflow to find out what function to use for a particular purpose.

>Trying to figure it out from MSDN + sourcecodes is too hard ;_;"
Reading documentation and source code is an important skill to develop, and the only way to really get good at it so you can understand it is, well, to keep reading.
>>
File: 1443410335571.gif (809 KB, 480x320) Image search: [Google]
1443410335571.gif
809 KB, 480x320
>>51676842
>mfw I invested tons of time into becoming a good PHP programmer and now it's gonna pay off
>>
>>51677082
The recommended approach is to either use something else or, failing that, just kill yourself; either solution is better than dealing with WinAPI.

The API definitely hasn't changed all that much since Windows 3.1, maybe earlier; they just keep adding more and more extensions all of which have "not breaking legacy code" as a higher priority than sanity.
>>
>>51677165

To be fair, a lot of the WinApi is mega-retarded.

>Hmm, I wonder what a lpctwtfnigr is
>>
>>51677165
>Use MSDN to figure out what a particular WinAPI function does.
>Use Google/Stack Overflow to find out what function to use for a particular purpose.

I know, I've been trying to. But I want to learn reverse engineering and all that and I'm just really struggling to understand winapi. It really seems like a separate language from C*.

I'm just wondering if there's some easy to follow tutorial or how other people learn it, besides just bruteforcing it that way.

Anything I try to find is just too confusing, like hooking processes it's all very strange... Just struggling to make sense of it all and I need some more beginner-friendly start.
>>
>>51676842
> AND is only getting better now.
Well, it's not like it could actually get any worse ...
>>
WinAPI mentioned

http://mollyrocket.com/casey/stream_0029.html
>>
>>51677236
>>Hmm, I wonder what a lpctwtfnigr is

THIS.

Like what the fuck is that shit?

>Looking at sourcecode of some random meme programs
>"Ok ok let's look and see how this works. This is a pretty simple, it shouldn't be hard at all!"
>WINAPI_ENTRY
>LPCSTR
>HANDLE GHERGIEG_TO GEHIGEHIGEG, SETWINDOWSHOOKEX

>mfw
>>
>>51677236

Long Pointer to Constant TCHAR, WTF NIGR?

>>51677239

>Anything I try to find is just too confusing, like hooking processes it's all very strange

Have you ever done the equivalent on Unix? Played around with fork(), exec(), pipe(), etc? What is your experience with system programming?
>>
File: 1401x788-177472309.jpg (103 KB, 1401x788) Image search: [Google]
1401x788-177472309.jpg
103 KB, 1401x788
>>51677283

WHY'D YOU MFCCREATESINKWRITERFROMMEDIASINK?

YOU WANTED TO!
>>
>>51676447
ArrayList<Integer> fizzbuzz(final int[] arr) {
final ArrayList<Integer> positions = new ArrayList<>();
int sum1 = 0;
int sum2 = 0;
for(int i = 0; i < arr.length; ++i) {
sum2 += arr[i];
}
for(int i = 0; i < arr.length; ++i) {
sum1 += arr[i];
sum2 -= arr[i];
if(sum1 == sum2) {
positions.add(i);
}
}
return positions;
}
>>
>>51677317

I meant LPC, but I slipped and put the T there. It's a force of habit, I swear on me mum.
>>
>>51677317
>Have you ever done the equivalent on Unix? Played around with fork(), exec(), pipe(), etc?

Not really tbqh. Just got a little bit into C++ after learning some C and wanted to learn how actual programs work and learn reverse engineering.

I guess maybe I should keep working on C++ and use Boost libraries more before trying to learn about winapi... I just thought it would be a lot easier than it currently is.

Would C# be better to learn then for windows programming?
>>
>>51677343

TCHAR - a type that could be char or wchar_t depending on whether or not gcc is fed the argument -municode. Because that's a brilliant API decision.
>>
>>51676945
explain this ebin meme to me please
I know it has something to do with github banning some shitty unicodes because muh sjw?
>>
File: windclas.png (188 KB, 826x544) Image search: [Google]
windclas.png
188 KB, 826x544
>>51677359
>Would C# be better to learn then for windows programming?

Yes, because 99% of the WinApi shit is already unfuckulated with based .NET

Warning, though: when you want to get things extra weird, you'll still need to pinvoke winapi shit.
>>
File: bill-gates.jpg (77 KB, 620x414) Image search: [Google]
bill-gates.jpg
77 KB, 620x414
>>51677372
>a type that could be char or wchar_t
>>
>>51677380
>explain this ebin meme to me please

Basically (like many big github projects) SJWs took over node.js and went meme with it
>>
File: eggplant.png (12 KB, 847x907) Image search: [Google]
eggplant.png
12 KB, 847x907
>>51677380
a man was crucified for posting an eggplant to somebody's internet safe space

>>51677372
o god wat
>>
>>51677413
>>51677414
>a man was crucified for posting an eggplant to somebody's internet safe space
Links please?
>>
>>51677391
Well Ok... I guess I will give C# a try. Seems kind of meme-like to learn a language for just using winapi tho.

But first I'll keep trying to figure out this winapi shit, maybe if i read 30 tutorials I'll understand how hooking processes works and what all these retarded arguments need to be passed to these cryptic functions.
>>
>>51677414
>a man
>>
Why doesn't Microsoft just write a new Windows API while leaving the old one in so that legacy code still works?
>>
>>51677464
because they already did that
>>
>>51677486
.Net doesn't count.
>>
File: Anders_Hejlsberg.jpg (390 KB, 1088x1484) Image search: [Google]
Anders_Hejlsberg.jpg
390 KB, 1088x1484
>>51677445
>Seems kind of meme-like to learn a language for just using winapi tho.

C# is really good in its own right. The tough looking nigger to the left designed it, and he also designed Delphi.

And Mono is pretty much complete, so you can bring your code over to gahnoo/loonix and it should mostly 'just work'.
>>
>>51677359

>Not really tbqh. Just got a little bit into C++ after learning some C and wanted to learn how actual programs work and learn reverse engineering.

Reverse engineering does require a bit more broad of knowledge than you have right now. You may want to take a look at how the operating system is seen from a user's perspective. If Win32 is too complicated to take in at the moment, it may be worth it to try doing some system programming on Unix, which is much simpler, before coming back and trying to tackle the ugly dragon that is Windows.

>Would C# be better to learn then for windows programming?

Learning C# will tell you about as much about Windows as learning Java would. It's rather abstracted from the operating system, and it's been successfully ported to Linux and Mac OS X.
>>
>>51675104
lol that guy on the right kind of looks like me.
>>
>>51677504
>You may want to take a look at how the operating system is seen from a user's perspective. If Win32 is too complicated to take in at the moment, it may be worth it to try doing some system programming on Unix, which is much simpler, before coming back and trying to tackle the ugly dragon that is Windows.

I'll read a couple more books/videos about RE, maybe in some time it'll finally start to "click" and begin to make more sense.
Do you have any other suggestions for me to make it a little easier? Should I just "bruteforce" my way into understanding, like it seems many others have done?

>>51677498
>>51677504
And I guess it makes sense that C# wouldn't be much use for lower level learning but it does seem quite nice & handy that everything is built into the framework and appears to be relatively easy compared to C++...

Seems like a blessing tbqh not to have to deal with all the low-level baloney and can just get things done quickly, but on the otherhand the low-level baloney is probably very necessary...
>>
>>51676545
>2 nights ago there was a translucent IDE layered over 2 anime characters who were coming up w/ an algorithm to find her lost brother
>speaking in a choppy English-C++ combo while the code gets written on my mind's eye
that's kinda /fa/
>>
>>51677495
>>51677464
>what is metro
>>
>>51677562
>on the otherhand the low-level baloney is probably very necessary...

C# has very good interop. You haven't worked with Java, so you don't know how bad something like JNI can be.
>>
>>51677595
W-why do people make fun of C# and call you a faggot though?

Is it really for homos?
>>
>>51677464
Easier said than done.

A clean break would mean that you can't use any of the old libraries in new code (because old libraries would be using the old API).

But the only thing that Windows has ever had going for it has been backward compatibility. The main selling point of Windows 1.0 was compatibility with DOS, the main selling point of later versions is compatibility with earlier versions.
>>
>>51677581
>WinRT is implemented in the C++ programming language and is object-oriented by design.
What the fuck were they thinking
>>
>>51677611
>W-why do people make fun of C# and call you a faggot though?

Because I am a complete fucking waste of space shitposter.

C# doesn't even enter into the picture.
>>
>>51677643
So is C# for fags or not, why does .net have such a bad rep? It seems incredibly handy not having to deal with a lot of stuff and being able to just pop programs out quickly.
>>
>>51677661
>So is C# for fags or not

It's like the 3rd most popular language or something. So the answer is no.
>>
>>51676752
nah man I want to make it

Love2D seems like too much for what I want
>>
>>51677562

>Should I just "bruteforce" my way into understanding, like it seems many others have done?
Everything I know about programming I have learned from reading and writing code. When trying to understand an API, I will often write small test programs to see how some function behaves based on the functions I throw at it. Experimenting with code, even with no intention of creating something useful, is important to understanding shit.

As for learning reverse engineering, I would note that knowing assembly is highly important to this, so you may try writing some C programs and compiling them with the -S switch to see the generated assembly, and following the logic until you get it.

>>51677562

>And I guess it makes sense that C# wouldn't be much use for lower level learning but it does seem quite nice & handy that everything is built into the framework and appears to be relatively easy compared to C++...

Well yes. If you want to make a tool that is useful, that doesn't need to be particularly fast, and doesn't need to be doing anything low level, then using languages like C#, Java, Python, etc... can be very helpful.

>Seems like a blessing tbqh not to have to deal with all the low-level baloney and can just get things done quickly, but on the otherhand the low-level baloney is probably very necessary...

You wanted to get into reverse engineering, yes? Then knowing the low level shit is HIGHLY necessary.
>>
>>51677751
Thanks senpai. You gave me some new motivation. I'll jump on the horse again and keep trying to learn by any means necessary.
>>
>>51677772

That's the spirit. You need determination if you are to take on the hard problems.
>>
>>51677751
>then using languages like C#, Java, Python, etc... can be very helpful.

Is there any particular reason you don't recommend Ruby?
>>
>>51677874
I'll be sure to ask you more specific questions next time if I encounter too much difficulty :^)
>>
int b = 5;
int a = 6;
int& rb = b; // rb refers to b
rb = a // b = 6, rather than rb refers to a

what the fuck is wrong with this language
>>
>>51677961
I don't see an issue here.
>>
>>51677961
You might want to use pointers instead.
>>
>>51677961
>int&
What does this mean exactly? I'm assuming you're assigning rb to the same memory address as b, which is why b also changes to 6.
>>
>>51677985
assignment on declaration means something different entirely with assignment otherwise
it should've been different syntax

>>51677992
but I must learn this shit language

>>51677993
it's a reference, C++ bullshit because people are too lazy to type int *pb = &b; *pb = a
>>
>>51677905

That wasn't a list of languages I recommend, only languages that are mainstream, high level, and useful. Also, a good portion of DPT doesn't really seem to like Ruby, so why start a language war?
>>
>>51676725
god damnit now i have to fap

i didn't think i would have to fap today or at least not right now but i guess i'll always have to do a preemptive fap before i have my coffee and start programming
>>
>>51677997
>but I must learn this shit language
And I must learn Java.
>>
>>51678006
I do too, just not right now
I'd rather learn java right now
what am I saying, nah
I'd rather learn a non C derivative right now
>>
How do I get really good at C++? I can already write substantial programs using it but there's still a lot of weird technical aspects like this >>51675586 that I don't really understand. Should I just chug through The C++ Programming Language or what?
>>
File: matz.jpg (71 KB, 300x451) Image search: [Google]
matz.jpg
71 KB, 300x451
>>51678001
>a good portion of DPT doesn't really seem to like Ruby

I think it's alright. And look how kawaii Matz-san is.
>>
>>51677439
>a man was crucified for posting an eggplant to somebody's internet safe space
it's anti-sjw speak. criticized == crucified to them.
>>
>>51678050
probably yeah

I don't get what the fuck a double reference is
>>
>>51676654
show me some syntax man
>>
>>51678061

Golang code of conduct live
>>
>>51677997
> because people are too lazy
References have nothing to do with reducing typing.

First, references differ from pointers in that a reference doesn't have an identity distinct from the referenced object. You can't take the address of a reference (you get the address of the object), you can't have a null reference, you can't change what the reference refers to after creation (assigning to a reference assigns to the referenced object), you can't do pointer arithmetic on a reference (adding or subtracting to/from a reference adds or subtracts to/from the referenced object, which may or may not be defined).

Second: syntax matters, because of templates. E.g. if operator[] returned a pointer to the element rather than a reference, so that you had to write *(a[i])=x, you wouldn't be able to use a single template for both primitive arrays and random-access containers (and if operator[] returned a copy rather than a reference, you wouldn't be able to assign to the element).
>>
>>51678116
This actually sounds kind of reasonable, unlike that github draft code of conduct that specifically had a clause that said "discrimination against white people doesn't real".
>>
>>51678050
its not that bad, its just some new C++11 stuff with templates.
>>51678110
Its just a reference but for a temporary object, again c++11 stuff.

Go read Tour of C++ and Effective modern C++
>>
https://github.com/apple/swift/pull/17
>>
>>51678156
I've been reading Absolute C++, was recommended here; are those better? I know C well so it doesn't have to introduce me to beginner stuff.
>>
Are there any programming languages that have a basis in another language?
>>
>>51678218
What do you mean?
>>
>>51678183
>krememek closed this 6 minutes ago

aww, i just missed it.
>>
>>51678226
Keywords and shit are in Spanish or something.
>>
>>51678001
Would you be willing to grace me with a recommended language, based on ease of functionality? Something that isn't python hopefully? I dislike how it makes my computer sound. It's like inflating balloons and then popping them. I took on the Cs and loved the hum of my computer but then was forced to take java because >muh CE degree.

I'm no programming nub, I actually have a pretty decent understanding of the whole paradigm I just hate finding that in trying a new language, I either have to abide some idiotic third party library ( meh ) or create everything I find useful from scratch and then fumbling about the manner that information is handled in it.

I tried reading through lisp, watched all the video lectures, listened to the lectures and occassionally go back. I have read through tons of programming books and even have a few peripheral coding books but none of that has prepared me for all the indian, excuse muh racism, bullshit and neckbeard shill as it applies to programming. I used to get headaches, I tell you.
>>
>>51678234
Oh, I thought >>51678218 meant a basis in another programming language. I guess APL?
>>
>>51676447
I'm a bit late to the party, but please rate this code, guys. It should run in O(2n):

int sum(int* arr, size_t size) {
int result = 0;
size_t i;
for(i = 0; i < size; i++) {
result += arr[i];
}
return result;
}
void arraysumthing(int* arr, size_t size) {
int lhs = 0;
int rhs = sum(arr, size);
size_t i;
for(i = 0; i < size; i++) {
lhs += arr[i];
rhs -= arr[i];
if(lhs == rhs) {
printf("Position found at %d\n", i);
}
}
}


run "arraysumthing" with arr being a pointer to your array, and size being the length of the array.
>>
>>51677961
It's a fucking highlight all then copy and paste you silly goose.

The right side is where you type or what you've highlighted.

The left side is where you're pasting. If the address variable is point to a particular address then the pasting gets transferred over to the original variable unless you specifically state that you want to simply change the address by, explicityly, giving it another address and not hoping that it >just werks.

The whole point is to describe a pure functionality, not expect it to >just werks.
>>
>>51678257
would it kill you to use some descriptive variable names?
>>
>>51678250
Ooops not lisp, well sorta, but really I mean sicp.

:p
>>
>>51678276
I thought it was pretty self-explanatory
"arr" usually refers to an array, "i" is always used to increment in a loop, "size" can refer to the length of an array, and "lhs" and "rhs" mean left-hand-side and right-hand-side.
>>
>>51678276
>arr = array
>lhs = left hand side
>rhs = right hand side
>i = index

duh
>>
>>51678234
Mexican Spanish or a Catholic Bible in Spanish.
>>
>>51675104
Well im playing around with IR receivers
Pretty fun
>>
What's the benifit to putting my variables in an array/table instead of just having them just be there

wouldn't I have to give each variable a key for when the function is called? It seems like it just adds work, I'm using Lua and making a card game so I need a deck of cards that can change, and a permanent deck that shows what's unlocked
>>
>>51678234
>>51678218
i = 0
mientras (i < 10)
si (i == 5)
imprimir("cinco")
sino
imprimir(i)
fin
i = i + 1
fin

https://github.com/primitivorm/latino
>>
>>51678367
Not sure if I understand your question right, but let's say you had a deck of cards.

Would it be more work to have 52 variables, one for each card, or to have 1 array with 52 elements?

If you had 52 variables, how would you individually inspect them all? With an array, you could just loop through it and get the values.
>>
>>51678388
>With an array, you could just loop through it and get the values.
Ya I'm not really a programmer, I just know enough to make games, guess I gotta read on what I can do with Tables in Lua
>>
>>51678250
I figure for now I'll just work on learning vim or emacs. Probably start with vim for now. Will check back to see if you've got any suggestions.
>>
>>51678408
>Ya I'm not really a programmer, I just know enough to make games

haha
enjoy being a codemonkey
>>
>>51675446
Legacy support. C++ can't remove or break any existing functionality with new releases (like basically every language past v1.x). C++ has been around for so many decades now (and so many poor decisions have been made along the way) that the cruft has piled up significantly.

Check out the C++ Core Guidelines; they're being written by Stroustrup and others and basically defines a subset of C++ that's recommended for use in modern projects, as well as other guidelines and best practices. (Even this is a 14,000 line document, just to warn you).
>>
>>51678430
I mean I'm good at problem solving and all that, but I haven't just sat down and taken a full programming course

like I could probably brute force through anything I had to make some quick code for, it just wouldn't be pretty
>>
>>51678439
>i mean i'm good at problem solving and all that
i sincerely doubt that
>like I could probably brute force through anything I had to make some quick code for, it just wouldn't be pretty
no you couldn't

and to prove i'm right, why don't you write a function that reverses a string in place?
>>
File: Capture.png (29 KB, 1157x625) Image search: [Google]
Capture.png
29 KB, 1157x625
Still working on the PowerShell script to maintain an Opus version of my music library. I didn't give PS a fair chance before; it's got lots of enterprise-y cruft but it's actually fairly expressive and some parts are actually nicer than Bash.
>>
>>51678458
>opus copy of library
I just make foobar do this for me with 1 click

also
why did you cover up the song names?
Are you really this insecure?
>>
>>51678439
How the fuck can you write games if you don't know the purpose of an array?

In what language are you writing them? Fucking pygame?
>>
>>51678408
Should have learned more of a static language with proper arrays.
But lua tables are weird so:

You can do this:
t = { }
t["foo"] = 123
t["wat"] = 999

which is equivalent to
t = { ["foo"] = 123, ["wat"] = 999 } 

You can loop through this but its not really an array right now.

If you do:
t = {"a", "b", "c"}

it does
t = {[1]="a", [2]="b", [3]="c"}

behind the scenes, this is an array in lua
so t[1] will give you "a"

You could store your deck in an array from 0 to 51, or 1 to 52 depending on if you want to override lua's 1-based indexing.

read this:
http://lua-users.org/wiki/TablesTutorial
>>
>>51678480
>I just make foobar do this for me with 1 click
I don't use Foobar2000. I prefer to write small scripts that do exactly what I need, but Foobar does have nice transcoding tool.

>Are you really this insecure?
Nope. The song that was currently transcoding was Tasmanian Pain Coaster from El-P's album Fantastic Damage.
>>
>>51678527
>Nope. The song that was currently transcoding was Tasmanian Pain Coaster from El-P's album Fantastic Damage.

No it wasn't.
You probably copied that from /mu/.
>>
>>51678457
function reversestring1(rsV)
print "Enter a string to reverse"
io.write ">>>" local answer1 = io.read()
string.reverse (answer1)
x = string.reverse (answer1)
print (x)
end

print (reversestring1())


Lua has a reverse function though I've no idea why I'd ever need that
>>
>>51678543
Okay.
>>
>>51678543
El-P isn't even /mu/-core
>>
>>51678547
>Job interviewer: reverse a string in place
>you: okay! string.reverse(answer) :^)


lemme make a game for you

game.make();
>>
>>51678547
I told you to write a string reversing function, not a bunch of glue code that utilizes a member function of a string.

You're worthless.
>>
>>51678495
>How the fuck can you write games if you don't know the purpose of an array?

Here's my terrible code for a test RPG combat game I was making, it's highly unfinished

It's technically a game since you can win or lose, but I just started playing hand of fate recently, so my game was already kind of made, though it was going to use the more traditional turn based battle system with a front/back mechanic

http://codetidy.com/7473/
>>
>>51678547
You don't know what "in place" means, do you?
>>
File: Untitled.png (72 KB, 1464x461) Image search: [Google]
Untitled.png
72 KB, 1464x461
>>51678543
Turns out you were right, because Tasmanian Pain Coaster is from I'll Sleep When You're Dead. I have a lot of El-P albums but I've only really listened to Cancer 4 Cure significantly.
>>
>>51678579
You mean write the thing that reverses a string?
>>
>>51678581
ahaha holy shit i remember you, mr. I DONT KNOW WHAT STRUCTS ARE FOR
>>
File: 1445511667448.gif (1 MB, 320x180) Image search: [Google]
1445511667448.gif
1 MB, 320x180
>>51678581
>543 lines of variable declarations
anon pls
>>
>>51678597
Yes, implement a string reversing function that reverses the input string in place without returning a separate string.
>>
>>51678584
No clue, all my programming knowledge comes from google searching to solve problems on how to create a game, I probably should actually learn how to program at some point
>>
>>51678598
I don't, what's the big deal? Although I think Lua replaces Structs with Tables
>>
>>51678581
Fucking awful. Please learn how to program before making any more "games".
>>
>>51678629
please stop programming until you learn what a struct and an array is.
And then look up what a struct array is.
>>
>>51678633
I said it was terrible, but it technically works
>>
DDD looks dated as fuck, but damn is it nice for debugging assembly
>>
>>51678644
Isn't the basic idea of that to keep all my data in one place so it's more readily usable?
>>
>>51678581
I don't really get it.
>>
>>51678654
the basic idea is you don't have to keep declaring everything all at once like that.
How the fuck are you supposed to expand your game and add features?
Don't you want a function that creates a new player character and subtracts HP, changes status alilments, etc?
>>
File: XAG Test 27.webm (2 MB, 976x604) Image search: [Google]
XAG Test 27.webm
2 MB, 976x604
>>51678658
Well the goal was to make a roguelike that played out like final fantasy tactics with an arena based combat game where the battles were randomly generated and there were bosses and such in it
>>
>>51678678
>How the fuck are you supposed to expand your game and add features?
by adding more functions and potentially more variables?

I take it if I took the time to actually learn programming I could do that all at once or something?
>>
>>51678704
Don't repeat yourself.
If you're using almost identical code in multiple places, it's much better to put it in a separate function and make it generic so it can be reused in many use cases.

Code reuse cuts down on development time, improves readability, and prevents your code from becoming an unmaintainable mess that doesn't scale.

Yes, you should learn some programming.
read a book nigger
>>
>>51678683
It's all about simplifying stuff and making your code more modular and easier to maintain, don't you think that something like this would be way cleaner?

local armors = {
{name = 'Leather', dr = 1},
{name = 'Scale', dr = 2},
}

function getArmorById(id)
return armors[id]
end

function getArmorByName(name)
for _, v in pairs(armors) do
if v.name == name then
return v
end
end

return nil
end

local playerArmorId = 1

function getPlayerDR()
local armor = getArmorById(playerArmorId)
if armor then
return armor.dr
end

return 0
end
>>
>>51678741
>function getArmorById(id)
Useless function
>>
>>51678723
I changed most things into functions instead of having it hard coded, but there were going to be 8 character slots, and 4 in battle slots, with 4/4 places you could be on the battlefield, so I needed variables to keep track of most of that, especially the permanent ones for the characters

it's why the shop stuff prints to the number 1 and not 0, as there were going to be more versions of that that changed the other character variables

>>51678741
and that can change and maintain the "armor" of 8 different total characters?
>>
>>51678753
Choke on a dick, it was just an example.
>>
>>51678763
>Choke on a dick
If I only had one.
>>
File: 1448994641412.png (99 KB, 234x231) Image search: [Google]
1448994641412.png
99 KB, 234x231
>>51678772
aaand thread over
>>
>>51676545
Her lost brother is actually you.
>>
best book to learn C#?
I'm learning it currently as I'm working on a project and I'd like a book I can use as a reference instead of googling everything
>>
>>51678922
>I'd like a book I can use as a reference instead of googling everything
what the fuck
>>
>>51678772
>no feminine penis
into the trash it goes
>>
>>51678772
Here's one
*unzips dick*
>>
>>51679008
how can you unzip your dick?
>>
When I was younger, I had tons of ideas for video games, but no ability to program them. Now that I am older and hold a bachelor's degree in Computer Science, I have the ability to program many things, but have not so many ideas about what to make... or the free time to make them.

Also, I completely lack artistic talent.
>>
>>51679025

Well if you think about it, to zip something is to compress it, so to unzip something is to decompress it. Unzipping a dick is really just making it larger. Pitching a tent and such.
>>
>>51679026
It's not that. It's just your ideas were shit or unrealistic. Now when you begin to have an idea you reject it based on your programming knowledge
>>
>>51679026
>>/vg/agdg
you'll fit right in
Thread replies: 255
Thread images: 29

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.