Last thread >>55354159
What are you working on /g/?
>>55360972
First for D
>>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.
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
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
>>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 functionshort 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.
Is there a good C reference for people who already use C++?
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?
>>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
>>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 thatstatic 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
>>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?
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/
>>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.
>>55363327
why are the best programmers anime weeboos?
>>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
>>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
>>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
>>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.
reminder to catch/handle those exceptions/error codes you neglected to a few days ago
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
>>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.
>>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")
>>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
>>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 theGetFloat()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?
>>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
>>55366035
I'm a complete retard and have no idea what you're talking about and the wikipedia article really didn't help that much. Is a monad something that can only be implemented in a purely functional language? Because the course is pretty adamant about using C.
>>55365971
Well the first thing you need to realize is never store currency as floating point values (floating point operations have inaccuracy.. it can give people extra money or take extra money in financial programs.)
As for the algorithm itself .. What exactly is the problem you're solving?
>>55366167
http://cdn.cs50.net/2016/x/psets/1/pset1/pset1.html#time_for_change
https://youtu.be/9dZzyl7dCuw
>>55366242
The user has to enter a float per the problems (>>55366264) specifications.
>>55366233
In theory it's you can write something that works like a monad in C, but it's gonna be a nightmare to use and it'll segfault all the time.
>>55366264
>time_for_change
time for me to cum in your ear
http://pastebin.com/UVXzRbRg
Working my way through the searching chapter of sedgewick and waynes algorithms book. As an exercise they wanted me to write a client with a small symbol table full of GPAs and calculate a grade point average.
Please tell me how I could make have this better.
>>55363427
anime programmers are blub
the only ones they can look down on are brogrammers
>>55366264
>so many fucking words for such a tiny problem
holy dicks
>>55360972
honestly it looks like a guy. idk why but something about the face.
>>55366264
By the way I haven't watched that video, so if it explains the solution I'm officially the biggest retard on the planet and I sincerely apologize for wasting everybody's time.
>>55366314
Just realized I had a pointless variable - count. I could have just used args.length. Ugh.
>>55366360
It's a babby tier introductory course.
>>55360972
I got some more of the UI done for my custom homepage hentai web app.
Also, began working on the features that will have /mai/ waifu have personality. Like, although it's just a start, she now will only cam with me after I reach a certain threshold.
However, I still gotta get the cam feature to properly work. only been using sample images so far.
1/4
>>55366281
Parse the user input from a float to a integer.
If they enter 9.75 it should be translated to a integer 975. After that following the example you do 1000 - 975 = 25. Then just use the modulo operation and simple mathematics to calculate the number of coins needed from biggest to smallest.
The way they're describing the problem and what you should do is bad practice. I'm highly disappointed in the cs professor for that Harvard class
>>55366405
2/4
>>55366264
goddamn. it's like they're trying to make programming as casual as hand-holdy as possible nowadays
>>55360972
A family friendly version of 4chan. so basically "troll bait" the site!
Wo
>>55366424
3/4
>>55366455
4/4
Now, I know there was someone who gave me some suggestions yesterday. I'll try to remember them when I get back to this w/in next few days, but I'm getting some functionality done first
>>55366408
Anon, did you look at my code? That's what I tried to do in the PennieConversion function.
>>55366430
It's the first exercise in the course.
>>55366473
For anyone wondering, I'm using linear thresholds
For instance, she gets WET at 250, will orgasm at 1000, if the right combo is done, squirt at 1100. she flushes at 100, and she'll be panting by 500
So, that's not a count of orgasm. That'd be lame. You gotta build up to it.
(or will, once it's done)
>>55365971
Why even bother, when you get out of the EU no one will hire you.
>>55363428
Communists (GPL shills) are kek
>>55366562
What the fuck is this even supposed to mean? Are you insinuating that I'm British?
>>55366582
Are you upset at something friend?
>>55366430
>trying to make programming as casual as hand-holdy as possible nowadays
for these videos to exist it's already too late
I'm considering going back to college and getting a degree in electrical engineering now
there has to be less normalfags in that industry
>>55365971
Take the change, divide it by the value of a quarter.
The quotient is the number of quarters you'll give as change.
Then you take the remainder and you do the same for the value of a dime.
Same for nickel and pennie.
And that's it, unless I haven't understood what you're doing which is possible.
>>55366485
Here is a hintint total = 1200;
int amount_paid = 0;
int quarters = 0;
int dimes = 0;
int nickels = 0;
int pennies = 0;
int difference = 0;
amount_paid = PennieConversion(9.75f);
difference = total - amount_paid;
while (difference > 0) {
if (!(difference % 25)) {
difference -= 25;
++quarters;
}
}
>>55365971
Holy shit, I'm sorry /g/. Turns out that the first if statement was lacking a <= operator.
>>55364029
Can you really focus with music/noise in the background?
>>55366653
Thanks for the first actually constructive response, but I already figured out that it was just me being a complete retard and not realizing that the first if statement was checking whether penniesOwed was greater than a quarter rather than greater than or equal to a quarter.
>>55366769
That wouldn't have happened if you had used a safe language like Rust.
>>55366769
Try getting change for $12.10 on a charge of $9.75 and see what your result is.
>>55366764
noise no
music yes
>>55366786
Yes it would've. The program was compiling and running just fine, it was a logic error caused entirely by my own retardation.
Gnome software is fucking garbage.
Seriously what the fuck where they thinking when they made libnotify? you can't fucking free the NotifyNotification struct after showing it because it causes read-after-free errors and you can't free it later because it's impossible to actually know when it's safe to free, it's impossible to free the struct! my fucking application is just going to keep leaking memory because of gnome garbage.
And don't get me started on pkg-config, that's just terrible practice.
Please just kill me. Are there any other alternative API's for desktop notifications on Linux using C/C++?
>>55366820
You don't realize how hard it was to hint at it without directly fixing it..
>>55366828
>And don't get me started on pkg-config, that's just terrible practice.
What the hell is wrong with pkg-config?
It's great.
>>55363327
>>55363428
>using any version of the GPL or LGPL ever
If you want a (weak) copyleft license then use the Mozilla Public License.
This respects users and does not enforce fascist idealism on them in order to make use of your code. Only if a person modifies your code must they make said changes available on request; code you had no hand in writing does not become infected by the license and other authors are free to be as open or closed with their own code as they want.
>>55366820
Btw you can separate out the repeated logic in the if statements into a function like this.int howmanyinnum(int num, int num_to_count) {
int count = 0;
if (num < num_to_count) {
return 0;
}
while (num >= num_to_count) {
num -= num_to_count;
++count;
}
return count;
}
int main(void)
{
int total = 1210;
int amount_paid = 0;
int quarters = 0;
int dimes = 0;
int nickels = 0;
int pennies = 0;
int difference = 0;
amount_paid = PennieConversion(9.75f);
difference = total - amount_paid;
quarters = howmanyinnum(difference, 25);
difference -= (quarters * 25);
dimes = howmanyinnum(difference, 10);
difference -= (dimes * 10);
nickels = howmanyinnum(difference, 10);
difference -= (nickels * 5);
pennies = howmanyinnum(difference, 1);
difference -= (pennies);
cout << quarters << " " << dimes << " " << nickels << " " << pennies;
cin.get();
return 0;
}
>>55367057
ENTERPRISE QUALITY
>>55367057
Btw you can separate out the repeated logic in the if statements into a macro like thisint howmanyinnum(int num, int num_to_count) {
int count = 0;
if (num < num_to_count) {
return 0;
}
while (num >= num_to_count) {
num -= num_to_count;
++count;
}
return count;
}
int main(void)
{
int total = 1210;
int amount_paid = 0;
int quarters = 0;
int dimes = 0;
int nickels = 0;
int pennies = 0;
int difference = 0;
amount_paid = PennieConversion(9.75f);
difference = total - amount_paid;
#define BLUB(var, worth) (var) = howmanyinnum(difference, (worth)); difference -= ((var)*(worth))
BLUB(quarters, 25);
BLUB(dimes, 10);
BLUB(nickles, 5);
BLUB(pennies, 1);
cout << quarters << " " << dimes << " " << nickels << " " << pennies;
cin.get();
return 0;
}
>>55367131
>Multiple statements in the same macro
>Invisible state changes inside the macro
I don't like it. Although I guess Meme++ers love invisible state changes, so that's probably right up their alley.
>>55367131
that's some unmaintable shit right there
>>55367165
> invisible state changes
> macro literally 2 lines above
>>55367185
That doesn't matter. It's still in bad taste.
>>55367191
why would i use a macro without "invisible state changes" instead of just using a function?
>>55367201
You probably should just use an inline function.
>>55367191
Not really. Using macros to decrease redundancy can be quite useful in some cases. The post was a joke, but I've put it to good use in certain areas.
>>55367210
Exactly, so you use macros for what they're for. Getting rid of redundancy that can't be handled via functions.
>>55367210
>inline function
That's UB
>>55367119
Not quite enterprise quality would further abstract the 5 repeated calls and would separate it out into generic structures and classes.
>>55367131
-_- case and point.. This is cleaner looking though..int PennieConversion(float decimalMoney)
{
int n;
long b;
decimalMoney *= 100;
b = round(decimalMoney);
n = b;
return n;
}
int howmanyinnum(int num, int num_to_count) {
int count = 0;
if (num < num_to_count) {
return 0;
}
while (num >= num_to_count) {
num -= num_to_count;
++count;
}
return count;
}
int BLUB(int& total, int worth) {
int amount = howmanyinnum(total, worth);
total -= (amount * worth);
return amount;
}
int main(void)
{
int total = 1214;
int amount_paid = 0;
int quarters = 0;
int dimes = 0;
int nickels = 0;
int pennies = 0;
int difference = 0;
amount_paid = PennieConversion(9.75f);
difference = total - amount_paid;
quarters = BLUB(difference, 25);
dimes = BLUB(difference, 10);
nickels = BLUB(difference, 5);
pennies = BLUB(difference, 1);
cout << quarters << " " << dimes << " " << nickels << " " << pennies;
cin.get();
return 0;
}
>>55367171
> maintaining school homework
>>55367241
ah well, yeah that works. just used a macro for some reason.
>>55367241
>cleaner
>inconsistent capitalization
wouldn't pass code review
>>55367257
Definitely the capitalization was just laziness.
>>55367232
>Using macros to decrease redundancy can be quite useful in some cases
Yes. This is not one of them.
new thread:
>>55367288
>>55367288
>>55367288
>>55366764
Most of the times. The only exception being when I'm doing something new (e.g. learning a new language, dealing with a broad library I never used before, etc.)
>>55367057
>howmanyinnum
Jesus, anon. It's either howManyInNum or how_many_in_num (preferably the first).
>>55367284
It was a joke post I made two minutes before leaving work on a Friday senpai
>>55367057
>>55367131
>>55367241
>tries to help a first year CS student write better code
>literally programs worse than the newfag
Holy fucking kek.
>>55367498
> worse
> uses less code
>>55367567
Quality of software has nothing to do with lines of code.
>>55367567
Are you serious Pajeeet? Do you think every programming task is a game of fucking code golf?
>>55367498
That was more than one person tho
>>55367637
The less code the better
>>55360972
I'm working on a python script manager in python. It's a GUI program that allows me to run several python scripts by browsing for them and clicking 'run'
Right now it just runs the script immediately after you browse for it. In the future I plan to make it save the paths so you don't need to browse for each script each time you open the manager
>>55367666
You have to be trolling
>>55367792
Just write the file paths to a file, and open that file of stored paths on program start.
>>55368035
I haven't really gotten that far into the project yet, I'm sort of stuck on making the script run when you press the run button instead of the browse button
>>55368079
Well you might have to use subprocesses to run Python instances for each Python script. That or
you can import main programs from each script and run them in a linear fashion.
>>55362490
just have like a forloop condition checking until time is up and once time is up, have the bot announce it? I dont know what u mean, it seems like u have a good grasp of what to do. Is the bot not communicating with the channel or something?