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

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 339
Thread images: 31

File: DPT.png (389KB, 934x1000px) Image search: [Google]
DPT.png
389KB, 934x1000px
Old thread: >>57001843

What are you working on /g/?
>>
Haskell
>>
>>57008081
This is a good choice.
>>
I'll seek for reply in a new thread as well.
>>57007652
>>
>>57008101
Short answer: You're fucked.
Long answer: Just read on classes, inheritances, class members, operator overloading and stuff then grab a cpp file for any large project and see if you can describe the stuff, if you're missing something, read up on it as well. Afterwards try to write something yourself and catch up with whatever is blocking you from progressing.
>>
>>57008101

cppreference should have examples of using pretty much every language feature of C++.

http://en.cppreference.com/w/cpp/language/classes

They tend to favor struct over class in their examples, but keep in mind that the only difference between struct and class in C++ is that struct defaults everything to public, and class defaults everything to private.
>>
I've been stuck on the same problem for hours now, not sure how I can resolve it. I'm making two classes, one class is used as an entry point, the other class is doing all the work. However, in the second class, I need to be able to print the loop in it's own class member (not within the same class member). Not sure if that makes any sense, I'll just post my code

First class:
package moduloTest;

public class ModuloEntryPoint {

public static void main(String[] args) {
new ModuloPrint();

}

}


Second class:
package moduloTest;

public class ModuloPrint {

public ModuloPrint() {
for (int i=1;i<=70;i++) if (i % 5 == 0) System.out.print(" "+i);
System.out.println();
}

}


I want to be able to print the loop in a seperate class member, but when I try that, i is undefined. Could someone break down the bare boned basics for me?
>>
>>57008101
Find a C++ fizzbuzz example.
Memorize it.
Write it on your test.
Describe it.

EZ.
>>
>>57008228
class Three : protected Fizz
>>
>>57008228
https://ideone.com/5HU2Ia
>>
Are there tools to strip away unused parts of binaries by running them and seeing which parts never get executed/manipulated? -Os+uclibc still gives large binaries
>>
>>57008266
define large
>>
File: AAAAAAAAAAAA.png (164KB, 413x352px) Image search: [Google]
AAAAAAAAAAAA.png
164KB, 413x352px
>>57008266
>writing unreachable code
>>
>>57008279
3.6mb
>>
>>57008282
I didn't write it, dipshit.
>>
>>57008221
>for (int i=1;i<=70;i++) if (i % 5 == 0) System.out.print(" "+i);

First of all let's make this readable

for (int i=1;i<=70;i++) {
if (i % 5 == 0) {
System.out.print(" "+i);
}
}
System.out.println();


>it's own class member (not within the same class member).
You're right in that this doesn't make sense. Maybe you want i to be a static variable? I don't know what else to suggest. Maybe if you try to explain it better.
>>
>>57008256
Nice anon, looks very idiomatic.
>>
>>57008266
Have you tried a different compiler?
Nobody does embedded with GCC, it's too bloated for microcontroller work.
It's partially the reason why alternative libc libraries exist.
>>
>>57008266
Dynamically link libc instead of statically linking it. Or don't link libc at all.
>>
>>57008329
I used buildroot (gcc) and uclibc. What compiler should I use? It might be a better idea to go through the code and fix it, but I'm not familiar with the codebase. I was just wondering if the technology was available, there are probably better solutions to my problem.
>>57008342
I need a static binary.
>>
>>57008329
>Nobody does embedded with GCC, it's too bloated for microcontroller work.
That's demonstratively false, since GCC toolchains exist (and are quite popular) for both AVR and ARM. GCC doesn't mean that glibc is used, you can specify alternative libc implementations (or none at all, which are the most common with embedded).
>>
>>57008361
AVR and ARM aren't embedded platforms.
If your platform has an MMU, it's not embedded.
>>
>>57008318
public class ModuloPrint { /** <--- Class **/

public void ModuloWork() { /** <-- First class member **/
for (int i=1;i<=70;i++) if (i % 5 == 0);
}
public ModuloPrint() { /** <--- Second class member **/
System.out.print(" " +i);
}


I know it looks horrible, but it's something like this I'm trying to do. In the second class member, i cannot be solved for a variable, so it won't print anything. So, how do I get the variable/loop from the first class member, so I can print it in the second class member?
>>
>>57008378
>If your platform has an MMU, it's not embedded.
Both Atmel and ARM make more than one microprocessor with and without MMUs.
>>
>>57008448
>First class member
That's a method, not a member.
>>
File: this_image_gets_me.png (297KB, 2000x1336px) Image search: [Google]
this_image_gets_me.png
297KB, 2000x1336px
>tfw too intelligent and nihilistic to program
>>
>>57008448
I see, what you need is a field
That is a variable that is usable by the whole member. Oh and when you say class member, what you mean is class method.

Here is a working example:
https://repl.it/DsOT
>>
>>57008489
Take your "intelligence" elsewhere then.
>>
>>57008329
>Nobody does embedded with GCC, it's too bloated for microcontroller work.
What did he mean by this?
>>
>>57008520
I really wish all of those fucking feelfags and frogposters would fuck off to reddit.
>>
File: don't grope the miku!.jpg (179KB, 512x512px) Image search: [Google]
don't grope the miku!.jpg
179KB, 512x512px
How does this make you feel, /g/?

https://github.com/csnxs/Terraria/blob/master/Terraria/Item.cs
>>
>>57008489
>iPhone 6
It's not 2015 anymore grandma
>>
>>57008531
He meant that he has no clue what he's talking about and he thinks that GCC means a specific version of libc that always gets linked in, no exceptions.
>>
>>57008542
>This repo contains the decompiled source of the Terraria.exe binary
>decompiled
It doesn't make me feel anything.
>>
>>57008489
Truely, I envy you.
>>
File: 1448625612411.gif (510KB, 700x827px) Image search: [Google]
1448625612411.gif
510KB, 700x827px
>>57008547
>tfw too intelligent to make a livable wage
>>
>>57008558
Same, but I haven't felt anything in years.

>>57008540
No bully, we usually stick to our containment board (/r9k/).
>>
>>57008590
No, we're gonna fucking bully you back into your hole

>>57008540
I agree
>>
>>57008542
That's caused by a decompiler although it makes me wonder why would you embed the items in the source file rather than having an external JSON/XML/INI/whatever the fuck file with items.
>>
>>57008512
Thanks, I think I'm starting to get it. Only problem is that it just prints 71, when I want it to print 5 - 10 - 15 ..... 65 - 70.

Really though, thanks a lot, been stuck on this for hours, finally might make some progress.
>>
>>57008540
Maybe you should stop being so uptight then, it's not hurting anyone. Also here's a secret, the shitposters are the best programmers in the gen.
>>
>>57008653
>Maybe you should stop being so uptight then, it's not hurting anyone
You seriously need to fuck off.
>>
/dpt/ can't even calculate the average of an arbitrary number of size_ts

size_t avg(size_t n, const size_t v[static n])
{
assert(n < (size_t)SSIZE_MAX);
assert(n != 0);

size_t lo = 0, hi = 0;

for (size_t i = 0; i < n; i++) {
hi += __builtin_add_overflow(v[i], lo, &lo);
}

if (hi == 0) {
return lo / n;
}

size_t val = 0;
for (size_t shift = 0; shift < sizeof(size_t) * CHAR_BIT + 1; shift++) {
val <<= 1;
val += hi / n;
hi %= n;
hi <<= 1;
hi += (ssize_t)lo < 0;
lo <<= 1;
}

return val;
}
>>
>>57008676
If you keep being mean to me I can't guarantee your safety
>>
>>57008700
>assert(n < (size_t)SSIZE_MAX);
>assert(n != 0);
>__builtin_add_overflow
You fail, mate.
>>
>>57008729
"no"
>>
>>57008676
I second this
>>
>>57008055
Anyone used OCaml before? Is it any good?
>>
>>57008737
It doesn't work for every possible input value and relies on non-standard shit.
You fail.
>>
>>57008781
>standard C
lol, enjoy being slower than Java
>>
>>57008781
>average of 0 numbers
hmmm
>>
>>57008823
The empty sum should be 0.
But I was actually pointing out that it can't accept arrays of any size.

>>57008700
Here is my version:
unsigned long ulavg(unsigned long n, const unsigned long arr[static const n])
{
unsigned long avg = 0UL;
unsigned long rem = 0UL;

for (unsigned long i = 0UL; i < n; ++i) {
avg += arr[i] / n;

unsigned long a = arr[i] % n;

if (rem >= n - a) {
rem = a - (n - rem);
++avg;
} else {
rem += a;
}
}

return avg;
}


>>57008788
>Standard C is slow
What?
>>
>>57008875
>Here is my version:
very slow
>>
fuck brehs

So I'm relatively new to programming (6 months) and I made up a personal project to use at a career fair. Problem is, everyone loved it so I think they're going to offer me an interview based on how good it was (to them). This is what it is:

>uses yahoo finance api to get data of stocks on FTSE100
>stores this data in a database
>creates graph which can be viewed in an application

This isn't too tough right? Could I feasibly do this within a couple of weeks?
>>
>>57008887
unsigned avg(unsigned a, unsigned b)
{
return (a + b) >> 1; // do you want fast or correct, nigga?
}
>>
File: 1475956772428.jpg (21KB, 365x378px) Image search: [Google]
1475956772428.jpg
21KB, 365x378px
>>57008918
>forgot to add image
>>
>>57008887
>very slow
Why?
    .p2align 4,,15
.globl ulavg
.type ulavg, @function
ulavg:
.LFB11:
.cfi_startproc
testq %rdi, %rdi
je .L17
xorl %r9d, %r9d
xorl %r8d, %r8d
xorl %ecx, %ecx
.p2align 4,,10
.p2align 3
.L16:
movq (%rsi,%r9,8), %rax
xorl %edx, %edx
movq %r8, %r10
movq %rdi, %r11
subq %rdi, %r10
divq %rdi
addq %rcx, %rax
subq %rdx, %r11
addq %rdx, %r10
leaq 1(%rax), %rcx
addq %r8, %rdx
cmpq %r8, %r11
cmovbe %r10, %rdx
cmova %rax, %rcx
addq $1, %r9
movq %rdx, %r8
cmpq %r9, %rdi
jne .L16
.L14:
movq %rcx, %rax
ret
.L17:
xorl %ecx, %ecx
jmp .L14
.cfi_endproc
.LFE11:
.size ulavg, .-ulavg
.ident "GCC: (GNU) 6.2.1 20160830"
.section .note.GNU-stack,"",@progbits

I'm only seeing 1 division and one branch (for the loop condition) here.
>>
>>57008932
because
$ time mine
0.25 total
& time yours
0.35 total
>>
>>57008942
I'm going to need a more comprehensive benchmark than that.
I'm not taking your word for it.
>>
>>57008948
way ahead of you senpai

#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>

size_t avg_fast(size_t n, const size_t v[static n])
{
assert((ssize_t)n > 0);

size_t lo = 0, hi = 0;

for (size_t i = 0; i < n; i++) {
hi += __builtin_add_overflow(v[i], lo, &lo);
}

if (hi == 0) {
return lo / n;
}

size_t val = 0;
for (size_t i = 0; i < sizeof(size_t) * CHAR_BIT + 1; i++) {
val <<= 1;
val += hi / n;
hi %= n;
hi <<= 1;
hi += (ssize_t)lo < 0;
lo <<= 1;
}

return val;
}

size_t avg_slow(size_t n, const size_t arr[static n])
{
unsigned long avg = 0UL;
unsigned long rem = 0UL;

for (unsigned long i = 0UL; i < n; ++i) {
avg += arr[i] / n;

unsigned long a = arr[i] % n;

if (rem >= n - a) {
rem = a - (n - rem);
++avg;
} else {
rem += a;
}
}

return avg;
}

#define N 50000000

int main(void)
{
size_t *vals = malloc(sizeof(*vals) * N);
for (size_t i = 0; i < N; i++) {
vals[i] = SIZE_MAX;
}

#ifdef FAST
size_t res = avg_fast(N, vals);
#else
size_t res = avg_slow(N, vals);
#endif

printf("%lu\n", res);
printf("%lu\n", SIZE_MAX);
}
>>
>>57008055
New to Java here, what are some good small projects to get started?
>>
>>57008955
This initial loop is actually very expensive so you get better results by using this main function:

int main(void)
{
size_t *vals = malloc(sizeof(*vals) * N);
for (size_t i = 0; i < N; i++) {
vals[i] = SIZE_MAX;
}

struct timespec start, end;

clock_gettime(CLOCK_MONOTONIC, &start);

#ifdef FAST
size_t res = avg_fast(N, vals);
#else
size_t res = avg_slow(N, vals);
#endif

clock_gettime(CLOCK_MONOTONIC, &end);

printf("%lu\n", res);
printf("%lu\n", SIZE_MAX);

long mus = (end.tv_sec - start.tv_sec) * 1000000 +
(end.tv_nsec - start.tv_nsec) / 1000;

printf("in %ld microseconds\n", mus);
}
>>
java101 question.

Lets say I'm making a simple bank account program to practice inheritance.

In my main method, what's the difference between

 
BankAccount account1 = new SavingAccount();
BankAccount account2 = new CheckingAccount();

//and

SavingAccount account1 = new SavingAccount();
CheckingAccount account2 = new CheckingAccount();
>>
File: 1469226267181.png (7KB, 212x238px) Image search: [Google]
1469226267181.png
7KB, 212x238px
>>57008918
pls help me guys
>>
>>57008918
>made up a personal project
So you literally didn't have anything? Maybe you should ask for some venture capital.
>>
i'm making a C library to interact with FAT12 filesystems. i'm also making a CLI frontend for it so you can create FAT12 images without having to make a program and link against the library
>>
>>57008918
>>uses yahoo finance api to get data of stocks on FTSE100
ez. Just scrape some json API.
>>stores this data in a database
ez. Just database calls
>>creates graph which can be viewed in an application
You could cheat and just create an excel sheet. I'm sure there are some graph libraries that would make it easy to do yourself.

Gl anon. Remember stack overflow and google are your key to success.
>>
>>57008777
It's good ish

Better than imperative langs
>>
>>57009025
That's nice, but can you average two ints in C or are you a webcuck in too deep?
>>
HI
Where can I find GOOD resources on functional programming?
>>
>>57009038
What is this meme?
>>
>>57009052
reactive*
>>
>>57009056
It's a stale meme. Ignore it.
>>
java
>>
>>57009052
SICP
>>
>>57009038
>webcuck
>knowing how a filesystem works
hah, a true webcuck wouldn't even know what FAT12 is.
>>
>>57009077
>FAT12
>file system
You're literally just saving memory pages to disk. Hardly a file system.

Also,
>implying average webcucks doesn't know more about file systems and database optimizations than a fizzbuzz master on /g/
>>
>>57009001
cmon fuckers, this is a quick answer i just need to know
>>
>>57009052
I am here

>>57009103
The difference is in the first example, account1 and 2 are cast to BankAccounts, while in the second example they are labelled with their exact subtypes
>>
>>57009001
Case 1: account1 and account2 have static type BankAccount.

Case 2: account1 has static type SavingAccount. account2 has static type CheckingAccount.
>>
>>57009063
Did someone once try to divide the sum of two very small floats and got an absurd result, and everyone went C is shit because hurr floating point operations, or what?
>>
File: amba.webm (2MB, 1280x720px) Image search: [Google]
amba.webm
2MB, 1280x720px
/dpt/-chan, daisuki~

>>57008932
>Why?
Because of this
        unsigned long a = arr[i] % n;

if (rem >= n - a) {
rem = a - (n - rem);
++avg;
} else {
rem += a;
}


>>57008777
Yes, i don't like the syntax, the object model sucks, the main implementation is quite fast but doesn't have parallel multi threading (only time sharing). overall, it's a good pl.

>>57008632
To prevent modifications, to optimize, ... it's not uncommon to generate C# code from a xml file.

>>57008542
__decompiled source__

>>57008540
please, don't bully.

>>57008266
https://linux.die.net/man/1/strip
http://reverse.lostrealm.com/protect/strip.html

>>57008055
Thank you for using an anime image.
>>
File: briebuttrub.webm (559KB, 594x808px) Image search: [Google]
briebuttrub.webm
559KB, 594x808px
>>57009122
Thanks!
>>
File: Custom Database Ripping.png (1MB, 1917x1005px) Image search: [Google]
Custom Database Ripping.png
1MB, 1917x1005px
My webcrawler/data aggregator can now be passed any site and have it save arbitrary data from them by tag
here's paheal, in the process of being ripped and sorted by auto detected tags
>>
>>57009196
almost forgot
>it saves the data into a database if that wasn't obvious
>>
/dpt/ doesn't even know how to unroll loops.

gcc -funroll-loops
>>
>>57009214
>oh hai, i'll just increase the size of my executable by a factor of hundred
>>
>>57009220
/dpt/ doesn't even know about

gcc -Os -funroll-loops
>>
Hey,

should I use python 2 or 3 for a uni project? It's basically an economic calculation/linear programming that I will have to port from visual basic to python, with a js front end.

Also what is a decent ide, ideally like vs studio since I haven't worked with python in quite a while

Cheers
>>
>>57009220
doesn't matter when storage limits are nonexistent but you can get only so many clock cycles
>>
>>57009231
/dpt/ doesn't even know about the new iCache from apple.
>>
>>57009214
>funroll-loops
sounds like a delicious kids cereal.
>>
>>57009231
>what is random access memory

>>57009226
You have to be an idiot, because it literally says in the documentation that -Os will cancel out unroll-loops.

/dpt/ can't even RTFM
>>
>>57009214
>>57009226
for what purpose

if anything, apply it to individual critical functions with __attribute__, and make sure you benchmark it to see if it's actually helping

>>57009231
>what is icache
>>
>>57009248
>You have to be an idiot, because it literally says in the documentation that -Os will cancel out unroll-loops.
even if you put -funroll-loops AFTER -Os?
>>
>>57009226
>>57009214
>Not using -O7 -funroll-all-loops
>>
>>57009231
>he doesn't know about the instruction cache
>>
>>57009261
Why ask 4chan when you can refer the documentation?
>>
>>57009244
>>57009248
>>57009249
>>57009263
ez
>>
>>57009279
>j-j-j-joke's on you, i-i was just pretending... le ebin trole xDDDDD
>>
>>57009277
you're an idiot

putting -funroll-loops AFTER -Os is fine if that's what you want
>>
>>57009295
>"read the documentation instead of using 4chan as your go to search engine"
>"you're an idiot"

What did he mean by this?
>>
>>57009323
you're even more autistic than i am

you can choose to understand or you can waste your time with this retarded shitposting
>>
>>57009323
He meant that talking to people on 4chan is more fun than reading documentation.
>>
this guy made the retarded claim:

>>57009248
>You have to be an idiot, because it literally says in the documentation that -Os will cancel out unroll-loops.
>/dpt/ can't even RTFM

my post in >>57009261 merely challenged his claim, i already knew the answer
>>
>>57009333
>What did he mean by this?
4chan is what I do for procrastination....

As in: it's LITERALLY what I do when I have time to waste.

You truly are autistic.
>>
>>57009345
see, most of you tards are LITERALLY fucking pathetic timewasters, i'm closing this thread now, i just finished my coffee anyway
>>
>>57009353
your contributions to the thread will be dearly missed
>>
>>57009196
Does dropbox sync code/repositories well? I tried Google drive but it would duplicate and rename shit and it fucked it all up. I'm too lazy to use git.
>>
>>57009369
It does.
It's not good for version control, though. I just use it for ez code sharing between my desktop and laptop, and as an extra backup for git (and as a way to get code onto machines without git)
>>
I am just starting to learn how to program. All I know is excel (accounting/finance)

I have been advised to learn SQL for marketability in my field and Python for learning actual computer science. Once comfortable with Python, I should branch out to other programming languages.

Am I being rused?
>>
>>57009339
>>57009295
You're wrong though, -Os takes precedence.

If you don't believe me, look at the disassembled code.
>>
>>57009379
>Python
>Am I being rused?
You have an excellent sense of intuition
>>
>>57009022
kek

>>57009031
thanks much anon, I'll do this
>>
>>57009387
but MIT teaches their intro course in Python, what should I learn first?
>>
>>57009401
>MIT

Please. Who do you trust, some random MIT niggers or 4chan, the pinnacle of human knowledge and insight?
>>
>>57008918
This is literally doable in one day.

You'll be fine.
>>
>>57009401
Python is by dumbasses for dumbasses
>>
>>57009401
keep in mind that what is good or even mostly harmless for a student in that class may not be so for you
>>
>>57009379
>>57009387
>>57009412
>>57009430
http://cacm.acm.org/blogs/blog-cacm/176450-python-is-now-the-most-popular-introductory-teaching-language-at-top-u-s-universities/fulltext
>>
Prolog is pretty bad for errors. I want to make a relationship that goes through a list of 'books(Title, Author, Genre, Pages)' and returns the book monty_python as the title. What am I doing wrong? Here's what I have:

mp(List,Book) :- List(Book|[_]), Book(monty_python,_,_,_).
mp(List,Book) :- List(_| [_|Tail]),mp(Tail, Book).
>>
>>57009439
like all dynamically typed langugaes, it's good for introducing newbies to programming and nothing else.
>>
>>57009430
>Python is by dumbasses for dumbasses
It's actually the inverse, Python is more concerned with making it easy to write good programs than difficult to write bad ones. Python favor good and talented programmers over the poor ones.
>>
>>57009430
>>57009379
python s good for web crawling programs as it is easy to write.
So unless you are doing a lot with the web, you should learn a different language

An easy language to start with is c#, java is a bit harder as you have more stuff you can mes up.
>>
>>57009455
>Python is more concerned with making it easy to write good programs than difficult to write bad ones.
All common langugaes are concerned with that.
>>
File: 1451635700062.jpg (144KB, 1220x976px) Image search: [Google]
1451635700062.jpg
144KB, 1220x976px
>>57009455
You're retarded, you have no idea what you're talking about.
>>
>>57009455
>it's actually the inverse
Fuck off
>>
>>57009483
no, read the java white paper for example.
>>
>>57009501
yeah, what does it say?
>>
>>57009486
Damn, that's some good c@ butt.

>>57009483
Except maybe Java; it's got fucktons of red tape and no-fun-allowed to aid massive codebases with questionable programmer skill levels.
>>
>>57009511
read it
>>
>>57009514
>c@ butt
?
>>
>>57009514
>it's got fucktons of red tape and no-fun-allowed to aid massive codebases with questionable programmer skill levels.
yes, in a desperate effort to make sure the programmer doesn't write something that isn't going to work properly.

I think Java isn't that great for many reasons, but the same goes for python.

I don't see what would make someone say that python makes it easier to write good programs more than other common languages.
>>
>>57009520
I suppose it's 'cat', but I don't know why he would say something so pointless.
>>
HOW DO YOU TEST THE TIME IT TOOK TO PERFORM AN ALGORITHM IN VISUAL STUDIO
>>
>>57009563
System.Diagnostics.Stopwatch
>>
>>57009563
What lang
>>
>>57009527
No arguments here.

However, I'd agree with:
>Python makes it easier to write programs

Whether good or bad.
>>
>>57009578
c++
how to write it out? sorry I'm shit
>>
>>57009591
Execpt for all the times it doesn't, which is most of the time. Python's type system makes it literally impossible to debug anything at all.
>>
>>57009563
>>57009596

>t1 <- get time
>perform algorithm
>t2 <- get time

>return (t2 - t1)
>>
What's a good resource for learning C?

Working through Build Your Own Lisp atm but the learning curve has gone vertical at chapter 7, having trouble making any sense of what's going on, feel like a secondary learning resource could be a help here.

Suggestions?
>>
What's the general knowledge I need to get into security.
Is there a specific language that os prefered, or just general knowledge about computers and how they work?
Any good literature on the subject, or online courses via edx or coursera?
>>
>>57009617
What part specifically?
>>
>>57009617
>What's a good resource for learning C?
K&R
>>
>>57009596
On windows you have something called QueryPerformanceCounter. Look it up in msdn
>>
>>57009591
>However, I'd agree with:
>Python makes it easier to write programs

that's why a specifically said "good programs".
>>
>>57009527
python doesn't care about such things as private/public, manifest typing, checked exceptions, ... those add complexity to the code and make it more verbose.
>>
>>57009603
>Python's type system makes it literally impossible to debug anything at all.
lel, ok tard. due to it's dynamic properties, the language itself is a debugger.
>>
>>57009660
>those add complexity to the code and make it more verbose.
agreed. They are make it easier to write good programs. That's my point.
>>
File: no problems.png (11KB, 477x181px) Image search: [Google]
no problems.png
11KB, 477x181px
>>57009603
>>57009665
>>
>>57009665
>the language itself is a debugger.
jesus christ guys...
>>
>>57009665
>the language itself is a debugger
McFucking What
>>
>>57009665
Does that include syntax errors too?
>>
>>57009682
https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop
https://en.wikipedia.org/wiki/Reflection_(computer_programming)
https://en.wikipedia.org/wiki/Type_introspection
>>
>>57009699
Most langugaes have those features. I guess most langugaes are debuggers then by your logic?
>>
>>57009699
Are you saying that when you load a Python file, it will tell you the type errors?
>>
>>57009738
https://ideone.com/vVMbYo

a = "123" + 1


stderr
Traceback (most recent call last):
File "./prog.py", line 1, in <module>
TypeError: Can't convert 'int' object to str implicitly
>>
>>57009753
That happens when you execute it anon, not when you load it. Do you what loading a python file means?
>>
File: esmssenalso.jpg (50KB, 720x540px) Image search: [Google]
esmssenalso.jpg
50KB, 720x540px
>>57008055
static int decrypt(uint8_t *data, unsigned int dataLen)
{
uint32_t acc = 0xCC;
for ( unsigned int i = 0; i < dataLen; i++ )
{
uint8_t acc2 = data[i];
data[i] ^= acc;
acc = acc2;
}
return 0;
}


Can someone please help me get this piece of code running? It's for decrypting 6 binary files from the Gauss NSA framework. I just want to have a small program that:

./unxor -i infile.dat -o outfile.bin
>>
>>57009753
https://ideone.com/aimDXa
def g(x):
return "123"
def f(x):
return x + 1
def z(x):
return f(g(x))

>success
>>
>>57009689
Syntax errors are exceptions.
Exceptions are objects in the language.
So I'll guess yes.
>>
Don't bother friends, pythonistas are helpless.
>>
>>57009791
>Syntax errors are exceptions.
Not actually true.

No one here but you even likes python and we still need to explain to you how your favourite language works.
>>
>>57009768
>That happens when you execute it anon
exactly, the language, being dynamic, allows me to catch such errors in the dynamic environment. https://ideone.com/gfq2Vl

>>57009768
>Do you what loading a python file means?
This is called compilation, pleb.
>>
>>57009826
>exactly, the language, being dynamic, allows me to catch such errors in the dynamic environment.
but not when you load it. which was the anons question.

The correct answer would be: no.

Also statically typed languages catch the same errors at runtime too. Python doesn't have some kind of special ability here.
>>
>>57009809
he's right. https://ideone.com/aPmouU
>>
>>57009847
No he's not. An exception is something handled by the runtime.
>>
>>57009837
he used an inappropriate terminology. loading a file in python does mean both compilation and execution.

>>57009864
which i did here.
>>
>>57009875
>which i did here.
syntax errors do not occur at runtime.
>>
>>57009809
>Syntax errors aren't exceptions

$ cat > some_shit.py
fuck)(
$ python some_shit.py
File "some_shit.py", line 1
fuck)(
^
SyntaxError: invalid syntax
$ python
>>> try:
... import some_shit
... except BaseException as e:
... e
...
SyntaxError('invalid syntax', ('some_shit.py', 1, 5, 'fuck)(\n'))
>>
>>57009837
>Also statically typed languages catch the same errors at runtime too.
having to handle such errors would mean that the type system is broken.
all the mainstream statically typed languages which predate python have type erasure.
>>
>>57009899
WHat's even going on here? Within the context of the compiler source code i guess a "SyntaxError" is probbaly an exception, but not in the context of the language itself.

What's going on from the 8th line on?
>>
>>57009948
>which predate python
What about ones that don't predate python and are mainstream? Why should only langugaes that predate python count?
>>
>>57009948
>having to handle such errors would mean that the type system is broken.
So you're saying python is broken?
>>
>>57009809
https://docs.python.org/3.7/library/exceptions.html#SyntaxError
>>
>>57009976
No, python is not statically typed
>>
So can we all agree that dynamically typed languages are pure cancer.
>>
>>57009950
In Python everything is an object. Even syntax errors.

>>> SyntaxError
<type 'exceptions.SyntaxError'>
>>> raise SyntaxError('ur a faget', ('some_filename', 1337, 13, 'this is the line'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "some_filename", line 1337
this is the line
^
SyntaxError: ur a faget


You can raise a syntax error on a made up filename at a made up line at a made up offset with a made up text in the line and with a made up message.
>>
>>57010025
oh right, you're raising a syntax error at run time. Got it.

You can do that shit in C# too if you want. Lots of langugaes have eval shit.
>>
File: kurt-godel.jpg (735KB, 765x1138px) Image search: [Google]
kurt-godel.jpg
735KB, 765x1138px
>>57009778
Kurt needs your help, please
>>
>>57010015
Dynamic typing isn't the problem, it's weak dynamic typing.

And Python, Python is also the problem.
>>
>>57010046
>at run time
Nigger, C# does that before you even try to compile.

You can't really get runtime syntax errors in C#, which is a good thing.
>>
>>57010015
Agreed, but language should also be able to allow it in some cases.

See: C#'s
dynamic 
keyword
>>
>>57010015
why
>>
>>57010015
It simply shouldn't be the default behavior.
>>
File: 1417392129126.jpg (11KB, 800x600px) Image search: [Google]
1417392129126.jpg
11KB, 800x600px
Just wasted 1h figuring out why the shebang line did not work.
Apparently Linux can't into CRLF line endings while interpreting the command.
>>
>>57010224
>shebang
>not "The Exclamatorie Octothorpe"
>>
>>57010224
Yes, you need to use UNIX line endings on a UNIX-like system.

Shocker I know.
>>
>>57010260
I'm not saying it's the fault of the OS and it should handle that MS abomination, but would it have hurt to include a more helpful error message than

>Failed to execute process './file'. Reason:
>', which is not an executable command.ified the interpreter '/usr/bin/<cmd>

Principle of least surprise applies here and it's the small thing that make an OS user friendly.
>>
>>57010015
Yes.
>>
My current project is being paralyzed by indecision. Help.
>>
>>57010330
Flip coins and throw dice.
>>
>>57010320
>>57010224
When it comes to filenames, the kernel gives absolutely no fucks about the character used, besides '/' and '\0'. It doesn't even do any parsing beyond that. It's just an opaque stream of bytes.
So pretty much, the kernel was doing exactly what it was supposed to and treated '\r' like any other character.
>>
>>57009778
>4chan cannot even help people with simple C style questions

fuck this board, only python faggots
>>
File: 1243667958271.jpg (49KB, 740x419px) Image search: [Google]
1243667958271.jpg
49KB, 740x419px
>>57010394
>mfw all the bugs created because of OSX normalizing and silently fucking up filenames before writing them to disk
>>
>>57010330
Are you sure you want help?
>>
File: 1476093225417.jpg (18KB, 250x226px) Image search: [Google]
1476093225417.jpg
18KB, 250x226px
I'm so tired.
>>
>>57010691
same senpai, I had like 2 hour sleep last night
>>
has dpt any active community project right now ? i am pretty good at programming and willing to help
>>
>>57010152
>You can't really get runtime syntax errors in C#
you can if you do runtime evals with roslyn.
>>
>>57010691
but aren't you 2 smart too sleep?
>>
>>57010742
I've made some good logos in the past. Maybe /dpt/ should diversify horizontally and start a graphics design business.
>>
>>57010755
Great idea. I'll get on making the company logo.
>>
>>57010742
A project by /dpt/- no. But there are several projects by people that post in /dpt/. I'm writing a realtime imageboard. https://github.com/bakape/meguca
>>
File: 1470343533729.jpg (45KB, 421x445px) Image search: [Google]
1470343533729.jpg
45KB, 421x445px
>>57010742
>i am pretty good at programming
Are you sure about that?
>>
File: 2016-10-10-161235_324x251_scrot.png (31KB, 324x251px) Image search: [Google]
2016-10-10-161235_324x251_scrot.png
31KB, 324x251px
>>57010786
honestly yes

offtopic: what the fuck is that captcha ? (pic)
>>
>>57010774
top meme
>>
>>57010836
>the current year
>not having a 4chan pass
>>
>>57010752
That's why I said "can't really", dumb faggot.

There are always exceptions.
>>
>>57010862
>2016
>paying the greedy chink
>>
>>57010774
we already have
https://github.com/microsounds/akari-bbs
http://akaribbs.mooo.com/
please stop making imageboard
>>
>>57010877
>That's why I said "can't really"
And that's why I explained why that's not true.
>>
>>57010015
>let's take the primary tool for static verification in a programming language and delay it until run time
Yep, pretty much.
>>
>>57010893
No.
>>
>>57010893
except akaribbs is garbage made by a fool
>>
Just learned about member pointers in C++. That's a pretty nice feature.

Captcha: Calle

wtf is calle. I've been getting calle quite often recently.
>>
>>57010330
My whole life is being paralyzed by indecision. Help.
>>
>>57010144
dynamic typing is also the problem
>>
>>57008641
Not him, but something like this maybe:
https://repl.it/DsOT/1
>>
Sup guize.

This is probably a dumb question because I'm a complete noob, but what would be the best/cleanest way to do this in Java:

I have a super class with several extending sub classes. There can be multiple different instances of these subclasses at the same time. What I need is that whenever a piece of code creates a new instance of this super class, it selects one of the subs at random and makes a class of that subtype.

Ideally I'd want the thing to automatically realise how many sub types there are and pick one at random, so I can add or remove sub types at will without having to touch existing code, though I'm not sure if that's even possible and if it is how I should do that.

To make it a simple example, if I have a superclass "Car" and subclasses "Ford", "Audi" and "Volkswagen", I want to make it so that the program randomly makes a Ford, Audi, or Volkswagen whenever I need a Car.

No need for a detailed explanation unless you feel like giving one, but I'd very much appreciate any tips to send me off in the right direction.
>>
>>57011165
You can't do that with a constructor for Car, but it could be a static method of Car like Car.create. To do it automatically, you'll need reflection, but reflection sucks and you're better off just doing it manually.
>>
File: programin.png (5KB, 624x121px) Image search: [Google]
programin.png
5KB, 624x121px
Is this correct? It's only the third week of doing this programming module in uni and I'm lost as fuck.
>>
File: 1476005453310.png (689KB, 1520x1080px) Image search: [Google]
1476005453310.png
689KB, 1520x1080px
>>57011165
>OOP
>>
>>57011192
it's java incase you didn't know already and that helps
>>
>>57011165
i doubt there's a library you can import that already does that but maybe there is. otherwise you may have to do it yourself. which should be easy enough. with a random number generator and a condition block
>>
>>57011192
yes
>>
>>57011192
google java default constructor
>>
File: cersei.png (12KB, 588x207px) Image search: [Google]
cersei.png
12KB, 588x207px
Made this today: https://asoiaf.now.sh/

It's a Markov chain based qutoe generator for characters in A Song of Ice and Fire based on what they've said. Used a NLP library to extract and identify the speaker of quotes to generate the base. Had a lot of fun :)
>>
File: 1466022268928.jpg (42KB, 637x438px) Image search: [Google]
1466022268928.jpg
42KB, 637x438px
>>57011210
thank you

>>57011218
I did and was still confused, just came for a definitive yes or no before submitting it.

Gonna nestle into my notes for the rest of the night and cry now
>>
>>57011230
>Poor Jon, our half brother, Arya, Arya and I were remarking on how pleased we were crossing the neck, I'll send for you sooner.
-sansa

really makes you think
>>
>>57011230
make it alphabetical reee
>>
>>57011207
Yeah I thought about that option, but it would be a bit clunky since I'd have to manually edit the code every time I add a new sub. At this point I have no way of determining how many subs there will be (in fact I expect it'll keep growing over time) so I was hoping for a cleaner solution.

>>57011197
I'm sorry senpai, like I said I'm a noob and I haven't really done much FP at all. OOP feels much more intuitive to my lizard brain.

>>57011187
I'll have a look at how reflection works, thanks. If it does turn out to suck I guess I'll just do it manually like a caveman.
>>
>>57011165
use an array that stores functions that create new instances, then use a random number generator to call one of those
>>
File: 8nLh.png (45KB, 720x644px) Image search: [Google]
8nLh.png
45KB, 720x644px
>>57011232
nvm, just submitted the test and got 50/50, that was the only answer I needed help with, ebin.

Maybe things aren't so bad
>>
>>57011269
stupid frogposter no wonder you needed mental help
>>
File: 8Lng.jpg (11KB, 250x201px) Image search: [Google]
8Lng.jpg
11KB, 250x201px
>>57011273
I don't usually frogpost but retard pepe speaks to my soul

you are correct
>>
>>57010998
>Calle
"Street" in Spanish.
>>
Why is the "protected" status in Java so retarded?

Did they really just want to be different than C++ for the hell of it?
>>
>>57011230
looks pretty
>>
>>57011307
How is protected different in Java than C++?

Does it differ from C#?
>>
>>57011307
>Why is X in Java so retarded?
There are many many questions like these. The answer is almost always that the Java devs are really just that retarded.
>>
File: PRgBUVn.jpg (1MB, 2448x3264px) Image search: [Google]
PRgBUVn.jpg
1MB, 2448x3264px
>>57010982
please, don't bully.

>>57010742
you must be crazy to post any code on /dpt/, trust me. just see >>57010982
>>
>>57011290
>retard pepe
all pepes are retarded
like the people who post them
>>
>tfw doing interviews in python instead of a language i actually like
>>
>>57011165
import java.util.ArrayList;
import java.util.Random;

abstract class CarBuilder {
abstract Car build();
}

class Car {
protected Car(String name) {
this.name = name;
}

public final String name;

private static ArrayList<CarBuilder> builders = new ArrayList<>();

protected static void registerBuilder(CarBuilder b) {
builders.add(b);
}

public static Car build() {
if (builders.size() == 0) {
throw new IllegalStateException("hurr durr");
}

Random gen = new Random();
int idx = gen.nextInt(builders.size());
return builders.get(idx).build();
}
}

class Ford extends Car {
private static class Builder extends CarBuilder {
Car build() {
return new Ford();
}
}

static void init() {
Car.registerBuilder(new Builder());
}

private Ford() {
super("Ford");
}
}

class Audi extends Car {
private static class Builder extends CarBuilder {
Car build() {
return new Audi();
}
}

static void init() {
Car.registerBuilder(new Builder());
}

Audi() {
super("Audi");
}
}

class Main {
static int i;

public static void main(String[] args) {
Audi.init();
Ford.init();

for (int i = 0; i < 10; i++) {
System.out.println("Car type: " + Car.build().name);
}
}
}
>>
>>57011477

what are your complaints with python?
>>
>>57011477
should not be a problem, python is like writing pseudo code.
>>
>>57011543
that's why i'm doing it
>>
http://149.202.189.83/
Script or noscript?
>>
>>57011477
Python is literally _the_ best language for interviews. Forgot an API call? Just use English and it's probably correct.
>>
>fired the only black employee recently
>feels weird making lighthearted black jokes now
>almost want to pull the affirmative action card just so we can have a token, because black programmers are so rare

Feels weird, man.

>>57011496
I'm pretty sure the idea was to not have to modify the code every time a subclass was added.

For that, you'd use reflection, yes?
>>
>>57009448
have you traced through it?
>>
>>57011355
Java protected gives access to everything in the same package as well as any derived classes (including those in different packages), which are completely different scopes that have no real business being bundled like that. As a result, Java has no way to restrict access to just derived classes, which would be actually useful. If you want to do that, you have to grant access to the entire package.

It's not a huge deal in most situations, it just struck me as a really pointless way to divide up access restrictions.
>>
https://docs.oracle.com/javase/specs/jls/se8/jls8.pdf

This looks like shit in chromium's pdf reader. How do they even manage that?
>>
>>57011595
>tfw I've never even seen a black programmer in real life
>>
>>57010025
It's not a syntax error, it's just an exception called 'SyntaxError'. You can't handle syntax errors in the same module/file in which they occur.
>>
>>57011711
Programming as a career has it's advantages..
>>
>>57011644
It also means that something which is "protected" (access granted to derivatives and the package) is actually _less_ protected than something with no modifier at all (access granted to just the package), which is just counterintuitive.
>>
>>57011748
Java is just nightmarish
>>
The only visibility that matters is public vs. private to the module. A powerful type system means encapsulation isn't necessary to preserve invariants, only to hide implementation details so they can be changed without having far-reaching implications.
>>
a language should not create problems that users of the language must solve in order to use the language

http://stackoverflow.com/questions/7510182/how-does-stdmove-transfer-values-into-rvalues/7518365#7518365
>>
>>57011595
Where is your company based? How many do you employ?
>>
>>57011804
Texas.

A little under 50.
>>
>>57011803
This. Lifetimes are just one thing Rust does so much better than C++.
>>
should i learn rust?
>>
>>57011900
no its a shit language for hipsters
>>
File: tumblr_lyz38enidG1qzwqifo1_1280.jpg (68KB, 645x700px) Image search: [Google]
tumblr_lyz38enidG1qzwqifo1_1280.jpg
68KB, 645x700px
static int decrypt(uint8_t *data, unsigned int dataLen)
{
uint32_t acc = 0xCC;
for ( unsigned int i = 0; i < dataLen; i++ )
{
uint8_t acc2 = data[i];
data[i] ^= acc;
acc = acc2;
}
return 0;
}


Can someone please help me get this piece of code running? It's for decrypting 6 binary files from the Gauss NSA framework. I just want to have a small program that:

./unxor -i infile.dat -o outfile.bin
>>
File: romme.png (718KB, 1280x720px) Image search: [Google]
romme.png
718KB, 1280x720px
anyone got tips on how to make better graphics for games? I just take some stock photo and change it a little bit because I suck at drawing
>>
>>57011900
Do you oozing out genderfluid like a cum soaked onahole? Then yes. https://github.com/rust-lang/rust/pull/25585
>>
>>57011964
How does this affect actually programming in the language?
>>
Reading about "inheritance mappers" in Fowlers enterprise architectures book.

here is the excerpt -

>" The basic behavior of the find method is to find the appropriate row in the database, instantiate an object of
the correct type (a decision that's made by the subclass), and then load the object with data from the database.
The load method is implemented by each mapper in the hierarchy which loads the behavior for its
corresponding domain object. This means that the bowler mapper's load method loads the data specific to the
bowler class and calls the superclass method to load the data specific to the cricketer, which calls its
superclass method, and so on."

why couldn't each subclass just load all of the data on it's own? why does he recommend that each subclass load only it's specific data, then delegate up the hierarchy?

is there something fundamental I'm not understanding here?

He even gives a code example (C#)

class CricketerMapper...
protected override void Load(DomainObject obj, DataRow row) {
base.Load(obj,row);
Cricketer cricketer = (Cricketer) obj;
cricketer.battingAverage = (double)row["battingAverage"];
}

class AbstractPlayerMapper...
protected override void Load(DomainObject obj, DataRow row) {
base.Load(obj, row);
Player player = (Player) obj;
player.name = (String)row["name"];
}

class Mapper...
protected virtual void Load(DomainObject obj, DataRow row) {
obj.Id = (int) row ["id"];
}


what's wrong with

class CricketerMapper...
protected override void Load(DomainObject obj, DataRow row) {
Cricketer cricketer = (Cricketer) obj;
cricketer.battingAverage = (double)row["battingAverage"];
cricketer.name = (String)row["name"];
cricketer.id = (int) row["id"];
}
>>
>>57011964
the pain is real
>>
File: Goodgraphics.png (251KB, 542x390px) Image search: [Google]
Goodgraphics.png
251KB, 542x390px
>>57011961
If it's just 2D images, either learn to draw or hire someone to draw shit for you.
>>
>>57011961
There are plenty of free (libre or near libre) graphics online.
opengameart is a good place I think, has music too iirc
>>
>>57011989
Prevents code duplication.
>>
>>57011999
Checked em, but can't do either

>>57012013
looks good thanks!
>>
>>57011980
It doesn't. In fact, the dining philosopher's example doesn't exist anymore in the book, so the sjw's effort was for nothing.
>>
>>57011989
I think the idea is to prevent code duplication. "id" only gets set in the Mapper class, instead of in every class that implements Mapper.

That shit looks nightmarish though if you ask me. That kind of code shares shit loads of state between inevitably complicated inheritance structures that becomes a nightmare to read and debug when you have problems.

I think it's kinda daft to share stuff like "id" fields via inheritance. Inheritance should be used very very sparingly. The first principle of OOP is to always prefer composition over inheritance. A very small number of OOP devs practice this though, especially in enterprise.
>>
Maybe I should have posted this on here
>>57012010
>>
>>57011999
fuck i miss homestar runner...
>>
File: cs.jpg (1MB, 1904x4706px) Image search: [Google]
cs.jpg
1MB, 1904x4706px
>>57011900
https://github.com/rust-lang/rust/pull/25585
>>
>>57012106
>The first principle of OOP is to always prefer composition over inheritance.

Not that i don't agree with this but: [citation needed]
>>
Inheritance is just syntactic sugar for a special case of composition + interface implementation.
>>
anyone here ever coded a neural net that's worth more than shit?
>>
>>57012136
I don't know. I read it in Head First design patterns years ago.

Maybe it's not the first principle or whatever...
>>
>>57012152
it also enables polymorphism.
>>
>>57012198
>+ interface implementation
>>
>>57012106
yeah. it does seem silly, which is why my brain was trying to comprehend it. I thought there must have been some compelling reason other than reducing code duplication.

I could see a situation in which there are 50 different classes, but with a small domain model, which have few fields, is the duplcation really such a big deal? I think not, and having each mapper load ALL of it's concrete object classes data is fine. Plus it's a lot simpler. and readable.
>>
>>57012152
no
>>
>>57012201
yeah, but you can't have polymorphism with just interfaces alone right? ... i guess you sorta can can't you... hmm
>>
>>57012212
How isn't it?
>>
>>57012203
>I thought there must have been some compelling reason other than reducing code duplication.
It's not.

Even notice that this example is a database scheme mapper. Relational databases don't have inheritance. I'll bet dollars to donuts that the database design looks 10x simpler than the retarded ass sky high class hierarchy.

Oh, and the code duplication? You'll end up with way more duplicated code due to all the fucking class declaration boilerplate, so that doesn't even work. Look how much shorter your own code is.

It may seem insanely stupid that people would recommend coding like this, but there's really no hidden meaning behind it all. It's really that dumb. And a lot of very well paid developers think it's great because they learned it in school and never thought about it critically.
>>
>>57008918
All trading platforms already do this, dipshit.
>>
>>57012231
have you read anything on plt ? anybody who even _thinks_ that inheritance is same as composition is horribly and utterly
confused, and doesn't understand the theory behind type systems.
>>
>>57012289
See >>57012201.

class Foo {
void hello() { print("Foo"); }
}

class Bar : Foo {
void goodbye() { print("Bar"); }
}


interface IFoo {
void hello();
}

class Foo : IFoo {
void hello() { print("Foo"); }
}

class Bar : IFoo {
Foo foo;
void hello() { foo.hello(); }
void goodbye() { print("Bar"); }
}
>>
>>57012338
Are you trying to say those two examples are equivalent?
>>
>>57012349
All other things being equal, yes.
>>
>>57010742
>>57010836
>>57012289
>using the question mark with the whitespace immediately prior

Damn communists.

>>57012279
I think the point is that he creates something like this, in order to prove that he could apply these skills to other tasks at a potential job.
>>
>>57012357
The compiler cannot tell that "Bar" is a type of "Foo" in the second one.

if a function accepts a "Foo" as an argument, you can pass it a Bar from the first example, but not a Bar from the second example.

Also (new Bar()).hello() in the second example will crash with a nullReferenceException.
>>
>>57012390
That's a superficial difference, you just write IFoo instead of Foo.
>>
>>57012390
>>57012403
>Also (new Bar()).hello() in the second example will crash with a nullReferenceException.
Who says this is Java? It's just pseudo-code.
>>
is there a command for testing ARP requests?

im working on a project with a virtual network, im checking my packets with wireshark and when i send a ping it reads as an ICMP which i guess it should but i need to check ARP request/response

is there a command for that?
>>
>>57012403
That's not the same thing.

Obviously inheritance can be made out to be sort of kinda like interfaces and composition if you leave out all the other stuff that doesn't cover.

>>57012414
I didn't say it was. It would crash in any language because you're calling a method on a null.
>>
>>57012429
>Obviously inheritance can be made out to be sort of kinda like interfaces and composition if you leave out all the other stuff that doesn't cover.
What else does inheritance do, then?

>I didn't say it was. It would crash in any language because you're calling a method on a null.
Not in C++.

>captcha: for sale java
>>
>>57012455
>What else does inheritance do, then?
polymorphism.

>Not in C++.
Surely it would still crash though? You didn't instantiate the object.
>>
>>57012471
>polymorphism.
Where do you not see subtype polymorphism there? That's what the interface is for.

>Surely it would still crash though? You didn't instantiate the object.
It would be constructed automatically. Not that there's actually anything to do.
>>
>>57011958
Well, what's the problem?
>>
>>57012373
What would actually be impressive is hooking straight into an exchange's data feeds and parsing that into something usable.
>>
>>57012480
I can't say in a method I want a specific class or anything that inherits from it. I can only specify i want a certain interface and I can't make any assumptions about the implementation.

>Not that there's actually anything to do.
surely the pointer to the function needs to be put in place. How does it know where to find the Hello() method at runtime otherwise?
>>
>>57012496
Thank you for the reply. I don't know how to open, read, process and save the file. Which is why it is half pseudo-code.
>>
>>57012525
I agree.

However, being able to properly:
>consume APIs
>store and retrieve data on a database
>design a front-end with good practices and UX
already puts you ahead of 70% of programmers on the hire-ability scale.
>>
>>57012537
>I can't say in a method I want a specific class or anything that inherits from it. I can only specify i want a certain interface and I can't make any assumptions about the implementation.
Good!

>surely the pointer to the function needs to be put in place. How does it know where to find the Hello() method at runtime otherwise?
It doesn't find the method at runtime.
>>
>>57012338
you are wasting memory in the second example due to the indirection (is a vs. has a)
>>
>>57012571
Memory to store what, exactly?
>>
>>57012583
the instance of foo
>>
>>57012594
What needs to be stored?

Why are you thinking in terms of a language when I didn't actually write that code in any particular language at all, anyways?
>>
>>57012565
>Good!
yeah, good if you hate inheritance like I do. Bad if you're trying to claim your code does all the same stuff as inheritance.

>It doesn't find the method at runtime.
So what happens at runtime then? It crashes? Does nothing? In any case your code doesn't work.
>>
>>57012603
>What needs to be stored?
Foo foo;
>>
The C Programming Language Second Edition
Exercise 1-3
>when your too dumb to want to do the work so you spend 15min justifying the ascii

>when your an ascii artist and the normalfags just dont understand

#include <stdio.h>

// fahr-cel table

main()
{

double fahr, cel;
double lower, upper, step;

lower = 0;
upper = 180;
step = 20;


fahr = lower;
printf(" |---------------------------|\n");
printf(" | Fahrenheit | Celsisus | \n");
printf(" |---------------|-----------|\n");
while (fahr <= upper) {
cel = 5 * (fahr-32) / 9;
printf(" |%7.2lf |%11.2lf|\n ", fahr, cel);
printf("|_______________|___________|\n");
fahr = fahr + step;
}

}
>>
>>57012540
I'm assuming you use C. (This works in C++ too.)

To open files, call fopen(). Once opened, you can read from it using fread() or even fgetc() if you want to read it one byte at a time. When you're done, close the file with fclose(). Read the contents into a buffer (malloc() and free() are your friends here), process it, then open another file and call fwrite() to save the data back. Close the output file normally. Done.

Any C tutorial that teaches file I/O will show you the details.
>>
>>57012604
You should stop talking about C++.
>>
>>57012642
Why?
>>
>>57012604
>Bad if you're trying to claim your code does all the same stuff as inheritance.
You can definitely abuse modules to have that effect. I guess I'm technically wrong but only because inheritance is actually worse than I was thinking.

>So what happens at runtime then? It crashes? Does nothing?
It's known statically.

>In any case your code doesn't work.
It's pseudo-code so I wouldn't expect it to.

>>57012613
Okay but what does foo store? Can you answer my second question?
>>
>>57012620
Alright I will try this and report back. Hopefully you are still here then.
>>
>>57012651
Because you don't know what you're talking about.
>>
>>57012657
An object of type Foo. are you retarded ?
>>
>>57012686
What about it takes up space? Can you answer my second question?
>>
>>57012691
no, you are fucking retarded, you don't even know the difference between an class and an instance of that class. fucking time waster.
>>
>>57012707
What about it needs to take up space?
>>
>>57012707
Friendly reminder >>57012642
>>
Animefags, Non-animefags, trapfags, and kpop shitposters, I ask you:

Where the fuck is the new thread?
>>
>>57012732
>page 4
>new thread
for what purpose?
>>
>>57012662
All I'm doing is asking questions. The only assertion i made is that the hello() method would not run as far as I can tell. Am I wrong?
>>
>>57012743
So the OOP autists can finish their conversation about inheritance as the thread goes to its demise, and the rest of the anons and migrate and start new topics of argumentation.
>>
>>57012757
>pseudo-code will not run as far as I can tell
Thanks, Sherlock.
>>
>>57012800
>>
>>57012768
The point was that if it was C++ it would not run. Or any language I can think of.
>>
>>57012618
>when I go make a coffe, and copy paste to fininish Exersize 1-4

#include <stdio.h>

// fahr-cel table

main()
{

double fahr, cel, celsius, fahren;
double lower, upper, step;

lower = 0;
upper = 180;
step = 20;


celsius = lower;
fahr = lower;
printf(" |---------------------------| |---------------------------|\n");
printf(" | Fahrenheit | Celsisus | | Centigrade | Fahrenheit| \n");
printf(" |---------------|-----------| |---------------|-----------|\n");
while (fahr <= upper && celsius <= upper) {
cel = 5 * (fahr-32) / 9;
fahren = celsius * 1.8 + 32;
printf(" |%7.2lf |%11.2lf| |%7.2lf |%11.2lf|\n ",fahr, cel, celsius, fahren);
printf("|_______________|___________| |_______________|___________|\n");
fahr = fahr + step;
celsius = celsius + step;
}

}
Thread posts: 339
Thread images: 31


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.