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

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

Thread replies: 255
Thread images: 29
OBJECT-ORIENTED PROGRAMMING DISCO

NO MULTIPLE CLASS INHERITANCE

STATIC TYPING

RESTRICTED TYPE INFERENCE

NO USER-DEFINED OPERATOR OVERLOADING

PASS-BY-VALUE ONLY

JAVA FOR THE LAVA
>>
>>52664756
op is a faggot
>>
>>52664756
this thread is fucking gay
>>
>>52664756
<html>op is a faggot
>>
OLD THREAD

>>52658863
>>
>>52664756
import gay sex
print op is a faggot
goto kill you're self
>>
PYTHON MASTER RACE
Y
T
H
O
N
>>
>>52664799
>python
faggot
>>
>>52664789
>looking at the past
>not realizing you're increasing suffering
>>
what's the story on op's pic?
>>
>>52664860

Giving attention to programming
>>
Python is the best language. Even nasa uses it.
>>
>>52664785
You're now google certified.
>>
What's the best way to learn programming?

AS in CS, BS in CS, Boot Camps, or Self taught?
>>
Anyone know why on earth maths would work differently on two different machines?

It's on .NET 4.5.2, both machines have it installed.


3.55*9.5*1.4=47.215
but the result the other machine is getting is 80.47

Why in the fuck would this be happening?
>>
>>52665485
I don't believe you. Unless you are doing something exceptionally stupid involving this:
https://en.wikipedia.org/wiki/Endianness
>>
>>52664756
Epic meme, dude.
>>
>>52665527
It's definitely happening, I ended up using an expression evaluator because it seemed to fix the problem before (but it required the other machine to type up the formula).

But this doesn't work now either, I don't understand it at all.
>>
>>52665551
No code = no advice.
>>
>>52665551
>expression evaluator
What the fuck are you doing.
What programming language is this?
Either you are doing something stupid or the people who implemented the interpreter/compiler are doing something stupid.
>>
Reminder that static typing leads to Enterprise Tierâ„¢ programs and is considered harmful.

>AbstractSingletonListenerBeanFactory
>>
>>52664756
JAVA is cancer
LOOK AT THE READ CELLS ON THE JAVA SIDE:
https://en.wikipedia.org/wiki/Comparison_of_C_Sharp_and_Java

TOP FUCKING KEK
>>
File: eVnIHIQ.png (7 KB, 418x89) Image search: [Google]
eVnIHIQ.png
7 KB, 418x89
>>52665563
>>52665572
It's not going to be of any use to look at my code. Because the maths works fine on my machine and completely wrong on his.

If I replaced all this with just standard math (double result = 3.55 * 9.50 * 1.40) it'd yield the exact same result.

The only reason I use the expression evaluator is because it worked before (but it required the user to set up the formula themselves)

Could it be an issue with some kind of culture based thing? They're using the .NET framework in a different language (Same version)
>>
>>52665587
red cells****
>>
First for Github's outage.
>>
>>52665587
You're really fitting in.
>>
>>52665591
In some languages the . is the thousand seperator and , is the decimal seperator.
>>
>>52665591
My guess would be - different input or different locale.
>>
>ActorBeanFactoryServiceGeneratorFactory
>>
>>52665627
But that shouldn't make a difference should it? If it's a simple bit of math in the code how would it magically come up with 80.47 instead of 47.215?

I tried replacing the "." with "," on my machine and it just immediately crashed the program.

Clearly that cant be the issue.
>>
File: mathsinjava.jpg (57 KB, 674x490) Image search: [Google]
mathsinjava.jpg
57 KB, 674x490
>>52665575
>>52665643
>>
>SingletonFactoryStatusCheckerServiceBean
>>
>>52665635
>>52665627
There is no way this should have any impact on
>double result = 3.55 * 9.50 * 1.40

>>52665591
First of all drop as much unnecessary junk as possible. Don't use Expression, don't use String.Format, verify it works on both machines then add things 1 by 1 until you find the culprit.
>>
Is python good to learn?
>>
>>52664756
blood on grills face makes my cock diamonds
>>
>>52667449
yes
>>
>>52667497
That's a rather specific fetish.
>>
>>52664756
i dont believe in anything that bleeds for a week and doesnt die.
>>
>>52667449
Do you suck dicks?
>>
>>52664967
Java is best language. Even White House uses it.
>>
faggot

literally 150 posts early
>>
In my experience, in order of fun factor:
C# > C++ > Java > web shit
>>
>>52670264
WRONG
C++ > C# > webcancer > Java
>>
>>52670413
C# with linq > anything else
when dealing with a lot of collections anyway

And anything involving javascript is automatically bottom of the barrel
>>
Was the OP image deleted because it was trap fag
>>
What are the chances of me bullshitting my way into getting real analysis to count as a cs course
>>
>C# shilling
where the fuck am i
>>
>>52670543
Pretty high. You'll have even better chances switching an off-domain course choice to it, though (that's literally what I did). Go to your undergrad advisor to make sure everything's in order.
>>
Asking experts - what language should I learn to make my own games in Unity?
How should I approach this?
>>
>>52670694
C#
>>
>>52670694
>unity
Suicide.
>>
>>52670816

Ok, so I should code my own engine?
I'm not going to be able to do it in the next 3 years if I start learning today, right?
>>
>>52670875
Depends
A 2d engine/framework is pretty easy
3d - no
>>
>>52670898

I was thinking about 2d engine
>>
>>52670898
How is a basic 3D engine significantly harder than a 2D one?
>>
>>52665326
typical Cshart

CPUs use differently sized FP registers. in java you'd just use the strictfp keyword to get the same result across different computers.
>>
>>52665587
more "features" != better
>>
Looking for some critique on my code. I'm just learning C and what I am trying to do is
1. Read a char from stdin
2. Append it to a dynamically allocated buffer
3. print the string stored in the buffer to stdout

Or is it better to have an array with a fixed length as a buffer? What I was trying to do is save memory (not that it really matters in this case, just for practice).

#include <stdio.h>
#include <stdlib.h>

int main ()
{
char *buffer;
unsigned int len = 0;

buffer = (char *) malloc(sizeof(char) * len);

printf("echo> ");

while (1) {
char c = getchar();
len++;

buffer = (char *) realloc(buffer, len * sizeof(char));

if (c == 10) {
buffer[len - 1] = (char) 0;
break;
} else {
buffer[len - 1] = c;
}
}

printf("%s\n", buffer);
free(buffer);
}
>>
>>52670922
Try it yourself bub.
>>
>>52670875
write your own engine if you're interested in programming and care about quality

otherwise fuck off to >>>/vg/agdg
>>
>unironically making a thread ONE HUNDRED AND FIFTY POSTS EARLY
>mods don't do anything about it
4chan is dead.
>>
>>52670922
A basic 3d engine is doable as well
The moment things get rather difficult is when you want good-looking lighting
And of course integrating physics / audio / different input devices / all kinds of 3d model formats takes time as well
Not to mention a good editor
>>
>>52671065
how is this thread early you tard? the previous is >>52658863 and this was posted at like 310+
>>
>>52670988
Allocate a reasonable fixed size of bytes first, let's say 1024 bytes, then of you need to store more than that size, realloc other 1024 bytes more, and so on.
>>
>>52671132
>being clinically retarded
>2016
Wew laddies.
>>
>>52671181
check the timestamps

unless there's a third thread that no one has linked to or anything then you're wrong
>>
>>52671220
ok there's >>52664670

lmao kill yourselves
>>
>>52671220
Found the inbred.
>>
Fag
Fag
Fag
>>
>>52671337
it still wasn't 150 posts early

it was posted around the same time as the other one
>>
>>52671140
For what reason?
>>
>>52671366
Being inbred must be nice. Not a single responsibility, no need to try to make good posts, shitposting all day err day without a worry in the world. Am I far off? Tell us your story!
>>
>>52671394
Because memory allocation is slow, reserving some bytes from start will speed up it.
>>
>>52671511
Thanks for the tip
>>
>campus computational cluster uses queue system
>queues run on nodes with no external network connection
>need to reference genomic features with the biomaRt package
>biomaRt is an R frontend for submitting queries to the ENSEMBL servers' databases
>can't reach ENSEMBL servers from job nodes
>absolutely no help on which ENSEMBL data dumps are necessary for working biomaRt local installation
>can't even run a mysql server on the cluster anyway so this is pointless
>>
>>52670640
Well Ive already taken set theory. Im going to take real this semester though. CS advisor doesnt know anything. But the chair of the math department is also in the cs department so theres some hope
>>
>>52664756
OP, did you remove the image?
Whoever did it is a faggot and i want to say that i took a screenshot and cropped it.
>>
>>52671775
It was one of hiroshima nagasaki's janitors.
>>
>>52671807
you mean hiroshima kawasaki?
>>
>>52671775
you can find the original pic on an archive site like rebeccablacktech.com/g
>>
File: laptimetest.webm (3 MB, 1280x720) Image search: [Google]
laptimetest.webm
3 MB, 1280x720
Do you like me bomb gee?
>>
I want to do Android development but I don't have an Android device. Any suggestions on which device(s) to get?
>>
>>52672267

The nexus devices are always refered to as "developer devices" - the old nexus 6 should probably be decently cheap now.
>>
>>52672299
Thank you for the suggestion. What makes Nexus devices developer-oriented?
>>
>>52672267
get one with snapdragon 800 (adreno 330 GPU) or better

it doesn't have to be very expensive

sony xperia z ultra has a large screen with very responsive touch

if you can get multiple devices then get ones from different manufacturers (they have different quirks like with audio and touch input) and ones from different price classes
>>
>>52672267
>>52672299
>>52672341

Or you could use AVD
>>
>>52672357
you should have at least 1 physical device imo

preferably quite a few devices if you can afford it depending on what you're doing
>>
>>52671944
print "allah akbar" when it turns on
>>
File: 1451549658590.png (201 KB, 462x312) Image search: [Google]
1451549658590.png
201 KB, 462x312
I want the edges of a matrix to not be modified while doing something, but I can't manage to get the last two rows/columns processed no matter what conditions I use. If I raise it by one I get an out of bounds exception, so it's not that simple.

if(i!=0&&j!=0&&i!=S.length-1&&j!=S.length-1){
B[i][j]=3*S[i][j]+(S[i][j-1]+S[i][j+1]+S[i-1][j]+S[i+1][j]);
}


Please help, I'm sure I'm doing something really retarded.
>>
>>52672422
it looks like your spacebar might be broken, or you have no thumbs
>>
>>52672422
for(int i = 1; i != S.length - 1; ++i)
for(int j = 1; i != S.length - 1; ++j)
>>
>>52672478
whoops j != S.length - 1 on the second one

if you're iterating through all of them anyway try
if(i!=0&&j!=0&&i<S.length-1&&j<S.length-1)
>>
>>52672478
Yeah, there's a reason I didn't do that, I just simplified it because I was pretty sure the problem was in the condition.

But now I realize I'm probably a retard and "fin" isn't generated correctly.
>>
>>52672422
why don't you merge the conditions with whatever you are using to iterate i and j
>>
File: file.png (5 KB, 547x212) Image search: [Google]
file.png
5 KB, 547x212
>>52672516
>>52672519
shit, forgot image

>>52672514
Already tried, but no worries, I think it was the other thing.
>>
>>52672534
It was that, problem fixed. I was retarded after all.

Thanks anyway /g/.
>>
>>52672534
java truly is the most readable language
>>
>>52672551
It's 60% java 40% my terrible coding practice
>>
>>52672534
>unnecessary if
>>
>>52672581
If you have a way of doing that without a single int pls illuminate me.
>>
>>52672609
for(int i = ini; i < fin - 1; ++i)
for(int j = 1; j < S.length - 1; ++j)
>>
>>52672631
I was going to add an else later to deal with the edge cases, nerd.
Also you didn't take into account that ini can be 0 and that fin can be S.length, which are both guaranteed to happen at least once per program.
>>
>just want to try composing some game music
>get extremely uncomfortable stringing itching sensations in my back, neck and head like some sort of inflammatory allergic reaction every time
REEEEEEEEEEEEEEEEEEEEEEEEEE
>>
>>52672689
>stringing
stinging
>>
This thread has turned to trash
>>
>>52672704
>t. tripfag
>>
The difference in culture between the C and Lua channels on Freenode is incredible.

Maybe it's just because the C guys are just inherently disgruntled, and Lua is a happy language.
>>
>>52673088
Lua is a gay language indeed
>>
>>52664785
look I can hack
>>
File: shit.png (94 KB, 969x735) Image search: [Google]
shit.png
94 KB, 969x735
this is fucking amateurish shitware fucking kill themselves
>>
i'm not even going to bother with music for now because composing it and synthesizing sounds is a giant pain in the ass and i don't want my variation of https://www.youtube.com/watch?v=MqZgoNRERY8 either because it's not really a great music track
>>
>>52673525
>that shitty MS Sans Serif edit
My sides
>>
File: Screenshot_20160128-174918.png (1019 KB, 1080x1920) Image search: [Google]
Screenshot_20160128-174918.png
1019 KB, 1080x1920
>>52671906
>>52671807
It's not about the image, i screencapped it when it was in the catalog but was deleted in the thread.
It's about the janitor being such a huge faggot he couldn't handle it.
It does not even remotely violate the rules, some threads start with an even more objectionable image and those images don't get removed.
>>
>>52673621
yes whoever deleted it is a massive faggot but just in case you want to have the full quality version of the pic you can find it on rebeccablacktech
>>
>>52673654
I have a 2K screen so the screencap probably went right.
Just crop and move and on.
>>
File: 1453964185926.jpg (34 KB, 392x391) Image search: [Google]
1453964185926.jpg
34 KB, 392x391
>>52673691
well it got resized at least
>>
>>52673713
+1
>>
>>52673088
##c on freenode is a shithole. People in there have no clue how to do any kind of c whatsoever and you'll learn more about c if you went to #lisp
>>
>>52673621
The worst is that this thread violates the rules but it's allowed to stay up even though a jani was confirmed to have seen the thread since they deleted the image.
>>
>>52673789
Hdym violate the rules?
I wouldn't know what it violates except b-tier content (OP's capslock)
>>
fuck yeah my todo list isn't very large

except i kinda want music ;_; and i don't want to license some crappy stock music and add many megabytes to the file size of this tiny little arcade game
>>
>>52673525
Why are you not using pirated FLStudio?
>>
>>52673525
Use Sunvox, fucker
>>
>>52673961
i have FL studio 10 already installed

do you think it would take long for me to learn how to use it? i just want like 4 instruments at a time and i want to be able to play with different rhythms like 6/8 (123,123 or 12,12,12) on drums for example combined with 4/4 on some other instruments
>>
>>52673998
It used to be the easiest one to learn, not sure about now. It definitely looks better than yours. Usually popular software is easy to learn, or it wouldn't be popular.
>>
>>52673937
there are tons of retards that upload decent libre music on newgrounds and other websites, try that
>>
>>52673525
RENOISE
E
N
O
I
S
E
>>
>>52674029
might give it a go, i think i'll work on something else first though.

>>52674049
i've listened to quite a few moddb tracks in the past and especially the public domain ones aren't that great or don't fit my particular game but good idea although i'd prefer to make my own music unless it's going to take more than a month or two to get something decent
>>
>>52674088
>i'd prefer to make my own music unless it's going to take more than a month or two to get something decent
if you're an absolute beginner you'll be completely lost. there's a reason why the vast majority of musicians (which already requires tons of practice and some kind of education to learn) can't compose for shit
>>
>>52674110
i've watched the entire "TTC - how music and mathematics relate" and i've downloaded a bunch of ebooks on music theory and composing and such and i know a bit of physics, math with the waves, logarithmic scales and such but yeah i know i might be in way over my head on this one
>>
File: 1453653438419.gif (147 KB, 850x613) Image search: [Google]
1453653438419.gif
147 KB, 850x613
Anyone got any good ideas for a simple, yet fun zelda game?
>>
>>52674319
Idk, but if someone does, i might make some app for it and put it on the appstore for $4
>>
>>52664756
Java a literal shit, reminder to use D
>>
Hello. :)
>>
>>52675043
Weird way to spell ocaml, bro.
>>
>lisp
>haskell
>f#
>d
>ocaml
which meme lang will you insufferable spergs shill next?
>>
>>52675175

One of those is not like the others.
>>
>>52675175
c# because it actually fucking sucks
>>
>>52675005
>When his shitty language is attacked, the Javafag lashes out at an imagined group of C users, usually resorting to ad hominems to defend against any and all criticisms. Another common defense seen by Pajeet, usually in response to the criticism that "Java doesn't have X", is "Well you don't need X"
>>
>>52675197
ok the d one was a bit cruel i actually have it on the official approved languages list
>>
>>52675216

Exactly.
>>
>>52675212

desu, Cmen get pretty salty, too.
>>
>>52675251
Yeah, but it's funnier watching the resident Javafag sperg out
>>
>>52664761
>>52664771
>>52664785
>Posts exactly 61 seconds apart
>Samefagging this hard
>>
>>52675270

Fair enough.
>>
>>52673713
>memegenerator
I don't think it was the janitor at all.
OP felt too much shame for using watermarked maymays, deleted their own image.
>>
>>52675216
>official approved languages list

Explain.
>>
>>52675175
F# desu
>>
>>52675396
The official approved languages list:
>C++
>Java
>C#
>D
>>
>>52675216
>ok the the worst language on the list was a bit cruel i actually have it on the official approved languages list
>>
>>52675175
I think I'll go back to shilling opendylan.
You?
>>
>>52675441
Whoops, typo
*the best language
>>
>>52675436
take out Java, c#, and D and it'll be perfect
>>
>>52675436
JUST
ENTERPRISE MY SHIT UP SENPAI
>>
>>52675462
>C++
>perfect

hue
>>
So I have this [spoiler]Java[/spoiler] program that generates a.json and b.json. I'm then reading those files in another program later.

Problem is: When I run two instances, of course those a and b files get overwritten randomly and it all breaks. What's the preferred way to do this? Add an "output filename" parameter? Can I pipe two files to stdout without it getting complicated?

I do have the sourcecode and can recompile.
>>
>>52675533
What are you trying to do? Why do you have things set up that way in the first place?
>>
>>52675533
implement RMI and have the server handle file concurrency :^)
>>
>>52675579
I'm trying to integrate it into a webservice, the .jar does some calculations on a database and I'm doing some filtering on the output to make it look nice

>>52675615
That uuh... sounds complicated
>>
>>52675436
Are you just trying to put people off C# and D completely by associating them with utter dogshite?
>>
>>52675691
I was jesting, but if it's a webservice don't you need only one instance, for the server?

Generate a hash filename for a json and b json then create a c.json and append the latest generated filenames, have the other program use the third file and access all the files dynamically.

But really you must be doing something wrong.
>>
>>52675750
>Generate a hash filename for a json and b json then create a c.json and append the latest generated filenames, have the other program use the third file and access all the files dynamically.
I guess that would be the easiest solution
>But really you must be doing something wrong.
I know...
>>
>>52675777
Wait. Please don't tell me you're running two instances of the same program to make it run faster.

Please tell me you know how to use concurrency with java. Please.
>>
>>52675805
No I don't do that. I just want to run multiple instances that produce different output, at the same time (because there would be multiple users using this thing). I'm adding a hash to the filenames now.
>>
I'm working on a website in Flask for the first time and I have data in a tree that I want to show to the user. I'm sending it to the browser with JSON like this:
<script type="text/javascript">
$(function () {
render({{ tree|tojson }})
})
</script>

and using a JS function render defined in another file to show the data. I did this more or less without thinking, but now it seems like a wrong place to use JS. Shouldn't I be generating the HTML on the server? It seems like this is what the templating library provided is for, but it isn't a trivial conversion to HTML. I'd have to write a procedure that generates HTML as a string, which seems wrong. Does anyone have any recommendations for generating the HTML? For what it's worth, the data I'm using is just a named tuple with one field for info and the second for a list of children.
>>
File: file.png (3 KB, 481x49) Image search: [Google]
file.png
3 KB, 481x49
>>52675829
>I just want to run multiple instances that produce different output, at the same time
>>
>>52674319
Does anyone know what language that is?
>>
>>52675861
I don't do it to make it run faster, but just to allow different output to different users based on their input parameters. I don't know, what's wrong with that?
>>
>>52675881
CHIP-8 assembly
>>
>>52674319
yeah but did you code a rollercoaster simulation game? I thought so
>>
>>52675984
Neat, thanks! I've never seen it before even though I've read a little about CHIP-8.
>>
>>52675691
But why is it saving the json files locally?
>>
If you disassemble roller coaster tycoon, will the variables still be named or will they be stripped?
>>
>>52664756
/sci/ here, we need your expert code monkey knowledge.

>>>/sci/7817700
>>
File: coltons_map_1852.jpg (669 KB, 1600x1152) Image search: [Google]
coltons_map_1852.jpg
669 KB, 1600x1152
Are neural networks for video games just a meme?
>>
>>52676460
> for video games
Yes.
>>
Is C worth learning?
>>
>>52675853
Never mind, pretty sure I have the right solution now.
>>
>>52676533
Do you like pain and no jobs?
>>
>>52676533
Yeah but not because you'll really have to use it anywhere. Just learn the basics. It improves your understanding of existing software and programming languages. You'll also be able to write a fast and efficient procedure for use via FFI if you ever need it.
>>
going to switch to C because C++ is annoying me
>>
>>52676651
Enjoy three orders of magnitude more annoyance.
>>
>>52676731
But C++ is an ugly clusterfuck. C is actually elegant and nice to write.
>>
>>52676651
that's retarded - or you don't know what you're talking about

just use C++ tools and don't write things C++ adds if you're so against it
>>
>>52676766
HAHAHAHAHAHAHAHHAHAHAA!
Good joke anon, tell it again!
>>
>>52676651
As who likes his C
Don't
>>
>>52676454
>Java is okay because it looks like C++ but lacks expression. But being honest, C lacks expression when compared to C++ but this is justified by it existing decades before C++. It is beautiful simply by being the father of the most beautiful programming language.
>lacks expression
>C++
>beautiful
wat
>>
>>52676789
Are you seriously implying that C++ is not an ugly clusterfuck?
Good joke, tell it again.
>>
>>52676798
*As a man who likes his C
Jesus
>>
>>52676651
In 99% of cases you shouldn't need C. Maybe even more. Switch to a language like Rust or D or whatever else is happening these days if need the speed. Otherwise use a nicer language.

>>52676789
C's bad, but if you think C++ is better you probably never learned how to write C properly.
>>
>>52676825
>>52676807

If you think C++ isn't a billion times better than C, you don't know the first thing about C++.
>>
>>52676913
If you think C++ is even close to being a valid replacement for C, you don't know the first thing about either language.
>>
>>52676938
If you think otherwise, you're about as smart and knowledgeable on the subject as my left foot's fungus.
>>
>>52676938
>>52677008
Just fuck already.
>>
If you think anything about anything, then you clearly don't know the first thing about anything or anything about anything else.
>>
wew
>>
>>52675658
You should totally try to do that shit in Ruby
(calling C libraries for whatever needs the performance)
>>
hey guys, first time posting here
I'm in college and I don't have a lot of programming experience, the most complex thing we've done so far is a Donkey Kong clone on java, I also know some C, Assembler and Pascal.
Now I'm on vacation but I have this constant feel that I want to do something useful but I just don't know what, so I'm for some inspiration I guess..
I thought about making a website where you can "read" these old text adventure books called Choose your own Adventure (I don't know if you had them in murrica), basically you follow a story and at the end of the page you are given a few options and jump to another page based on what you've chosen.
>>
>>52677552
fizzbuzz
>>
>>52677552
>I also know some C, Assembler and Pascal.
spotted the nazi
>>
Hey /dpt/

#include <iostream>

class Test {
private:
int n;
public:
Test (int n);
~Test ();
int getN ();
};

Test::Test (int n) : n (n) {
std::cerr << "new " << this << std::endl;
}

Test::~Test () {
std::cerr << "del " << this << std::endl;
}

int Test::getN () {
return this->n;
}

std::ostream &operator << (std::ostream &os, Test test) {
return os << "(" << &test << " " << test.getN () << ")";
}

int main () {
Test test (42);
std::cout << test << std::endl;
return 0;
}


I run that code but I obtain a strange output

new 0x7ffe7d475f60
(0x7ffe7d475f70 42)
del 0x7ffe7d475f70
del 0x7ffe7d475f60


Why do I have 2 destruction and 1 construction. WTF is happening?
>>
File: 1441684460338.jpg (92 KB, 1280x720) Image search: [Google]
1441684460338.jpg
92 KB, 1280x720
>>52677596
>That code
How the hell do people defend that shit?
>>
>>52677652
It's just a test. Please enlighten me.
>>
>>52677658
I'm no Sepples fag, but I assume it's because this clusterfuck:
std::ostream &operator << (std::ostream &os, Test test) {

is making a copy of the argument, which is then destructed after that function, then the original is destructed in main.
>>
>>52677596 (me)
destructors are called by function with argument as value. But constructors are not called.

AND SOME STILL DON'T GET WHY C++ IS ABSOLUTELY DISGUSTING.
>>
>>52677687
Nobody's fault that you're retarded.
>>
About to write a language similar to python for a school project. Trying to fix some of python's deficits and add more features.

Right now it looks a little like:
Lua-like syntax (fuck not having a end-of-block identifier)
First-class functions
More sane scoping rules (like Lua's)
ADTs as part of the core language
ADTs are immutable, runtime will opportunistically use mutable operations to keep amount of copying down to optimal as possible (this allows all ADTs to be arbitrarily nestable unlike Python's)
comprehensions for all the ADTs
lazy-evaluated higher-order functions like map, reduce, etc. but you can force evaluation
coroutines for generator functions and async shit

Trying to work through the design of the class system now. Prototypal inheritance is a hell no, I actually want operator overloading, multiple dispatch, and access protection. But I've never really been much of an OO fanatic, so I'm not sure what to do. Any ideas? Also requesting any features that would improve the language and fit with what I have now.
>>
>>52677710
C++ fans will always defend their language even when huge flaws are spotted.

A destructor is called without the corresponding constructor call.
NO IT'S NOT A FLAW, YOU'RE RETARD.

Stay pleb anon.
>>
>>52677715
Choose lisp syntax instead. Or at the very least, ML syntax (ML syntax is very conductive of pattern-matching and lisp syntax is great for its unbeatable regularity).
You should make everything strict by default, with a keyword to delay the computation.
As for class, either remove them completely (use sum and product types instead, or add ML-style structs), or do them via typeclasses.
>>
>>52677745
It's too bad that you were born without a brain.
>>
>>52677596

Two conductors are called, and two destructors are called here. The constructors are the normal constructor, which takes no arguments, and had been overwritten to print it's address to stderr, and a copy constructor, which is not overwritten, bit which must necessarily be called when passing the object by value (rather than by reference or pointer) to the ostream operator overload you provided. The copy is destroyed at the end of the ostream operator call, so you will see the destructor called twice. Notice that the memory address for both calls are different.
>>
>>52677596

Two constructors*

Goddammit autocorrect. If there's any other typos there, I blame Google keyboard.
>>
I wish real life was written in Haskell.
>>
>>52677756
>(use sum and product types instead, or add ML-style structs)
Not particularly familiar with ML, how does OO work in it? I was thinking about type classes at first. Not sure about pattern matching though, that's quite a departure from python.
>>
>>52677868
I wish Haskell was written in real life.
>>
>>52677906
You wouldn't use classical OO. You would obtain either a closed or open type which contains "constructors" and optionally values. For instance,
type 'a tree = Leaf of 'a | Node of 'a tree

is the type of a tree which holds arbitrary items. One then pattern-matches to destructure the object
let do_something f = function
| Node tree -> do_something f tree
| Leaf value -> f value

With closed types, this is restricted to tree-typed objects only. With open types, anything that has a constructor called Node and another called Leaf can participate.
ML-style structs are basically like C-structs but with a functional spin (you can do functional updates on them efficiently).

If you really insist on real OO, there's smalltalk/dylan or ocaml-style OO which are both a lot nicer than "classical" OO.
>>
CONDUCTOR WE HAVE A PROBLEM
>>
>>52664793
ERROR: cannot parse "kill you're self"
>>
File: 1452403462016.png (79 KB, 307x400) Image search: [Google]
1452403462016.png
79 KB, 307x400
>Sepplesfags will try to justify the output of this program
#include <iostream>
#include <exception>

template <typename T>
class Test {
T n;
public:
Test() : n(0) {
std::cerr << "horrible " << this << std::endl;
}

Test(T n) : n(n) {
std::cerr << "shitty " << this << std::endl;

if (n % 2 != 0) {
throw std::bad_exception();
}
}

Test(const Test &old) : n(old.n / 2) {
std::cerr << "meme " << this << std::endl;
throw 7;
}

~Test() {
std::cerr << "language " << this << std::endl;
}

friend std::ostream &operator << (std::ostream &os, Test test) {
return os << "(" << &test << " " << test.n << ")";
}
};

int main ()
{
Test<int> test();
std::cout << test << std::endl;
}
>>
Hey can someone make a script to download images from http://rule34.paheal.net/ based on a search term?
>>
>>52664756

Anything that I'd be tempted to use C++ for now, I'll try to use Rust instead.
>>
>>52678458
I could, but why can't you?
You should be able to throw something together extremely quickly with python + requests + beautifulsoup.
It's good practice.
>>
>>52679072
>write 2 lines of code after importing a million different libraries to do the actual work for you
>"good practice"
haha
>>
>>52679083
If someone else has already done the work, and they've probably done it better than he can, why should he waste time reimplementing it?
What do you suggest he do it in, str8 C?
>>
>>52679083
Yeah, and those idiots who import the standard libraries need to learn to code
>>
>>52677868
>tfw no type-safe gf
>>
Any actionscript bros. Nothing big just wanna know what this does. I'm ripping textbooks from webaccess and it has each page as a .swf.
I can render it but some swf renderers simulate the action script and cause this to have "WIDTH" and "HEIGHT" in red text

dims._alpha = 0; if (gApp != eval("undefined")) { dims.unloadmovie(); dims._alpha = 0; } else { foo._visible = false; dims._alpha = 100; var tThis = this; tThis.onmousedown = function () { if (!key.isdown(68)) { foo._visible = false; dims._alpha = 0; } else { foo._visible = true; dims._alpha = 100; } }; tThis.onmouseup = function () { foo._visible = false; dims._alpha = 0; }; } stop();


im guessing gApp is some variable that a parent swf would declare
>>
>>52679124
>he doesn't first write a programming language specific to the task and then implement the solution in that
>>
>>52679119
>and they've probably done it better than he can
Why do you assume that if a library exists, it's automatically better than anything you can produce? Why not try and do it yourself? If you don't, you never actually learn how to do anything and you're just doing the equivalent of copying and pasting code from the internet. There's nothing wrong with using libraries if you're not actually interested in learning to program, but don't try and suggest that it's "good practice" to just use 3rd party libraries for everything, you're not practising anything except copy+pasting.

>>52679124
Read again, he suggested that using libraries for everything is a good way to practice programming. This is objectively false.
>>
>>52679226
>don't try and suggest that it's "good practice" to just use 3rd party libraries for everything

It usually is when you're trying to get work done.
>>
>>52679296
Read again, if you're not actually trying to learn how to program (for example, when you're working) then go ahead, but this guy is obviously trying to learn how to program and it's unhelpful to just say "use these libraries". It's like someone asking a javascript question and just being told "use x function in jQuery". Sure, it's easier to do with jQuery, but if you're trying to learn JS - why are you, well, not learning JS and just using other peoples' code?
>>
>>52679329
>this guy is obviously trying to learn how to program and it's unhelpful to just say "use these libraries".

I suppose that's true, but you don't need to implement EVERYTHING yourself.

For instance, someone who wanted to learn how to program wouldn't need to reimplement sockets. Sometimes you just learn how to use things and move on.
>>
>>52679072
mine is slow as fuck
from urllib import urlretrieve
import requests
import re
import os

searchTerm = 'foo'

def findAllBetween(string, start, end, match='(.*?)'):
regex = re.escape(start) + match + re.escape(end)
return re.findall(regex, string)

def extractImageUrls(source):
return findAllBetween(source, '<a href="', '">Image Only</a>', '([^"]+?)')

def getFileExt(url):
return url.split('.')[-1]

def getNumPages():
lastPage = findAllBetween(downloadPage(1), '<a href="/post/list/{}/'.format(searchTerm), '">Last</a>', '([0-9]+?)')
return int(lastPage[0])

def downloadPage(pageNum):
url = 'http://rule34.paheal.net/post/list/{}/{}'.format(searchTerm, pageNum)
contents = requests.get(url)
return contents.text

def makeSaveDir():
saveDir = os.path.join(os.getcwd(), searchTerm)
if not os.path.exists(saveDir):
os.makedirs(saveDir)
return saveDir

def downloadImages():
saveDir = makeSaveDir()
numPages = getNumPages()
saveFile = 1

for pageNum in range(1, numPages+1):
print 'Downloading Page: '.format(pageNum)

page = downloadPage(pageNum)
images = extractImageUrls(page)

for image in images:
filename = '{}.{}'.format(saveFile, getFileExt(image))
savePath = os.path.join(saveDir, filename)
urlretrieve(image, savePath)

saveFile += 1
print 'Saved an image.'

if __name__ == "__main__":
downloadImages()
>>
>>52679365
Sure, I agree that there's a line to be drawn somewhere, but just listing off a bunch of libraries instead of offering actual advice is unhelpful and counterproductive.
>>
File: tt.png (178 KB, 2392x300) Image search: [Google]
tt.png
178 KB, 2392x300
why can't I put a static instance of a child class in that child class' abstract base class and then access the static instance variable without getting this error

PaddleStrategyAI inherits from IPaddleStrategy, I don't get it

it also works fine if I put the static instances in their own respective classes instead of the base class; I can do that but I want to know why this isn't working before I move on, because this makes absolutely no sense to me
>>
File: fblogo.png (4 KB, 300x300) Image search: [Google]
fblogo.png
4 KB, 300x300
if(x == true){
y = true;
}
else if(x == false){
y = false;
}
>>
>>52677868
unfortunately god chose Java
>>
File: 42233472_m.jpg (120 KB, 428x600) Image search: [Google]
42233472_m.jpg
120 KB, 428x600
>>52679174
a
>>
>>52679800
MY EYES
y=false;
if(x) y=true;
>>
>>52679856
Not sure if inbred or just braindead.
>>
>>52679856
y=x;

I didn't know we have feminine coders here.
>>
>>52679884
>>52679886
true
>>
>>52679886
x isn't boolean, it's a custom type with overloaded equality and assignment operators. :-]
>>
Does C inline composed functions? like:
foo(bar(bat()))
becomes composedfunction() bat -> bar -> foo with the code from foo bar and bat all stuck together into one function?
>>
>>52679934
There must surely be a compiler option for it.
>>
>>52679934
Depends on the compiler and a whole bunch of other shit.
>>
>>52670975
In the case of type inference, user defined operators, and value types, I'd have to say that yes, more features is better.
>>
>>52679934
That's just normal inlining, and if the C compiler decides to inline the code then yes it would.
>>
>>52679998
ok charles

i for one don't use those features not even when i have them available to me
>>
>>52679906
Kill yourself.
>>
>>52679884
I'm braindead. I haven't slept all week m8.
>>
>>52680045
I use "auto" in C++ religiously and it's fucking great.
Disallowing user-defined operators would make sense if they didn't magically exist for object types like Integer and String etc. It just makes the entire language inconsistent and not very expressive.
Value types are useful but I guess not that useful if you give no shits about memory and performance, and if you avoid mutating state.
>>
New to /g/ first time poster

I recently began some mechanical engineering courses this semester and down the road they have us start learning to program in Matlab.
I wanted to look into starting into learning it ahead of schedule just to make it easier down the line.
I checked the wiki but I didn't see a recommended book/ starting point for Matlab.
Could you help a newfag out?

Also, how quality is Matlab in terms of engineering?
Should I look into learning other languages as well?
What languages would best suit my purposes post grad?
>>
>>52680205
Go back to facebook please we don't want you here.
>>
>>52680205
you'd probably get better answers in >>>/sci/questions
>>
Thinking about learning lisp but I'm not sure what it would be good for that other languages arent. If I do what should my projects mainly be doing that would be easier than in other languages?
Thread replies: 255
Thread images: 29

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

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