[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


Thread replies: 340
Thread images: 26

PRIME FIZZBUZZ EDITION
[ f(x) | x <- [1,100] ] where f(x) = 
| "Fizz", prime(x) ∧ (x % 3 = 0)
| "Buzz", prime(x) ∧ (x % 5 = 0)
| "FizzBuzz", prime(x) ∧ (x % 15 = 0)
| string(x), otherwise


>i don't understand
Don't call us, we'll call you

Last thread: >>54827174
>>
You forgot the "What are you working on /g/? "
Here I'll do it for you.
What are you working on /g/?
>>
Guise look LOOK!

I can learn ALL of the C++ language watching this YT Tutroial!!!1

https://www.youtube.com/watch?v=Rub-JsjMhWY
>>
File: asdasd.gif (2MB, 245x251px) Image search: [Google] [Yandex] [Bing]
asdasd.gif
2MB, 245x251px
>>54832945

>print if x is prime and divisible by 3 5 or 15
>prime and divisible by
>prime
>divisible
>>
>>54832945
#!/usr/bin/env sh
for i in $(seq 1 100); do
if [ $((i % 15)) -eq 0 ]; then
printf 'FizzBuzz '
elif [ $((i % 3)) -eq 0 ]; then
printf 'Fizz '
elif [ $((i % 5)) -eq 0 ]; then
printf 'Buzz '
else
printf '%s ' "$i"
fi
done

Am I doing it right?
>>
>>54833021
>using namespace std;
dropped
>>
Sixth for Python is the best
>>
>>54833034
>he likes to write everything by hand
>>
>>54833022
Try actually reading that code
>>
>>54833045
>uses std

there's a reason it is called STD you know.
>>
>>54833045
don't put a (using namespace _) in the global namespace
>>
>>54833048

Λ means "and" you faglord.
>>
>>54833022 >>54833048 >>54833064

No helping each other.
>>
how did i do guys?

#include <stdio.h>

int main()
{
int i = 1;

counter:
while (1)
{
printf("%d, ", i++);
if(i > 100) goto exit;
if(i % 3 == 0) goto fizzer;
if(i % 5 == 0) goto buzzer;
}

fizzer:
while (1)
{
printf("Fizz");
if(i++ % 5 == 0) goto buzzer;
printf(", ");
if(i > 100) goto exit;
if(i % 5 == 0) goto buzzer;
if(i % 5 && i % 3) goto counter;
}

buzzer:
while (1)
{
printf("Buzz, ");
if(++i > 100) goto exit;
if(i % 3 == 0) goto fizzer;
if(i % 5 && i % 3) goto counter;
}

exit:
return 0;
}
>>
>>54833030 >>54833094

Please read the problem before attempting to solve it.
>>
>>54833064
If by prime you mean
isprime
then you are correct, but if you do you should learn basic function naming, otherwise I will continue on the assumption that prime(n) returns the n-th prime, which will always evaluate to true (in most languages).
>>
>>54833094
goto always triggers my autism.
>>
>>54833094
Enterprise/10
>>
What was the worst place that called you to work for them?

Mine was some "IT company" working with Microsoft Sharepoint, and people called themselves .NET developers.
>>
File: 26041546.gif (397KB, 1092x417px) Image search: [Google] [Yandex] [Bing]
26041546.gif
397KB, 1092x417px
Is there a sticky somewhere?

I'm learning C++
Watching thenewbostons tutorials, starting to lose me at video 45. Any complimentary literature?
>>
>>54833030
>
    if [ $((i % 15)) -eq 0 ]; then

Not sure but I guess this isn't even needed. One could just append the buzz. Correct me if wrong.
>>
>>54833094

magnificent
>>
learning regex and shit desu
>>
Ruby or Python? Can't decide but I want to try something more comfy than C.
>>
File: Traffic.gif (8KB, 306x301px) Image search: [Google] [Yandex] [Bing]
Traffic.gif
8KB, 306x301px
>tfw this happens in your program
>>
>>54833163
Sometimes I love it when this happens.

A good way to learn shortcuts, glitches also nice for databending when it happens to media processing.
>>
File: 1443131813754.jpg (92KB, 333x500px) Image search: [Google] [Yandex] [Bing]
1443131813754.jpg
92KB, 333x500px
>>54833163
>.gif
>doesn't move
>>
>>54833195
It does move, they're just in gridlock.
>>
>>54833161
Tqbh ruby is more of a structured language than python

there isn't even a switch/pattern match in python!
>>
File: 1440115199471.jpg (28KB, 480x360px) Image search: [Google] [Yandex] [Bing]
1440115199471.jpg
28KB, 480x360px
>>54833177
Sort of related: How to create such glitches?
Language doesn't matter.
>>
>>54833152
If you're going to learn sed, read this:
http://www.grymoire.com/Unix/sed.html
It's a god's gift.
>>
>>54833152
also this: http://www.grymoire.com/Unix/Regular.html
>>
>>54833118
prime(x) = x is prime
>>
>>54833310
>>54833297
ty
>>
>>54833260
easy, don't clear the drawing buffer.
>>
>>54833260
Turn off compositing on your window manager or whatever. Don't ever update your buffer.
>>
>>54833130
If you add in "liver health", this gif is a representation of my life.
>>
>>54833195
>thinks gifs have to have more than one frame
This is a technology board, please leave.
>>
>>54833397
>Don't ever update your buffer.
what ?
>>
>>54833130

Video tutorials suck for learning a language desu

I recommend C++ Primer or any of Bjarne's books.
>>
how to git gud
>>
>>54833478
The image buffer.
>>
>>54833397
You *have to update* the buffer, you just *don't clear* it so the old pixels remain as is.
>>
>>54832945
>
[1,100]

What does this part produce, OP? And in general what lang is that?
>>
>>54833566
If only I knew T_T
>>
>>54833566
Learn Haskell and reach satori
>>
>>54833679
It's Haskell with list comprehension
>>
>>54833679
Probably a range enumartor between [1, 100]. Just like range() generator in Python or D's range aggregator expression 1..100. And that's Haskell if I'm not mistaken.
>>
>>54833712
WTF? This is definitely not Haskell, do actually look at it. Plus my problem is that in Haskell,
[1,100]
produces a list with two elements, in order 1 and 100. Are you OP? If so can you explain yourself?
>>
>>54833737
Again, definitely not an enumerator in Haskell. So either it's not an enumerator or it's not Haskell.
>>
>>54833152
a bit late but i use this for testing regex i dont know regexr.com
>>
>>54833152
>basic substitute one word for another
>I'm learning regex guys!
>>
>>54833781
I just looked it up out of curiosity and there are what seems to be ranges in Haskell.

http://learnyouahaskell.com/starting-out#texas-ranges
>>
>>54832945
http://joelgrus.com/2016/05/23/fizz-buzz-in-tensorflow/
>>
>>54832945
>[1,100]

Why not [1...] senpai?
>>
>>54833783
That site is great. Don't forget to check out the favorites or whatever they call it. People put up all kinds of neat stuff.
>>
>>54833781
>>54833864

To add onto this, I'm not saying the OP is using ranges because those are indeed list comprehensions as you stated before so I stand corrected, I just wanted to point out that there are ranges in Haskell.
>>
>>54833022
>I can't read haskell code
>>
>>54833864
But, but, but...
>>54833923
Ok, agreed. Still my ongoing quest for wtf is this lang (must be a non-whitespacey ML now that I think about it), but thanks.

>>54833898
Right, why?
>>
File: 20160317_193145.jpg (412KB, 600x747px) Image search: [Google] [Yandex] [Bing]
20160317_193145.jpg
412KB, 600x747px
>>54833963
IT IS NOT HASKELL FFS read the thread
>>
>>54833575
if you don't update the buffer, the image just froze, nothing happens. do you know what you are talking about ?
>>
>language discussion
Why are you all faggots who don't write software? If you're interested in (existing) languages you're clearly only in it to write masturbatory code.

Right now C (alternatively a small subset of C++) is one of the only languages capable of writing actual software.
>>
>>54832945
>>54832996
>What are you working on /g/
An alternative implementation of a CMIS server to replace our Alfresco installtions which suck.
>>
>>54834073
>the old sickly one lang to rule them all meme
Get the hell back in Mordor, 0/10
>>
File: out.webm (2MB, 1920x1080px) Image search: [Google] [Yandex] [Bing]
out.webm
2MB, 1920x1080px
>>54834039
Isn't this what you're talking about?
I just took some glfw test code of mine, added an infinite loop before the rendering loop, and turned off my compositor.
>>
#include <cstdint>
#include <cstdio>
#include <functional>
#include <memory>
#include <string>
#include <utility>
#include <vector>

struct Rule
{
std::vector<uint32_t> divs;
std::string word;

Rule(std::initializer_list<uint32_t> divs, const std::string &word)
: divs{divs}
, word{word}
{
}

bool applies(uint32_t i) const
{
for(const auto &div: divs)
{
if((i % div) != 0)
return false;
}

return true;
}
};

struct Range
{
uint32_t from;
uint32_t to;
std::function<void(uint32_t)> cb;

Range(uint32_t from, uint32_t to, const std::function<void(uint32_t)> &cb)
: from{from}
, to{to}
, cb{cb}
{
}

void run()
{
for(decltype(from) i = from; i <= to; ++i)
cb(i);
}
};

struct FizzBuzz
{
std::vector<std::unique_ptr<Rule>> rules;

void add(std::initializer_list<uint32_t> divs, const std::string &word)
{
rules.push_back(std::make_unique<Rule>(divs, word));
}

void run(std::initializer_list<uint32_t> range)
{
if(range.size() != 2)
return;

(Range{*range.begin(), *(range.begin() + 1), [this] (uint32_t i) {
bool applied = false;
for(const auto &rule: this->rules)
{
applied = false;
if(rule->applies(i))
{
fprintf(stdout, "%s\n", rule->word.c_str());
applied = true;
break;
}
}

if(!applied)
fprintf(stdout, "%d\n", i);
}}).run();
}
};

int main(int, const char **)
{
FizzBuzz f{};
f.add({3, 5}, "FizzBuzz");
f.add({3}, "Fizz");
f.add({5}, "Buzz");
f.run({1, 15});

return 0;
}
>>
print_string:
pusha
mov ah, 0x0e

compare:
mov al, [bx]
cmp al, 0
je end
int 0x10
add bx, 0x1
jmp compare

end:
popa
ret


print_string:
pusha
mov ah, 0x0e

compare:
cmp bx, 0
je end
mov al, [bx]
int 0x10
add bx, 0x1
jmp compare

end:
popa
ret


Anyone know why the top one works but the bottom doesn't?
>>
>>54834562
because they do different things
>>
>>54833161

I'm a Ruby fan personally

How's my Ruby FizzBuzz guise?

(1..100).each do |i|
s = ""
s << "Fizz" if (i % 3 == 0)
s << "Buzz" if (i % 5 == 0)
puts (s.empty? ? i : s)
end


Or there's my one line version but people never comment on it, maybe because it looks like a bit of a clusterfuck

(1..100).each {|i| puts (s = "#{'Fizz' if (i % 3 == 0)}#{'Buzz' if (i % 5 == 0)}").empty? ? i : s  }
>>
File: why_c_is_shit.png (154KB, 1354x347px) Image search: [Google] [Yandex] [Bing]
why_c_is_shit.png
154KB, 1354x347px
>>54832945
How correct is this?
>pic related
>>
>>54834616
Pretty correct. C is obsolete in this day and age and only used in legacy projects.
>>
>>54834616
it's true
look at recent updates in language, they are becoming more ``functional"

soon it will be immutable by default and have more monads
>>
iota(1, 21).map!(a => a.predSwitch!("a % b == 0")(15, "FizzBuzz", 3, "Fizz", 5, "Buzz", a.to!string)).writeln;


>smug Andrei Alexandrescu.jpg
>>
>>54834616
>Tries to criticise C
>Brings up C++
wat?
>>
>>54834659
The arguments against both are the same; tons of little gotchas that make the language a pain in the dick to work with.
>>
>>54834666
C and C++ are completely different languages.
It makes absolutely no sense to lump them together.
>>
>>54834670
Read what I wrote; specifically, both have many little things that can trip you up.

I'm not saying the languages are similar.

I'm saying they both have a particular annoying quality that is solved by higher-level languages.
>>
>>54834688
>both have many little things that can trip you up
You can say that about literally ANY language. No language is perfect at anything.
>I'm saying they both have a particular annoying quality that is solved by higher-level languages.
Which comes with its own costs. Every high level language isn't even close to filling C's niche.
>>
>>54834600
s = ""


vs

s = Array.new


?
>>
>>54834616
not really true, but it's hard to do *good* code these days.

true

true

I'm not quite sure, but the zero terminated stuff is problematic in qutie a few situations

C++ is a world on its own
>>
>>54834712
>anything
"everything" I mean
>>
>>54834721
>the zero terminated stuff is problematic in qutie a few situations
such as?
>>
Hey /g/ rate my string sort
string_length = None
def strlen( string ):
global string_length
if string_length == None:
string_length = 0
try:
string[ string_length ]
string_length += 1
except IndexError:
string_length -= 1
string_length_to_return = string_length
string_length = None
return string_length_to_return
return strlen( string )
>>
>>54834616
It is too vague, and makes many claims without anything to back them up.

For example, but not limited to:
>C is anti-efficient
>Not cleaner than assembly
>"""Many""" gotchas and traps
>Not fast.
>Complains about a petty program entrypoint spec. Misuse the term "calling convention"
>Again, vague claims this time about C++
>Vague claims about his langage of choice (probably Go or Rust or D), attacks the community, and again vague claims about C++

That's a hell of a long post to basically say nothing.
>>
>>54833702
He said git gud, not turn into a massive useless faggot.
>>
>>54834770
Absolute trash
>>
>>54834770
enterprise/10
>>
>>54834770
def strlen( string, string_length=None ):
if string_length == None:
string_length = 0
try:
string[ string_length ]
string_length += 1
except IndexError:
string_length -= 1
string_length_to_return = string_length
string_length = None
return string_length_to_return
return strlen( string, string_length )


No need for the global.
>>
>when the IRC starts speaking in Portuguese

Fuck.

I didn't want to talk about programming anyway.
>>
>>54834809
Still absolute trash
>>
>>54834580
Yes evidently.
>>
>>54833094
I'd say this is Pajeet-tier but it's not C# or Java so at least you have that going for you
>>
>>54834713
Well you wouldn't use Array.new because when you print that, it will print each element to a different line, and you want "FizzBuzz" on the same line.

You could use
s = String.new
but that's literally no different to
s = ""


If you want to avoid either of those you could just do this:

(1..100).each do |i|
s = "#{'Fizz' if (i % 3 == 0)}#{'Buzz' if (i % 5 == 0)}"
puts (s.empty? ? i : s)
end
>>
>>54834770
>>54834809
(defn string-length [s]
(cond (empty? s) 0
:else (+ 1 (string-length (rest s)))))


stringLength [] = 0
stringLength (x:xs) = 1 + stringLength xs
>>
File: let_it_take_me.jpg (205KB, 776x1054px) Image search: [Google] [Yandex] [Bing]
let_it_take_me.jpg
205KB, 776x1054px
>>54834809
>>54834770
>>54834917

I don't know what to say.
>>
>>54834979
Does Python have functional constructs? If so, implement it in those.
>>
How many languages can we implement this in?

std::string::size_type strlen(const std::string &str, std::string::size_type n = -1)
{
if(n == -1)
n = 0;

n = n + 1;

try {
str.at(n);
} catch (std::out_of_range const &) {
return n - 1;
}

return strlen(str, n + 1);
}
>>
>>54834979
By all means, please post about your shortcomings on this Chinese cartoon website, stranger.
>>
>>54832996
Thought I'd take Lua for a spin.
>>
>>54834770
>string sort
>strlen
>>
>>54832945
i really, really like that image
>>
>>54835144
Save it, it's all yours :)
>>
>>54835155
>>54835144
>>>/b/
>>
>>54832945
 
1 ]=> (define (perform2x f x) (f (f x x) x))

;Value: perform2x

1 ]=> (perform2x + 3)

;Value: 9

1 ]=> (perform2x + 6)

;Value: 18

1 ]=> (perform2x * 2)

;Value: 8


lisp makes me feel like an arcane sorcerer even though i doubt i'll ever use high order procedures on intense mathematical problems like the wizard book has in its examples
>>
someone needs to make a programming version of this with OOP vs FP
>bloated OOP encapsulation vs advanced type system
>>
File: has_u_red_it.jpg (3MB, 2448x3264px) Image search: [Google] [Yandex] [Bing]
has_u_red_it.jpg
3MB, 2448x3264px
>>54835258
Feel free to be the change you wish to see in the world.
>>
>>54835258
have you noticed that OOP is POO backwardz?
>>
>>54835285
Have you noticed that functional programming is shitty and unintuitive in most applications?
>>
>>54835314
> unintuitive
Compare the above code samples for finding the length of a string, in Python, then Haskell.

Haskell is clear as fuck.
>>
>>54835344
>for finding the length of a string
Yes, let's compare languages based on one trivial task.

Retard.
>>
>javafriends want to ban THIS
 
1 ]=> (define (f9) (lambda (x) (+ x 5)))

;Value: f9

1 ]=> (f9 3)

;The procedure #[compound-procedure 13 f9] has been called with 1 argument; it requires exactly 0 arguments.
;To continue, call RESTART with an option number:
; (RESTART 1) => Return to read-eval-print level 1.

2 error> 1

;Value: 1

2 error> ((f9) 3)

;Value: 8

2 error>
>>
>>54833094
Production ready
>>
>>54835314
it's really not. you make low level tools and combine tools to make more complex tools. the top level ends up as being as elegant and abstract as you want it to be
>>
File: 1464694237246.png (218KB, 716x362px) Image search: [Google] [Yandex] [Bing]
1464694237246.png
218KB, 716x362px
>>54835344
>Compare the above code samples for finding the length of a string, in Python, then Haskell.
?
print(len(str))
>>
>>54835416
The point was to replicate the originally written function, not use built-ins that can already achieve it.
>>
>>54835442
i think you chose a shitty way to make your point m8
def strlen(s):
i = 0
for c in s:
i += 1
return i
>>
Is anybody here particularly handy with SQL?

I'm trying to build a lightweight online tabletop system and have a bit of a design quandary.

Any given game will have to have token information stored for it. All that information I already have mapped pretty easily.
However: How should I actually tie that stuff together?
The way I'm storing token info is just to have a general "token" table, with a GUID to tie into a token image table, and everything else would just be some light strings and ints.

But I'm not sure how to...tie that into a table of games? Should the games table just be a GUID for the individual game and ownership/membership of it, and then have a column in the token table to tie them into their respective game?

If that didn't make sense: A game has any given number of tokens. The token information is currently going to be stored in it's own table. I need a way to tie tokens to a game without having a trillion billions records in the game table. Also, I have no idea if having a general token table like I described will cause an issue.
>>
>>54835442
Why is it even a point of comparison between the two languages?

Every modern language has built-in functionality for that.

Haskell has a built-in, too, right?
>>
Why are we having TWO threads for fizzbuzz?
>>
>>54835519
That does not do the same thing that the original function does.

>>54835529
>Every modern language has built-in functionality for that.
Well ask that retard that wrote the original function instead of doing len(string).
>>
>>54835520
A foreign key, maybe?
>>
>>54835555
Yeah that's what I'm leaning towards, but it's mostly the "this will generate enormous tables over time" thing.
I guess thinking about it, the token table would be the problem area since for every game that is made a dozen token records or more will be made. But I don't think there's a better way to split that up?
>>
>>54835520
create a "Game" table and add a foreign key to your tokens

>inb4 muh performance
DBs are built for this shit
>>
>>54835354
The triviality emphasises how shit Python is when compared to Haskell, retard.
>>
>>54835547
yes it does
>>
>>54835520
Think about identifiers.

Does a token have a particular game it belongs to?

When you say game, are you referring to a type of game, or the game itself? (Checkers, or MyGame1547 which is a Checkers game)

You could have something like the following:
>Games
Game name, information about the game type, created by, date modified, etc.
>Sessions
Session name, information about the session
>Players
Info about each player
>PlayerSessions
A tie-in table that allows a many-to-many between players and sessions
>Tokens
All tokens go here, with information about only the token itself
>GameTokens
Many-to-many for games and tokens
>SessionTokens
Many-to-many for sessions and tokens.

This would get you flexibility to have a single token with custom properties belong to many games, say a custom character in a DND game.
>>
>>54835587
You should be concerned with performance only if you expect to have billions of records.

Do you?

If you do, make a simple prototype now, and go back to it later IF it's an issue (it won't probably)
>>
>>54835614
this
speed isn't a problem until it's a problem
i know it sounds like bullshit, but its actually pretty good advice
>>
>>54835344
>>54835416
>>54835442
>>54835519
>>54835547
>>54835610
guiz it was bait

>>54835610
Actually it doesn't, the original returns len(string) - 1
>>
>>54835529
Haskell's built-in for string length, or any length:
length
>>
>>54835663
Early optimization is root of much evil, amirite?
>>
>>54832945
>ever checking prime(x) ∧ (x % 15 = 0)
>checking 3 and 5 on every iteration instead of just printing them at the start
retard
>>
>>54834616
what's he even complaining about? about the performance of C? what's a better alternative then?
>>
>>54834562
because the bottom one never ends
bx will never be 0 and cmp bx,0 will always fail
(don't know whether intentional)
>>
>>54835695
if you honestly believe that guy is better off thinking about the speed of his never to be released personal practice game instead of learning more useful shit like how to manage and release a large scale project complete with documentation and testing, you're a fucking idiot
but whatever, go fix the stack alignment and cache misses of your fizzbuzz program

>>54835666
no it doesn't
>>
>>54833909
Good site use it all the time.
>>
>>54835787
you can do both you fucking retard
>>
>>54835787
I was agreeing, actually.
But I'm always up for some eFighting.

>faggot
>>
>>54835520
>>54835787
>>54835812
especially database shit can be INSANELY inefficient and end up costing you gorillions in hosting expenses
>>
>>54835787
>no it doesn't
which 'original' function are we talking about here?
>>
>>54835822
Reminds me of that time someone was using a SQL abstraction library and they ended up generating like 400,000 unique connections all doing a small query.

That would be a fun bill at the end of the month, depending on if your usage plan has a per request rate.
>>
>>54835819
>I was agreeing, actually.
oh

>>54835822
yeah you're right
usually tha happens because of A LOT of unnesessary queries and duplicate information and not so much because of design flaws though
>>
>>54835822
>especially database shit can be INSANELY inefficient
only if you're a literal retard
>>
Not sure where to post it but
Is it possible to know the pages in a file that i want to print? I'm using windows and printing through cmd
>>
>>54836045
what command are you using tho?
you should refer to the docs of that command, probably
>>
So I wrote a simple threaded function manager that enqueues tasks in a safe manner (using locking/signaling mechanism) and always executes these functions that are enqueued one by one, is it safe to assume that if those functions fire and access the same data, there's no need for mutexes inside of them because the manager already guaranteed only one will execute at a time?
>>
>>54836092
yes
>>
>>54836092
uh
is there even a point using multiple threads if you're gonna execute them synchronously anyways?
or did i read your post wrong?
>>
>>54836073
print "file"
with ShellExecuteA
>>
>>54836114
Just two threads (main thread & manager thread), the manager will execute the logic synchronously but the enqueued functions will come from an asynchronous socket. It's for a simple multiplayer game based on async networking.
>>
>>54835778
Thanks for the reply.

It was unintentional. I didn't realise that the
cmp bx, 0
was comparing the address and not the value at the address.
>>
>>54836218
is this for osdev?
>>
Anybody send help
I found this
>http://morf.lv/modules.php?name=tutorials&lasit=21

And sometimes it crashes "SIGSEV" and i have no idea why i had this before and it was when i tried to send/write data in a closed/disconnected qtcpSocket
>>
>>54836233
Yeah just starting
>>
>>54836274
what resources are you using?
>>
>>54836329
I know about OSDev and the various other tutorials, but I like how slow this one is so I'm using it for now https://www.cs.bham.ac.uk/~exr/lectures/opsys/10_11/lectures/os-dev.pdf
>>
>>54836357
i actually used that too
>>
What is the area in industry/academic circles in which functional reigns over imperative?
>>
File: 1444700676915.jpg (823KB, 1920x1080px) Image search: [Google] [Yandex] [Bing]
1444700676915.jpg
823KB, 1920x1080px
/dpt/-chan, daisuki~

>>54835778
>bx will never be 0
>add bx, 0x1
This should make bx overflow to zero when its value equals 65535

>>54833163
diamonds ?
>>
>>54836390
fedora-tipping
>>
File: 6489.jpg (497KB, 2560x1440px) Image search: [Google] [Yandex] [Bing]
6489.jpg
497KB, 2560x1440px
>>54836390
PLT
>>
>>54836427
aka leeching government funds to talk about endofunctors
>>
>>54836387
Yeah lots of well worded explanation.
>>
>>54836390
none?
>>
I've only ever made some basic web applications (mostly project management/task assignment stuff). I'm looking at making a basic desktop application that will effectively be a time clock.

Here's what I want it to do:

Have a list of employees that you can add/remove
Allow each employee to clock in and clock out multiple times a day
At the end of the week generate a report for each employee that shows each day and a total number of hours at the end of the week

I know how I can implement the features but what I'm not sure about is the structure. I'm not sure what classes I should use. Should there be an employee class, a timeclock class, and a report class or should all of the functionality be consolidated to one or two classes?

I wind up with analysis paralysis when I try to think of how to organize things like this and then I never start coding. I know how I'd do it as a website but I'd prefer this to be a desktop application that I can learn the basics of C# through.

Thanks for any and all help.
>>
>>54836483
>Have a list of employees that you can add/remove
employee class

>Allow each employee to clock in and clock out multiple times a day
timeclock class
>At the end of the week generate a report for each employee that shows each day and a total number of hours at the end of the week
report class or a generateReport method of the timeclock class
>>
>>54836427
Why is it so smug?
Also why the fuck can i see its eyebrows on top of the hair
>>
Have any of you guys learnt programming completely online (No lynda or any other paid course bullshit) and are now good at it? Is a professor mandatory for learning a language?
>>
>>54836607
the thing barely even looks human with those freaking animu eyes
>>
>>54836616
a professor is hardly any help at all, going to a school just slows you down and is only for getting the degree and maybe networking, it's better to self-learn programming
>>
>>54836607
to make the character's emotions more obvious to the reader. zelda wind waker did the same with great success.
>>
>>54836681
>the reader
autists and children that is
>>
>>54836607
>Why is it so smug?

There is high demand for smug anime grills.
>>
>>54836647
>it's better to self-learn programming
You still need to practice working with other people who are experienced, or you'll end up doing something in a horribly inefficient way for a long time.

Best case scenario is to learn enough for an entry-level position and learn as much as you can on the job.
>>
I just love that whenever someone criticizes OOP, people immediately jump and assume that they must be a "functional programmer", and then rattle off the same, incorrect, knee-jerk "le FP no side effects useless" and things like that.
>>
>>54836920
Noted.
>>
>>54836920

People's criticisms of OOP are usually substance-free. Moreover, the people who posit these non-arguments typically are functional or procedural programmers. I don't recall one of the OOP-haters preferring any paradigm aside from those two.
>>
int width, height;
bool gotwidth = false;
bool gotheight = false;

FILE* f = fopen("size.txt", "r");
int pos = 0;
char linebuffer[256];
char c;
while ((c = fgetc(f)) != EOF)
{
if (c != '\n')
{
linebuffer[pos] = c;
pos += 1;
}
else
{
char* string;
pos = 0;
strncpy(string, linebuffer, pos);
string[pos] = '\0';
if (!gotwidth)
{
width = atoi(string);
gotwidth = true;
}
if (!gotheight)
{
height = atoi(string);
gotheight = true;
}
}
}
fclose(f);


This causes a crash, but I can't see what's wrong with it. Any C gurus want to give it a look?
>>
>>54836976
>People's criticisms of OOP are usually substance-free.
Not really. It's easy to show that OOP is a failure, in that encapsulation doesn't control state very well. It's also easy to show that inheritance-based code reuse isn't nearly as powerful as composition-based code reuse, and that the restrictions OOP imposes on your data are typically not conducive to performance.
The common response is the wholly unsubstantiated "b-but you can't write big programs without OOP" and/or to immediately change the subject.

>Moreover, the people who posit these non-arguments typically are functional or procedural programmers.
That doesn't matter. You can't defend OOP by attacking FP, or anything else for that matter. They're not somehow polar opposites, where anything you say about one is negated for the other.
>>
>>54837088
>It's easy to show that OOP is a failure

By all means, do so. I'm not suggesting that OOP is the be-all end-all programming paradigm, but it's hardly as bad as its detractors suggest.
>>
>>54837065
Do you check if the file successfully opened? f will be null in that case.
>>
>>54836920
This is just you people (honestly think you do seem like a coordinated shit posting group right now) pretending that's the case. I've been opposed OOP for years without people assuming I'm in favor of FP to any large extent.
>>
>>54837142
>I've been opposed OOP for years without people assuming I'm in favor of FP to any large extent.

But truthfully, you are. You are a functional programmer.
>>
Yo for real the fuck is std and cout
>>
>>54837065
Why not something like this?
int width = 0, height = 0;
FILE *file = fopen("size.txt", "r");
if(!file) return;

char buffer[256];
fread(file, buffer, sizeof(buffer));
fclose(file);

sscanf(buffer, "%d %d", &width, &height);


I don't know C so you might need to adjust sscanf/fread calls but you get the gist.
>>
>>54837124
the file opens fine, i just checked

damn c is confusing
>>
>>54837119
OOP Is as bad as you make it. Pure OOP is pure garbage. A little OOP doesn't really matter. (and frankly a little OOP could easily be regarded as no OOP because it's a rather absolute paradigm).
OOP does nothing to assist the programmer though. You usually find that what people like about OOP is that it's the first time they've structured their programming in some way. It's also very common for it to be the first real libraries people use so they feel powerful perhaps.

What people tend to like about OOP isn't really about OOP most of the time. Polymorphism is one of those things I feel people confuse with OOP all the time. When people say that large software projects are impossible without OOP they usually mean they can't build large software without polymorphism.

Not all the time obviously. But often.
>>
>>54837156
I haven't used a functional programming languages. I'm an IP programmer to the core. I think that FP could be OK. The promises are appealing and the idea is way more solid than OOP. But I haven't really tried it so I can't say much about it.
>>
>>54837203
What's the intent there?
It's pretty hard to tell but it seems to me all you're doing us reading a file and extracting some ints
Wouldn't it be simpler for you to read the file and then extract the ints?
>>
>>54837119
The "point" of OOP is that you can control complexity by breaking things up into smaller components and hiding the inner workings of these components from one another by forcing them to communicate through "messages". This doesn't work, because without some other system in place, you have no guarantees about what OTHER objects are doing to a particular object. Now, OOP works against you because of how easy it is to hide away objects' dependencies on one another, especially if you're working in a team with the way OOP is usually taught (which is where OOP programmers say the strength of OOP lies, no?)
>>
>>54837203
>>54837203
char* string;
pos = 0;
strncpy(string, linebuffer, pos);

Read how strncpy works. You're declaring `string`, but not allocating or assigning it anything. Then you try to copy 0 characters to a place that doesn't exist, using an uninitialized pointer.
>>
>>54837249

What is your favorite lang?
>>
>>54837276
>you have no guarantees about what OTHER objects are doing to a particular object

lol @ you
>>
>>54837292
If you're making fun of the fact that I like to have the compiler work with me to provide guarantees, why would you ever use something like OOP, which posits to do this?

No matter whether you like to juggle everything in your own head or put it in your code and have the compiler check it for you, OOP does not accomplish what it's intended to do.
>>
>>54837291
A small subset of C++.
Really it'd be dumb to consider it my favorite language. It's what I have to live with. Arguably I could move to D or whatever. But I just feel they don't offer enough to be worth the move. Maybe I'm wrong though. I keep saying I should look into it but I don't.
>>
>>54837270
That is what I'm doing. Is there a better and much easier way of doing this?
>>
>>54837310
I making fun of the fact that you think you can't guarantee what's going to happen to an object.
>>
File: 7phuJaq6.jpg (42KB, 512x512px) Image search: [Google] [Yandex] [Bing]
7phuJaq6.jpg
42KB, 512x512px
>>54837318

Do it for him.
>>
>>54837323
Not just OOP, you can't. If you put another system in place like linear types, then why even bother using OOP in the first place?
>>
Being that you're coming from a subset of C++, you should read two articles on the D wiki:

D for C programmers
D for C++ programmers

They cover most of the feature differences.
>>
>>54837335
I have no clue as to what you mean by 'not just OOP'.

I like to use OOP/sane programming practices, or as I've taken to calling it, OOP + Sane Programming Practices.
>>
>>54837362
Alright, then, how does OOP help guarantee what will or will not happen to an object by some external force?
>>
>>54837321
Read the entire file into a buffer.
Read the entire buffer for the values you want and save them in some way.
Work with the ints.
If only to just get to ignore the fuzziness with files and just work with extracting ints from a stings.

I think maybe your problem is that atoi is rather picky. To me it looks like you're having two ints (presumably space separated) on the same line and want to take them one at a time.
>>54837196
This does pretty much what I'd do. Except this doesn't do it per line. As I assume is your intent.
>>
>>54837368
You said that you have no guarantees about what is being done to objects.

You can design your program with OOP principles and guarantee object behavior.

I'm not entirely sure what your argument is here.
>>
>>54837379
>You can design your program with OOP principles and guarantee object behavior.
Who's talking about substance-free arguments, again?
>>
File: 1442196753224.jpg (613KB, 3000x3000px) Image search: [Google] [Yandex] [Bing]
1442196753224.jpg
613KB, 3000x3000px
>>54833062
>using namespaces
>not writing everything yourself from scratch and just naming it in a failsafe way
please refrain from posting every again
>>
>>54837368

An object with no public fields or methods will not have its state changed by 'external force'.
>>
>>54837340
I'l check it out.
First thing tomorrow! Assuming nothing important comes up.
>>
>>54837391
So every object in your program should have no public interface?
>>
>>54837374
>Read the entire file into a buffer.
Do it line per line as the unix elders did, don't listen to this guy.
>>
am I doing it right
for i in xrange(1,100):
FIZZ = not bool(i%3)
BUZZ = not bool(i%5)
if FIZZ and BUZZ: print "FizzBuzz,",
if FIZZ: print "Fizz,",
if BUZZ: print "Buzz,",
else: print str(i) + ",",
>>
>>54837405

If you want to prevent any sort of sudden state change, sure. Of course, that also makes it useless, but that's what you wanted.
>>
>>54837421
So...you agree with me.
>>
>>54837405
the exposed interface is just some high-level functionality like setTripCode() and shitpost(), nothing that will break your program
>>
>>54837400
Not bad at all. I'd go for
i%3 == 0
instead of
not bool(i%3)
, it's less convoluted and better conveys your intent.

No wait there's a bug, you need elif on line 4 and 5, see why? And also you never output a newline which is strange
>>
>>54837405
https://www.youtube.com/watch?v=QM1iUe6IofM
This is OOP.
I think the first YouTube comment (for me anyway, by SGresponse) is a very nice summary of the video and OOP programmers. I agree that there's not that many people defending OOP.
>>
File: mofo.png (18KB, 444x241px) Image search: [Google] [Yandex] [Bing]
mofo.png
18KB, 444x241px
>>54837447
meant for hypocritical tripfag >>54837418

son of a bitch
>>
>>54837431
Nah he's just conceding that you're an idiot
>>
>>54837438
I don't think you understand the issue. setTripCode() clearly modifies the object's state. What if you're using the object from one thread and, from another thread, setTripCode() is called on it? You either have to make sure that this will never happen, put mutexes on everything, which is inefficient, or attempt to solve these bugs as they happen.

OOP has fixed nothing.

>>54837471
I'm an idiot how?
>>
>>54837452
TL;DW

>why does OOP dominate the instrustry?
>why does OOP not work?
durr
>>
>>54837447
>>54837465
I'm sorry, I forgot to take my trip off from over at /flag/tism on /int/
I'd rather not clog a terminal with newlines
Using an elif is moreover just an aesthetics thing, three ifs work just as well as one if and two elifs
>>
>>54837479
any non-trivial program has state for fuck's sake kill yourself idiot
>>
>>54837493
Exactly.
>>
>>54837487
>Using an elif is moreover just an aesthetics thing, three ifs work just as well as one if and two elifs
Oops, fuck me, I'm wrong. joj
>>
>>54837479
>I'm an idiot how?

You're asking for a way to eliminate state change in a paradigm that it designed for state change. If this is bothersome, use functional programming.
>>
>>54837481
Someone else here. I persist in my secret enlightened opinion that OOP is just such a fluid dogma that it either is ridiculously convoluted or takes up credit for things that it didn't make work. But no one cares, and we need this to separate the plebeian masses from those who really understand what's going on, and when they get to the control room, just don't change anything because it's in fact perfectly working even though it cunningly pretends like it doesn't.
>>
>>54837481
Because it's not OOP when it works. And it's not dominating the industry because most don't do OOP.
>tl;dw
Why even argue on 4chan if you can't even watch a video? Clearly no interest in furthering your understanding them.
>>
>>54837493
and if you pass around objects to different threads you use mutexes in those parts, not in the object itself
>>
>>54837509
I'm not asking to eliminate state change, I'm asking to CONTROL it. OOP claims to do this (as a significant part of controlling complexity), but it doesn't. OOP is designed to write programs that have unchecked state mutation everywhere? Sounds pretty awful to me.

Haskell in particular (not FP in general, though) controls state change by eliminating it, yes. I much prefer that state change is allowed, but controlled through linearity.

>>54837537
Same outcome.
>>
>>54837533
you're just trying to redefine the term 'OOP', just accept what OOP could mean to someone who can think in shades other than black and white
>>
How the fuck do I functional algorithm
Like really, it pisses me off, got a 10/10 on my C++ exam, but a fucking 2/10 on my fucking functional algorithm exam, why the fuck do they need some fucking sentences in a fucking program

So who got a nice online lesson ?
>>
that's oddly satisfying


>inb4 "kek@memes" how dumb xDDD
>>
File: bananaman.jpg (232KB, 1536x1158px) Image search: [Google] [Yandex] [Bing]
bananaman.jpg
232KB, 1536x1158px
>>54837487
>>54837508
Yep, I see you understand what you're doing. Congratulations, you passed the Python FizzBuzz trial, here's your Codemonkey diploma. No offence for the tripstuff, I hereby grant you pardon for this faux pas. (Yeah don't take it too seriously when you get called a mofo on 4chin, obviously. But you knew that, soo)
>>
>>54837537
>you use mutexes
>in those 'parts' not in the objects
OK? So you're telling me you're not doing OOP anymore. What you should be saying is that you should have a manager class which stores the state you need. How you're gonna pass messages in that structure starts getting tricky after a while but it can work.
>>
>>54837546
you are controlling the state for fuck's sake, that's what the setter methods are for, you set the state in a controlled manner and the object is designed to work properly no matter its current state
>>
>>54837568
see >>54837552

the mutexes are in the threaded OBJECTS

kill yourself
>>
>>54837572
Except when you throw threads into the mix, and you have to lock everything behind a mutex instead of ensuring that only one thing can ever mutate a given piece of state at a time. Or not do that, and keep it all in your head, which may work for personal projects but never for a team.
>>
>>54837564
>Terminator
>~/Desktop
>Bash
How new are you
>>
>>54837590
any non-trivial multithreaded program requires a mutex or memory barrier of some sort KILL YOURSELF RETARD
>>
>>54837599
I'm waiting.
>>
>>54837593
I hate LXTerminal, wanted to get rid of it. Personally I could give less of a fuck.
Is working on Desktop haram or something?
I have a zsh config, I'm just to lazy to change it. :^)
>>
>>54837606
fuck off and die smug tard
>>
>>54837590

It's a good thing that procedural programming has eliminated the need for mutexes when using threads.

oh, wait..
>>
>>54837614
I'm smug for asking you to substantiate your argument?

>>54837616
Never said it did. I said linear types do, which are usable in any "paradigm".
>>
>>54837552
>shades other than black and white
OK so you'd consider it functional programming if you do imperative stuff all over the place?
Why can't you accept that you don't follow a paradigm dogmatically?
Because if your program is at odds with the idea of OOP it's not an OOP program. It may have sections of the program which encapsulates the state properly and passes messages like a real OOP program. But just because you have that doesn't make the entire program OOP. It's just that one bit.
I have pure functions in almost any program I write. I'd never call my program written under a functional programming paradigm because my max(a, b) is a pure function. That'd be dumb. And if that's' redefining' a paradigm then maybe consider just how many different programming paradigms exist in a single program and if these labels would make any sense to use in that case.

If your break out of the FP scheme your language starts being an IP program.
If you break out of the OOP scheme your program stops being OOP.
>>
File: captainbanana.jpg (204KB, 520x520px) Image search: [Google] [Yandex] [Bing]
captainbanana.jpg
204KB, 520x520px
>>54837616
Ok, so basically both of you are arguing something orthogonal to the issue of OOP versus non-OOP, right? Maybe either we move on to another topic, or one of you actually presents an argument which makes this relevant to the issue?
>>
>>54837564
needs bigger titlebar
>>
>>54837630
>if it's not 100.0% what i personally deem as "OOP" it's not OOP
literally black and white thinking

and you're doing the same as what you're accusing OOP of doing, you're trying to relabel everything as whatever is your favorite paradigm

kill yourself
>>
for i in range(1, 100):
if i%3 == 0 and i%5 == 0:
print("FizzBuzz")
elif i%3 == 0:
print("Fizz")
elif i%5 == 0:
print("Buzz")
else: print(i)
>>
>>54837656

I'm not here to actually argue the matter, all I said earlier was that OOP detractors are poopyheads.
>>
>>54837656
>the issue of OOP versus non-OOP
That isn't the issue. I'm saying OOP is useless, in isolation.
>>
>>54837678
>I'm saying OOP is useless, in isolation.

Sure, but only because multi-paradigm is GOAT.
>>
>>54837695
What I mean is that OOP is useless, and there's no practicality to having it included with other paradigm(s).
>>
>>54837630
Point to a 100% OOP program then, it'll be intersting. If you don't, that's OK, I'll just argue that OOP is a fuzzy dogma in which everyone picks what best suits them and the problem they have at hand, and that in fact it shouldn't be considered a thing by itself, but rather a blob. Or maybe we keep the secret?
>>
>>54837678
you're just talking shit

>>54837715
kill yourself
>>
>>54837723
Great arguments.
>>
>>54837678
>OOP is useless in isolation
Agreed. I'd say it shouldn't even be considered a thing in serious company, just a lure for dogmatic programmers to reveal that they have no critical thinking skils, but that's just my randomish opinion.
>>
>>54837728
as if you made any sensible argument lmfao off yourself
>>
>>54837715

Not an argument.
>>
>>54837716
>and that in fact it shouldn't be considered a thing by itself, but rather a blob
That's the thing, though. When you realize that OOP as its own thing is useless, you also realize that the "useful parts" of OOP are not specific to OOP and in fact are much better realized in the context of e.g. FP.

>>54837742
I already made my arguments.
>>
>>54837669
wrong

fizzbuzz goes until 100
for i in range(1, 101): <------------
if not i%3 and not i%5:
print("FizzBuzz")
elif not i%3:
print("Fizz")
elif not i%5:
print("Buzz")
else:
print(i)
>>
File: goat.gif (8KB, 300x165px) Image search: [Google] [Yandex] [Bing]
goat.gif
8KB, 300x165px
>>54837728
Agreed, best arguments ever, I'm totally convinced. ALL HAIL SIMULA!
>>
>>54837748
Not an argument.
>>
>>54837748
110% agreed. Should we keep it tho? Is the fact that you can realise this useful?
>>
is there a reason why i wouldnt be able to download galleries from imgur with a script
>>
>>54837771
You can't really tell OOP to fuck off entirely, because it's possible to do in anything with pointers or closures. People will emulate it because it feels good.

I don't think it's worthwhile to put features in languages that are specifically to make writing OO code easier, though. The language I'm designing already has closures, dependent types, linear types, etc. so there's literally nothing to gain from adding "OO features" like records with private fields.
>>
>>54837662
I'm not accusing OOP of relabling anything. OOP is a paradigm that's separate from what it's users understand it as.
Did I ever say I genuinely consider programs to follow paradigms as a whole? No. I didn't. What I said was that you're ignoring what an OOP solution would be to a problem and labeling it as the OOP solution. While it's actually just the border where you stopped using OOP because you'd much rather not have it work like that. Just like how I can enjoy pure functions because I don't have to worry as much but I don't find them appropriate all the time.

Id never label a section of code which does IP as FP because that'd be contradictory. With OOP if you break the rules you shouldn't either. You felt that OOP was convenient for some section of your program but for this other thing it wasn't.

If OOP solves everything it should work for all situations (I'm not saying you're saying that, but there's people who think that). But if you break OOP you have to stop pretending your entire program is OOP. Others (more reasonable imo) argue that OOP is appropriate for modeling certain systems (usually you find it in stuff like GUI). That's fine. Have that opinion. Argue why OOP is so great there. I can disagree but we're not even getting there because most OOP programmers I talk to pretend like they made polymorphism, the only way to do polymorphism is inheritance and it's the only way to keep large programs in check. And commonly they consider polymorphic code to be indicative of object oriented programming.

>>54837716
OOP isn't a fuzzy dogma really. But it's like arguing with anarchists. Tons of promises based on a single idea which they generally don't agree with entirely.

OOP itself is clearly defined though. I don't know of pure OOP programs. I'd imagine college kids write that during their first few years. At least some of them. Monkeys with typewriters.
>>
>>54837779
Either your script a shit or they're rate limiting.
>>
>>54837748
>I already made my arguments.

Sophistry, at best.
>>
>>54837835
Deconstruct them, then. How am I wrong?
>>
Whenever somebody mentions C being obsolete, the response is usually "BUT EMBEDDED"

But I keep seeing embedded devs say they do all their work in C++ or Java nowadays...
>>
>>54837822
TL;DR

enjoy those hot opinions of yours
>>
>>54837863
They're actually extremely moderate and personally I'd suggest it as a read. But I'm very bias of course.
>>
File: 1431389665411.gif (973KB, 256x186px) Image search: [Google] [Yandex] [Bing]
1431389665411.gif
973KB, 256x186px
>>54837822
>Id never label a section of code which does IP as FP because that'd be contradictory. With OOP if you break the rules you shouldn't either.
>>
>>54837824
neither actually i was just modifying a version of my text file that's sitting in another folder
>>
>>54837822
>OOP itself is clearly defined though.
Provide def pls.

>I can disagree but we're not even getting there because most OOP programmers I talk to pretend like they made polymorphism, the only way to do polymorphism is inheritance and it's the only way to keep large programs in check. And commonly they consider polymorphic code to be indicative of object oriented programming.
>Monkeys with typewriters
agreed

Problem is when someone with power drinks the kool-aid and you have to prove to them that you're applying OOPrick tho.
>>
>>54837844
> OOP is designed to write programs that have unchecked state mutation everywhere? Sounds pretty awful to me.

In this point, which you made earlier, you are missing the point of OOP. It was never intended to prevent, or restrict, or "check" state change. It was meant to provide meaningful interfaces for the state change to occur.

I think people get stuck on the phraseology of "encapsulation! encapsulation! encapsulation!"
>>
>>54837873
>>54837882
you label a PROGRAM as being based around a certain paradigm. if an FP program has some parts that are imperative it's still FP. also, if a program is OOP it doesn't mean it's not imperative, you should be arguing about OOP vs procedural vs functional or imperative vs functional, not OOP vs imperative.
>>
>>54837916
>It was never intended to prevent, or restrict, or "check" state change. It was meant to provide meaningful interfaces for the state change to occur.
So it's not a failure, it just never tried to be very useful in the first place?

I mean, I understand that controlling state is not a big deal in a small program, that you're writing yourself, that doesn't need multithreading or can get away with just using mutexes everywhere. But that's not what OOP proponents like to talk about. They like to talk about how OOP is awesome for massive software with big teams. That's when it's really important and it's something that OOP simply cannot do.
>>
>>54837822
So basically your argument is
>there are people who claim OOP should be used exclusively
>there are people who claim OOP should be used to model certain systems in a program
>the latter are wrong because the former exist
>the former are wrong
>thus OOP is stupid
>>
>>54837882
I thought it was pretty clear I meant that if you stop doing OOP you've stopped doing OOP and should recognize that. It's just more clearer to present the FP IP example because FP programmers have a more realistic world view usually and don't pretend their non-FP code is FP.

>>54837912
https://en.m.wikipedia.org/wiki/Object-oriented_programming
This is pretty decent. It's not a controversial thing though. I imagine most sources that aren't 'tutorials on OOP' (prone to not do OOP because it's useless alone) could explain it to you.

Encapsulation is core to OOP though. And that's really where the problems start.
>>54837924
>if an FP program has IP parts it's still an FP program.
I think you'd disagree that a cake entirely made gluten free should contain gluten.
Please elaborate a bit. You can say it's 'primarily FP' or OOP or whatever. I'd never complain about that.
>>
>>54837973
>So it's not a failure, it just never tried to be very useful in the first place?
>being THIS smug
kill yourself

and multithreading is fucking irrelevant, you're fucking clueless, OOP is compatible with multithreading, FP or IP or whatever doesn't magically solve multithreading
>>
>>54838000
>OOP is compatible with multithreading, FP or IP or whatever doesn't magically solve multithreading
I never said otherwise. OOP is perfectly compatible with safe and efficient multithreading, yes, but OOP cannot be responsible for it. The only other thing OOP is good for is ensuring that an object can't be in an invalid state, but that's solved with a better type system in a way that doesn't involve making details hard to get at when you need them.
>>
>>54837973
>That's when it's really important and it's something that OOP simply cannot do.

Tbh, it seems to work fine for that purpose. I don't think there's a paradigm in existence that hasn't been denigrated as being 'incapable for use in large software projects'.

As a non-argument, it's fairly common.
>>
>>54837990
>Please elaborate a bit. You can say it's 'primarily FP' or OOP or whatever. I'd never complain about that.
of course an OOP program can contain pure functions or whatever, doesn't necessarily make it non-OOP. i think you're stuck in the black and white thinking mentality that just because something is labeled as OOP it has to be your arbitrary overly strict definition of OOP that it's a set of classes and objects and nothing else or something
>>
>>54838042
>of course an OOP program can contain pure functions or whatever, doesn't necessarily make it non-OOP. i think you're stuck in the black and white thinking mentality that just because something is labeled as OOP it has to be your arbitrary overly strict definition of OOP that it's a set of classes and objects and nothing else or something
I never said otherwise. OOP is perfectly compatible with safe and efficient multithreading, yes, but OOP cannot be responsible for it. The only other thing OOP is good for is ensuring that an object can't be in an invalid state, but that's solved with a better type system in a way that doesn't involve making details hard to get at when you need them.
>>
>>54837822
>>54837630
Holy shit, you've managed to have the most asinine opinions I've read in this thread.

Nice.

>If it isn't 100% OOP, it's not OOP

LOL
>>
>>54838034
OOP may work fine in big projects, but it's not helping much with regards to controlling complexity for the reasons I've set out. OOP isn't necessarily a detractor of code quality, either, unless you're not using anything else because you think OOP is perfect or something.

>>54838056
Eh?
>>
To whoever asked what [1,100] is, that's range notation in mathematics

[1,100] is (1..100) inclusive
(1,100) would be exclusive

I don't actually think anyone's even fucking done it yet
>>
>>54838070
>OOP may work fine in big projects, but it's not helping much with regards to controlling complexity for the reasons I've set out.

Even functional languages cannot innately control complexity or quality (after all, there will be naive implementations until the end of time). Best practices are more important than paradigm if you want a large project to be useful, modular, readable, etc.
>>
>>54837983
No I haven't even begun arguing about why OOP is wrong yet. There's so much confusion about what OOP is that it wouldn't make sense to try before we at least make some sort of definitions for the discussion.

Personally I do hold that OOP serves no real purpose. But at this snails pace I'd never get to say why. The short explanation would be that for OOP to be convenient to use you have to escape it at first wim. It's woefully unfit for programs you iterate on. And I think you will see that with how most OOP is taught. There's upfront design. If the requirements change (as they do) or you've made an error they're a large hassle to work around. With Multiparadigm you're not limiting yourself to solutions that are inconvenient.

And again. This is just a very short explanation PRESUMING the understanding of what OOP is like what I have. I'm not talking about how you're not supposed to have member functions for your classes or structs or any of those things new programmers think makes OOP OOP. It's about the OOP. Which I've been trying to elaborate on what it is.
>>
>>54838099
>Even functional languages cannot innately control complexity or quality (after all, there will be naive implementations until the end of time). Best practices are more important than paradigm if you want a large project to be useful, modular, readable, etc.
I mean, I understand that controlling state is not a big deal in a small program, that you're writing yourself, that doesn't need multithreading or can get away with just using mutexes everywhere. But that's not what OOP proponents like to talk about. They like to talk about how OOP is awesome for massive software with big teams. That's when it's really important and it's something that OOP simply cannot do.
>>
>>54838070
>unless you're not using anything else because you think OOP is perfect or something
Literally no one is saying this, because that's the equivalent of using the Linux kernel with no operating system.
>>
>>54838091
The issue is that it's not range notation in Haskell.

>>54838099
Didn't say that either, I was talking about linear types specifically with regard to controlling state. It's also funny that you keep bringing up FP because this all started when I said that people who criticize OOP will always be met with attacks against other things instead of defenses of OOP itself.
>>
>Ctrl-F OOP
>More than 100 matches

Today is off to a great start I see
>>
>>54838091
Thank you captain obvious. Except it's not so in pretty much any lang we know of, and that we still don't know what KoolAid OP was on. Also the French notation is better.
>>
>>54838125
Not OOP.
>>
>>54838056
i'm not even talking about multithreading in >>54838042, multithreading doesn't really have to do with the paradigms, i'm saying that you should call a spade a spade, that if a program makes use of classes and objects it was probably written with OOP concepts in mind
>>
>>54838117
I know. I was saying that that's the only way OOP could really have a negative effect on your code - if you're using it instead of something else because you THINK that the OOP solution is good enough.
>>
>>54838119
>It's also funny that you keep bringing up FP because this all started when I said that people who criticize OOP will always be met with attacks against other things instead of defenses of OOP itself.

I'm not defending OOP, I'm just saying that these issues are not solely relegated to OOP.

Sawdust, plank, etc.
>>
>>54838062
this
>>
>>54838119
>>54838128
It's the language of mathematics you complete fucking faggots
>>
>>54838042
OOP can have a pure function, only touching the state of the object you're in (effectively that's what member functions tend to be, through the implicit this pointer).

So there's a barrier. But I've never said you can't use FP with OOP. What I've said is you can't use IP with FP and when you start using IP in a way that conflicts with OOP it stops being OOP.

Nothing surprising there. This is obvious stuff. If we're dealing with classes, objects and a proper message model were in OOP land. Move away from that and we're not.
>>
>>54838149
That's irrelevant, though.
>>
>>54838174

It's pretty relevant, though, considering the accusations of uselessness could be evenly applied across most/all strict paradigms.

Don't be retarded, now.
>>
>>54838167
Ocaml is a functional language
>>
OOP. OOP? OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP.
OOP. OOP. OOP. OOP. OOP! OOP? OOP? OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP.
OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP? OOP! OOP! OOP? OOP! OOP? OOP.
OOP! OOP. OOP. OOP? OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP.
OOP. OOP. OOP! OOP? OOP? OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP?
OOP! OOP! OOP? OOP! OOP? OOP. OOP. OOP. OOP! OOP. OOP. OOP. OOP. OOP. OOP. OOP.
OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP! OOP. OOP! OOP. OOP. OOP. OOP. OOP.
OOP. OOP. OOP! OOP. OOP. OOP? OOP. OOP? OOP. OOP? OOP. OOP. OOP. OOP. OOP. OOP.
OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP! OOP? OOP? OOP. OOP. OOP.
OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP? OOP! OOP! OOP? OOP! OOP? OOP. OOP! OOP.
OOP. OOP? OOP. OOP? OOP. OOP? OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP.
OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP! OOP? OOP? OOP. OOP. OOP.
OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP. OOP.
OOP. OOP? OOP! OOP! OOP? OOP! OOP? OOP. OOP! OOP! OOP! OOP! OOP! OOP! OOP! OOP.
OOP? OOP. OOP? OOP. OOP? OOP. OOP? OOP. OOP! OOP. OOP. OOP. OOP. OOP. OOP. OOP.
OOP! OOP. OOP! OOP! OOP! OOP! OOP! OOP! OOP! OOP! OOP! OOP! OOP! OOP! OOP! OOP.
OOP! OOP! OOP! OOP! OOP! OOP! OOP! OOP! OOP! OOP! OOP! OOP! OOP! OOP! OOP! OOP!
OOP! OOP. OOP. OOP? OOP. OOP? OOP. OOP. OOP! OOP.
>>
>>54838183
i was just pretending to be retarded
>>
>>54838160
There is no such thing as a language of mathematics, asshat. Only notational conventions that are more common than others. Still, without a tractatus or a reference to one, your fag program isn't well-defined, quite the opposite.
>>
>>54838167
fuck off with this black and white thinking stupid sperg

you label something as OOP or FP to get the gist of what kind of paradigm it's build upon, you don't label it as "IP with a bit of OOP and a dash of FP", that's just retarded
>>
>>54838195

I prefer this dialect of Ook. It is better.
>>
>>54838167
>touching the state of a the object you're in
>pure
pick one. Sure you CAN write actual pure functions, but not all member functions are pure functions, your statement blows away all the laws of pure function, and that's not an argument anyway soo.
>>
NEW THREAD >>54838244
>>
>>54832945
from sys import stdout as so

for i in range(1, 101):
if i % 3 == 0:
so.write("Fizz")
if i % 5 == 0:
so.write("Buzz")
if i % 3 != 0 and i % 5 != 0:
so.write(str(i))
print

> Here. It is unnecessary to make a separate case for numbers divisible by 15.
>>
>>54838154
>>54838062
OK so what motivates that a Multiparadigm approach should be considered OOP?

I don't see why it should. And again. I've made it perfectly clear again and again there's hardly any programs that are pure OOP to my knowledge (C++ doesn't even allow it as I understand, since you need a main that isn't class bound, but I'm not sure I don't do OOP much obviously).

But there can be sections of programs that follow paradigms and you can evaluate the non-multiparadigm approach (since multi paradigm approaches are so common it's hard to find cases where you can evaluate FP, OOP or whatever you like well if we constrained it to entire programs)

But I'm just repeating myself now. I'm pretty sick of how much I can write and yet none of you dinguses seem to get it. It's not a difficult concept to grasp. A chocolate cake contains chocolate. A cake made OF chocolate is just chocolate. The chocolate cake is Multiparadigm (presumably), the cake made of chocolate is just chocolate (OOP, bad analogy because I like chocolate).

I'm not sure I can reach more than this. It should be obvious by now.
>>
Ok, theoritical question incoming.

Is there a way to calculate the maximum number of logic gates that can exist for a set number of inputs and outputs?

To clarify I don't need the exact number, I just want to create an array that will contain their results.
>>
>>54838183
At that particular issue, sure. It's the linear type system that solves the issue of controlling effects, not the programming paradigm (although pure functions by default mean that you add effects as needed instead of taking them away everywhere).

I don't like talking in paradigms, anyways, it's meaningless. It's just that the actually useful parts of OOP, when you break it down, are outclassed or subsumed by the "equivalents" you find associated with other paradigms.
>>
>>54838268
if it's overwhelmingly or primarily based on OOP you could label it as OOP
>>
>>54838268
>pure OOP
Stop this shit.

No one waltzes into a room, grinning confidently, and announces
>MY PROGRAM HAS ATTAINED PURE OOP STATUS

You've got some fucked up idea of what you think should be labeled as OOP.

In reality, OOP is simply a set of practices that gives you direction on how to manage states of data and create structure for a large application.

It's fuzzy, it's not agreed on, and everyone does 'OOP' differently.

Stop being autistic.
>>
>>54838290
Yes.
>>
>>54838214
>black and white thinking
I'm pretty sure you're the one doing that. Nothing is Multiparadigm everything is OOP or non OOP (potentially qualified by other label).

What would you call a section of code which doesn't qualify as OOP but uses some OOP things? What if it has some pure functions in it. What if it's imperative. I call that Multiparadigm. (it seems) You call it whatever happens to fits your argument.

My approach is clearly not black and white. It's more that everything is a dithered blend of black and white forming grey but when you look close enough you can distinguish if any individual section is black or white. If you come up with grey you're either not looking close enough or you're looking at a scope where there's no determining. A simple operation on types could not be considered any paradigm. They're larger than that.
>>
>>54832945
> I got you:
for i in range(1, 101):
if i == 3:
print "Fizz"
if i == 5:
print "Buzz"
if i != 3 and i != 5:
print str(i)

> Enjoy, lol. 3 and 5 are the only "Fizz/Buzz primes"
>>
>>54838247
Well it works because of the implicit this pointer. As I said. It's always an input. So there's FP and OOP overlap there.
>>
>>54838353
see >>54838299 >>54838325

if there is say 40% OOP 40% FP 20% procedural you could call it multi-paradigm

if the program is 80% """"pure OOP"""" with some sections of code that doesn't qualify as OOP in your book it's not incorrect to say that it's still fucking OOP
>>
>>54838375
No m8, if you mutate an input, you're not pure, period. I think you're cuntfusing impure and using global state/global variables, that's not the same flaw.
>>
>>54833163
seriously how often can deadlock happens
>>
>>54838350
Care to share anon?
>>
>>54838414
it doesn't have to happen at all if you design your program carefully enough
>>
>>54838416
inb4 axiom of irrelevance of proof
>>
File: Untitled.png (32KB, 819x364px) Image search: [Google] [Yandex] [Bing]
Untitled.png
32KB, 819x364px
As I said yesterday, today I took my time to finish FizzBuzz in Game Boy assembly.

Source pastebin:
http://pastebin.com/sX8s5A4h
Hardware.inc pastebin:
http://pastebin.com/uWBwmVGx
Addsubb pastebin:
http://pastebin.com/wN0FwRea

Download .gb ROM from here:
https://drive.google.com/file/d/0B2YI91EWUu1AWTl2c05kM3pJaWc/view?usp=sharing
>>
>>54837065
pos = 0;
strncpy(string, linebuffer, pos);


why are you copying 0 bytes ?
>>
>>54838416
Basically, you just have to write the equation of the output, and the number of operations is your maximum number of logic gates:

For example, here's a table representing a xor, with A and B as input, and O as output.

AB|O
00|0
01|1
10|1
11|0

You can write the equation of O by looking everywhere O == 1, and adding (OR) a product (AND gate) and negating (NOT) whether A or B is 0.

O = /A.B + A./B
If you want the minimum number of gates, you can just reduce the expression to
O = A ^ B.

If you're looking to write expression of multiples input/outputs, you might want to take a look at Karnaugh maps.
>>
>>54838526
Thanks anon, but I was speaking entirely hypothetically.
Assuming that we don't know the equation, just the numbers of inputs and outputs, could we calculate the maximum number of gates that could exist and create a circuit that is unique?
The more I think about it the number seems infinite.
>>
>>54838706
Let's say N input and 1 output.
Your table will have 2^N rows of N - 1 ANDs and possibly N NOT, if your looking at the less optimal solution.

Maximum number of gates = 2^N * (N - 1) * N

I think you can multiply that by your number of outputs.
>>
>>54838771
That makes sense (at least it seems to).
Thanks a lot.
>>
>>54838706
Look at the sum of products and product of sums techniques. I don't remember the details exactly, but you can use either one to generate a circuit for any function. Obviously the circuit is not optimal, it usually has a lot of redundancy and grows very quickly when you increase the number of inputs or outputs.
I think (don't remember exactly) for N inputs and M outputs you would need
2^N and gates
M or gates
N not gates
This is assuming the every gate has enough inputs. If not (i.e. in the real world), you can cascade gates to build up larger gates with more inputs.
>>
>https://forum.qt.io/topic/29280/simple-tls-ssl-suppoerted-smtp-client-for-qt5

What do i need to change in order to send with a Micorsoft email ? outlook hotmail?
>>
>>54840061
Well, Pajeet, you'd need to look up the OWA APIs.
>>
>>54840132
sorry just came back from the streets

It looks like i need to switch it up to StartTLS 587 but i not sure how i'm following the responses and changed some stuff but now stuck on
"220 2.0.0 SMTP server ready\r\n"
>>
>>54840185
This is really not the place to ask about this particular subject. You'd be better off on stackoverflow or some specialized forums.
Thread replies: 340
Thread images: 26
[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.
If a post contains illegal content, please click on its [Report] button and follow the instructions.
This is a 4chan archive - all of the content originated from them. If you need information for a Poster - you need to contact them.
This website shows only archived content and is not affiliated with 4chan in any way.
If you like this website please support us by donating with Bitcoin at 1XVgDnu36zCj97gLdeSwHMdiJaBkqhtMK