[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/DPT/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 31
File: 1440841567255.jpg (119 KB, 1280x720) Image search: [Google]
1440841567255.jpg
119 KB, 1280x720
Last thread >>55354159

What are you working on /g/?
>>
>>55360972
First for D
>>
File: 6euKF.jpg (512 KB, 852x973) Image search: [Google]
6euKF.jpg
512 KB, 852x973
>>55360972
First for C.
>>
You made this before the bump limit, you silly idiot
Now I have to delete a thread, thanks
>>
>>55360972
Trying out Idris
>>
>>55360999
fuk u m8.
>>
>>55361005
*had
>>
First for a 3D cheese pizza MMORPG in WebGL
>>
>>55360972
I am still trying to understand the Lempel Ziev 77 Algorithm and I have something that confuses me.

I wanted to write out a detailed explanation of what makes me go full on anxiety, but are you even willing to listen and give feedback?
>>
>>55361005
No, I made it exactly at 110.
>>
>>55361049
No, OP (this thread) is 19:46:10 whilst post 310 (last thread) is 19:46:23
>>
>>55361075
Wrong, the 110th post was posted at 21:45:58
>>
>>55361100
No, that was post 309 - look, previous /dpt/ has 311 replies - the last reply is reply #311, the one before is #310
>>
>>55361043 . >>55356109 . >>55352167
>>55338954 . >>55337721 . >>55294799
>>55283770 . >>55281024 . >>55280013
Why do you post this every thread?
>>
>>55361128
He literally has no life
>>
>>55361128
you tracked all of my posts thru every thread? lmao whats wrong with you senpai?
>>
>>55360972
Is that a trap?
>>
>>55361151
Yes
>>
>>55361136
>thread watcher
That might be the post count rather than the reply count (i.e. reply count + OP)
either way I forgive you

>>55361144
No, I just looked through all 15 /dpt/s in the archives (plus the 2 in the catalog)
>>
>>55361151
He is also a programmer.
>>
>>55360972
first for sauce
>>
>>55361142
at least I'm not you I guess
>>
How do you solve the multiple instance Haskell problem?
Say you have a semiring/rig, you would want it to be a monoid under addition and multiplication

>>55361176
>I forgive you
(but only because you posted an anime image)
>>
>>55361193
newtypes
>>
>>55361128
hi, can you compile a list of posts where Ruby says something retarded?
>>
>>55361182
Ryuunosuke Akasaka from Sakurasou no Pet na Kanojo
>>
>>55361231
But that fucking sucks and is a disgusting solution anon
>>
>>55361252
http://degoes.net/articles/principled-typeclasses
>>
>>55361241
choice, thanks cunt
>>
>>55361302
99 Type Extensions But <Wanted> Aint One
>>
>>55360999
>>55361001

Do you mean like the "Head First X" O'Reilly books? I heard those were shit.
>>
File: pythonlogo.jpg (49 KB, 680x459) Image search: [Google]
pythonlogo.jpg
49 KB, 680x459
I only get the first occurrence of a pattern when I use regex in python. Does anyone know why this is?


re.search(r'\d+\.(webm|jpg|png)', content)
>>
>>55361151
Kinda
>>
>>55361370
No, lurk more.
>>
>>55361371
That's what search does. Use findall instead.
>>
>tfw using self hosted git repo instead of GitCuck
maximum freedom
>>
File: 1465096824469.png (2 MB, 1200x1726) Image search: [Google]
1465096824469.png
2 MB, 1200x1726
Why do for loops not work sometimes in Mathematica?
>>
>>55361418
>tfw zipping up my code and emailing it to myself when I make a change
>>
File: 1445057824647.png (98 KB, 300x250) Image search: [Google]
1445057824647.png
98 KB, 300x250
>>55361442
I remember doing it in the past and want to kill myself
>>
>need a custom dhpc server for my cluster
Should I make it in C or just say fuck it and do it in an hour with C# with mono?
>>
>>55361302
Does Idris have a solution for this?
>>
>>55361442
Ah, the classic email version control system.
>>
I bet I can out program all of you
>>
>>55361580
Nah you can't. I'm Turing-complete.
>>
>>55361593
1v1 me in a programming contest in real life
>>
>>55361580
Write a program that contains a single assembly instruction.
>>
>>55361511
You need a custom network driver to send layer 3 packets, it's probably going to be hard with .NET. Unless you mean you're making your own dhcp-like thing in layer 4?
>>
what's the difference between a normal function
short texture_w(texturestruct *t) 
{
short w;
SDL_QueryTexture(t->texture, NULL, NULL, (int*)&w, NULL);
return w;
}

and a defined function
#define texture_w(t) ( { short w; SDL_QueryTexture(t->texture, NULL, NULL, (int*)&w, NULL); w; } ) 


I don't know the actual names for these, i'm a learn by myself pleb
>>
>>55361616
HLT
>>
>>55361633
>defined function
It's called macro

>#define texture_w(t) ( { short w; SDL_QueryTexture(t->texture, NULL, NULL, (int*)&w, NULL); w; } )
This makes use of a gcc extension, it is not valid C.
>>
>>55361633
I could tell you but you wouldn't learn anything by it.
>>
>>55361622
It's fucking UDP. Why would I need a driver to do it?
>>
>>55361674
so it wouldn't work in microsofts compiler then? I had to define strdup this way
#define strdup(s) ( { char *d = malloc(strlen(s) + 1); if (d != NULL) strcpy (d,s); d; } ) 

because otherwise the compiler wouldn't let me use it
>>
>>55361719
>so it wouldn't work in microsofts compiler then?
It would not work in any compiler that does not support gcc extensions.

>because otherwise the compiler wouldn't let me use it
What do you mean?
>>
>>55361692
You're right, I got my protocols mixed up. It's for things like custom ARP packets that you need custom drivers, as your regular drivers will only let you send TCP/UDP packets. But of course as you said DHCP is sent with UDP so there's no issue. My bad.
>>
>>55361780
>as your regular drivers will only let you send TCP/UDP packets
Wrong, every non-shit system allows for raw sockets.
>>
>>55361521
Not sure yet, I've only just started playing with it.
>>
File: 56537764_p0.png (761 KB, 1024x1136) Image search: [Google]
56537764_p0.png
761 KB, 1024x1136
Is there a good C reference for people who already use C++?
>>
File: 1454690514521.jpg (22 KB, 637x480) Image search: [Google]
1454690514521.jpg
22 KB, 637x480
Could anybody provide me with a resource for C++ practice problems?
Did C in hs and I'm looking to expand into OOP.
>>
>>55361893
>>55361897
Sounds like you two need to get together and program on eachothers keyboards if you know what I mean.
>>
>>55361893
Why would you need a C reference if you already know C++? C is basically the spartan version of C++.
>>
>>55362003
Lots of C functions aren't used in C++
They're there, but they aren't used
>>
>>55362085
just look up sprintf and you're good to go
>>
>>55362085
Just look up malloc and sprintf.
>>
Bad-tier hobbyist here. I'm working on adding a polling function to an IRC bot I manage for my channel. I can handle most of the voting mechanics fine, and I can give it a simple time limit to stop accepting votes after, but being a shit-tier programmer I can't figure out how to have it announce to the channel when the voting period has ended and announce the results.

This is roughly what I've been able to come up with:
class PollVotes(object):
def __init__(self):
self.votes = []
self.stoptime = "some date/time"

def has_closed(self):
if int(time.time()) >= self.stoptime:
return True
else:
return False


poll_list = {}
#irc processing...
if got_vote_command:
if poll_list["poll_name"].has_ended():
send("The voting period has ended.")
else:
poll_list["channel_or_poll_name"].add_vote(persons_vote)
#send the tally
send("%d people have now voted!" % poll_list["channel_or_poll_name"].tally_votes())


Obviously, this will only have announce the end of the vote when someone tries to vote outside of the timeframe. Any idea where I should start with adding some sort of passive timer? This is in Python by the way.
>>
>>55361128
because he's making a fucking cheese pizza mmo
>>
>>55362357
>>55362003
Strings were the big thing. It seems like you cannot use them entirely the same way as in C++. I will look at malloc and sprintf.

Thanks.
>>
>>55362612
Literally noone cares
On average he gets 1/3 of a reply
>>
>>55361046
go ahead please
>>
>>55362632
you can but you'd probably not want to
>>
>>55362632
you could make your own header-only string library for C, or you could find a library someone else made and use that
but yeah, c++ strings are great
>>
>>55362642
im making it to bait autistic faggots into raging and raving about it, and it seems to be working
>>
>>55362721
So you admit you're spamming, then?
>>
>>55362660
So, I have this example:
these (bit as a number, bit as a value), are the coordinates for how a string is compressed.
In my case, it is a String that goes like this:
AABABBBABAABABBABABB
LZ77 has divided them like this:
A|AB|ABB|B|ABA|ABAB|BB|ABBA|BB
So
-A
1B
2B
-B
2A
5B
4B
3A
7-

And after 2A, I do not understand a single thing anymore
I wanted to decompress a picture afterwards which has 64pixel or units of space.

I really want to understand these two sons of high class bitches' train of thought.
>>
>>55362770
idgaf
>>
>>55361719
>no free

kill yourself please
>>
>>55362825
what needs to be free'd?
>>
When should you use the words filename, dirname and path?
>>
File: smug anime girls.png (955 KB, 1066x781) Image search: [Google]
smug anime girls.png
955 KB, 1066x781
>>55362825
>freeing memory
>ever
>>
>>55362849
You need a loop which constantly checks the polls lifetime.
if( currentTime - startTime > lifeTime ) {
broadcast or whatever the fug;
}
*
fixd
>>
>>55362850
when you're referring to a filename, dirname, and path
>>
>>55362835
oh I don't know maybe it's the fucking malloc you onelining piece of trash
>>
>>55362905
> not using automatic garbage collection

what a fucking pleb
>>
>>55362925
i've ran it in a loop a bunch of times, never saw the memory increase, then again I have it free'd elsewhere
>>
>>55362925
>actually falling for the garbage collection meme

and you say I'm the pleb
>>
File: Ryuunosuke_Akasaka.jpg (166 KB, 1280x1316) Image search: [Google]
Ryuunosuke_Akasaka.jpg
166 KB, 1280x1316
>>55361151
>>
>>55362825
the b8 is real
strdup standard returns a pointer that has to be freed by programmer
>>
>>55362825
Are you a fucking retard?
>>
im writing a virtual machine in C, is there any reason the stack grows downward? I'd much rather start that shit at 0x0 -> rather than <- 0xFFFF. Besides it'd be fun to overflow the stack and start writing code if it was at 0x0
>>
>>55363051
I never put stacks in the instructionset
>>
>>55363051
Most compilers aren't just going to let you write to 0x0
>>
>>55363051
It's easier to process memory that grows down. You'll get used to it
>>
>>55363074
yes they fucking are its my virtual machine i chose the spec, and the assembler
>>
>>55360972
The only language I like is python but it's too slow
>>
>>55363084
Yeah, I originally thought that

static void vm_set_u16(vm_t* vm, uint16_t addr, uint16_t val)
{
assert(addr <= 0xFFFF);
vm->m_Mem[addr] = val & 0x00FF;
assert(addr+1 <= 0xFFFF);
vm->m_Mem[addr+1] = val >> 8;
}


If you want to write memory that grows downward the regular function I wrote to write memory doesn't work. (Try subbing in 0xFFFF for addr and see where the problem arises)

You need to write the memory in an opposite direction and maintaining two different functions for that is autistic
>>
>>55363124
>The only language I like is python but it's too slow
that depends.

what are you using python for?
>>
>>55363124
then stop being a "coder"
>>
>>55363124
Why would you like such a shit language?
>>
>>55363124

get pypy or cython pleb
>>
>>55363140
>>55363142
>>55363143
>>55363150
I just want to get into programming. I probably want to make very simple programs as well with PyQt.

I hate java with a fiery passion, too overengineered. Same with C++
>>
>>55363170
Try Haskell instead
>>
File: c4jt321.png (310 KB, 580x282) Image search: [Google]
c4jt321.png
310 KB, 580x282
>>55363181
>>
>>55363193
Haskell's not that difficult to get into
>>
>>55363170
Java hate is justified, c++ not so much. Try C. It's a golden language.
>>
>>55363219
$ disassembler
disassembler version date
Copyright (C) 2016 your name
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Here, your title screen.
>>
>>55360972
Why are "Expert Programmers" in anime effeminate?
>>
File: title-screen-r4.png (56 KB, 948x423) Image search: [Google]
title-screen-r4.png
56 KB, 948x423
I'm still working on a title screen for a disassembler.

>>55363256
It has a Qt GUI.
>>
>>55363170
>I hate java with a fiery passion, too overengineered.

so you know nothing about programming, but hate a language you never used?

kys
>>
>>55363256
Can you just claim something is copyright?
>>
>>55363285
Is it free software?
>>
>>55363296
Yes, GPLv3: https://panopticon.re/
>>
File: cbs-logo.png (97 KB, 2272x1704) Image search: [Google]
cbs-logo.png
97 KB, 2272x1704
>>55363285
>>
>>55363267
Because they are actually "a programmer's dream".
>>
>>55363289
Man, I tried, it's just too much work for the simplest of simple programs. Compare
>>55358042
to
>>55360014 (I know it's not a good code)
>>
>>55363327
>GPL
>free
GPL is a trojan virus
GPL is communism
GPL requires all derivative works to be GPL
>>
>>55363327
Oh, it's actually cute! I will try it soon.
>>
>>55361633
A macro "function" allows for generic arguments. Not to be confused with void* pointers or anything like that.

You could have two different structs which each have x and y attributes, and you could use a macro to do something simple to those attributes.

#define normalize(vector) (vector.x /= vector.length; vector.y /= vector.length)


This would define a macro that would normalize a vector. You can have different kinds of vectors, for example, one could use floats instead of ints. This means that you don't have to write the same function twice for different argument types.

Of course, if you use C++ you can just use templates instead.
>>
File: hUUCnmyG.png (88 KB, 248x248) Image search: [Google]
hUUCnmyG.png
88 KB, 248x248
>>55363327
why are the best programmers anime weeboos?
>>
File: 1435439488227.jpg (380 KB, 1069x1081) Image search: [Google]
1435439488227.jpg
380 KB, 1069x1081
>>55363291
yes and no. by putting that on something it makes it officially copyrighted, but for it to stand up in court you need some form of proof that it existed and was copyrighted for that long.
>>55363345
see pic related
>>
>>55363327
GPL meme?

Why didn't you use a MIT license??
>>
>>55363327
np
http://forum.exetools.com/showthread.php?t=17664
https://kat.cr/ida-pro-6-8-bindiff-4-2-t12685413.html

everything else is scum
>>
File: 1460357360208.jpg (33 KB, 676x403) Image search: [Google]
1460357360208.jpg
33 KB, 676x403
>>55363392
normalize((a, b++))
>>
>>55363003
doing work that a computer can do for you is pretty much the definition of pleb
>>
>>55363436
alternatively google this exe
idapronw_hexarmw_hexx64w_hexx86w_150413_cb5d8b3937caf856aaae750455d2b4ae.exe
>>
I just tried writing C wrappers for the push and pop instructions, then I realized why that was probably a bad idea.
>>
>>55363436
>nonfree
>>
>>55363465
see
>>55363432

piracy > gpl
>>
>>55363428
but the BSD is moar free, it has the freedom to change licenses
>>
File: 1466917291247.png (25 KB, 710x225) Image search: [Google]
1466917291247.png
25 KB, 710x225
>>55363428
What's happening ITT?
>>
>>55363486
See >>55363428
GPL > MIT > illegal copying
>>
>>55363427
You can recognize good programmer by their anime avatar. The better the programmer the smugger the avatar.
>>
>>55361151
It's definitely not a woman, if you meant that.
>>
>>55363460
why
>>
>>55363445
good programming practices != doing work the computer can do

Garbage collection is a cancer and with simple accommodations garbage collection is totally not needed.
>>
>>55363542
> simple accomodations

linear types are fun mental masturbation but programming with them again requires you to do work a garbage collector will automatically do for you
>>
>>55363574
garbage collection in large programs is aids

see minecraft
>>
>>55363540
Functions generally store all sorts of information on a stack during a function call, and messing with it during runtime would probably be bad for the program
>>
>>55363574
there's literally no need for a garbage collector
there's no need to manually allocate memory
in C++ just use string or vector and you never need to use the keyword new
>>
>>55363591
the same optimizations programmers do in high-performance games (allocating pools of memory and using their own allocators rather than malloc/free) works just as well in a garbage collected language. In most other applications, this is not necessary.

>>55363602
oh, i was thinking you were the virtual machine in C guy.
>>
>>55363602
yes but stack manipulation allows you to peek at what the fuck previous functions were doing aslong as the state isn't fucked with that the next function expects
>>
File: ancap_pepe.jpg (19 KB, 320x320) Image search: [Google]
ancap_pepe.jpg
19 KB, 320x320
>>55363428
>MIT license
>>
>>55363619
what kind of memory management are you talking about?

scope-based (RAII)? that's quite limited, and the standard C++ way of getting around it's limitations is by using smart pointers (reference counting gc) or unique pointers (linear types).
>>
>>55363637
limited garbage collection that isn't aids > language wide garbage collection that poisons the whole global state
>>
>>55361001
Is that book worth owning?
>>
>>55363664
what limited garbage collection? smart pointers poison everything by injecting overhead everywhere
>>
ᴺᵉᵛᵉʳ ᵇᵘʸ ᵃ ᵏᵉʸᵇᵒᵃʳᵈ ᵒᶠᶠ ᵒᶠ ᵃ ᶜʰᶦᶰᵉˢᵉ ᵇᶦᵈᵈᶦᶰᵍ ʷᵉᵇˢᶦᵗᵉ⋅ ᴱᵛᵉʳʸᵗʰᶦᶰᵍ ʸᵒᵘ ᵗʸᵖᵉ ʷᶦᶫᶫ ᵃᵖᵖᵉᵃʳ ˢᵐᵃᶫᶫ⋅
>>
>>55363637
again, you don't need to use smart pointers because you don't need to ever free memory
you don't need to free memory because you never need to manually allocate memory

and you never need to manually allocate memory because any kind of dynamic memory allocation is handled for you when you use strings, vectors, queues, etc

the only exception to this rule is when you have to implement your own data container (read: essentially never)
>>
>>55363717
when are these objects deallocated?
>>
>>55363746
when they exit scope
>>
>>55363746
Never, they're always lurking in memory, for the rest of your life.
>>
So I'm using shell_exec in php to run a .sh on my Linux. I'm trying to split the echo of the .sh on \n characters. But for some reason the result has no \n characters. But if I run it in my terminal it works fine.

Anyone knows how to fix this?
>>
>>55363746
when the amount of references to that object is 0 or when they are destroyed by leaving scope, (their destructors are called which then free() or delete[] memory)
>>
>>55363746
Everything exists in the stack friendo, WITH overflow protection
>>
>>55363762
what if an object needs to escape that scope?

ur fukt m8
>>
>>55363784
thats what shared_ptr is for

rekt
>>
>>55363784
>what if an object needs to escape that scope?
there are guards watching him
>>
>>55363784
pass by copy
>>
>>55363772
that's reference counting aka smart pointers aka cancer

>>55363776
doesn't handle objects that escape their scope
>>
>>55363784
then define it in the outer scope bruh
>>
>>55363793
shared_ptr is fucking reference counting which is exactly what i was talking about you retard

>>55363795
you mean linear types
>>
>tfw bikeshedding
>>
>It's a "program compiles first try" episode
I love this rerun
>>
>>55363327

This is a really neat project. Does Rust eventually stop giving you eye cancer?

I've used it for some small projects, but nothing serious.
>>
File: linear.gif (326 KB, 256x256) Image search: [Google]
linear.gif
326 KB, 256x256
reminder to catch/handle those exceptions/error codes you neglected to a few days ago
>>
File: cover.jpg (51 KB, 400x579) Image search: [Google]
cover.jpg
51 KB, 400x579
Where should I start with programming?

There's so much information I'm like a deer in the headlights

Should I read pic related?
>>
>>55361897
bumping for replies
>>
>>55363959
KEK no

start with C
>>
>>55363959
start with hello world in literally any language
>>
>>55363959
That book is a meme you dip.
>>
REPLY TO THIS POST WITH SHIT YOU LISTEN TO WHILE PROGRAMMING

Getting ready for a long programming session
>>
>>55363959
i wouldn't start with sicp but it's pretty damn good for once you have a handle on things

>>55364017
no it's not
>>
>>55363769
Anyone? This shit is driving me up the wall. Where does my \n go?
>>
>>55364029
gangster rap
>>
>>55364029
https://www.youtube.com/watch?v=TPYqrVDlc_4
>>
>>55364029
https://youtu.be/u0P9u8nCFyY
Or some GY!BE
The Mars Volta is also good
>>
File: 141762559931.png (94 KB, 396x385) Image search: [Google]
141762559931.png
94 KB, 396x385
>>55364029
https://www.youtube.com/watch?v=CYu8mEOHMF0

Hardcore gangster rap
>>
>>55363942
What error codes?
>>
>>55364029
https://www.youtube.com/watch?v=YcsYSJwewWk
>>
>>55363959
Start with the Greeks
>>
>>55364037
PHP is sketchy with exploitable characters

http://stackoverflow.com/questions/4238433/php-how-to-create-a-newline-character
>>
>>55363920
For me Rust looks like every other ALGOL inspired language, compared to C++ the syntax for things like lambda functions and type parameterized constructs Rust is miles ahead.

After you get past the Borrow Checker it's an amazing language that has the potential to reach Java-level popularity.
>>
>>55364029
https://www.youtube.com/watch?v=jgNvzc-ZdME
>>
>>55360972
Writing a perl sc-annnndddd it's done.
>>
File: ihatematplotlib.png (141 KB, 1280x800) Image search: [Google]
ihatematplotlib.png
141 KB, 1280x800
>>55360972
Made a python program that generates school schedules base on various preferences (course times, preferred proffs, number of daily courses). Going to make a web interface then start up a server for people in my uni to use.
>>
>>55364155
>After you get past the Borrow Checker it's an amazing language that has the potential to reach Java-level popularity.

I think I'm stuck on the 'fighting the borrow checker' stage and haven't touched it since. Need to get back to it.
>>
>>55364098
The list I get comes back from a grep into a cut if that helps. It should return a 30ish items, but the explode only gets me 2 parts. The first part and the end (nothing).

So the entire string comes from a single echo.
>>
>>55364155
PIPE DREAM
I
P
E

M
E
M
E

It's okay. The syntax is scary for the plebs unfortunately. That's why it'll never catch on completely.
>>
>>55361128
Topkek
>>
>>55364202
take a screenshot if you want help
>>
>>55364178
Nice
>>
Hi anons , tell my what i need to learn and how long to be a good programer. I am 16 and i know basic of html and c++
>>
>>55364204
>The syntax is scary for the plebs unfortunately.

Not just 'scary for plebs' but unnecessarily complex in many situations. Go through that source and you'll see a lot of it.

That doesn't condemn it to failure, though, since a lot of languages are like that.

Big learning curve.
>>
I once saw a thread where ppl talked about how /g/ is full of cuteboys, how true is this?
>>
>>55364155
the borrow checker is part of what makes it good
>>
Daily reminder to never ever use system("pause")
>>
File: 1446683077160.jpg (121 KB, 640x896) Image search: [Google]
1446683077160.jpg
121 KB, 640x896
>>55364349
What if I want to pause the program?
>>
>>55364349
>it's a "return of the tripfags" episode

what about system("");
>>
TO change a variable type in C:

number = (int)number

In C++

number = static_cast<int>(number)


why.
>>
>>55364237
Can't really screenshot it but I'll try to dummy code it.

The .sh is:

#!/bin/bash

echo <gather information> | grep ### | cut @@@


The result of this in the terminal:

Line1
Line2
Line3



The PHP:
<?php
$list=shell_exec("path/to/file.sh");
$arr = explode("\n", $list);
foreach($arr as $item){
$outputVar++;
}
?>


The result of this is depending on \n or \r and any combinations 1 or 2. It should be at least 20.

Even if I try to paste the content of the list variable to a p tag it has no newlines. Something like:

Line1Line2Line3
>>
>>55364424
>TO change a variable type in C:
>number = (int)number
>In C++
>number = (int)number
fix'd
>>
>>55364458
Oh, so you can use the C syntax in C++?
>>
What is the difrences betwen c++ and c#
>>
>>55364471
yeah
>>
>>55364496
one requires a microsoft runtime to be installed on your operating system
>>
>>55364496
C# runs on a stack based vm
C++ is compiled directly to host platform

They both have to deal with autistic windows APIs

C# is becoming the next hipster thing whenever the Mac fags get sick of javascript
>>
>>55364517
So why the does the 'static_cast' function exist
>>
>>55364393
just block input with getch or scanf
>>
>>55364572
because C++ has 3 different types of casts, C has 1
>>
Does a circular buffer stop stack buffer overflows?

eg stack pointer % 256
>>
>>55364197
What helped me a lot when I was starting out with Rust around a year ago were the compiler hints. This is one the reasons I stuck with Rust while I gave up on Haskell. Following the compiler hints allowed me to build programs I did not fully understood but worked. This was different from Haskell where doing what GHC tells you just gets you an even longer error message.

>>55364204
Rust occupies a niche that is only rivaled by C, C++, Java and C#. I've been programming C++ for a decade and I currently work in the security industry as a C++ programmer and Rust solves exactly the problems I have daily: writing fast, portable and secure code. C with its lack of strong abstraction an encapsulation mechanisms is strictly worse than C++. While C++ has changed immensely since 2009 the language is simply collapsing under the weight of all the legacy shit that has been piled up since 1989. Just look at the lambda function syntax. That's completely insane. This leaves Java and C# and while they are ubiquitous in many industries this is often the result from a lack of alternatives. If you want to write a large application that needs to be efficient what else can you pick? Rust has many advantages over Java. The tooling that already exists for C/C++ can trivially be extended to support Rust. The language is not only as fast as C today -- one year after 1.0 -- but it also does not depend on a GC what makes interacting with other languages and C library easy. Idiomatic Rust is memory safe and free of data races what helps with concurrent programming. Doing this in Java is pain in the ass. Last but not least the HN hipsters love it and they are the early adopters a language needs to be successful. As I said Rust has the potential. You don't need a Sun shilling your language, C++ got popular w/o.
>>
Is it possible to port a visual c# console app to linux?
>>
>>55364654
mono
>>
>>55364572
it's for the kind of autist who needs to be maximally verbose at all times
>>
>>55364393
Just do while (1); until the user presses ctrl+c
>>
>>55361423
Example?
>>
>>55364647
>Just look at the lambda function syntax
lambdas should never have been added to C++
they did this to appease the functional paradigm autists and all it did was fuck the language
>>
>>55364726

just be happy you can put them in std::function
>>
File: anonymize.png (3 KB, 352x70) Image search: [Google]
anonymize.png
3 KB, 352x70
>>55364398
Please don't ruin it for people who aren't subjecting themselves to tripfags
>>
>>55364726
Honestly, lambdas were one of the best additions to C++. You can finally use all the stuff in <algorithms>. Nobody will write a whole class w/ operator() just to use std::accumulate.
>>
>>55363694
wow what a fresh meme m87
>>
>>55364792
the language has now officially spread itself too thin
I'm all for the concept of "multi-paradigm" but fuck the meme shit, man
>>
>>55363531
Shut the fuck up
>>
>>55364792
>not just using a functional language in the first place
>>
>>55363531
How good a programmer is >>55362853
>>
>>55360972
osu-web
>>
What are some good resources to learn modern C++11/14? Last time I used C++ was back in '07, since then I moved to Perl and now Haskell.
>>
>>55364952
Professional C++ by Marc Gregoire

Cuts all the shit and its for C++ programmers by C++ programmers. It's more of a reference with side shit than a tutorial
>>
>>55364952
look up "auto"
that's all you should use from 11 and 14
and even that is debatable
>>
>>55364994
atomics nigger
>>
>>55360972
Learning rust. Here is what I've got so far.
#![allow(dead_code)]

struct Registers {
v : [u8; 16], // 16th register reserved for carry flag
i : u16, // Index Register same restrictions as pc
dt : u8, st : u8,
sp : u16, // Stack pointer keeps return location after a call
pc : u16 // Program counter 0x000 - 0xfff, initial val 0x200
}

impl Registers {
fn new() -> Registers {
Registers {
v : [0; 16],
i : 0x200,
dt : 0,
st : 0,
sp : 0,
pc : 0x200
}
}
}

/*
* Ram Layout for chip8
*0x000 - 0x1ff - Interpreter / font set
*0x050 - 0x0A0 - Built in Pixel font set 4x5 (0-F)
*0x200 - 0xfff - Program Rom / Work Ram
*/

struct Memory {
ram : [u8; 4096],
stack : [u16; 16],
gfx : [u8; 64*32],
keypad : [u8; 16]
}

impl Memory {
fn new() -> Memory {
Memory {
ram : [0; 4096],
stack : [0; 16],
gfx : [0; 64*32],
keypad : [0; 16]
}
}
}

struct Cpu {
regs : Registers,
mem : Memory
}
>>
>>55364986
Thanks. I'll check it out.
>>
Where the fuck are the problems in composing programs?
>>
>>55365215
>Professional C++ by Marc Gregoire
dont forget to get the latest edition to get C++14 shit if you do intend on buying it
>>
>>55365284
>buying words
>2016
gen.lib.rus
>>
>>55365126
nice
>>
>>55365364
theres satisfaction about owning a 1000 page book

what're you fucking poor?
>>
>>55365364
DELETE THIS
>>
>>55364994
>>55365023
>>55365284
Is C++14 even being used in the industry? Isn't C++98 the most common standard followed?
>>
>>55365481
c++11 is gaining traction because they finally standardized threads and other shit

industry is limited to C++98 because compiling STL for embedded systems is autistic
>>
What's a good strategy to build a program with a particular language I only have basic understanding of?

I have an ambitious idea for a website and I don't know where to start. An online resource with common tools/software implemented onto websites would be a good deal. Anyone have any suggestions?
>>
>>55365372

Yeah so far it is looking like I'll save a hundred lines of code or so over the c++ version I did a while back.

Kinda going blind on graphics libraries and audio though. Not quite sure what I'll end up with.

It's meant to be a quick dirty project to get the basics. I'm 100% sure things won't turn out idiomatic or proper. I mean I've only got about a couple days experience in the language so far.
>>
I realize I'm a retarded faggot who cannot into basic programming problems, so save your breath. But can somebody please tell me what I'm doing wrong here?
#include <stdio.h>
#include <cs50.h>
#include <math.h>

#define QUARTER 25
#define DIME 10
#define NICKEL 5
#define PENNIE 1

float GetChange();
/* Ensures the user entered a positive denomination of money */
int PennieConversion(float decimalMoney);
/* Rounds the value obtained from GetChange to the nearest hundreth, then converts
that value to an int representing the amount of pennies owed. Implemented
to ensure there was no inaccurate fuckery on the float from GetChange()'s behalf. */

int main (void)
{
int coinsGiven = 0, penniesOwed;
float desiredChange = GetChange();
penniesOwed = PennieConversion(desiredChange);

while (penniesOwed >= 0) {
if (penniesOwed > QUARTER) {
penniesOwed -= QUARTER;
coinsGiven++;
continue;
} else if (penniesOwed >= DIME) {
penniesOwed -= DIME;
coinsGiven++;
continue;
} else if (penniesOwed >= NICKEL) {
penniesOwed -= NICKEL;
coinsGiven++;
continue;
} else if (penniesOwed >= PENNIE) {
penniesOwed -= PENNIE;
coinsGiven++;
continue;
} else {

printf("%d\n", coinsGiven);
}
}

return 0;
}

float GetChange(void)
{
float dc; // desired change
do {
puts("Please enter how much change you are owed:");
dc = GetFloat();
} while (dc < 0);
return dc;
}

int PennieConversion(float decimalMoney)
{
int n;
long b;
decimalMoney *= 100;
b = round(decimalMoney);
n = b;
return n;
}
>>
>>55365971
>what I'm doing wrong here?
well, for one, you use C.
>>
>>55363341
See, you don't even understand why it looks like that.
>>
>>55365971
Forgot to mention that I'm using a library provided by the course, but the only time I used it was in the
GetFloat()
call in PennieConversion.

Not sure if the terminology I used is entirely correct either, so feel free to correct me on any of that as well.
>>
How good would my math have to be to understand algorithms?
>>
File: categorised monad.png (203 KB, 2132x666) Image search: [Google]
categorised monad.png
203 KB, 2132x666
>>55365971
use a monad
>>
>>55365997
Oh I'm sorry, next time I'll use python and remain a Pajeet for the rest of my life.
>>
>>55366015
gotta love cs50 using american currency for international courses available online

autism

what the fuck is a dime?
>>
>>55366041
about two nickels
>>
>>55366041
it is a half pence times 20
>>
>>55366041
half a quarter + 5 pennies
>>
>>55366041
A coin worth 1/10th of a US dollar, or .10 cents.

I used an int to represent it because the clusterfuck of for loops that I wrote to poorly implement the algorithm described by the problem set is working with an int meant to represent the amount of pennies (.01 of a US dollar, lowest denomination in our currency) owed to the customer.
>>
>>55366041
about 10 yen
>>
>>55366120
what must you do? just paste the question pls
>>
>>55366146
a what
Thread replies: 255
Thread images: 31

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

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.