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

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 324
Thread images: 24

File: 1445573554067.png (835KB, 1200x1080px) Image search: [Google]
1445573554067.png
835KB, 1200x1080px
Last thread: >>59048165

What are you working on, /g/?
>>
File: 1467570941060.jpg (517KB, 1521x1076px) Image search: [Google]
1467570941060.jpg
517KB, 1521x1076px
>>
This is how to generate Pi in C
#include <stdio.h>
#include <stdbool.h>

int main(void) {
double n = 3;
long long k = 2;
while (true) {
if (k > 1000000) {
break;
}
n += 4.0 / (k * (k + 1) * (k + 2));
n -= 4.0 / ((k + 2) * (k + 3) * (k + 4));
k += 4;
}
printf("pi = %.15f\n", n);
return 0;
}


This is how to generate Pi in Rust
fn main() {
let mut n: f64 = 3.0;
let mut k: i64 = 2;
loop {
if k > 1000000 {
break;
}
n += 4.0 / (k as f64 * (k as f64 + 1.0) * (k as f64 + 2.0));
n -= 4.0 / ((k as f64 + 2.0) * (k as f64 + 3.0) * (k as f64 + 4.0));
k += 4;
}
println!("pi = {}", n);
}


Seriously, what the fuck
>>
Going through C++ book. Pretty cool stuff.

That said, what is some project that I could use to cement my knowledge of C? Not looking at toys like "implement a binary tree" - looking at something that actually does something.

I was thinking about a simple web framework since it includes:
> handling utf-8
> sockets
> asynchronous stuff
> using third party libs (parsing http)
>>
>>59050879
>(parsing http)
just use regex
>>
>>59050927
Am kinda lazy and already did an http parser in another project.
>>
>>59050867
fn main() {
let mut n: f64 = 3.0;
let mut k: f64 = 2.0;
loop {
if k > 1000000.0 {
break;
}
n += 4.0 / (k * (k + 1.0) * (k + 2.0));
n -= 4.0 / ((k + 2.0) * (k + 3.0) * (k + 4.0));
k += 4.0;
}
println!("pi = {}", n);
}



fixed that for you.
mixing ints and floats in rust is a bad idea
>>
i'm at an important crossroads, please advise me

should i ditch c++ and learn c, not knowing anything about how to program without oop, or should i stick with c++?
>>
>>59051197
Is there any particular reason you want to switch? I mean almost all C syntax works just fine in C++, are you going for a minimalism thing?
>>
>>59050867
How to generate pi in x87:
fldpi
>>
>>59051261
>x87
deprecated
>>
>>59050819
YOU WANT A FUCKING ANIME CLUB STORY!?!? WELL HERE'S ONE FOR YA
>GO TO FUCKING ANIME CLUB
>BITCHES SEE MY FLY ASS TASTE IN ANIME LIKE K-ON! AND TALKS SHIT ABOUT K-ON!
>"Those fucking moeblobs are shit, watch real anime like Naruto" SOME NARUTO FAGGOT SAID
>RUN UP TOWARD HIM AND RIP HIS FUCKING NARUTO HEADBAND
>I PUT IT IN MY MOUTH AND CHEW IT WHILE HE CRIES ON THE FLOOR SCREAMING HIS MOM BOUGHT THAT FOR HIM BEFORE SHE DIED OF CANCER AND AIDS ON HIS BIRTHDAY BEFORE CHRISTMAS
>I DIGEST THAT SHIT, OPEN THAT FUCKING FAGGOT'S MOUTH AND SHIT DOWN THAT SHIT THROUGH HIS THROAT
>THE FAGGOT CHOKES ON IT AND DIES WHILE ME AND THE BITCHES GO OUT AND WATCH THE K-ON! MOVIE
>>
File: when the D hits you.jpg (23KB, 512x512px) Image search: [Google]
when the D hits you.jpg
23KB, 512x512px
>Rustfags of all people telling me D is dead
>>
Is it resource efficient to do preliminary simple calculations to find a result close that's close enough before passing it on to a more complex calculation?
>>
>>59050789
"The most powerful programming language is Lisp. If you don't know Lisp (or its variant, Scheme), you don't know what it means for a programming language to be powerful and elegant. Once you learn Lisp, you will see what is lacking in most other languages." -Richard Stallman
>>
>>59051411
>garbage collection
>>
>>59051483
>implying I care
Not that I wouldn't be happy if they finally get the GC out of Phobos
>>
>>59051441
Possibly, depending on exactly what you're doing, but why would you ever optimize for memory instead of for processor cycles?
>>
>>59051441
Is it resource efficient to find an impossible to find solution to a differential equation, rather than making a series approximation?
>>
>>59050867
>>59050972
Also, in your Rust example you're adding float literals to k, which you don't do in the C example (e.g
k + 2.0
instead of k + 2).
A fairer example:
fn main() {
let mut n: f64 = 3.0;
let mut k: i64 = 2;
loop {
if k > 1000000 {
break;
}
n += 4.0 / (k * (k + 1) * (k + 2)) as f64;
n -= 4.0 / ((k + 2) * (k + 3) * (k + 4)) as f64;
k += 4;
}
println!("pi = {}", n);
}


The only difference to the C code is the explicit cast to double, but otherwise it's the same.
>>
>>59050927
parsing http with regex is a security risk, it's fine if you're just doing it on the command line for something personal but inside your app fuck no
>>
>>59051715
>security risk
how?
>>
I'm trying to compute 3x3 determinants for cramer's rule, and this only seems to work half the time.
Am I supposed to subtract more than once, or does this only apply when computing the second 2x2 determinant?

int det3(int mat[3][4], int r)
{
unsigned i, j, c, det = 0;
for (c = 0; c < 3; c++) /* column */
{
unsigned a[4], idx = 0;
for (i = 0; i < 3; i++)
for (j = 0; j < 3; j++)
if (r != i && c != j)
a[idx++] = mat[i][j];
int neg = (c == 1) ? -1 : 1;
det += neg * (mat[r][c] * ((a[0] * a[3]) - (a[1] * a[2])));
putchar('\n');
}
return det;
}
>>
>>59051715
No it isn't, you fucking retard. Kill yourself.
>>
>>59051861
it absolutely is, does nobody Defcon/Blackhat here?

Rust's regex library has been fuzz tested, it's the only one I'm aware of that's at all 'safe' to even consider using for simple regex. The other's will have tons of exploits
>>
>>59051743
The easiest way to get started with bug hunting is set up afl-fuzzing on some trivial code that has lots of potential for going wrong. Stuff like JSON/HTML/HTTP parsing in C/C++ is a great candidate to find integer/buffer overflow or complexity bugs. Throw some CPU time for the fuzzing, and pretty soon you should have a handful of repro cases.

If someone wants a suggestion for a project to try some fuzzing against, the h2o/libh2o web server and its HTTP parser component (picohttpparser) look very well written but not very well tested (only a handful of hand written, hard coded test cases). I'm pretty sure there's one or more potentially disastrous bugs in it because there always is disasterous bugs in any kind of regex that hasn't been fuzzed relentlessly.
>>
>>59051861

Arbitrary code could be a security risk in this.
>>
>>59051762
Use LU decomp.
>>
>>59051762
I THINK I know what you are doing wrong. 2x2 matrices are called the "minors" of a 3x3 matrix Let them = M. Then the "co-factor" is (-1)^(i + j) * M_ij. Thus in the case where we use row 0 entries as our co-factors to get the determinant, C_00 = (-1)^0 * M_00 = 1 * M_00, C_01 = (-1)^(1)*M_01 = -1 * M, ect. (Det is the sum of each co-factor * its value, i.e. A[i][j] * C_ij). Wolfram has a good page on determinants if you wanna better explanation.
>>
H-hey, is there a game engine, or some kind of tool which could create/run a browser game with session system (I mean recognize a player, allow him to save his progress etc.) and multiplayer support? If yes, how much user friendly is it? I know some programming, but not much.
>>
>>59052371
Writing such an engine could be a fun and enthralling learning experience for you.
>>
>>59052396
No, fuck that. Been there, got burned, never again.
>>
File: 1389030868456.gif (2MB, 550x310px) Image search: [Google]
1389030868456.gif
2MB, 550x310px
redpill me on radare2
>>
>>59052425
then maybe programming isn't for you
>>
>>59052433
I just know what I can handle and what I cannot. Hence me asking about the engine.
>>
>>59052486
not him, but the most interesting part in programming a game is the engine itself.
>>
>>59052486
If you can't make an engine, you're not a real programmer.

You're just a sissy webdev who needs a big strong programmer to write all your tools and your runtime environment.
>>
>>59052371
Probably could do that with Godot. I know it can export to HTML5.
>>
>>59050867
How to generate pi in Lisp:
PI
>>
>>59052660
>he thinks calling a built-in constant is generating
>>>/r/learnprogramming
>>
>>59052688
>falling for obvious bait
>>
How do I pick a name for my project?
The best I can come up with is some completely undescriptive and unpronouncable acroynm.
>>
>>59052758
Pick some anime meme reference
>>
>>59052044
>backpedaling to "any code can have bugs"
mkay
inb4
>adding 2 numbers is a security risk
>cpus are a security risk
>being alive is a security risk
>>
>>59052783
>mkay
>>59052688
>>
>tfw Java is all I think about day and night

I can't stop it either
>>
>>59050867
>>59052660
>>59052688
;; C like code
(do ((n 3) (k 2 (+ k 4)))
((> k 1000000) (format t "~x~%" n))
(progn
(incf n (/ 4.0 (* k (+ k 1) (+ k 2))))
(decf n (/ 4.0 (* (+ k 2) (+ k 3) (+ k 4))))))

;; Functional style
(labels ((self (n k)
(if (> k 1000000)
(format t "~x~%" n)
(self (+ n (/ 4.0 (* k (+ k 1) (+ k 2)))
(/ -4.0 (* (+ k 2) (+ k 3) (+ k 4))))
(+ k 4)))))
(self 3 2))


Type declarations are optional.
>inb4 functional has moar lines
>>
>>59052432
the graphs are nice
the debugger is a pig to use
gdb is a better debugger
binja is broken right now since the data structure crap came out
radare has better graphs right now
rax2 is a really useful tool
>>
File: Chimperino.jpg (275KB, 700x443px) Image search: [Google]
Chimperino.jpg
275KB, 700x443px
I'm new. How do i haskell lambdas?
>>
>>59052941
\x -> e
>>
>>59052941
(lambda (<args>) <body>)
>>
>>59052941
if u have to ask don't try just use something easier like C
i also do not know
>>
>>59052967
>haskell
>>
Error handling: Exceptions or error codes?

I'm leaning towards exceptions because they make life easier for the programmer and make for cleaner looking code.
>>
>>59052981
>maybe these non-lisp languages really are lisp, just in a clever disguise
http://letoverlambda.com/index.cl/guest/chap4.html
>>
>>59052931
Thanks for the reply, I'm a complete noob and have recently started learning about assembly and systems programming.

How does radare2 compare to IDA pro? Is it a decent replacement, or even in the same league? I can't afford IDA's four digit price tag.

If I want to look at graphs in radare2 and debug, do I have to run both radare2 and gdb, or can gdb be run from inside radare2?
>>
>>59053011
Conditions and restarts.
>>
Ok, how do I make my Python tkinter Widget react to all events occurring on my system, regardless of if its window has focus?

I'm trying to make an alternative to AutoHotKey, but I need it to be able to respond to any and all input from my keyboard and mouse.

Basically, an overlay to my whole system. It should NEVER NOT receive input.
>>
>>59053038
i've never used IDA so i can't really say, but there's nothing you can't do with any old disassembler and a decent debugger
i generally use them as completely separate tools, generally using the disassembler's graph view to plan my paths, python scripts to automate input, and gdb to attach to the running process and analyze its behaviour.
i'll always argue that you don't need fancy tools to do this stuff. just take a lot of notes and you'll be fine.
it is possible to connect radare to gdb if you need to. i find it generally isn't necessary though.
>>
>>59053076
I understand this to mean checking error codes. That's terribly annoying. What's your reasoning?
>>
>>59053011
exceptions
why is this even a question?
>>
>>59052941
Think of them as unnamed (anonymous) functions that you can pass around. Consider map, which takes a function and one lists, and produces a second, possibly of a different type. The function itself must map from the types in the first list to the types in the second list. Type sig:

map :: (a -> b) -> [a] -> [b]

What if our first list is integers, and we want the second list to be the square of those integers (i.e. function from int -> int). In this case, we could pass map something like:

(\x -> x**2). In this case, \ begins to define the function, all parameters before the -> define the arguments, and anything after the -> defines the function body. Our call to map would then be:

map (\x -> x**2) [1,2,3,4]

Now, here is another more interesting example:

map (\x y -> x**2 + y) [1,2,3,4]. What kind of list does this return? A list of FUNCTIONS, that take a single integer and return the sum of itself + some precomputed (in our case, either 1,2,3 or 4) squared constant. if we let F = our returned list, F[1] = f(x) = x + 4, F[2] = f(x) = x + 9, ect. Note that lambdas aren't callable like functions in C, they act more like variables, and can be passed around as such.
>>
>>59050867
This how you generate Pi in bc:
echo "scale=n; 4*a(1)" | bc -l

Where n is the number of digits you wish to generate.
$ time echo "scale=10000; 4*a(1)" | bc -l
3.1415...
[...]
375676

real 1m58.092s
user 1m58.088s
sys 0m0.004s
>>
>>59053186
Two reasons i often hear is that exceptions are unsafe and exceptions are expensive.
>>
Let's say I have a C# program that generates 20 circles from an array to random poisitons and I have a circle with a static position (f.ex(50,50)).

How do I use foreach loop and Vector.Distance to determine the closest circle from the randomly placed circles to the static circle?
>>
>>59053125
I see, thanks

You seem like you know a lot on this topic, could you recommend me any good books/tutorials to get started with reversing binaries?

Also, do people have jobs reverse-engineering programs? I don't intend to get a job in the field, but there are ads for programming jobs everywhere and I never any ads for reverse engineers
>>
If there's no portable threading lib for C why don't they just compile lib in c++ and extern c the threading api?
>>
>>59053339
What would happen if you "extern c" an overloaded function?
>>
>>59053245
Expensive in terms of code size, yes.
In terms of run-time performance, no, provided that the exception is only thrown in exceptional situations and not used as normal control flow.
Unsafe, in what way? The exception handler winds down the stack, calling destructors on any objects and freeing their memory. That's more safe than having to check return codes and free memory manually.
>>
File: question mark4.png (187KB, 706x245px) Image search: [Google]
question mark4.png
187KB, 706x245px
>>59050867
>
    loop {
if k > 1000000 {
break;
}

what the fuck is this?
>>
>>59053278
I don't know much about C#, but some pseudo-code (pseudo-C) might help you:
circle_t *circles = generate_circles();
circle_t *static_circle = get_static_circle();
circle_t *closest = NULL;
float closest_dist = INFINITY;

foreach (circle_t *now : circles)
{
float now_dist = distance(now, static_circle);
if (now_dist < closest_dist)
{
closest_dist = now_dist;
closest = now;
}
}
>>
>>59053356
You cannot extern c methods you would have to declare c function that calls the overloaded method.
>>
>>59053374
The same as:
>#include <stdbool.h>
>while(true)
>break;
>>
>>59053374
An if-expression inside an infinite loop.
>>
Are C++11 lambdas interchangeable with function pointers?
>>
>>59053401

In what context?
>>
>>59053401
Not c-style function pointers.
We have std::function nowadays.
>>
Do you take handwritten notes of your work?

It's depressing me that my work leaves no physical trace. I'm switching to a paper work diary.
>>
>>59053360
Expensive too if the error handling occurs high in the stack.
>>
>>59053426
You can still print your code.
>>
>>59053444
Or even better, your documentation.
>>
>>59053422
For example for use in legacy C libraries, but >>59053425 already answered that
>>
>>59053444
Yes, maybe that, too.
For now I'm just writing a few lines every day, what I worked on and what I learned. It's surprisingly motivating and helps with mental structuring
>>
>>59053426
I used to take physical notes, now i have hundreds of sheets of paper with little organization and terrible retrieval.
So i go digital for everything i can.
>>
>>59053360
>Expensive in terms of code size, yes.
That's funny because my code is always neater when i allow myself to use exception.

>Unsafe, in what way? I'm unsure. Maybe some who hold the opposite opinion could weigh in on this.
>calling destructors on any objects and freeing their memory.
But this assumes my code is structured from an OOP architecture. Which i'm kind of trying to learn to get away from.
>>
>>59053426
I have a grid-lined notebook to help with visualizing algorithms before writing them, but it's just scratch paper.
>>
>>59053520
>>Expensive in terms of code size, yes.
>That's funny because my code is always neater when i allow myself to use exception.
Compiled code size.
>>
>>59053539
That can't to a significant degree, surly?
>>
>>59053111
Does anyone know how to go about this?

I've tried a few things with grab_set_global, but it didn't seem to work.

I need the window to receive input from the keyboard and mouse EVEN IF the Window is NOT visible OR has focus.

In other words, it should basically run at the same level as my Window Manager, receiving all keyboard and mouse interrupts 100% of the time
>>
>>59053573
It can sometimes - in embedded c++ you always disable exceptions in the compiler.
>>
>>59053307
opportunities in the field are sparse, but do exist. i personally don't reverse or develop exploits for my job as much as i'd love to though.
as far as learning resources go, i'd suggest osdev, the x86 assembly wikibook and wikipedia. there's also the reverseengineering, regames and netsec subreddits, which occasionally have some good reads. however i'd only suggest using resources like them to supplement your practical experience that you gain from applying your current knowledge in real world ways, like cracking software, writing exploits or developing cheats for games.
ctfs are awesome too. check out overthewire, pwnable.kr and smashthestack.
>>
>>59053608
That's mostly a case of stubbornly clinging to old habits. Nowadays there's no reason anymore not to have entire gigabytes of memory in an embedded computer.
>>
>>59053698
>not to have entire gigabytes of memory in an embedded computer.
Cost
>>
>>59053698
>Nowadays there's no reason anymore not to have entire gigabytes of memory in an embedded computer.

What about part cost?
You don't want a full blown microcontroller especially when they cost several dollars to do what a tiny IC and a few lines of assembler can do for fractions of a cent.
>>
>>59053698
Not true, memory is cheap but why make every single board cost more instead of just
-fno-exceptions
?

And there's low power devices and ones that must be made as small as possible.
>>
>>59052968
haskell is easier than C though.
>>
>tfw /dpt/ is the only place I feel like I belong
>>
>>59053426
Yeah, unruled comp books and a mechanical pencil. I outline algos, take debugging notes, circle "good ideas" for later.
>>
>>59053912
can you please give us an example of an algo problem you did and your method please post
>>
>>59053900
You do not belong anywhere.
>>
>>59053608
>>59053698
>>59053727
>>59053736
>>59053750
>>59053912
My takeway from this is that i can start worrying about noexcept if i ever end up working with embedded system?
>>
>>59053950
/dpt/ is a fun loving board for lisp programmers who like anime and all other programmers
>>
>>59053953
large microcontrollers are fine for prototyping, but you don't want to ship out that expensive chip for every single unit, especially when it's functionality could be replaced by a much smaller and cheaper IC.
>>
>>59053975
lol. The lisp programmers made their own general and when it get deleted too many times they moved to lainchan or somewhere else.
>>
>>59053995
I remember seeing the Lisp general a couple of times and wondered where it went.
>>
>>59053975
>>59053995
>>59054009
lisp is white and based. i am the official monarch of this thread
>>
>>59054026
Is this now a Lisp thread?
>>
>>59054040
#.(if (zerop (random 2)) 'yes 'no)
>>
>>59051483
>>59051506
Don't forget D will soon have a borrow checker, making it even safer than Rust and easier to use since you can always fall back on optional GC that Rust doesn't have
>>
>>59053995
I'm actually a Java programmer it's all I know and I am too lazy to learn any other languages because I spent most of my time learning and working with Java
>>
>>59054040
yes, I am the monarch of lisp and this thread.
>>
>>59054049
>>59054092
CL-USER> (if (zerop (random 2)) 'yes 'no)
YES

Let it be known that this thread is now a Lisp thread.
>>
If python is so great and friendly, then why has no one made a compiled version of it?
>>
>>59054147
http://cython.org
>>
File: frustration.png (75KB, 330x400px) Image search: [Google]
frustration.png
75KB, 330x400px
ARGH! The macro pollution in Microsoft code is insane. Insane and retarded.
>>
>>59054147
>>59054160
samefag
>>
File: Capture.jpg (14KB, 349x106px) Image search: [Google]
Capture.jpg
14KB, 349x106px
>>59054175
kill urself
>>
File: stages-of-grief-14-728.jpg (41KB, 728x546px) Image search: [Google]
stages-of-grief-14-728.jpg
41KB, 728x546px
>>59054064
> Don't forget D will soon have a borrow checker,
>>
>>59054175
non sequitur too
>>
>>59054197
It's not important what language wins as long as Rust loses.
>>
>>59054064
>Don't forget D will soon have a borrow checker
What are you referring to?
>>
>>59054217
Walter Bright is making a borrow checker for D and he said it wasn't that hard
>>
>>59054162
this
>>
>>59054233
source?
>>
>>59052963
>>59052967
>>59052968
>>59053186
Forgot to thank you all for your answers.
Chimpanzee is processing your information.
>>
>>59054249
Here is the design https://github.com/dlang/DIPs/blob/master/DIPs/DIP1000.md
>>
what is the best gaming engine to use to make a game?
>>
>>59054301
x86_64
>>
>>59054301
opengl
>>
>>59054301
Lisp
>>
>>59054301
Binary
>>
>>59054301
Hex editor.
>>
File: very nice.jpg (38KB, 434x448px) Image search: [Google]
very nice.jpg
38KB, 434x448px
>>59053234
>>
>>59054301

Just use a pen and paper, fucks sake.
>>
>>59054301
unity
>>
>>59054301
>>59054316
>>59054317
>>59054324
>>59054328
>>59054349
>>59054360
>I want to make a game
>Actually expecting /g/ to recommend a Game Engine
Make your own Game Engine, fag. Use SDL2 and maybe OpenGL, depending on what you want it to do.

OBVIOUSLY, you should program it in C or C++, though. Anything else is retarded.
>>
>>59054301
Unreal Engine - it's quality AND oss.
>>
i have these _valid_ escape sequences:
\f \n \r \t \\ and \"

i'm trying to write a regex that will match any escape sequence *except* the valid ones

this is what i came up with

\\.|[^\\[\\\"fnrt]]

do you agree?

\\. matches any escape sequence that starts with \ (e.g \k)
>>
>>59054368
I want to hear from the best programmers though to make a game which engine is the best

I am not going to make my own engine because I will never finish making the game
>>
>>59054404
TempleOS
>>
>>59054404
>best programmers
>/g/
HA!!

The only good ones here either don't make games OR make their own engines, fucklord.
>>
>>59054404
>>>/vg/agdg/
>>
>>59054430
not true a good programmer would know which of the gaming engines is really good to make a game and why

this is what I am asking to you good programmers which of the engines is good out there and why?
>>
>>59054404
Game genre?
Indie-looking -> Unity
RPG Sprite -> RPG Maker XP
Others -> Source/Unreal/Unigine
Programming? -> Some high/mid-performance language like C, C++, Common-Lisp, Fotran (?), C#.
>>
>>59054459
A diesel engine
>>
>>59054284
>No lifetime polymorphism
>No lifetime subtying rules
>No difference between mutable and immutable references
>No implicit move on return
Wait, this isn't a borrow checker at all, it's just what it says it is - scoped pointers, prevents you from returning pointer to local variables. And it's gonna be disabled by default and nobody gonna use this switch because it's gonna break their code. 2/10, there was an attempt.
>>
Borrow checkers are trash!
>>
>>59054400
\\[^fnrt\\"]
>>
>>59054459
>not true a good programmer would know which of the gaming engines is really good to make a game and why
What part of:
>>59054430
>The only good ones here either don't make games
>OR make their own engines
didn't you understand?

Now, to be srs, there have been a few decent suggestions, here:
>>59054366
>>59054376
>>59054463 (best)
but really, you're talking to a group where maybe like 16/400 people here actually work on games AND are good programmers. The other 50 game devs here don't know much in terms of programming.

But, when you look at it, there's only a few "Engines" to choose from that people here are even likely to know.

>>59054463
I literally only knew of 2 of these(Unity and Unreal)
(3 if you count RPG Maker, but idk if that should really be called an "Engine")

I DO, personally, plan to get into Games at some point, but I have no real intention of using anything other than SDL+OpenGL, maybe Cairo or something, though.
>>
>>59054404

Fuck off to /vg/ already. It's not like you'll even finish it, just go do some shit in gamemaker and piss off.
>>
>>59054404
see >>59054432

People on /dpt/ use video game development as a vehicle to understand programming better, so there's no reason to skip out on writing an engine, the most techincally challenging part.

People on /agdg/ want to produce and publish video games as fast as possible, so they prefer to use ready-made engines.

You would be more interested in the second group.
>>
>>59054553
thanks!
>>
#include <iostream>

using namespace std;

struct Person() {
bool outside() {
std::cout << "How bout dat\n";
}
}

int main() {
try {
Person me;
} catch (Person me) {
me.outside();
}
return 0;
}
>>
As someone in a low paying construction position, I was looking to get into programming, I've been interested in it for a while but never really jumped on it but now that I've got some money saved up I don't mind losing some hours at work to really get into learning.

Since I'm mostly looking to do it for work, would it be a good idea to start with something like Head First Java 2nd edition? Since Java seems to be the most popular in the business world, and then move to learning C / C++ once I have Java basics down
>>
>>59054767
so you're trying to steal my job?

frick off
>>
>>59054587
You can count RMXP as an engine if (and only if) you expand it through big scripts. It's base classes (the ones that do the rendering) are very similar to what you'll end up doing with SDL's software renderer.
If you want to use SDL+OpenGL (please, use SDL2, not SDL), I'd recommend you for 2D based or simple games OpenGL ES 2.0 because it works on most phones (it's kind of horrible not to have vertex array objects (VAOs) but you can handle through it. For performance reliant projects, >OpenGL 3, specially OpenGL 4.5 (yes, fuck you Intel's Windows driver) which adds some low-overhead facilities or just Vulkan. I don't know if SDL2 now works on Vulkan (I tried it when it was just realised and did not work).
>>
>>59054751
>C++
>using namespace std;
>std::cout
>"\n" no std::endl
>>
>>59054751
what the fuck?

outside() doesn't return ANYTHING, and instead PRINTS A LINE...
What are you trying to catch? No exceptions are thrown.
The struct only generates an object-level function... there's no data.

What even is this?
>>
>>59054751
Truly c++ is marvelous, throwing strings is simply the best!!!!!!
>>
>>59054767
thats noble as fuck my dude.
web dev is also a massive field if u dont mind the prospect so much
can really vouch for the book or anything but good luck to ya
>>
>>59054802
>using namespace std;
why is this considered bad?
>>
>>59054803
You silly you can throw anything in c++ :^)
>>
>>59050789
>>59050819
Should management encourage this professional conduct?

>What are you working on, /g/?
Chewing through couple hundred poorly commented classes written in Spring Framework trying to figure out what it was supposed to do and why it doesn't. I'll give it until end of the week and then refactor the whole damn thing in something else.
>>
>>59054791
Well, yeah, I meant SDL2. Sorry.

And ok, sounds fair, regarding RMXP.
I have RPG Maker VX Ace, tho.
Haven't rly used it much, tho
>>
>>59054823
It's bad because he's calling it to avoid writing std:: but then calls std::cout.
That's because of reading in every single brain dead website:
#include <iostream>
using namespace std;
>>
so i ran into a little problem in my parser

when i try to catch an double quote " i print "quote opened!"
like
"\"" :: print ("quote opened! ")

but when i try to detect the corresponding closing quote " it says i have already defined that rule
"\"" :: print ("quote closed! ")


because basically the rule to open and close it the same
>>
>>59054856
>i have already defined that rule
Why aren't you writing your own parser?
>>
>>59054885
because i have to use this tool and its a lot easier, anon
>>
File: uno.png (251KB, 470x384px) Image search: [Google]
uno.png
251KB, 470x384px
>learn C
>learn LLVM
>learn OpenGL calls
>learn data structures and algo
>80% of jobs just want someone to write in PHP
>>
>>59054907
Just think of it this way anon

at least you don't have to write PHP
>>
>>59054896
Then pick a different tool or actually git gud enough to write a state machine in a for loop.
>>
File: 1487188825202.jpg (114KB, 970x880px) Image search: [Google]
1487188825202.jpg
114KB, 970x880px
Is anime referentially transparent?
>>
>>59054802
>std::endl

Are you serious? std::endl is defined to always act as '\n', even on Windows, there is no portability gain for using it. What it also is defined to do, is that it always flushes the stream you pass it to. This can greatly reduce performance of a program, as the system cannot use buffering effectively. Only use it where you'd write
<< '\n' << std::flush


The C++ Core Guidelines recommends needless usage of std::endl in SL.io.50.
>>
>>59054907
story of my life

i guess you have to learn/work on those projects on the side
>>
I don't want to be a Java/.NET monkey for my whole life.

What should I do before graduating from university? What kinds of interesting programming jobs are out there?

Is academia worth it?
>>
>>59054827
But it's not even throwing the exception. There's no exception class at all.
What is it going to do? Try to generate a Person object, and if it fails... generate a Person object and print that line?

I've never seen a program written like this.
>>
>>59054919
>state machine
i'm using one, but again the rule to open and close its the same..
>>
>>59054921
Yes
>>
>>59050819
This image makes me want death.
>>
>>59054938
somebody PLEASE respond, I don't want to write `````business logic''''' until i die of old age
>>
>>59054950
Write your own state machine, you dumb faggot. It will at worst be a few hundred lines of code, at best 2-3 switches in a loop.
>>
>>59054990
Start your own business.
>>
>>59055001
why don't you write your own OS, faggot?
>>
>>59054990
Learn Lisp and start writing Emacs plugins. You'll get money for them.
>>
Suppose I want to create my own P2P TOR network with a single directory server. The communication between the clients should be encrypted by means of TLS/SSL. How can I realize this without having to import every generated certificate into a nigger truststore™®©?
>>
>>59055007
>too lazy to write a for loop
>>>/g/wdg
>>
>>59055005
I just want to have fun writing interesting software, is that too much to ask for?

>>59055011
please
>>
>>59055040
>I just want to have fun writing interesting software, is that too much to ask for?
No, it's not. Start your own business for it.

That's what I hope to do.
>>
>>59054944
Kek, i didn't even look that much at it. But you're rigth 0.o;
>>
I'm currently not working on anything.

I am reading a book called Hacking: The Art of Exploitation by Jon Erickson.
It's a very good book. I've never worked with x86 architecture assembly language before reading this book, so I am having a lot of fun. :)

I am playing around with stuff I learn in this book.

In the chapter I just finished reading before coming to 4chan, the author disassembled a very simple C program which was basically a for-loop that prints "Hello, world!" 10 times and then analyzed the disassembled main function.

Now, I am disassembling more complex C programs that I've previously written using objdump and studying the disassembled main function, so that I can improve my knowledge in x86 architecture assembly.

I only started reading this book yesterday, so I've only read 6 chapters so far.

It is so fun, so far. I am really enjoying it! :)
>>
>>59055033
>too lazy to write a OS
>>>/g/wdg
>>
>>59055132
Why did you space your post like that, redditor?
>>
>professor wants a typerchecker for his language done by Friday
>>
>>59055145
I'm more into parsers, synchronization algorithms and networking with a side of GUIs.
>>
>>59055146
It is more convenient for others to read. :)

I personally prefer reading a post that is separated into paragraphs when it's a long post; rather than a continues one.
>>
>>59054751
this doesnt compile with g++
>>
>>59055177
>I personally
I don't care about your feelings, redditor.
>>
>>59055155
better get off 4chan and get to work then
>>
>>59055155
Make it output anime quotes instead of error messages.
>>
>>59055192
You hurt my feelings! :'(
>>
>>59055146
I space my posts somewhat like that, too, tbqh, famalam.
And I don't use Reddit.

>>59055132
However, the specific way in which you write makes it look like a pretentious blogger, so I can kind of see why he thinks you may be a Redditor.

>>59055177
>Doesn't deny being a Redditor
FUCKING NORMIE!!!!
REEEEEEEEEEEEEEE

>>59055192
Now THIS kind of attitude is what I'm used to.

>>59055132
I may, however, check this book out if it has decent ratings and is also available for Kindle.
>>
>>59055187
--- a.cpp
+++ b.cpp
@@ -2,11 +2,11 @@

using namespace std;

-struct Person() {
+struct Person {
bool outside() {
std::cout << "How bout dat\n";
}
-}
+};

int main() {
try {
>>
>>59055226
>I may, however, check this book out if it has decent ratings and is also available for Kindle
It is; I have it on Kindle.
>>
I'm currently working on learning how to use Direct2D and DirectWrite.
Is this a good idea? I'm a bit worried about what to do if i ever reach a point where i want to write programs for Linux and OSX.
>>
>>59055226
>And I don't use Reddit.
Prove it.
>>
>>59055226
great post, take my upvote sir!
>>
>>59050789

youre a fag
>>
>>59055211
Any examples?
>>
File: 1486603594166.png (442KB, 500x712px) Image search: [Google]
1486603594166.png
442KB, 500x712px
>>59055226
>And I don't use Reddit.
>REEEEEEEEEEEEEEE
Sure thing, buddy.
>>
>>59055282
I find on reddit the people are more helpful in the programming sections they will actualy pm you and help and not give meme answers like shit on you for liking a certain language pretty helpful imo
>>
>>59055269
Make "Anta baka?" the error message for the most obvious mistakes. Also preferably make it output an anime image coupled with the error
>>
>>59055315
Then why don't you fuck off to there?
This place would be unquestionably better if you weren't here.
>>
File: rena.jpg (8KB, 225x224px) Image search: [Google]
rena.jpg
8KB, 225x224px
>>59055269
There you go:
https://en.wikiquote.org/wiki/Higurashi_no_Naku_Koro_ni#Rena_Ryuugu
>>
>>59055315
That sounds terrible.
>>
>>59055330
I like browsing both because sometimes there is hidden gems here of useful information like last thread when everyone spoke of different algorithms books they found best

>>59055345
it's pretty nice some of them even offered jobs and contract work and networking and other cool things etc
>>
#include <iostream>

int main()

try {
throw 1;
} catch(...) {
std::cout << "Hello, World\n";
}


This actually works.
>>
Exception handling in programming was a mistake
>>
my program now works with arbitrarily sized files, are you jealous?
>>
>>59055490
*pipes a 5GB file*
>>
>>59055132
I'm thinking of buying that book.

Wasn't the latest edition published almost 10 years ago? Are the contents of the book still relevant today?
>>
>>59055439
Yep.

Sadly, this doesn't.
try {
throw 22;
}
catch(22)
{
}
>>
>>59055479
monad transformers
>>
>>59055501
>catch 22
lel
>>
File: a.jpg (41KB, 720x547px) Image search: [Google]
a.jpg
41KB, 720x547px
>>59055439
proof
>>
>>59055479
Why do you think this?
>>
>>59055479
null was a mistake
>>
>>59055490
No. Why is this a bragging point?
>>
>>59055529
Fire was a mistake
>>
>>59055529
0 was a mistake.
>>
When should you start using public repos, and what should you put on them? I see some repos with worthless bash scripts and dotfiles and wonder why they're there.
>>
>>59055529
(void*)0 was a mistake
>>
>>59055501
Does this actually compile? Will g++ shit our all the exception/stack unwinding code for an empty catch statement?
>>
would you rather program in Java or use reddit?
>>
>>59055550
Anything under a free license.
>>
>>59055587
compile into the blob*
>>
>>59055591
Fuck you...
That's disgusting...

But... at least Java... can be useful, no?
:ok_hand::skin-tone-1: :sunglasses: :gun:
>>
>>59055587
No, it won't compile. You have to catch(int) or something, which is kinda cool in it self but totally ruins the joke.
>>
>>59053995
It didn't get deleted too many times it got pruned too many times. Not enough discussion about the subject to warrant a new thread every time it died. Lainchan is slow enough that they can reach the bump limit without having to worry about getting pruned beforehand.
>>
>>59055591
>lose my intelligence or lose my humanity
The first.
>>
>>59055501
My point was no "{" and "}" on main in >>59055439
>>
>>59055591
Reddit, any time. There are some sexy people over there.
>>
>>59054301
GNUmaku
Racket's Big Bang
>>
>>59055652
you need to be smart to use Java properly though
>>
>>59055647
I have never seen a more wrong post in my life. You will be gunned down in short order if you don't leave the premises.
>>
File: 1413115237509[1].png (274KB, 3000x3000px) Image search: [Google]
1413115237509[1].png
274KB, 3000x3000px
>>59055439
I once added a
try { throw 0; } catch (...) { }

at the beginning of a program since I found that the first thrown exception was extremely slow while subsequent exceptions barely had any performance impact.
>>
Oh. Well that's an interesting quirk of the parser.
>>
What is the best language to write other languages in?
>>
Still working on my twisty puzzle collection game.
>>
>>59055857
Interpreters: C.
Compilers: Self-hosted.
>>
>>59055859
you need better graphics if you want this to sell
>>
>>59055868
>Compilers: Self-hosted.
How do you expect me to do this without first writing it in some other language?
>>
>>59055857
Haskell, apparently. Or so i've been told many times.
>>
>>59055906
1) I don't want to sell it.
2) You never need graphics to sell a game.
>>
>>59055910
With magic.
>>
>>59055910
Binary -> Assembly -> Lang
>>
>>59055857
Racket. It's literally touted as a DSL language.
>>
>>59055937
>Calling machine code "binary"
Fucking idiot.
>>
>>59055941
*DSL-writing language
>>
>>59055927
I'm not a magician though
>>59055937
>Assembly
Which is a language.
Also >>59055942
>>59055941
How different is it from normal Scheme?
>DSL
My language wouldn't really be a DSL though.
>>
>>59055974
It's very batteries-included and has a bunch of macros like for/fold, for/list, etc for simplicity. It also has a single GUI library that allows programmers to use the host-specific platform for windowing and shit --- On Windows it's WinAPI, on Linux it's GTK+3, and on OS X it's Cocoa (or some shit, I don't remember)
>>
>>59055857
Haskell, it's type system makes interpretation of grammars super easy.
>>
>>59055433
I was a chantard before i was a redditor.
>>
File: 1351040310960.jpg (14KB, 296x296px) Image search: [Google]
1351040310960.jpg
14KB, 296x296px
>currently working a job which involves babysitting a legacy java system with rare deployments of new features
>looking for things to read up on that might be useful for future job positions and interviews

anyone have suggestions for new trends and memes that i should jump on that are becoming sought out in industry? currently just going through basic OOP design templates and ruby fundamentals for my own kicks.
>>
>>59056103
>trends and memes
Sounds like webdev. React, Node, Elixir, Go.
>>
>>59056044
Examples?
>>
>>59056103
how is it like working with Java legacy enterprise FactoryBeans code?
>>
>>59055857
Lisp.
>>
>>59056103
>java
>OOP
Don't disgrace anime with your post.
>>
>>59056234

im reading about generic OOP design templates, not java specific. The gang of four book is based off smalltalk primarily
>>
>>59056254
OOP is better than functional programming
>>
>>59056267
No programming at all is better than any programming.
>>
>>59056267
You're funny.
>>
>>59056267

i thought OOP was a meme on this board.
>>
File: programmer-pepe-is-sad-239766.jpg (64KB, 460x517px) Image search: [Google]
programmer-pepe-is-sad-239766.jpg
64KB, 460x517px
Taking software courses for the first time next semester, but because my schedule is weirdly balanced, I have to take at least two different languages at once. I have experience in python, but how fucked am I?
>>
>>59056298
Which languages?
>>
>>59056267
How can it be better than something which can be a subset of it?
>>
>>59056315
Haskell and Malboge
>>
>>59056315
Next semester is Html/CSS and also C++. Both intro courses.
>>
>>59056298
>ribbit the reddit frog
Back to your subreddit.
>>
>>59056330
What kind of institute of pajeeting offers html/css courses?
>>
>>59056351
Sinclair Community College :(
>>
>>59051411
Rustfag reporting in, D is my second favourite language
>>
>>59056298
Stupid frogposter
>>
File: cute little penis.jpg (23KB, 321x274px) Image search: [Google]
cute little penis.jpg
23KB, 321x274px
>>59050789

C-can someone help me? How do I get started on learning to code at home?
>>
Serious question no memes aside I have a team of 4 programmers who we all are going to program a business web application

How do we go about splitting up the workload and different sections of code?

How does a programming team go about doing this?
>>
>>59056391
>cute little penis
my sides

kill yourself please
>>
>>59056391
http://ddili.org/ders/d.en/Programming_in_D.pdf
>>
>>59056391
Learn C, then assembly, then Haskell. Then do whatever you want
>>
>>59056429
Why those first?
>>
>>59056443
Because they don't possess a large amount of outright garbage qualities
>>
>>59056395
Agile test-driven waterfall development.

On a serious note, that very much depends on the requirements of that specific application. Ideally you could split work into modules and agree on what features need to be implemented first.
>>
>>59056443
C is a beginners' language
>>
>>59054064
They don't even have a GCless stdlib right now.
There is only so many times you can fail and D has passed that line long ago.
Rust on the other hand only has its SJW community part as serious downside and that will disperse.

>>59054475
That guy never disappoints to disappoint.

>>59054540
They are certainly no fun. I hope Jai succeeds as I need a fun system programming language for grashing this blane with no surbibors.

>>59054147
They made it in several flavors and it sucks. You basically have to change the semantics of the language to make it worth it. See what's Crystal to Ruby, Cython and Nuitka are crippled attempts at this.

>>59050789
Thank you for not using chinese carto--
>>
>>59056402
I lost to that filename too
>>
>>59056411
You actually want me to read this whole book?!
>>
>>59056525
>There is only so many times you can fail and D has passed that line long ago.
How, other than opt-out GC
>>
So after seeing a thread a while ago (and got reminded of it today) I decided to make an assistant, so far it can tell me the weather, respond to basic questions, tell me my IP, do a speedtest and currently working on checking if a domain is down just for me or everyone - what else should I add?
>>
>>59056356
Ah well, I'm sure it's not that bad. Atleast you're learning and improving. :)
>>
>>59056214
Well, it's kinda hard to explain without knowing how much you know about semantics/logic/grammars and there mathematical properties, and that's not even going into the general concepts of a language you would need to be familiar with. I guess a good first example (post parsing, which Haskell also does well, check out the Parse type), you need a way to translate your languages "types" back to Haskell's (or whatever language you choose) underlying types. This is very easy with algebraic types:

data Val = IntVal Integer | SymVal String | ExnVal String

In this case, our new 'language' has 3 types: IntVal, which we will use Haskell's Integer type to represent internally, SymVal, which is represented as a string internal to our interpreter (in this case, could be a keyword, like instead of '+' in C, you could represent addition as the string "horseBattery", ect, and ExnVal, which represents a value we can pass back from doing evaluations on Vals to represent errors (ExnVals here can represent exceptions). I am not going to go into lifting/lowering values from your language to the interpreter language. But you can see how easy it is to extend the types your language can use.

Now, Haskell's pattern matching makes evaluation (which you would probably want to turn into a type itself, i.e. different types of evaluation of values) easy as well.

Consider:

eval :: Val -> Val -> Val -> Val
eval e1 e2 e3 = case e1, e2, e3 of:
IntVal, IntVal, Intval -> printIntVal e1 e2 e3
IntVal, IntVal, SymVal -> doOperation e1 e2 e3
ExnVal, _, _ -> printError e1

Ect. You can see it is also very easy to extend your "evaluation function(s)" as well as you add new types. Generally, you would have algebraic data types for just general Types, Expressions (i.e. sub evaluations, adding two computations instead of constants), and an environment, like a hash map, to keep track of the scope of the variables used in each evaluation.
>>
>>59056607
-> major language redesign as a last straw
-> standard library fight
-> license issues with DMD (you basically were forced to trust on Symantecs whims)
-> not even two years ago you still needed DMD for quite a lot of dub libraries
-> wasting manpower in stuff like supporting C++ ABI... all countless versions of them

In general, there always seems to lack a clear vision to target other than being a better C++. That alone isn't enough.
>>
How is scheme/racket in terms of safety?
>>
how can I create an alarm clock with python that will open a video file of a rising sun?

Google doesn't seem to help regarding using python as an alarm clock, I am just more confused. Suggestions?
>>
>>59056789
use Rust
>>
>>59050867
How to generate pi in C#
Console.WriteLine(Math.PI);
>>
>>59056789
A meme. Just like in any other aspect.
If you want a working Lisp, use Common Lisp.
>>
>>59050789
Now that I have my image viewer supporting FLIF images properly, I'm converting a bunch of my larger PNG's (>= 1.0 MB) to FLIF to losslessly compress them a little more. Feels pretty nice, actually.
>>
>>59056888
Why?
>>
>>59056789
Safety in what way? Racket will bring up contract errors if you try to go out of bounds on anything. That being said, there are a number of unsafe libraries (it's obvious because they have "unsafe" in their name) that will do some wild things if you're unfamiliar with how to use them. ffi/unsafe, for example, gives you control over raw pointers, which means you're playing fast and loose with memory and will probably end up fucking your shit up if you aren't careful.
>>
File: W399mqk.png (705KB, 640x1136px) Image search: [Google]
W399mqk.png
705KB, 640x1136px
>make an SQL database for my android app
>have no idea how to design a database properly
>do something that seemed good enough at the time
>now i realize how poorly it was made and isnt sufficient enough
>installed on 1k+ devices at this moment
>>
Good resource on datastructures and algos?
>>
>>59056989
Datastructures and algorithms
>>
>>59056995
thanks!
>>
>>59056937
>Scheme: An incomplete standard coined under the pretense of minimalism that to the last didn't even include a standardized import mechanism. Its creator eventually gave up and created Common Lisp.
>Racket: An experimental implementation of Scheme with meme DSL extensions.
>Clojure (for completeness): A meme web tier script Lisp that doesn't even reap half of the advantages that JVM offers. With community infights and hipster projects.
>Common Lisp: A somewhat aged but usedful, complete standard that has the most convincing compilers and environments. That includes commercial implementations.
>>
>>59057005
no problem!
>>
>>59057011
While SBCL is a self-hosted implementation (it's implemented in Common-Lisp), most Scheme implementations translate its code to C and then compile it, which is trash.
And macros. I hate hygienic macros.
>>
>>59055859
Nice, what language are you using. Is it going to be mobile?
>>
File: 1485173668037.jpg (106KB, 593x578px) Image search: [Google]
1485173668037.jpg
106KB, 593x578px
>His function doesn't even have multiple return values
I hope you aren't using a shitty language, /dpt/
>>
>>59057142
Been programming for more than 9 years and can't remember the last time I used Tuples.
>>
>>59057142
just return a struct with as many values as you want you retard
>>
>>59057142
still waiting for structured bindings
>>
>>59057166
>>59057188
>while on real language:
_, top = lmao(kek)
>>
NEW THREAD!

>>59057215
>>
Where were you when C was kill?
https://benchmarksgame.alioth.debian.org/u64q/performance.php?test=knucleotide
>>
>>59057011
CL has aged like a fine wine. The standard/hyperspec is an enjoyable read.
Thread posts: 324
Thread images: 24


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.