[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: 336
Thread images: 32

File: 1420411763451.jpg (39KB, 460x460px) Image search: [Google]
1420411763451.jpg
39KB, 460x460px
old thread: >>56288112

What are you working on, /g/?
>>
Finally making some progress on my theorem prover.
>>
>>56288584
dependently typed?

>>56288582
yes
>>
someone explain this code
def all_permz(elementz):
if len(elementz) <=1:
yield elementz
else:
for perm in all_permz(elementz[1:]):
for i in range(len(elementz)):
yield perm[:i] + elementz[0:1] + perm[i:]

for i in all_permz([1,2,3]):
print i


output
[1, 2, 3]
[2, 1, 3]
[2, 3, 1]
[1, 3, 2]
[3, 1, 2]
[3, 2, 1]
>>
>>56288602

That's pretty autistic, but I guess it's also correct.
>>
>>56288584
nv put your trip back on
>>
>>56288649
There's more to dynamic programming than just memoization, and there's a lot of mathematical background
>>
>>56288606
It calculates all permutations
>>
Thought: glitches made a number of old video games a lot more awesome. Why not design a video game for modern times with integer overflow vulnerabilities, no-clip/out of bounds, and other glitches intentionally programmed into the game? Maybe make an alternative ending only accessible by exploit?
>>
>>56288661
invoke's was not in Haskell but in some meme language like f sharpie or ocaml
>>
>>56288606
The idea is defining permutations on a set recursively based on the first element of the set and permutations on the rest of elements. If you have a permutation p on x:xs, you can define it uniquely by the position of x in p and the permutation on xs resulting from removing x from p.
>>
>>56288672
I suppose, if you regard things like 'adding numbers together' as deep mathematical background
>>
how do I into generics?
>>
>>56288686
Is it an exploit if you're meant to do it?
>>
>>56288703
Stop using go
>>
>>56288722
??

is this a riddle?
>>
>>56288767
No, no go
>>
Is it possible to code a meme generator that generates only the dankest memes based on input of dank memes?
>>
>>56288705

Consider the following: other bugs will exist in the game. You decide not to fix any of them unless they completely make the game unplayable. No one knows which bugs are intentional and which are not.
>>
>>56288779
>other bugs will exist in the game
Maybe if you can't program

>>56288776
A program that just returns the input
>>
>>56288779
u r a cheeky cunt dad ill give u that
>>
>>56288789
>t. someone who has never programmed a real program
>>
>>56288602
>dependently typed?
Yes. Currently, I have Type:Type, but I'd like it to be something like CoC or UTT with the cumulative hierarchy of universes. I'd also like to roll out at least the very basics of implicit arguments, but that'd probably require higher-order unification, so I'll keep that for later.

>>56288661
literally who?

>>56288691
>implying Haskell isn't a meme language
*<|:^)
>>
>>56288686

Too many modern games are excessively bug-tested and patched.

In Call of Duty 4, elevators & bounce glitches were a lot of fun.
>>
Programming should be done in Faroese so that Pajeet cannot pick up just enough Java to steal jobs but not produce code of any quality
>>
>>56288806
post code?

>>56288806
It's not a meme language

it's THE meme language
>>
>>56288823
if Pajeet can steal your job, it's your fault because you're shit
>>
>>56288835
No, it's because he can work for much less than me because he lives in a country with a much lower cost of living.
>>
>>56288827
>haskell is the only meme language
>what is lisp, prolog, coq, forth, perl, brainfuck, befunge, apl
>>
File: Capture.png (4KB, 158x120px) Image search: [Google]
Capture.png
4KB, 158x120px
Anyone has any experience with CLEO?
>>
>>56288880
sure, lots of people have
>>
>>56288827
>post code?
I'd prefer not to. It's a bit messy :3

>>56288868
Jokes on you, Coq is not a language.
>>
pis r8
// Author :: Ranjit Gupta
public class PooSimulator
{ public static void main( String [] args)
{ while ( true == false == true == false )
{ System.out.println( "go to street")
; System.out.println( "expand bowel")
; System.out.println( "go to tech suport")
; System.out.println( "eat delicuous curry")
;}}}
>>
>>56288922
it's ok, we won't embarass you too much
>>
>>56288944
8/88
>>
>>56288944
I can't remember what this brace/semicolon style is called but I unironically love it
Maybe you could use semicolons as a divider? Like
s0;
while (b)
{ s1;
; s2;
; s3;
};
>>
>>56288951
you're an embarrassment yourself nigger
>>
File: Untitled.png (2KB, 250x250px) Image search: [Google]
Untitled.png
2KB, 250x250px
post a screenshot of your programming environment
>>
>>56288978
wow rude, please mind the DPT Code of Conduct
>>
>>56288672
>>56288429
Can you recommend any resources on DP?
>>
will experimenting with drugs once ever for the only time in my life, but two months ago, be enough to deny my secret clearance
>>
File: 1471500268870.png (425KB, 730x916px) Image search: [Google]
1471500268870.png
425KB, 730x916px
>>56289037
this

quite clearly says no ruding

>>56289001
i just use atom, not really screenshot worthy
>>
>>56289045
https://people.cs.clemson.edu/~bcdean/dp_practice/
>>
>>56289037
suck my CoC faggot
>>
>>56289052
sup Markov?
>>
File: Calculus of Maki Constructions.png (312KB, 452x355px) Image search: [Google]
Calculus of Maki Constructions.png
312KB, 452x355px
>>56289071
You designed your own derivative of the Calculus of Constructions?
Can I see the paper?
>>
>>56288951
I'll write a tutorial once it's done. Watch out for lainzine 5.
>>
>>56289001
here, I guess
>>
>>56289063
Thanks!
>>
File: 1466560283644.jpg (86KB, 602x802px) Image search: [Google]
1466560283644.jpg
86KB, 602x802px
>>56288576
Man, the post image has a nice effect, was it done by hand, or was it made with one of those image to ascii converters? All the ones I've seen are cowshit.
>>
>>56289092
yeah, but cia niggers aren't allowed to see it
>>
>>56289110
nice, are you a hacker? :DDDD
>>
I do not quite understand what this exercise wants from me.

>>Write a method called letterHist that takes a string as a parameter and returns a histogram of the letters in the string.
I can understand

>>The zeroth element of the histogram should contain the number of a’s in the string (upper- and lowercase); the 25th element should contain the number of z’s.
I.. what?

>> Your solution should only traverse the string once.
Okay, I understood this at least

So, what do?
>>
>>56289132
0≡a
1≡b
2≡c
…
25≡z
>>
>>56289117
dunno, saved that image months and months ago
>>
>>56289132
You index the letters of the alphabet with a-z corresponding to 0-25 so that the nth element of the histogram is the number of times the nth letter occurs in the string.
>>
>>56289132
i think they just mean an array of the letter counts
dunno why they're saying histogram, pretty meme

>>56289162
>≡
>>
>>56289110
>BAT 105,73%
WEW
>>
File: 1466560360433.jpg (59KB, 500x333px) Image search: [Google]
1466560360433.jpg
59KB, 500x333px
>>56289167
Thanks anyway, anon
>>
>>56289110
> using the editor of the beast
It's like you _want_ to be a heretic
>>
>>56289129
No, I just use vim as editor and have a two terminals (tabbed) in the bottom left for make and gdb and in the bottom right is my hex editor I'm writing.
I am happy to answer more questions if you have any.

>>56289193
yeah, it was displaying fine before I bought a battery off amazon but hey, it's still working so whatevs
>>
(defmacro meme ()
'Xdddddddd
'(meme))
(defmacro just (&whole just fuck &rest shit)
(list 'progn '(fuck) (list 'just just)))
(JUST MEME MY LANGUAGE UP)
>>
>>56289001
Any other way of programming is pleb-tier.
>>
>>56289275
>waah this language allows me to fuck up and not hold my hand like a baby
>>
File: 1.jpg (154KB, 800x600px) Image search: [Google]
1.jpg
154KB, 800x600px
>>56289244
how do you like your computer?
>>
File: FortranCardPROJ039.agr.jpg (376KB, 1687x809px) Image search: [Google]
FortranCardPROJ039.agr.jpg
376KB, 1687x809px
>>56289277
M'terminal
>>
>>56289275
s/'(fuck)/(list fuck)/

>>56289300
>waah my meme language is good because it's an incomplete unusable useless piece of trash
>>
Stupid question.

In C/C++

I want to fill a the memory of char pointer with a certain sequence. Is there a faster way than assigning each char individually?

Like

void Device_LaserDock::GetName(char* name)
{
name[0] = 'L';
name[1] = 'a';
name[2] = 's';
name[3] = 'e';
name[4] = 'r';
name[5] = 'D';
name[6] = 'o';
name[7] = 'c';
name[8] = 'k';
name[9] = '\0';
}


I can't just do name = "LaserDock"; can I?
>>
>>56289348
>a getter with a void return type
Just make the method return the char*
>>
>>56289313
It's heavy and too big, I bought that before going to college and it is really quite bothersome.
When it breaks i'm going to replace it with something lighter and smaller.

That said, it is quite a nice workstation, it handles video encoding quite well and has good ventilation.
>>
>>56289348
memcpy(name, "LaserDock", 10);
>>
>>56289375
But what happens to the memory after the function that creates the char pointer ends? Isn't the char then out of scope and can be overwritten at any time? Unless you create it on the stack but then you have a memory leak as you don't have a way to delete it after
>>
Welp it's time to learn C for me, any good starter books ?
>>
Anyone have an opinion on the Jon Duckett books for learning webdev? They're £25 for a two pack of HTML5&CSS3 and JavaScript&JQuery and I can get them Prime'd for a Bank Holiday straight session.
>>
>>56289434
> Unless you create it on the stack
I meant heap*
>>
>>56288576
redpill me on JUnit testing
>>
>>56289348

Remember there is technically no such thing as arrays in C. It's just syntax

name = "LaserDock";

name then becomes the pointer to "L". name[0] deferences the pointer like *(name) does, and name[x] deferences the pointer like *(name + x) using standard pointer arithmetic
>>
>>56289434
This guy has it >>56289416

Use std libraries and memget/memfree
>>
>>56289416
thanks
>>
>>56288602
This is wrong.
>>
>>56289463
>there's technically no such thing as arrays in C
>now let me tell you about arrays in C
>>
>>56288813
my nigga and i thought we'd never agree on anything
cod4 movement is glorious
>>
>>56289348
>C/C++
This is clearly not a C code.

>I want to fill a the memory of char pointer with a certain sequence. Is there a faster way than assigning each char individually?
memset for the same byte, memmove/memcpy for this case.
>>
>>56289463
>Remember there is technically no such thing as arrays in C.
God damn, that is a fucking stupid statement.
Arrays ARE a thing in C, and they are a type which is distinct from pointers.
They just decay into pointers when passed into functions.
>>
>>56289463
Remember there is technically no such thing as pointers in C. It's just syntax
>>
>>56289162
>>56289173
>>56289183
Thanks.
So far, I have succesfully changed the String into a charArray and ran it through a foreach loop.
guess the challenge will be to order the count of these letters.
>>
>>56289569
It's C++ but I said C/C++ as the question is about char pointers not strings as one would normally use in C++
>>
>>56289571
the same way floats decay to ints when assigned to int variables
>>
>>56289589
>I said C/C++ because I'm retarded
>>
>>56289652
>I need to make sure that every fucking day someone in /dpt/ is insulted for saying C/C++

>there is literally nothing in common between C and C++, not even the C
>>
>>56289602
No, not really.
>>
>>56289652
What exactly was retarded about that statement?
>>
Help me /g/ I hate C++ but it's really powerful
>>
I want to be the ultimate obnoxious shit-eating holier-than-thou cunt possible. Here's my list of subjects I'm studying to achieve this goal:

Category theory
Type theory
Dependent typing
Formal languages

What else can I study to be the definitive computer science ivory tower prick?
>>
>>56289799

if you're interested in building ivory towers archaeology might be your thing
>>
>>56289787
but it's not though

>>56289799
You've posted this before
>>
>>56289864
>You've posted this before
Not the same person, I did use his post however.
>>
>>56289787
There is literally nothing wrong with C++ itself.
At least not a small subset of C++

- Don't use exceptions, like ever. (I disable them in the compiler)
- Use operator overloading with caution
- Don't go overboard with templates
- Objects themselves are fine,... but watch out for the OOP way of thinking.
- Don't use multiple inheritance ( "Interfaces" (base classes with only functions and no data) are okay though.)
- Boost a shit.
>>
>everything i code works first execution now
is this a prestige perk i unlocked now that i'm a junior or will this not last?
>>
>>56289891
It's the template system that makes it so powerful though.
>>
>>56289902
I unlocked that too recently. On large programs I still get a few bugs but they are easy to debug.
>>
Which is better to learn, C++ or Rust?
>>
>>56289891
There's not a whole lot more wrong with sepples than with any other language 2bh.

>watch out for the OOP way of thinking.
You have to GO BACK to C m8.

>Boost a shit.
Nah. There are some shit libraries in Boost but on the whole they're decent.
>>
>>56289999
checked
>>
>>56289703
wrong
>>
>>56289999
>OOPfag
>in /dpt/
How the fuck did you get in here?
>>
File: file.png (72KB, 955x565px) Image search: [Google]
file.png
72KB, 955x565px
ordered K&R 2nd edition
>>
>>56290069
Buy It Again
>>
File: shill.jpg (289KB, 1162x850px) Image search: [Google]
shill.jpg
289KB, 1162x850px
>>56290069
Buy It Again
>>
>>56290069
ok?
>>
>>56290041
>I'm shit at OOP and incapable of actually good object based design
>it's OOPs fault
ok bubba, better go write another fizzbuzz
>>
>>56290101
>object based
found the webshit
>>
File: 1443896031822.gif (2MB, 360x193px) Image search: [Google]
1443896031822.gif
2MB, 360x193px
http://hastebin.com/yezasokowi.coffee

This is my code for my game's .ini parser. I had no idea what I was doing when I made it, I just started typing and that's what I ended up with.
It works, but is it okay? Is there anything I should change?
>>
>>56290113
you're not clever mate

you're wrong and you're a thick cunt. pick up a book sometime.
>>
File: OOP.png (69KB, 1210x467px) Image search: [Google]
OOP.png
69KB, 1210x467px
>>56290101
>there's literally nothing wrong with OOP! you must just suck at it!
this argument did not inherit from Reasonable
>>
>>56290069
https://stallman.org/amazon.html
>>
>>56289447
Bumping this question.
>>
>>56290160
too late, I already bought it
>>
>>56290201
>>>/g/wdg
>>
>>56290209
I posted there too, thanks. I've asked about webdev here before so I thought it would be okay to ask here.
>>
File: never go full guardian.jpg (485KB, 1187x1200px) Image search: [Google]
never go full guardian.jpg
485KB, 1187x1200px
>>56290160
>rms links to The Guardian
>>
>>56290116
It's shit.

Read books on parser theory.
>>
>>56290116
you can literally parse a .ini with a loop of scanfs
>>
>>56290118
>mad for getting told
>>
File: mpv-shot0001.jpg (138KB, 1280x720px) Image search: [Google]
mpv-shot0001.jpg
138KB, 1280x720px
>>56289799
>Type theory
>Dependent typing
>>
>>56289799
Type theory is fundamentally about programming, though. And category theory allows type theorists to take abstract mathematical concepts and explore how they can be applied to programming (through type theory).
>>
File: 1468057021260.jpg (50KB, 475x483px) Image search: [Google]
1468057021260.jpg
50KB, 475x483px
>>56290243
>How can our future Mars colonies be free of sexism and racism?
>Guardian Shop's T-shirt sizes don't fit with its feminist image
People actually got paid to write this shit?
>>
>>56290384
They write that article's title as if they're opposed to racism, but they're both sexist and racist:
>"Why white people aren't as cool as black people"
>"Is there anything worse than a man who cries?"
>>
>Loop up a programming subject
>hey there is a yt video about it
>open it
>Guy starts talking with an Indian accent

Fuck this shit. I'm not a native English speaker myself but poos have to worst accent. It makes my ears bleed.
>>
>>56289799

ruby on rails
>>
>>56290428
That's reverse-racism and reverse-sexism, you're lucky this isn't github or you'd be already banned for that.
>>
This is all Rust fucking needs for "unsafe" unions.
#[repr(union)]
struct Foo {
pub i32 bar;
pub f32 baz;
}

But nooo, the fact that unions are just structs with a layout where all fields are at the same offset is too hard.
>>
>>56290540
but Rust's supposed to be a safe space language that's a memory safe space and a concurrency safe space etc
>>
>>56290540
why do you care
>>
>>56290540
#[repr(union)]
struct Foo {
pub bar: i32,
pub baz: f32
}

Obviously, not sure why my brain was in C-mode there.

>>56290551
You wouldn't be able to use them except in "unsafe" blocks.

>>56290555
Because I'm doing FFI with libraries that use unions.
>>
>>56290565
Are you allowed to violate the code of conduct in unsafe blocks?
>>
>>56288779
I just wanted to say that you have a nice tripcode. That's all.
>>
>>56290565
>I'm doing FFI
Just use C you fucking SJW.
>>
C the programming language or another book for it to learn ?
>>
>>56289001
ok
>>
>tfw you will never get millions in funding for a shit idea because you can't set up shop in America
>>
>>56290705
Fix the bug where leading spaces get converted to a '+' sign.
>>
>>56288576
Is it hard to write a good file manager for Linux? I'm tired of using ones that don't offer all the functionality I want.
>>
>>56288686
It'd have to be singleplayer because otherwise having this sort of fun present in multiplayer would cause incessant whining about everything being broken. Ironically, the naggers wouldn't be wrong this time. I think that's a fun idea though and would add unpredictability, but would sadly trigger many autistic fat fucks.
>>
File: tay%20tweet[1].png (94KB, 800x406px) Image search: [Google]
tay%20tweet[1].png
94KB, 800x406px
>>56288776
look into screenshots of Microsoft TayandYou and you'll see that this has been done.
>>56288789
this guy knows whats up
>>
how do i organize realistic milestones for my projects?
>>
>>56290774
Fixed!
>>
>>56290265
I tried this, and I've got it almost working, but what if I want to include comments in the .ini file? So for example maybe my .ini file would look like this:
> // screenwidth
> 1920
> //screenheight
> 1080

How would I ignore the comment lines and only look at the numbers?
>>
>>56291396
ini files use ; comments. just check if the first character is ;
>>
>people still believe that full program verification through types is impossible
It may not be practical yet, but it's certainly possible.
>>
>>56291233
thanks
>>
>>56291411
 ;comment
^space

What about this?
>>
having a hard time with recursive functions

was this hard for you?
>>
Can anyone recommend any books about markup language-based GUIs? Also, low-level rendering. I'm using SDL right now and it's kinda interesting.
>>
>>56291671
prefer not to say
>>
>>56291671

Tell me something you want to code, and I'll do it recursively and explain how it works.
>>
>>56291790
can you do something a bit harder than factorisation and fibonacci?
>>
>>56291411
But then wouldn't I have to use getline to grab the entire line, just like I was doing in my original code? Or is there another way to check?
>>
>>56288576
GOAT OP IMAGE


FUCK
A
N
I
M
E
>>
File: IMG_0419.jpg (1MB, 2592x1728px) Image search: [Google]
IMG_0419.jpg
1MB, 2592x1728px
kind-of-done.
still looks pretty awful. have to keep working on it. and add a few little extras
>>
bit operations are confusing as fuck
>>
>>56291823

What kind of thing are you looking for Anon?
>>
>>56292028
i can't wrap my head around
knking.com/books/c2/programs/qsort.c
>>
>>56292010
They are quite literally the simplest things in programming.

https://en.wikipedia.org/wiki/Bitwise_operations_in_C
>>
>>56292010
You're just fucking stupid and don't know binary.
>>
Why are all CS youtube lectures by Pajeets?
>>
>>56292076
>>56292089
this.
How can bit operations be confusing? Wtf. That's simple logic, bruh

see:
float Q_rsqrt( float number )
{
long i;
float x2, y;
const float threehalfs = 1.5F;

x2 = number * 0.5F;
y = number;
i = * ( long * ) &y; // evil floating point bit level hacking
i = 0x5f3759df - ( i >> 1 ); // what the fuck?
y = * ( float * ) &i;
y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration
// y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed

return y;
}


easy peasy
>>
>>56292111
>jewtube
read a book faggot
>>
>>56292111
And why do they use shitty headset mics from the 90s and talk on the edge so it's both too quiet and ear-piercingly loud at the same time?
>>
>>56292076
>>56292089
>>56292131

i guess its confusing in the sense that i dont have a clue where i would use it in a real program
>>
>>56292131
Bit operations are easy as fuck. They have nothing to do with floating point representation. Kill yourself, my man.
>>
>>56288672
The name's a little misleading. A lot of the time when an adjective precedes the word "programming" it's to denote a paradigm that has fundamental differences to other paradigms; dynamic programming isn't really a paradigm, it's a description of ways in which conventional forms of algorithms can be rewritten to improve performance. You really can't choose one or the other to live by, 'dynamic programming' wins over naive programming every time. It really should just be called "algorithm optimization" because that's all it is. It's not like the programs are rewriting themselves either.
>>
>>56292131
>( i >> 1 );
That divides the number by 2.
>0x5f3759df
That's just a number, right? Why does it have to be in hexadecimal, why not just the number?
>>
>>56292146
fuggin everywhere?
>>
>>56292162
:)
>>
>>56292162
>Why does it have to be in hexadecimal, why not just the number
It's just a different notation
>>
>>56292162
Hexadecimal is basically a short form for binary. Decimal isn't as directly convertible.
>>
>>56292163
such as?
>>
Bitwise operations are for vectorizing boolean operations.
>>
>>56292162
>That divides the number by 2.
and is faster because it's a bitshift and not a division.

>That's just a number, right? Why does it have to be in hexadecimal, why not just the number?
because combining bitwise operations with decimal numbers is haram.
>>
>>56292238
bits =/= bools
>>
>>56292222
If you've used SDL then you've already used them. It uses the bitwise OR flag | to combine settings together in the init function and other functions where you can pass combinations of features. The enums are perfect powers of two (1 << 0) (1 << 1) (1 << 2) (etc) to allow this.
>>
>>56290116
>what is a case statement
>>
>>56292263
Integer division is actually faster on x86 than bit shifting.
>>
>>56292264
__m128 =/= float[4], what's your point?
>>
>>56292222
Don't listen to that memer, they are mostly used in low level languages, when working on things where each single bit can hold independent meaning. For example, the original nintendo controller had 8 buttons: up down left right a b start select. So to store the state of the controller you only need 1 byte. You could check if each individual button was pressed like so:

char controller = getControllerInput();
if (controller & 0x1) // A button
if (controller & 0x2) // B button
if (controller & 0x4) // Start button
if (controller & 0x8) // Select button
if ... etc.
>>
>>56292111
because all of the people in academia have published using other platforms. There are many MOOC platforms. MIT OCW, coursera, stanford online, udacity.
>>
File: funny meme.png (149KB, 850x800px) Image search: [Google]
funny meme.png
149KB, 850x800px
I made a funny meme, guis
>>
Threadly reminder that lisp > hasklel
>>
>>56292330
What's that thing around his ear?
>>
>>56288661
:^(
>>56289799
>I want to be the ultimate obnoxious shit-eating holier-than-thou cunt possible
step 1: get a tripcode
>>
>>56292347
shame
>>
>>56292330
>Final abstract class with a constructor
heh
>>
>>56292330
You forgot to implement Fooable
>>
>>56292010

you should try assembly
>>
>>56292065
The algorithm or the implwmentation? naybe start thinking about it from the base case up, really helps cause that's how the logic for proving the correctness of the algorithm goes really.

https://youtu.be/XE4VP_8Y0BU maybe?
>>
>>56292417
I heard programming in assembly is hard therefor it's impossible to learn.
>>
>>56290540
1. It is not a thing regular programmer would do each day
2. It's kind of unstable. I mean, it could generate different code
>>
>>56291839
Bump.
>>
>>56292486
>It is not a thing regular programmer would do each day
So? Rust isn't really a "regular" programming language.

>It's kind of unstable. I mean, it could generate different code
What do you mean? It would fit C union semantics exactly.
>>
>>56292498
So what? Get the entire line and discard it if it's a comment.
First thing in your loop should be:
if (line[0] == ';') continue;

Done and done.
>>
Can you clear up something for me? I know what pointers are, but what's their use? I.E. when would I need a pointer instead of a variable?
>>
>>56292583
Actually I re-read your question. You want to know if it's necessary to read the entire line and then only check the first one right?

Yes it's necessary. Even if you just read the first byte and see that it's a comment, you don't know how far ahead the newline character is. A comment could be 10 or 100 characters, so you would still have to check ahead until you find a newline character. Which is exactly what getline() is doing.
>>
>>56292592
If you wanted to use something after it goes out of scope.
For example, lets say you're making a game where you can shoot bullets. As soon as the player presses the mouse button, call some createBullet() function. After that function goes out of scope, though, the bullet will be lost forever if you use variables.
So what you do instead is create a pointer to a bullet, then save it somewhere else (usually a vector of bullet pointers). That way, even after the function ends, you'll still be able to get the bullet.
>>
>>56288779
>other bugs will exist in the game. You decide not to fix any of them
This already happens.
>>
>>56292592
strings, arrays, modifying shit.
Just look at the <strings.h>, almost everything there uses pointers.
>>
>>56292592
When stack allocated variables go out of scope, they get destroyed. With heap allocation their life time extends until the memory is freed. Pointers are used to point to the location in the heap where the memory was allocated. In this way you can pass around what that pointer points to, the memory location, between functions so that different scopes can have access to that same memory location.
>>
>>56292592
Indirection.
>>
>>56289891
>There is literally nothing wrong with C++
>Now let me list things that are wrong with C++.
>>
>>56292751
To be fair, he did say

>There is literally nothing wrong with C++ itself.
>At least not a small subset of C++

Which is basically C
>>
>>56292774
I'm think of just going back to using C with classes and templates.
Full on C++ is making my code pretty ugly and weird. I still can't find a way to use exceptions reasonably and properly.
>>
>>56292651
>>56292644
Thanks. Does the pointer reserve the part of the memory it points to or does it risk being overwritten?
>>
>>56292846
String literals are stored in static memory.
They won't go out of scope for the whole duration of the program.
>>
>>56292868
>string literals
are pointers a kind of string literal?
>>
>>56292644
You can also move something outside of a scope by...returning it.
>>
>>56289891
>- Don't use multiple inheritance ( "Interfaces" (base classes with only functions and no data) are okay though.)
Composition is better than inheritance anyways.

>- Don't go overboard with templates
The amount of code generated may be bad, and some of the syntax is horrible, but they're extremely useful. The type trait system feels stapled on though.

>>56292846
It can be overwritten, any number of pointers can point to the same memory location. You should do your best to minimize the amount of pointers pointing to a memory location but it may become necessary when you introduce multithreading so you have to exercise caution.

The pointer itself is allocated on the stack if that makes it clearer.

>>56292868
That was never his question.
>>
>>56292910
Returning a string literal actually just returns a pointer of type char to the actual string stored in static storage.
>>
File: Tuvix.jpg (33KB, 636x487px) Image search: [Google]
Tuvix.jpg
33KB, 636x487px
/dpt/ pls help me understand this syntax error

    const sortedEffects = effects.map((effectSize, index) => {'bitIndex': index, 'effectSize': effectSize}).sort((left, right) => right.effectSize - left.effectSize)
^

SyntaxError: Unexpected token :
at exports.runInThisContext (vm.js:54:16)
at Module._compile (module.js:375:25)
at Object.Module._extensions..js (module.js:406:10)
at Module.load (module.js:345:32)
at Function.Module._load (module.js:302:12)
at Function.Module.runMain (module.js:431:10)
at startup (node.js:141:18)
at node.js:977:3

>>
File: ini.png (10KB, 612x395px) Image search: [Google]
ini.png
10KB, 612x395px
>>56292621
So, something like this?
http://hastebin.com/bodujosoco.coffee

I'm still doing something wrong, though. All the items in the values array are 0 after the while loop, and fscanf returns five 0s and a -1. Pic related is what my .ini looks like.
Please forgive my dumbassery, I don't used C FILEs or scanf very often.
>>
>>56292922
>You should do your best to minimize the amount of pointers pointing to a memory location
You mean there are pointers pointing to a physical address and pointers pointing to variables?
If a pointer points to a variable that gets destroyed, what happens when the memory location of that variable gets overwritten?
>>
I don't understand how to get everything to work with pow in C.
I include math.h, but doing
gcc exercise2-3.c

I get
/tmp/ccbveyVS.o: In function `htoi':
exercise2-3.c:(.text+0x180): undefined reference to `pow'
exercise2-3.c:(.text+0x227): undefined reference to `pow'
collect2: error: ld returned 1 exit status


So I go to Stackoverflow, and see someone else already asked the same thing. I'm led to believe the linker in C can't find where pow is defined. (Why it can find stdio.h on it's own, but not math.h?)
So I try compiling like so:
gcc -o exercise2-3 exercise2-3.c -lm

Which I don't know the meaning of, I'm just blindly trying to compile. So, I do ./a.out and there is no file/directory.

How do I run my program?
>>
>>56293010
I'm completely reckless when it comes to having tons of pointers pointing to the same location in memory, i just make my functions exit early if the pointer is null.
>>
>>56292988
{} denotes a block, not an object literal. Wrap it in parentheses.
>>
>>56293136
Thank you! That seems to have fixed it.

Arrow functions have weird caveats sometimes...
>>
>>56293168
It's not a caveat. { that is not part of an assignment always starts a block.
>>
>>56293075
check if you have math:
find / -name libm.so


try compiling this:
main() {
printf("%lf", pow(3,2));
}


using just
gcc file.c


it should work (although with some warnings)
>>
>>56293010
It would be pointing at that same memory location, but it wouldn't have any information on how it's represented. The types of pointers (char,int,float, etc) tell the compiler the size of the data at that location (a byte for chars, 4 bytes for float, etc) and the semantics of the data (ints and floats may take up the same amount of memory but their representation in bits has completely different meaning). Since those local variables are all allocated on the stack, it's likely that the same memory locations are being used between function calls because the stack is just that, a stack and there's usually only one per process. Stack allocated variables just go down the stack for more memory, and then when function call ends the stack pointer is moved back up.

And yes, you can point to local variables, look at example
int a = 0;
int *p = &a

the & is the deference operator and what it does is give the address of the variable it's dereferencing. It's trivial here but if you have a function like
 void foo(int &a){
a++;
}

void bar(){
int a = 0;
// a = 0 here
foo(a)
// a = 1 here
}


If foo is made to run on it's own thread and you pass it a, and bar doesn't wait for foo to finishe, and you use a before foo ends, or bar ends before foo finishes, you'll run into the issue of foo referencing a variable that doesn't exist or either bar or foo modifying/reading a variable whose value may be changing (a race condition).
>>
>>56293200
Object definition works just fine without parens in other contexts.
>>
>>56293274
Such as?
>>
>>56293162
Find an FFT library and do the rest, which is trivial and also down to what you want, yourself.

For example, brightness could be based on amplitude and colour based on, well, the colour of the sound (i.e. its harmonics).
>>
>>56293075
-o is a flag for the compiler
what it means is create the executable with the name following the flag so in that case the executable would be named "exercise2-3" rather than "a.out"
-lm is required because it tells the linker to link the math library.
Check this for info on that http://stackoverflow.com/questions/1033898/why-do-you-have-to-link-the-math-library-in-c
>>
>>56293284
All of them

http://www.w3schools.com/js/js_objects.asp
>>
>>56293347
All of those are part of an assignment expression, retard.
>>
>>56293075
gcc -o exercise2-3 exercise2-3.c -lm

The -o just says the next parameter (which is "exercise2-3")is the output name (default is a.out), you'd call your program with ./exercise2-3 or whatever you typed after -o (also escape spaces with \ or just don't use them).
Then you just pass the file name of your code to gcc (here "exercise2-3.c).
And the "-lm" just means to link with the math library, you'll need to do this whenever you use functions defined in math.h. Why you have to do this for math but not for stdio/stdlib/etc. I don't know, just take it for granted.
>>
>>56293387
Excuse me?
>>
>>56293417
const foo = {bar: true}  // Assignment
const {bar} = foo // Destructuring assignment
({bar}) => // Parameter destructuring assignment
doFoo(bar)

{true} // A block
if (true) { // Also a block
doFoo(foo)
}
>>
>>56293009
I'm feeling lazy so I can't be bothered debugging it myself. However you have:
fscanf(configFile ...
I believe this should be
fscanf(line ...
Because you have already read the line of text into the "line" variable, and now you are looking to read it from "line" and into values[].

Inside your else, add a print for line and a print for values[i], you'll be able to find what's wrong I'm sure.
>>
File: 1466699976493.png (177KB, 367x321px) Image search: [Google]
1466699976493.png
177KB, 367x321px
>when your mouse scrapes against your mouse mat
>when you know that putting on extra mouse feet still wouldn't fix it
>>
>>56293833
stupid frogposter
>>
>>56293845
fag
>>
>>56293833
>>>/v/
>>
File: 1450922382383.jpg (5KB, 250x250px) Image search: [Google]
1450922382383.jpg
5KB, 250x250px
>>56293499
Thanks, just got it working. It's a whole 100 milliseconds faster than the original code.
>>
>>56293917
>>>/kys/
obnoxious sperg
>>
>>56293943
100 milliseconds is a tenth of a second
couldn't get away with that in a real time system
>>
>>56293387
>>56293485
But it also works with multiple lines and in return statements and when passing them to functions.
>>
How do people keep using vim and having to hit esc all the time? for an editor that prides itself on letting you keep your hands on the home row, I'm sure finding myself stretching to the very corner of my keyboard a lot.
>>
>>56294209
You can hit Ctrl+c for the same effect.
>>
>>56294222
how are you supposed to know that
>>
>>56294222
Not in VsVim. ^c and ^v are reserved. I guess that's a problem with VsVim and not Vim though, I should have specified.
>>
first for C# 7
>>
Guys, I need help on clojure. I have a code that is not tail call optimized and often gives off stack overflow error.
(defn to-tree [start nodes]
(list* start
(if-let [connections (seq (nodes start))]
(map #(to-tree (second %) nodes) connections))))


The problem is at the call to the function that map receives. That function calls recursively, and map is not on tail call, as it needs the result of that function to append it to the list it returns. How can I optimize this function? I'm a clojure newbie and when I solved this problem on C++ I used loops and such. thanks
>>
>>56294249
Well, somehow most of Vim users know about that. Btw http://vim.wikia.com/wiki/Avoid_the_escape_key
>>
int main()
>>
>>56294209
get a compact mechanical keyboard and don't use shitty meme editors
>>
>>56288576
#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <limits.h>

int gcd(std::vector<int> & numbers)
{
std::vector< std::vector<int> > div_matrix;
int min_size = INT_MAX;
int min_size_index = 0;
int ret = 1, ret_aux = 1;

for (int i = 0; i < numbers.size(); i++)
{
std::vector<int> div_vec;
div_matrix.push_back(div_vec);

for (int j = 1; j <= numbers[i]; j++)
{
if ((float)(numbers[i] % j) == 0.0)
{
div_matrix[i].push_back(j);
}
}

if (div_matrix[i].size() < min_size)
{
min_size = div_matrix[i].size();
min_size_index = i;
}
}

for (int i = 0; i < min_size; i++)
{
int counter = 0;

for (int j = 0; j < div_matrix.size(); j++)
{
for (int k = 0; k < div_matrix[j].size(); k++)
{
if (div_matrix[j][k] == div_matrix[min_size_index][i])
{
counter++;
ret_aux = div_matrix[min_size_index][i];
break;
}
}
}

if (counter == div_matrix.size())
{
ret = ret_aux;
}
}

return ret;
}

int main()
{
std::vector<int> numbers;
int num;

while (std::cin >> num && num > 0)
{
numbers.push_back(num);
}

std::cout << "\n\nGreatest Common Divisor = " << gcd(numbers)<<"\n\n";

return 0;
}
>>
>>56294347
>
(float)(numbers[i] % j) == 0.0

what
>>
>>56294378
what or why?
>>
>>56294496
numbers[i] % j == 0
>>
do people actually include the "objective" section in resumes? it looks so dorky, but if people do it i'll write one
>>
>>56294537
your mom looks dorky
>>
>>56294537
I'm not sure about including it in your resume, but it's a common question during the interview.
>>
A test for you /g/.

Write a program that defines variables for each letter of the alphabet, and assigns the number of the position of that letter.

So:

var a = 1;
var b = 2;
var c = 3;
var d ...
etc.


or int a = 1; (depending on the language you use)

of course you need to do this with a loop, not like that CS degree meme kind of way where you define each separately

So how will you do it /g/ ?

Show me your metaprogramming skills
>>
Sup /g/entoomen where can i efficiently learn C books/courses/any online reads ?
>>
File: boredom.jpg (94KB, 640x640px) Image search: [Google]
boredom.jpg
94KB, 640x640px
So I've got 6 hours free. What kind of major coding can I do in 6 hours?

Any suggestions?
>>
File: hanzo-gameplay.jpg (46KB, 700x396px) Image search: [Google]
hanzo-gameplay.jpg
46KB, 700x396px
Hello, /g/ents,

I know shits and bits of C++ and Java, but I can't retain any of it. Am I working at the wrong language or do I just have to keep practicing?

I understand the theory, but everything just drains out of my head if I stop practicing for like a week.
>>
>>56294727
Program me a Lain.
>>
>>56294727
IRC bot.
>>
>>56294768
**by everything I mean the syntax and sheeit
>>
>>56294768
Read a proper book and make the exercises nigger.
>>
>>56294780

is this actually fairly simple to do?

>>56294773
I would LOVE to program an AI that would talk to me and actually provide conversation that was stimulating. Do you know how much people would pay for that shit?
>>
For someone who's got little experience with Linux kernels, what distro would you recommend for a beginner?

I know how to use the command line, but that's about it.

Any ideas?
>>
>major coding
>6 hours

choose one
>>
>>56289062
why not sublime?
>>
>>56288880
i occasionally cheat on vcmp and get away with it

if you get smashed with a teleporting vehicle out of nowhere it's me
>>
How much of a performance overhead do you incur in rust by writing in a functional style, as opposed to something more C-like?

More specifically, how much slower will my code be if I use lots of higher order functions and array operations?
>>
Can somebody give me tips on writing pseudocode
my professor didn't explain it too me well.
Am I supposed to break down how im writing the code?
he wants me to write pseudocode everytime I make a program
>>
>>56294921
43%
>>
>>56290324
That cartoon is Illuminati propaganda. https://www.youtube.com/watch?v=4tu6sgZUk7A
>>
>>56294955
>he wants me to write pseudocode everytime I make a program
bullshit
>>
>>56294955
Pseudocode is just code in not any particular existing language. It should be up to how he taught you to write pseudocode, if he didn't you can assume you can write however the fuck you want
>>
>>56294955

You're supposed to write it almost as if it's written in English. It can really help to clear things up, so basically just think of writing step by step instructions of how you would, on paper, describe the algorithm to another person.
>>
>>56294959
Could you perhaps provide a more satisfying answer?
>>
>>56294955
He means write it in python
>>
File: aa.png (129KB, 699x96px) Image search: [Google]
aa.png
129KB, 699x96px
>>56294977
unless I read this wrong
>>
File: Y2Kzlx4.png (2MB, 2856x1734px) Image search: [Google]
Y2Kzlx4.png
2MB, 2856x1734px
>>56288576
Toying with a program that takes an image and fucks with it.
>>
>>56294621
dic = {}
count = 1
for i in range(97,122+1):
dic[chr(i)] = count
count += 1

print dic


output
{'a': 1, 'c': 3, 'b': 2, 'e': 5, 'd': 4, 'g': 7, 'f': 6, 'i': 9, 'h': 8, 'k': 11, 'j': 10, 'm': 13, 'l': 12, 'o': 15, 'n': 14, 'q': 17, 'p': 16, 's': 19, 'r': 18, 'u': 21, 't': 20, 'w': 23, 'v': 22, 'y': 25, 'x': 24, 'z': 26}
>>
>>56295040
why did you upload that image to imgur?
>>
>>56295058
Because all my screenshots get uploaded automatically
>>
>>56295040
why does every method start with NS, Erik ??
>>
>>56295079

BOTNET
>>
File: 1472312741915.png (279KB, 707x1000px) Image search: [Google]
1472312741915.png
279KB, 707x1000px
Is C# something you can learn with only very basic programming skills? Does it make sense to use for making a game or are there better languages?
>>
>>56295083
>swift
applel cannot into namespaces
>>
>>56295093
Unity uses C#, so it's a good choice,
>>
>>56295093
java and C++ are better but go with C# and go to >>>/vg/agdg if you want to use the piece of shit unity engine
>>
>>56295083
Because it's leftover stuff from NeXTSTEP.

>>56295116
Swift 3 drops a lot of the NS* names
>>
>>56295148
>Because it's leftover stuff from NeXTSTEP.
source?
>>
>>56295137
Bad advice, unless you have a 100 man team developing a custom engine for you
>>
>>56295167
https://en.wikipedia.org/wiki/NeXTSTEP#Legacy

>Following an announcement on December 20, 1996, Apple Computer acquired NeXT on February 4, 1997 for $429 million. Based upon the "OPENSTEP for Mach" operating system, and developing the OPENSTEP API to become Cocoa, Apple created the basis of OS X, and eventually, in turn, of iOS.
>>
>>56294955
SHAMEFUL COPYPASTA! Someone posted the exact same weird stupid question sometime ago. Do you honestly think this is any degree of funny?
>>
>>56295093
Are you writing everything from scratch or do you have a development environment in mind already?
>>
>>56294347
Use std::vector::reserve and std::vector::shrink_to_fit for better performance.
>>
>>56295178
kill yourself, even if you want to use a shitty third part engine UE4 is miles better than jewnity
>>
>>56295050
what man no
dic = {}
for i in range(ord('a'), ord('z')):
dic[chr(i)] = i-ord('a')+1

print dic
>>
>>56295212
You're another one of those autists that never finishes any of their projects because they're too obsessed about making it perfect, aren't you?
>>
>>56295204
I want to start by building something very simple from scratch
>>
>>56295257
and you're one of those manchildren who make lazy steaming piles of shits and think they're being productive

fuck off to >>>/vg/agdg retard
>>
>>56295245
isnt that the same?
ord('a') = 97
ord('z') = 122
>>
>>56295270
then definitely start with java or C++ with opengl. don't take shortcuts with shitty third party libraries/frameworks (except to help you set up an opengl context), it'll just hurt your learning experience and waste your time on learning those libraries/frameworks
>>
>>56295293
thanks a lot
>>
>>56295270
What's your prior programming experience?
>>
>>56295273
No, I actually make useful things while you spend all your time failing to write fizzbuzz in x86 :^)

It's time to grow up and realize that making something is better than making nothing at all.
>>
>>56295245
dic = {chr(i): i - ord('a') + 1 for i in range(ord('a'), ord('z'))}
>>
>>56295305
stay delusional jackass
>>
>>56295329
Wow, you sure are flustered kiddo. Just fail to finish another project recently?
>>
>>56295339
already got a game green lighted on steam, pal
>>
>>56295339
if that's what you want to believe then sure
>>
>>56295353
And my uncle works at nintendo
>>
>>56295353
If you judge success by getting games greenlighted then by your own definition using engines like unity is better because 95+% of games on steam use pre-made engines.
>>
>>56295402
most of those games suck ass and don't make much money
>>
>>56295040
Is it worth it to learn swift if I never upload anything to the appstore ?I mean is there jobs outside of this ?
>>
>>56295353
spotted the underage liar
>>
>>56295428
no and no
>>
>>56295424
The statistic is the same for AAA games. No sane studios are going to waste money making their own engines if something suitable is already available, or unless of course making and selling the engines are part of their business plan like for unreal and crytek.
>>
New thread: >>56295464
>>
>>56294846
>is this actually fairly simple to do?
Yes. Depends on your language though. 10 lines in python or 100s in C.
>>
>>56295468
This. See Heathstone, Shadowrun and such.
>>
>>56295468
AAA games use unreal engine, cryengine and a whole bunch of other engines (in-house as well), they mostly don't use unity
>>
>>56295486
>Heathstone, Shadowrun
those could easily have been made from scratch, the game logic doesn't get helped much by the engine, it's mostly just the graphics rendering, audio and input which is nothing special either
>>
So whats with the C++ and C fad, when making something really simple without OOP, python is good, when doing something with OOP, Java is way better and optimized for the task, way more quicker when in comes to implementing the logic, no fiddling and shit with C++ hundreds of STL includes etc.


I want to focus on my project, not the syntax bullshit
>>
>>56295557
>C++ and C fad
I think you need to check what the definition of a fad is.
>>
>>56295557
>C++ and C
>The complaints are only about C++
>>
>>56295557
C / C++ are hardly a fad.
The biggest advantage they offer over Python and Java is performance in low level areas where the prior two are generally unsuited.
Java and Python offer useful abstractions that help the speed of development but do that via magic "hand waves" like garbage collection.

If your writing a game that is going to run on a modern PC Java and Python will do you fine, but if you're on something more specific like a Gameboy C or even assembly is going to be the better choice.
>>
>>56295788
I am writing a small logistic program for a warehouse, java is good enough to speed the process, leaving me with 2 weeks free time

the program, even tho there is GUI, is not that slow on any platform tested so far, it runs really good on mobile too

Writing for the game industry is the only acceptable C++
>>
>>56294378
Sorry you're right... my brain just had a shortcircuit in there and I made that horrible mistake... the modulo operand always work with integers and return integers or 0...
>>
>>56296238
>and return integers or 0...
>or
Maybe you should go to bed.
>>
>>56295093
You can learn any language with basic programming skills. Using it is a different story.

>gaymes
Fuck off.
Thread posts: 336
Thread images: 32


[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.