[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: 47
File: combine_images.png (778 KB, 400x720) Image search: [Google]
combine_images.png
778 KB, 400x720
old thread: >>54585050

What are you working on, /g/?
>>
First for C++
>>
>>54590561
Working on ur mom
>>
>>54590561
Not too sure what I should be working on. I suddenly traded my free time for a job and classes.
>>
>>54590581
first for PHP is C for the web
>>
>>54590561
>combine_images
This must be your house then, anon? I love it, great work.
>>
contemplating my miserable existence.
>>
>>54590479
for /F "tokens=1,2,3 delims=:" %%a in ('echo 12:34:56') do (
set /a s="%%a*3600 + %%b*60 + %%c"
echo %s%
)

if you really need to use batch
>>
Anyone here experienced with MATLAB and image processing? I'm encountering some issues with what seems like a basic problem

i = 256x256 image
h = 3x3 filter
i_h = 258x258 filtered image

Now, given i_h and h, I want to numerically recover i. To do this seems simple enough, just divide the ffts, but I'm running into an issue.

First I got the fft of both
i_h_fft = fft2(i_h);
h_fft = fft2(h, 258, 258);

I then fixed a zero at (1,1) in h_fft by making it eps + eps*i.

Then to recover the image
i_orig = ifft2(i_h_fft ./ h_fft, 256, 256)

This truncation is fucking me up though, I end up with a massive complex expression that resembles the original image but isn't there.

Any ideas?
>>
>>54590741
This reminds me of that one D screenshot that has its fizzbuzz logic in strings.
Why do languages do this? If the interpreting of the string is part of the compiler, why not just have it not be a string? Is this just so you can pass around arbitrary code? Aren't there better ways to do that? I don't know a lisp but isn't that kinda what ' does?
>>
>>54590808
you won't find taylor
>>
>>54590741
doesnt work
>>
File: finiteworld.png (63 KB, 892x699) Image search: [Google]
finiteworld.png
63 KB, 892x699
>>54590561
Writing a method of saving world data to disk for my minecraft clone. Just a very small bit left. Then I have to write a way to read it.
>>
>>54590863

Nice paren colors.
>>
>>54590863
what language is this

are you writing a Minecraft clone in Haskell, how are you doing the graphics?
>>
>>54590836
you obviously have to replace the %% with % if you're using it directly in the command line, and not from a batch file, if you haven't done that
>>
>>54590922
lots of parens means a lisp dialect. maybe Scheme
>>
>>54590931
im running it from a .bat and it's not printing anything for %s%.
>>
>>54590561
Is that hime?
>>
>>54590946
Bingo

>>54590922
Sweet jesus not Haskell.

Right now it's mostly C and some Scheme. I'm writing the low level engine bits in C. I'm using SDL and OpenGL for graphics.

You can tell which procedures are written in C by whether the procedures use _'s.
>>
So the best way to become good at programming is to practice obviously, but you would do this by completing harder and harder projects as you learn right?
>>
What is your Topcoder rating /g/?

I just broke 1800
>>
>>54590973
huh, I'm looking for a project to do this summer and was considering some sort of game, though I'm a pussy so I'll do it in C++
>>
I program in Ruby only
>>
>>54590974
Generally, yes.
The hardest part is learning to compose code freely instead of sitting there for 10 minutes getting a headache because you're not used to thinking like a dumb computer.

I learned to get over it by doing all the challenges on codeeval, until they broke their C evaluator and now they won't let me overwrite the test input file before running the program anymore.
>>
>>54590931
solved it
@ECHO OFF
echo echo Current File: "%~n1%~x1"

echo Start Time(HH:MM:SS)
set /p start=

echo End Time(HH:MM:SS)
set /p end=

>output.tmp (
echo %start% | sed s/:/*60+/g | bc
echo %end% | sed s/:/*60+/g | bc
)

<output.tmp (
set /p s=
set /p e=
)

set /a total=%e%-%s%

ffmpeg -y -i "%~n1%~x1" -vcodec copy -acodec copy %sound% -ss %s% -t %total% "%~n1[cut]%~x1"
sdelete -p 1 output.tmp


i think its impossible using pure batch. sed/bc are needed for windows, as well as optional sdelete for removing the temp file the echo is stored in.
>>
why is recursion taught in schools when its not that efficient?
>>
>>54591201
it's useful for algorithms operating on tree structures.
how is it inefficient?
>>
>>54591201
It's not inefficient.
>>
File: 1375074177933.gif (828 KB, 200x189) Image search: [Google]
1375074177933.gif
828 KB, 200x189
>>54590561
>keeping a server next to a heater
oh shit nigger what are you doing?!
>>
>>54591201
-O2 optimization exists.
>>
>>54591227
I am reading in this book that generally iterative functions are more efficient. The reason the book gave was that the function calls require a big overhead on most platforms. I just find it weird reading this when most of the time the professors taught me iterative then recursive functions.

I am just trying to study for coding exams and trying to learn stuff that I am not taught in the classroom. I guess I am just still looking at very simple programs that should not require complex calculations
>>
>>54591316

it's useful in some cases like tree traversals and modifying trees. It's also useful as some people think better around recursion compared to iteration for some reason.

and recursion is only really fucking bad when it's a huge recursive loop which creates a fuck ton of stack calls.
>>
>>54591316
Small tail recursion with -O2 optimization is condensed into iteration.

Iteration is more efficient only if you do cache optimization. Otherwise the time spent doing that function call is negligable as you'll be waiting on data to come in from memory.
>>
>>54591316
That book is wrong. Iteration is 100% equivalent to recursion when optimized properly. For a given loop/recurrence, the work you do in an iteration is the exact same that you would do in a recursive call. The issue is that compilers aren't always great at optimizing recursion (which "by default" allocates a new stack frame), whereas with iteration everything is explicit and so the compiler has no say in it. Most of the time, a recurrence is easier to write then the equivalent loop, though, so if you have an optimizing compiler you should prefer it.
>>
>>54591166
What makes you think this is impossible with pure batch?
@echo off
echo Start Time(HH:MM:SS)
set /p startTime=

echo End Time(HH:MM:SS)
set /p endTime=

for /F "tokens=1,2,3 delims=:" %%a in ('echo %startTime%') do set /a startSec="%%a*3600 + %%b*60 + %%c"
for /F "tokens=1,2,3 delims=:" %%a in ('echo %endTime%') do set /a endSec="%%a*3600 + %%b*60 + %%c"

set /a totalSec="%endSec%-%startSec%"
echo %totalSec%
>>
>>54591316
>>54591397
Also, recursion in principle doesn't have to involve mutation (it will when compiled, of course), so it allows you to write pure code which is easier to reason about.
>>
File: screen.1463458994.png (25 KB, 1505x397) Image search: [Google]
screen.1463458994.png
25 KB, 1505x397
>>54591398
I keep running into the same error with that method
>>
>>54591463
>HH:MM:SS
>1:00
>1:30
>>
>>54591473
LOL

I just assumed it worked without needing 00:01:00.

my way works with just inputting 1:00 as 1 minute.

thanks for the help though
>>
File: 1453766357284.gif (237 KB, 276x268) Image search: [Google]
1453766357284.gif
237 KB, 276x268
Rust or Sepples, anons?
>>
>>54591796
For what?
>>
>>54591819
an openGL IDE
>>
>>54591855
You mean for OpenGL programming? Glium seems okay, and I'd choose Rust over C++ in general any day.
>>
File: angel-holding-an-olive-branch.jpg (177 KB, 845x1300) Image search: [Google]
angel-holding-an-olive-branch.jpg
177 KB, 845x1300
>>54590561
Writing an irc bot.
Not sure how to parse stuff.

int loop(bot_t *bot)
{
int k = 0;
char buf[513], (*message)[513] = malloc(513 * sizeof(char*));
char pong[64] = "PONG :";
const char *pass = "PASS bot1234\r\n";
const char *nick = "NICK mybot\r\n";
const char *user = "USER mybot 0 0 :mybot\r\n";

send(bot->sfd, pass, strlen(pass), 0);
send(bot->sfd, nick, strlen(nick), 0);
send(bot->sfd, user, strlen(user), 0);

int len = recv(boogiepop->sfd, buf, 512, 0);

for (int i = 0; len != 0; ++i)
{

for (int j = 0; j < 512; ++j)
if (buf[j] == '\r' && buf[j + 1] == '\n')
{
strncpy(message[k], buf, j + 1);
message[k][j + 2] = '\0';
printf("%s\n", message[k]);
++k;

if (k >= 512)
message = realloc(message, sizeof(message) + 513 * sizeof(char));
}
len = recv(bot->sfd, buf, 512, 0);
}

free(message);
return 0;
}


In this code I expect that
message
contains k separate lines of text which together makeup the bulk of data received hitherto.

But it mocks me.
>>
It's late and I keep getting a seg fault when I run this. I feel like I'm fucking up something obvious. Pls help
#include <stdio.h>
#include <stdlib.h>

struct node {
int data;
struct node *next;
};

struct node *makeNode(int data, struct node *n) {
if(n == NULL) {
n = (struct node *) malloc(sizeof(struct node));
n->data = data;
n->next = NULL;
}
else
n->next = makeNode(data, n->next);
return n;
}

int main() {
struct node *root;//, *a, *b, *c;

root = makeNode(5, root);

return 0;
}
>>
>>54591908
I meant to put
int len = recv(bot->sfd, buf, 512, 0);
on line 14.
>>
>>54591925
You're using and comparing an uninitialized value.
>>
>>54591925
compiled fine on arch no segfault anon

may I ask what exactly you are trying to do their tho it's a pretty retarded way to do a linked list.
>>
>>54591925
You need a list struct that holds the "head" node pointer and the depth of the list.
You need to initialize the head node with a pointer to NULL if you want your little makeNode function to actually work.
>>
File: 1416805378870.jpg (75 KB, 717x499) Image search: [Google]
1416805378870.jpg
75 KB, 717x499
>applying for positions in software engineering or data engineer/scientist
>lots of entry level positions
>mfw so god damn many require 1-2 years of software work experience

I don't understand this shit how is it entry level if it still has work experience required?
>>
>>54591925
The first thing you do in makeNode() is test if n == NULL, but root has not yet been initialized when you pass it in for n.
So struct node *root = NULL.
Not sure if that's the cause of the seg though.
>>
>>54590741

Why are people still trying to use Batch when Powershell exists?

Seriously, if you wanted to convert a string in the format of HH:MM:SS to just seconds, it looks a lot cleaner in Powershell:

function convert_timestamp([String] $time)
{
$ary = $time.split(":")
$seconds = [Convert]::ToInt32($ary[2])
$seconds += [Convert]::ToInt32($ary[1]) * 60
$seconds += [Convert]::ToInt32($ary[0]) * 3600
$seconds
}


I mean granted, it's slightly more verbose, but is is insanely more intuitive. And this is available on every single Windows system since Windows 7 IIRC. (It might be in Vista, not sure, I don't know anyone who uses Vista).
>>
>>54592025
not to mention, now I haven't looked to far into powershell but, the batch interpreter is terrible. It parses line by line (even parsing through comments) and there are cases where comments are parsed into the program!

Do not use cmd, ever. Not when POSH (and now BASH) exist as upgrades.

Using cmd.exe is like those old school unix guys you see who still use plain vi even though vim has been out forever and isn't as annoying or featurless.
>>
>>54591925
the segment fault may be caused by this line:

n->next = makeNode(data, n->next);

since when you pass root it isn't initialized to NULL it could just jump to the else statement at which point it tries to access an unitialized struct leading to the segment fault.

*root = NULL;

will fix the problem.
>>
>>54592008
fuck off, writing software is free. That's why there are so many pajeets who get sw jobs.

>electrical engineering positions 2-3 years experience minimum
>small scale interesting electrical projects are at least $50
>>
>>54591941
>>54591972
>>54592016
>>54592052
Yup, this is what the problem was. Could have sworn that structs were automatically initialized to NULL if they were simply declared. Thanks senpai

>>54591957
>may I ask what exactly you are trying to do their tho it's a pretty retarded way to do a linked list.
lol yeah I haven't fucked with basic data structures in like two years, so I'm refreshing memory. I've also never implemented any in C so I'm getting acquainted with that. I realize the implementation is dumb, I was just trying to bang something out real quick.
>>
>>54592078
>fuck off, writing software is free.

pajeet please I actually worked hard for a degree
>>
>>54592008
just apply for it anyway
>>
>>54592135
ok well I was just checking, I would try to write that linked list using a for loop first instead of starting with recursion to avoid problems like this

>>54592052
>>
File: 1460516248551.jpg (103 KB, 1024x921) Image search: [Google]
1460516248551.jpg
103 KB, 1024x921
>>54592140
nice waste of money shit degree, and nothing to show for it.
>>
>>54592135

btw after the malloc you need to check if the pointer has a value. Malloc can return NULL if your system can't return any memory from the heap.

so a simple if(!pointer){pritnf("out of memory"); return -1;}

should work to prevent a failed malloc from fucking your system up
>>
>>54592152
Recursion is much sexier though
>>
>>54592188
Yeah I was just typing up something quick and dirty without necessarily abiding by conventions
>>
>>54592207
yeah I agree, but also it can be unwise in some situations.
>>
>>54592008
to fuck over people without connections.
>>
>>54592292
aka social retards

natural selection automatically filters out people who cannot even talk to someone face to face
>>
>>54592425
its an unnecessary barrier thats fucks over far more people then those types.
>>
>>54592292

I have multiple references from professors and 1 from my boss who I developed a website for.

I just lack work experience in shit other than class work and PHP.
>>
>>54592425
just be a female, POC (no asians), or other surface-level minority and you can skip the line!
>>
>>54590561

>what are you working on /g/

My employer has tasked me with shilling /pol/ with anti-Trump pro-Bernie stuff, and pro Hillary upvoting on r/politics.

Aside from that I'm meant to gain positive replies for Windows 10 threads in /g/, and as much as possible keep threads that are positive for Windows 10 active for as long as possible. I have to log everything I do and submit it every four hours.

I hate my life
>>
>>54592571
i'm curious about this apparent market for shilling. is there a site describing and brokering this work, or are you just making all this shit up?
>>
>>54592498
It's to discourage people who don't think they can take the job. You apply for it and assert in a cover letter that you ARE material for the position. Don't be a pussy.
>>
Hey guys r8 my code

public int findWinner(int userMove, int compMove){
if(userMove==ROCK&&compMove==PAPER||userMove==PAPER&&compMove==SCISSORS||userMove==SCISSORS&&compMove==ROCK){
this.CWins++;
return COMP_WINS;
}else if(compMove==ROCK&&userMove==PAPER||compMove==PAPER&&userMove==SCISSORS||compMove==SCISSORS&&userMove==ROCK){
this.UWins++;
return USER_WINS;
}
return TIE;
}
>>
>>54592637

are cover letters still a necessity? I talked to some managers and they said they don't even look at them anymore and focus on the resume and interviews.
>>
>>54592645
beautiful.

>>54592669
>focus on the resume
Let me translate that for you: look at the cover letter
>>
File: 1356068184823.jpg (33 KB, 400x388) Image search: [Google]
1356068184823.jpg
33 KB, 400x388
>>54592677

>mfw I applied for jobs without a cover letter

OH FUCK
>>
>>54592669
not him, but i've gone through resumes and done interviews a few times.

cover letters are useful if you don't match the profile they claim they're looking for. it's basically
>here's my resume oh here's this short explanation for why i'm applying even though on paper i look like a shitty candidate

it's not guaranteed to work, but it's guaranteed to work better than just submitting your resume without any explanation for why such a mis-match applied to the job in the first place.
>>
>>54592677
>>54592685
what the fuck is a cover letter?
you have to write an essay along with your damn cv?
>>
>>54592689
honestly if you're asking and not willing or able to look this shit up (e.g. googling your first line, pic related) then don't worry about it. it only makes a difference in marginal cases

also
>write an essay
google image search. should give you a sense for how long it should be. they're thinking about spending a lot of money to have you in the same workspace as them 5 days a week; everyone who's been in hiring wants as much signal to work with as possible.
>>
>>54592669
Here's the trick. You need to show that you aren't afraid to take initiative and play by your own rules, but you also know your place and are humble. If you're having trouble finding a job, try cold emailing a cover letter (make it bomb as hell) and your resume to a hiring manager. Even if you're not super outgoing and self-assured the worst that can come out of this is that you send your information to someone who never reads it. The best is that you get a job, but oftentimes there lies compromise in having your documents passed to a different hiring manager by the one you spoke to. You got nothing to lose—carpe diem my boy.
>>
>>54592721
>implying they don't redirect unsolicited resumes to /dev/null
>>
>>54592732
Chances are if you get to the manager's internal email it's not gonna have any fluff protecting it. Think about those types of people, now. And to reiterate: what did you lose? Not much.
>>
I have 20min

Can i use a scanner to scan what button the user presses instead of using if, dont ask why just help me find another way instead of if

int r;
if (JOptionPane.showConfirmDialog(null, "Do you want to take a risk?") == 0) {
r = Integer.parseInt(JOptionPane.showInputDialog("How much?"));
}
>>
File: suicidenow.gif (108 KB, 480x455) Image search: [Google]
suicidenow.gif
108 KB, 480x455
>>54592571
do you get penalties for spilling the beans in dpt?
>>
I come up with shit tons of ideas when I'm swamped with schoolwork.

And then I'm dead for ideas when the summer starts and I have time to actually implement them.
>>
>>54592759
You think he's serious?
>>
Unification algorithm for Haskell
data Ty
= VarTy String
| ConTy String [Ty]
deriving(Show,Eq)

type Subst = [(String, Ty)]
type SubstResult = Either String Subst

substFail :: String -> SubstResult
substFail = Right

apply :: Subst -> Ty -> Ty
apply [] t = t
apply ((x1,t1):rest) (t@(VarTy x)) =
if x == x1 then
rest `apply` t1
else
rest `apply` t
apply s (ConTy c ts) =
ConTy c (map (s `apply`) ts)

unify :: Ty -> Ty -> SubstResult
unify (ConTy c1 xs) (ConTy c2 ys) =
if (c1 /= c2) then
substFail $ "Incompatible types: " ++ c1 ++ " and " ++ c2
else
foldM (uncurry . foldUnify) [] (zip xs ys)
where
foldUnify s t1 t2 = do
s' <- unify (s `apply` t1) (s `apply` t2)
return (s ++ s')

unify (VarTy x) t = return $ [(x,t)]
unify t (VarTy y) = return $ [(y,t)]
>>
>>54590561
Learning how to do automated smart contract testing. Protip: TestRPC is buggy, use geth instead as an RPC provider (even though you lose those sweet, sweet instamined blocks).

Also how to use MathJax.
>>
>>54592582

Applied to an add through a Google add asking for data entry, work from home stuff. Ended up being shilling. While I can't tell you the company name a simple google search will show you how prevelant these companies are.
>>
>>54592950
tldr
what is this supposed to do
>>
>>54593106
you tell it to unify the type
a -> a
with the type
b -> Int
and it gives you a result saying to assign the 'a' and 'b' type variables to the Int type.
if you'd done
a -> a
and
Int -> Bool
it would give you an error because it wants either Int -> Int or Bool -> Bool

It's one of the central algorithms in what's called "hindley-milner type inference" which is really cool and not very many languages support a type system capable of it very well but the ones that do let the compiler decide the types for a variety of programs where you don't specify the types, while still checking to make sure they're valid.
it's p. cool. the algorithm works something like this:

we have some code that we want to know what the resulting type is. our code is
x + 1
since we have yet to figure out the type, for now we give it a "type variable", we will name this one 'a'. we say that
x + 1 :: a
meaning "x + 1 has type 'a'".
now we also don't know what the type of our variable x is either. we will give x a type variable, 'b'.
x :: b
now, thankfully we do know the type of (+), which is a function. it's type is
Int -> Int -> Int
(takes two integers as arguments, returns an integer).
by our hindley-milner algorithm, we create the following type for our "x + 1" code:
b -> Int -> a
because x :: b, 4 :: Int and (x + 1) :: a
we then call our 'unify' routine
b -> Int -> a
Int -> Int -> Int
it succeeds, assigning the Int type to both type variables a and b.
we have no inferred that x must have type Int and "x + 1" must have type Int as well
>>
>>54591908
Please respond.
>>
>>54591908
>>54593207
Text parsing is a complete pain in the ass in C, not worth using C under any circumstance for something like an IRC bot that not only does not need to be performant, but also whose bottleneck is mostly likely network latency, not CPU. You could probably write a 100 LOC Python script that does the same as you'll get in 1000 LOC spread across 5 files in C, without once having to worry about memory leaks or segmentation faults.
>>
>>54593166
and I assume this is a type inference implementation in a custom language?
>>
>>54593242
You could put type inference in any kind of language, preferably functional due to how the algo works. OCaml uses a type inference scheme closest to my code, as the algorithm was originally invented for the ML language. Haskell (what the code was written in) also uses type inference although their algorithm is going to be more complicated in order to handle type constraints, rank-n types, GADTs and all the other extension shenanigans in Haskell.
>>
>>54593166
All the good ones do (Haskell, f#, ocaml, etc)
Only shit tier Scala has a retarded type inference
>>
Writing an AI that plays a hexagonic version of 'dots and boxes' in java. It's only playing itself using opening moves and then minimax towards the end game.

I've finished but i'm scared it will fuck up somewhere as I have no other agents to test it against. Besides a random player and a semi-shit player (which are both far worse)..
>>
>>54590561
Need your advice /dpt/.

I want to get into programming, but I'm looking for a programming language that requires little to none math, any suggestions?
>>
>>54593462
>want to get into programming
>language that requires little to no math
but why

you can learn JavaScript if you wanna fit the hipster numale style I suppose
>>
>>54593316
>Only shit tier Scala has a retarded type inference
How on earth does Scala do type inference?
>>
>>54593462
oh come on now anon

I'm atrocious at math in general but it isn't ever much more complicated than converting bits to bytes or swapping between hexadecimal/decimal/binary. That is unless you make complicated things, which you wouldn't do even with a language that required no math.

tl;dr programming gets mathy the better you are at no matter the language
>>
>>54593485
It's shitty, all the code I see have it explicity write the type most of the time

The problem probably lies in that Java doesn't do any type inference so they would need to hack it in the JVM to have some form of proper type inference
>>
>>54593462
Most if not all
What matters is the application

http://www.vex.net/~trebla/haskell/prerequisite.xhtml
>>
>>54593462
Common Lisp or Racket.
>>
File: confused.gif (862 KB, 300x169) Image search: [Google]
confused.gif
862 KB, 300x169
>code works
>add feature
>code doesn't work
>revert feature
>code still doesn't work
no worse feel
>>
>>54593528
b-but i want to be able to find a job after that
>>
>>54593634
>I want to be able to hardly get good at something and then get paid a lot for being mediocre
>>
>>54593652
Then... Clojure? That's becoming popular these days.
>>
>>54593663
Whoops! meant to quote
>>54593634
>>
I'm pretty new to C. By using CPP and/or Makefile, what's the best way to compile for one library if you want in a makefile, or compile using another library if you want.

I want the user to be able to type:
>make using_library1
and the program will compile using bindings for library 1
or
>make using_library2
and the program will compile using bindings for library 2

What's the best way to achieve this? Do I need to compile a .so file for the different bindings/
>>
>>54593855
Not sure of the best way, but you can pass arguments to make and choose the lib from that. Or just have two separate rules for each lib.
>>
File: frac.jpg (1 MB, 5120x5140) Image search: [Google]
frac.jpg
1 MB, 5120x5140
I think I'm done with this one.
>>
>>54593961
Great job!
>>
can someone tell me what is wrong with my code
http://pastebin.com/gBzAewXR
>>
>>54594352
Everything
>>
>>54594371
well I think it looks good
>>
File: frac2.jpg (2 MB, 2560x2560) Image search: [Google]
frac2.jpg
2 MB, 2560x2560
>>54594304
Yeah, I know, it's babby's first program. It was still very fun and I thought I might just as well share some pictures. At least I always loved looking at them.
>>
>>54594399
looks amazing wow nice job
>>
>>54591908
I suggest you first learn about TCP because you've no idea what you're doing.
>>
>>54594399
Reminds me of an octopus I saw trying to fit inside a mason jar.
>>
I have a challenge for you /g/:

Implement Sleep Sort in the language you've recently learned
>>
>>54594477
inb4 30 google results for their memetastic language

>>>/prog/
>>
>>54593221
Exactly. Higher level languages exist for situations like these. Ruby would also be a good choice.
>>
File: Capture.png (19 KB, 1143x695) Image search: [Google]
Capture.png
19 KB, 1143x695
Doing a game engine for a school project. Using C# and OpenGL, PhysX and IronPython as a scripting engine.

>Why Ironpython and C#?
Because that was an assignment requirement...
>>
>>54593221
so what do you think about java for an ircbot
>>
>>54593961
>>54594399
I'm a noob and what is this? and how'd you do this?
>>
>>54594604
its mandlebrot
cool math
>>
>>54594604
https://en.wikipedia.org/wiki/Fractal
>>
>>54594604
It's called a Mandelbrot Set.
>>
>>54594352
you are making it choose a random int between 1,1 wich is invalid. the change getting completely through this is extremely low and not something that should be expected in a lifetime
>>
>>54592188
That's dumb as fuck, malloc can return a valid value even if all your available physical address space has been commited in your process address space.

May be a valid concern for embedded systems, but it surely isn't the case here.
>>
>>54590561
Does anyone know what this error means? It is output from SunOS tool bcheck

signal ILL (illegal opcode) in (unknown) at 0x23454
0x00023454: _PROCEDURE_LINKAGE_TABLE_+0x0008 [PLT]: illtrap 0x241c0
>>
>>54594622
random.randint(1,1)

this returns 1 what you say is incorrect
>>
>>54594651
It means a crossdressing faggot is writing your code for you.
>>
>>54594688
a sick crossdressing faggot*
wich they all already are but whatever
>>
File: rekt.webm (3 MB, 852x480) Image search: [Google]
rekt.webm
3 MB, 852x480
Ask your much beloved programming literate anything (IAMA).

>>54593462
http://programarcadegames.com/
or
http://www.braveclojure.com
>>
>>54593462
No language require math.
But being good at math is an important part of being an actual good programmer.
>>
>>54594688
lmao
>>
File: lua.gif (5 KB, 256x255) Image search: [Google]
lua.gif
5 KB, 256x255
tell me about lua
>>
>>54594688
but I wrote the code, and I really hate homosexuals
>>
>>54593961
>>54594399
can I have source :)
>>
>>54594736
Small, concise, simple, can be quite fast with LuaJIT, perfect for embedded scripting systems.
>>
>>54594651
Whatever you are compiling is trying to read an assembly opcode at a memory address where there is no legal opcode.
>>
Why do I keep getting physcomp to be a boolean value?

def Start():
global physcomp

pc = trans.GetOwner

print(physcomp)
physcomp = pc.GetGameComponent<PhysicsComponent>()
print(physcomp)
>>
>>54594736
not interesting at all.
>>
>>54594777
>trans
because THERE IS ONLY MALE OR FEMALE IN GODS NAME
>>
>>54594777
nice trip sevens

do you want to execute trans.getOwner() when you assign it to pc? not sure what language this is so just idle curiosity
>>
>>54594798
It's Python mixed with .NET. GetOwner is a property not a method of trans

>>54594795
kek
>>
How good of a programmer do i need to be to find a stable programming job?
>>
>>54594868
I also am curious about this
>>
Why is the first window clearing to black?
        if (!glfwInit()){std::cout<<"glfw failed to initialize\n";return 0;};
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR,3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR,3);
glfwWindowHint(GLFW_OPENGL_PROFILE,GLFW_OPENGL_ANY_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT,GL_FALSE);

glfwWindowHint(GLFW_RESIZABLE,GL_FALSE);
GLFWmonitor* monitor = glfwGetPrimaryMonitor();
GLFWwindow* window = glfwCreateWindow(width,height,"choco banana",NULL,NULL);
glfwMakeContextCurrent(window);
glClearColor(1.0f,1.0f,1.0f,1.0f);

GLFWwindow* window2 = glfwCreateWindow(width,height,"doodoo penis",NULL,NULL);
glfwMakeContextCurrent(window2);
glClearColor(1.0f,1.0f,1.0f,1.0f);
>>
>>54594900
Gee I dunno maybe because you clear it?
>>
>>54594900
You need to use glClear(GL_COLOR_BUFFER_BIT), glClearColor does nothing on its own.
>>
>>54594868
Good enough to fool people into thinking you can program.
>>
>>54594928
I did. This is the first half of my message loop.
    while(!glfwWindowShouldClose(window))
{
glViewport(0,0,width,height);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(1.0f,1.0f,1.0f,1.0f);

glfwSwapBuffers(window);

glViewport(0,0,width,height);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(1.0f,1.0f,1.0f,1.0f);

glfwSwapBuffers(window2);


It just resets to black for only the first windows immediately after clearing the second. I've never worked with multiple contexts before.
>>
>>54594948
>multiple contexts before
http://www.glfw.org/docs/latest/group__context.html#ga1c04dc242268f827290fe40aa1c91157

Read the docs you fag.
>>
>>54590561
I'm afraid of picking up AC for the 3DS. I played it way too much on the DS, it's too comfy. Sage for sage.
>>
>>54591796
Sapples, definitely.
>>
>>54594948
I think you need to call glfwMakeContextCurrent everytime you want to render to another window.
>>
>>54594948
Oh, I don't know then, I never used multiple contexts either. Try putting the glClearColor before the glClear at least, even though it shouldn't make a difference in a loop like that.
>>
>>54591796
D
>>
>>54594980
That worked. Thanks guv.
>>
>>54590863
>Writing a method of saving world data to disk for my minecraft clone. Just a very small bit left. Then I have to write a way to read it.
Indent hell
>>
>>54594990
XD
>>
>>54595049
say that to my face fucker
>>
I'm trying to RE something just for fun. Currently I'm going through reading CPUID flags. Looks like it checks if MMX is available.
I still don't know why it checks if cpu family is greater than 5 and later on if it's greater than 6.
>>
What impact does const pointer (or const reference in C++) have on optimization?
Is it worth using?
>>
File: 1463052497847.gif (558 KB, 500x288) Image search: [Google]
1463052497847.gif
558 KB, 500x288
>>54594700
source?
>>
>>54595147
Why are you using raw pointers in C++, it's 2016
>>
>>54595187
Did I imply such?
Stop changing the subject.
>>
>>54595147
const has literally no impact on optimization whatsoever since in CPP you can simply cast away const.
>>
>>54595147
None, const keyword in C and C++ has no effect at all, it's just a compile time flag that makes the compiler yell at you if you try to modify a const object.
>>
File: W1TeV1R.gif (628 KB, 500x332) Image search: [Google]
W1TeV1R.gif
628 KB, 500x332
>>54595165
First, thank you for your question.

Source is Ajin: Demi-Human

https://en.wikipedia.org/wiki/Ajin:_Demi-Human
>>
>>54595147
As far as I know there's no const optimizations in any compilers, it's purely for the programmer's sake. There is the restrict keyword which does have an impact though, but I've never seen it actually used.
>>
>>54595187
>>54595198
>>54595204
>>54595210
Okay, what about C++ references? you cannot change what they point to, they are always const.
Couldn't the compiler treat that as if the restrict keyword was given and apply the same optimizations?
>>
>>54595205
Thanks. Dangerous place for water tanks, btw.
>>
>>54595147
>>54595198
>>54595204
>>54595210

http://www.gotw.ca/gotw/081.htm
>>
>>54594777
Found a stupid solution..
I make a property for each specific gamecomponent and use that in python instead.

Apparently generics is complicated for ironpython?

C#:
//--------------------------------------------------------
//Properties for IronPython. This segment hurts.
public PhysicsComponent GetPhysics
{
get
{
PhysicsComponent p = GetGameComponent<PhysicsComponent>();
return p;
}
}
//--------------------------------------------------------


Python:
def Start():
global physcomp

pc = trans.GetOwner
physcomp = pc.GetPhysics
>>
>>54595226
references are just crippled pointers and are just like const only meaningful to the programmer and not the compiler.

>you cannot change what they point
Wrong, in C/C++ you can always change the value of something if you really wish. Think of reinterpret_cast.
Not that you should actually do this. But you still can.

Personally I don't like references and just use pointers instead.
>>
>>54590561
LEarning JAVA
I like JAVA.
Soon I will be able to code some games.
Something similar to Castlevania, but more grimdark futuristic and dytopian.
THEN I wll stat learning Haskell and dOH EEEET EGG AYN!
>>
File: 1439751841352.jpg (46 KB, 691x624) Image search: [Google]
1439751841352.jpg
46 KB, 691x624
>>54595471
Is this bait?
>>
>>54595490
It will leave the thread.
WITH NO SURVIVORS!
>>
How hard would it be to create a filter that gave photos this effect. I have no idea how to do this effect by the way, was hoping there was a guide somewhere.
>>
File: 1463351359376.jpg (16 KB, 320x320) Image search: [Google]
1463351359376.jpg
16 KB, 320x320
Is it possible to follow sicp using a different language than Scheme, such as Python ?
>>
>>54595352
Working with ironpython is like sucking dick for money.

It might not be that bad, but at the end of the day, you're giving fellatio to someone you're not sexually attracted to.
>>
>>54595695
or JAVA?
>>
>>54595703
yeah or Java I don't care I know both
>>
>>54595703
>JAVA
Yes, we know JAVA here in /DPT/ on /G/ on the website 4CHAN.

Stop capitalizing random shit.

It's like pronouncing words that aren't french as if you were french, like buff-ayy for buffet (it's pronounced 'buff eht').
>>
>>54595756
Are you french ?
>>
>>54595756
>buffet (it's pronounced 'buff eht')
kys
>>
>>54595756
https://www.youtube.com/watch?v=EhwMIcb8kJI
>>
>>54595799
Oui, je suis un travesti, mais pas un travesti typique.

>>54594868
The hardest part is appearing to be a competent programming.

Once you've got the job, you can easily learn what you need to know to coast.
>>
>>54595841
Oh cool, je suis luxembourgeois. C'est marrant mais quand je traîne sur 4chan j'imagine que les anon sont tout sauf francophones, je sais pas pourquoi.
>>
File: sfKnsa5.png (259 KB, 724x761) Image search: [Google]
sfKnsa5.png
259 KB, 724x761
>>54595858
Anon, I think you may be talking to Eddie Izzard.
>>
File: maxresdefault.jpg (137 KB, 1280x720) Image search: [Google]
maxresdefault.jpg
137 KB, 1280x720
>>54595540
forgot image.
I know this is an anime picture but its the exact effect I want on my images.
>>
File: david shing.jpg (34 KB, 770x433) Image search: [Google]
david shing.jpg
34 KB, 770x433
>>54595858
>je suis luxembourgeois

Why are you on 4chan instead of counting your jewgolds all day long?
>>
>>54595540
Those are some pretty bold lines.

There are plenty of filters that do similar things.

Consider looking to see if GIMP's filters are open-source.
>>
>>54595756
JAVA
AVAJ
VAJA
AJAV
>>
A bit off topic, but were desktop threads really banned? Why?
>>
>>54596039
They were completely off-topic.

Anime is fine, but literally just spamming ecchi on /g/ is not.
>>
>>54595994
>Those are some pretty bold lines.
for you
>>
>>54595756
>like buff-ayy for buffet (it's pronounced 'buff eht').
You can't be serious.
>>
>>54596039
When was this? Where was this announced?
>>
>>54596039

>>54594047
>>
>>54596237
the auto-sage could be a fluke if it's just this one time that someone put it on auto-sage
>>
>>54596039
Probably because desktop threads are a mix between dumping anime unrelated to desktops and two guys dumping history of their desktops.
>>
Not working on anything. Tried programming a few times and gave up. For how long do you have to learn programming to get over the initial bump? Should I kill myself?
>>
>>54596703
use a non-shit language and you can get started straight away

https://docs.oracle.com/javase/tutorial/
>>
>>54596703
Work on a project that actually interest you.
>>
>>54596718
>java
>non-shit language
this is bait.
>>
File: 1452403462016.png (79 KB, 307x400) Image search: [Google]
1452403462016.png
79 KB, 307x400
>>54596718
>Talks about non-shit languages
>Java
>>
>>54590561
>What are you working on, /g/?
Crafting/streamlining agile user stories for my crowdfunded full stack Rails app using the most async version of node.js while figuring out how to make it scale and perhaps include some deep learning into it. Why do you ask?
>>
>>54596801
>Doesn't contain 'synergy'
2/10
>>
Working on first yera college homeworks. I've to program Othello, and i can't get it work.
How much am i failure from 0 to 10?
>>
>>54596769
>>54596775
same old hilarious meme
>>
>>54596718
honestly java looks fugly.

>>54596756
hmm yeah then I must find something that really interests me. im so lazy i still didn't configure my arch install in vm.

OT: does weed makes you lazy and ok with doing nothing?
>>
>>54596851
>OT: does weed makes you lazy and ok with doing nothing?
obviously
>>
In C, if I wanted to use the length of a string to define the field of a format specifier, eg

 printf("%*s", strlen(words), words);


Would I be best off casting strlen to int with
(int)strlen(words)
? Compiler warns me if I don't that the field assignment wants an int.
>>
>>54596851
>OT: does weed makes you lazy and ok with doing nothing?

only if you let it. i know people who work efficiently while stoned. i cannot, though.
>>
>>54596865
>printf("%*s", strlen(words), words);
If that's how you're using it, there is literally no point. Specifying the length is only useful when you're trying to print a substring or something that isn't null terminated.
Otherwise, yes.
>>
>>54596874
>i know people who work efficiently while stoned
either they smoke like pussies or they've smoked so much and fried their receptors that it doesn't have much of an effect any more
>>
File: MandelBox06.png (766 KB, 1008x1034) Image search: [Google]
MandelBox06.png
766 KB, 1008x1034
>>54594399
Hello fractal bro!
>>
>>54596893
Yeah I know it's useless, it was a test of sorts from something I'm reading. Thanks
>>
Anyone here ever tried to program a learning AI?
>>
>>54596703
>Not working on anything. Tried programming a few times and gave up.
NEET? Not a STEM major? Doesn't matter.

Start out doing an hour a day, maybe 45 minutes if your babby ADHD kicks in. Try learning Java first (as pajeet as it may be) to get acquainted with the fact that if you want to program, you're gonna type a lot. C is also an excellent choice, if not better, and is generally more respected around these parts.

If you get a book, make sure you look at all the practice examples, but don't get nuts about doing every last one of them. I personally got more out of asking "why does [x] work?" and spending time looking at documentation after finishing an easy example than wracking my brain for something you're going to learn how to do more efficiently later on, but make a note on what didn't click and come back to it later.

>does weed makes you lazy and ok with doing nothing?
I don't know many people who are energized or focused by weed, so that would be a yes.
>>
File: weights002_scale8x.png (126 KB, 224x2240) Image search: [Google]
weights002_scale8x.png
126 KB, 224x2240
>>54596934
I have programmed a multilayer perceptron and successfully trained it to discern handwritten digits (MNIST dataset). There are plots of some of the weights learned by the first layer.

Machine Learning is real but you have to downplay your expectations about "learning AI".

Just read http://karpathy.github.io/neuralnets/
>>
I'm working on fixing a bug in neovim that effectively makes it unusable when I run my music player in it.

It's been bothering me for months, and I'm only just now getting around to solving it.
>>
>>54597222
you run a music player in your text editor?
>>
>>54597381
Not until I fix this bug, I don't.
>>
>>54593622
i know this feel
>>
How do i learn the "theory" of programming?
I mean if-statements and loops and such are fun, but where do I go if I want to get a better idea of the bigger picture?
>>
File: plsno.png (12 KB, 331x283) Image search: [Google]
plsno.png
12 KB, 331x283
>inherit large code base
>see this

I'm scared to remove anything, because this shit is like a house of cards.
>>
>>54597543
it's mostly black magic, there are books on the subject but no one can spoon-feed you in-depth programming knowledge, you need hands-on experience and intuition
>>
File: 1463084837591.jpg (9 KB, 219x239) Image search: [Google]
1463084837591.jpg
9 KB, 219x239
>>54597543

> Theory

What do you mean?
>>
>>54597585
But the only things I can come up with are either too small to offer any worthwhile experience, or so large that I lose interest in a few hours :_:

Should I just try going trough a book first?
>>
>>54597567
>ex
>ex
>e
>e
>e

I want to put money on these being exceptions that are never referenced.
>>
>>54597618
design patterns and concepts and such
>>
>>54597618
Think of a thing, a really cool thing, to do

write it and it's going to be messy and shitty and probably require you to learn a heap

then rewrite it again, and again, and again until it's clean and organized and uses the best and most memory efficient ways of doing those things that you need to do in order to get your thing done

eventually you'll get there, or lose interest in programming entirely/commit suicide halfway through ~ the second rewrite
>>
>>54590561
I can't seem to get an answer, so I'm asking you SICP worshipping fucks. I'm writing mit-scheme code and getting a weird error:

(define (make-sum a1 . an)
(let ((num (sum-list (filter number? (cons a1 an))))
(vars (filter-not number? (cons a1 an))))
(if (null? vars)
num
(filter-not (lambda (x) (=number? x 0))
(append (list '+ num)vars)))))


gives the error:

";Unbound variable: |â|
;To continue, call RESTART with an option number:"

Specifically, I've narrowed the issue down to the statement

(append (list '+ num)vars)


The weird thing is that if I get rid of the let clause and just write out vars everywhere, everything works fine. What the hell is going on?
>>
>>54597621
Duh
>>
>>54597703
this
>>
>>54595914
Haha, I'm 100% cliché but I'm a law and economics student, I was taking a break from my textbook.
>>
>>54590561
If I were to make a website with a database, where do I start? I know html/css/js, so the front end would be easy, and I know enough php to get around. I am also willing to learn SQL. Where do I start?
>>
>>54597834
Host a database and store and call data using php.
>>
>>54597860
Ok. Do I use one of those MS Database builder things, or do I write a database from scratch?
>>
>>54597891
>write a database from scratch?
lol

Just use something like MariaDB.
>>
>>54595994
can you give me some examples. The name of a filter or something. Im not even sure what exactly Im looking for.
>>
>>54592689
Are you 12?
>>
>>54597741
Works fine for me, I don't see any unbound variable. It could be interpreting some weird character. The only thing on that last line that could be a problem would be the lack of space after num)
>>
>>54597926
If your site is going to store very basic/few things, making your own simple database might be a better idea.
>>
>>54597758

Duh yourself, little nigger.
>>
>>54598042
Every time I post this 4chan removes that exact space, but it's there in my text editor. It seems to be interpreting '+ in a weird way (hence the bizarre |â| symbol in the error message), but only when append is called. Glad to be sure I've at least written something correct.
>>
What is the default way windows deals with programs trying to write data to the drive when there is no space left, assuming it is not handled by the program?
>>
File: rolleyesbarf.gif (30 KB, 326x450) Image search: [Google]
rolleyesbarf.gif
30 KB, 326x450
>>54596916
>JavaScript
>>
File: 1429075470429.jpg (280 KB, 700x849) Image search: [Google]
1429075470429.jpg
280 KB, 700x849
>>54597543
Try reading SICP
Thread replies: 255
Thread images: 47

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.