[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: 28
File: Arikawa.Hime.full.1796750.jpg (263 KB, 462x554) Image search: [Google]
Arikawa.Hime.full.1796750.jpg
263 KB, 462x554
old thread: >>54370219

What are you working on, /g/?
>>
>>54377910
But that's just like, your opinion man
https://www.youtube.com/watch?v=p4RBHCsLLI8
>>
>>54377946
Well, yeah.
>>
Daily reminder that this isn't fucking /mu/
>>
Crosspost.

>>54377114
What's the memory consumption like on that? Seems like a fun project.
>>
>>54377924
Hime:goto is considered harmful
>>
>>54377986

13mb
>>
File: dsfghjkl;.jpg (100 KB, 600x338) Image search: [Google]
dsfghjkl;.jpg
100 KB, 600x338
>>
>>54378005
C is harmful.
>>
>>54377946
This was pretty good. Unique dedication to the aesthetic, fantastic lyrics etc. Great music for doing something else..

He has money now though, he should be making a follow-up, or better yet re-recording some old Giles Corey or whatever to sound better. I get the lo-fi thing, but more sheen could help in some places
>>
>>54378033
Name a better way to create an early out from a deep nested loop structure.
>>
>>54378072
Refactor to use Node.js
>>
>>54378072

Having labelled loops.
>>
int b = 0;

while(b != 'a'){
cin >> b;
cout << b;
}


how do/can I make that work?
>>
I want to buy hime a computer so I can teach him Haskell while he sits on my lap.
>>
>>54378081
THIS FAMBLOMALOMBALY
>>
>>54378072
Refactor so that you're not using those, or break it into its own function and use return.
Goto should never, ever be used except in short-term fix situations.
>>
>>54378117
char b;

cin >> b;
while(b != 'a'){
cout << b;
cin >> b;
}
>>
>>54378117
>int b = 0
>while 0 != char a
you w0t

If whatever language you're using will allow you to dynamically change the type of the variable, then that should work.
Otherwise b needs to be a char/string and you can parse it later.
>>
>>54378072
M O N A D S
>>
File: 1457274399165.jpg (44 KB, 544x529) Image search: [Google]
1457274399165.jpg
44 KB, 544x529
>>54378186
>>
File: 1415587391074.png (171 KB, 394x346) Image search: [Google]
1415587391074.png
171 KB, 394x346
>>54378195
>>
>>54378179
>>54378186
Thank you for responding. But I need to use b as an integer to perform various computation, and display it. And only exit the loop if the supplied value is not an int.

I'm starting to think that the assignment I'm trying to complete is worded wrong.
>>
File: 1370023987126.jpg (27 KB, 580x346) Image search: [Google]
1370023987126.jpg
27 KB, 580x346
does anyone have any advice for getting into mobile development? mostly wondering about:
>what language/tools? i was thinking of using something like xamarin or ionic/cordova since it would let me share the majority of the codebase for both android/iphone
>books/articles/tutorials on designing a mobile ui
>things i should know related to publishing, monetizing, etc
>>
would you hire a female iranian computer science phd y/n
>>
>>54378235
Mind posting the whole assignment and/or your code? You can still display it and use it as an int if you do (int)b. This will give you the ASCII value of the current symbol. Here's a ASCII table: http://man7.org/linux/man-pages/man7/ascii.7.html
>>
>>54378290
You created your own type with B, so you have to call it as Vector vec.
>>
>>54378235
int i;

do {
cout << "Please enter an integer: ";
cin >> i;
} while (!cin);


According to
http://www.cplusplus.com/forum/beginner/76374/

I don't know C++ but the gist of the logic makes sense. Take an input and run a check that it's an integer, if not, rerun the loop. It just looks like C++ has a handy check on the last cin on whether it was successful or not.
>>
>>54378277
y<CR>
>>
Anyone else here a code artisan?
>>
>>54378323
>>54378235
Wait am I getting this whole thing right. Do you need a character or a number?
>>
>>54378342
he needs the input to end us as an integer. And it sounds like he needs to only have one variable assigned to make that happen, so taking in a char and parsing won't work (or at the least is roundabout)
>>
>>54378336
Aye
>>
>>54378336
>admitting to being a code autist
>>
File: assignement.png (143 KB, 917x608) Image search: [Google]
assignement.png
143 KB, 917x608
>>54378312
>>54378323
>>54378342
It goes for several more points, and I've done all of them and the fact that I can't make number one work bugs the hell out of me.
>>
>>54378336
here
>>
In html how can I make a further set of options appear in a form if a user checks a box? (ex: if they want to name something they check that radio button and then a place to enter appears in the form)
>>
>>54378485
javascript
>>
>>54378485
>>>/wdg/
>>
>>54378485
css don't use fucking javascript for something this simple
>>
>>54378419
so...the first point?
Again, I'm not handy with C++ but I threw >>54378323
into an online C++ scratchpad and it mostly works. If a number is put in it exits the loop correctly.
If you put in a letter it'll spam the cout endlessly, so I'm not sure what that's about, but the check at least works right.
>>
>>54378500
>he doesn't know how to link a catalog search
>>
>>54378567
I'm not linking fucking cancer you dumbass
>>
>>54378606
>>>/g/wdg
>>
File: average dpt poster.png (147 KB, 500x281) Image search: [Google]
average dpt poster.png
147 KB, 500x281
>>54378620
Delete this
>>
>>54378641
>>>/g/wdg
>>>/g/wdg
>>>/g/wdg
>>>/g/wdg
>>>/g/wdg
>>
>>54378186
this is why you learn C first
>>
>>54378525
I looked at http://www.cplusplus.com/forum/beginner/76374/ and I did:

while (cin>> a >> s)

and now when I enter a character it ends the program instead of repeating infinitely, so it turns out there was a way. In any case thank you all for helping.
>>
File: 1442071737199.png (11 KB, 364x312) Image search: [Google]
1442071737199.png
11 KB, 364x312
>>54378665
>>
Working with Python, imagine I have a whole text with multiple strings that start with "yup"
and I want to run a regular expression search

I understand that if I put
^y
it will find all the strings that start with "y"
what should I do if I want to search for those that start with "yup" ?
can I just type
^yup
?
>>
>>54378693
yup
>>
>>54377924
Please stop this trap curry(scat) meme.
>>
>>54378186
>Otherwise b needs to be a char/string
Fucking idiot, how do these people exist?
>>
>>54378693
yup
>>
>>54378693
yup, ^yup is right
>>
Today i had to use VBscript again. Did you guys know that 1 does not equal true?
VBscript uses -1 for that.
>>
>>54378708
Rather than insulting me, why don't you explain why I'm wrong so I can further my understanding?
Not everybody learned to program by starting with C and assembly.
>>
>>54378703
thanks I actually tried it in the console right after I asked and it worked, but this was only the first half of my question. the second is :

now imagine all these strings starting with yup are in fact file names, like that for example :
yupipap.png
yupipop.png
yupipip.png

so right now the expression is like that :
expr = r"^yup"
but what should I do if I wanted to skip all the text between "yup" and "png" ?
something like
expr = "^yup,png$"
(what do I replace the comma with ?"
>>
>>54378731
Alright anon, my bad, those meme pic responses made me think you were joking around

char is a number type, you can compare int and char and it will work. eg: 'a' is 97 in ascii. The following will print 'yes':
int b = 97;
if (b == 'a')
printf("yes");
else
printf("no");
>>
>>54378731
Not that guy, but i think he was hinting at the fact that a character is also just a number and in c it's possible to use it as such.
>>
File: 1315476422437.jpg (53 KB, 864x788) Image search: [Google]
1315476422437.jpg
53 KB, 864x788
>>54378793
>>54378813
Makes sense.
I've had the unfortunate situation of learning on the job in C# so pretty much everything I know is abstracted away from how the language/compiler actually works.
I really need to get around to reading K&R
>>
>>54377924
Can someone link me to some commercial .NET/Java applications I can try cracking/making keygens for? I wanna practice my reversing. Obviously I'm not going to post the cracked executables or anything or warez, I just wanna practice shit.
>>
>>54378154
>Goto should never, ever be used
Okay non-programmer, how do you propose I handle this without using goto labels, huh?
static void check_int13h_ex(uint8_t driveno)
{
asm goto(
"clc\n"
"mov ah, 0x41\n"
"mov bx, 0x55aa\n"
"mov dl, %0\n"
"int 0x13\n"
"jc %[fail]\n"
:
: "g" (driveno)
: "ah", "bx", "dl", "cc", "memory"
: fail
);

return;

fail:
panic("int 13h extensions not supported");
}
>>
>>54378921
Alright fine, you asinine fuck
Goto should never be used in high level languages.
Happy?
>>
>>54378154
>goto should never be used
That's like saying
>"x tool should never be used."
Goto is a tool. Use it only in the right situations. Alot of people say never ot use goto even when it's a perfectly valid situation to use them and could greatly simplify shit and/or solve the current problem.

The problem people have with goto isn't the goto itself, it's that alot of people want to avoid making spaghetti code shit with it by just throwing goto all over the place. The ironic part is that goto, when used correctly, can actually greatly reduce spaghetti code that otherwise would have had to be created to avoid the goto.

Don't be a sheep and fall for the whole
>o le dont use dis xD
that everyone on /g/ and reddit likes to do.
>>
I think the worst thing I see anti-goto C devs do is using variables to escape through nested loops, or other variable manipulation fuckery to perform some other unneeded traversal of a loop structure.

Just use goto ffs, it's not the 1970s anymore where we were lazy
>>
>>54378851
zelix klassmaster

there is already a crack for it so it's doable although i don't know if it's written in java itself
>>
>>54378960
>referring to goto statements as a "tool"
Hate this cringe
>>
>>54378951
It should be used for cleanup when returning from a function in C, a high level language.
>>
>>54379006
goto is a tool.
>>
>>54379006
you're a tool
>>
>>54379006
>Avoiding my points entirely
It IS a tool though...
I don't understand why you are letting people tell you what features to not use that are apart of a programming language.

Can you explain to me your reasoning? Why should we not use goto?
>>
>>54379010
Not the guy you were talking to but, are you retarded? C is about as low level as it gets. I don't think you know what that means.
>>
I've used C for like 5 years and did not know about this sexy beast known as function pointers and it's usage in things like callbacks until I started using SDL2. What cool things have you lads used it for?
>>
>>54379045
No, I don't think you know what you're talking about.
C is not that low level.
>>
How do you define a low level langauge?
>>
>>54379045
It is still classified as a high-level language you retard
>>
>>54379063

C is assembly++ xDD
>>
>>54379061
You never read K&R?
>>
>>54379080
Fuck off and drink bleach you retarded tripfag.
>>
>>54379063
Can someone turn this into a meme with the college graduate?
>>
>>54379022
>>54379028
>>54379033

I never said anything about goto being bad, I just find this "tool" nonsense cringeworthy.
>>
>>54379084
Heard it was a meme
>>
>>54379092
If you can use it, it's a tool, you self-righteous cunt
>>
>>54379085

I will if you go first.
>>
File: 235235.jpg (63 KB, 845x506) Image search: [Google]
235235.jpg
63 KB, 845x506
>>54379089


>>54379116
>if you can use it it's a tool
Fuck off

Sorry, I meant use your goto instrument from your toolset assortment to leave in a idiomatic fashion
>>
>>54379092
I find your existence cringeworthy.
>>
>>54378761
At least in ruby regex ^yup.*\.png$ will work. The . matches any single character, and the * matches zero or more of the previous, so .* matches any string.
>>
>>54379137
tools does not imply it belongs to an idiomatic practice

it is as it is, a tool, something you can use to achieve something. Variables are tools, functions are tools, classes are tools, now fuck off
>>
File: 1460411498656.jpg (128 KB, 900x675) Image search: [Google]
1460411498656.jpg
128 KB, 900x675
>>54379139
>>
>>54379092
Why?
>>
Goto should also be used to break out of loops in C and Java (where it has been renamed break), two high level languages.
>>
>>54379148
It worked, thanks a lot man
>>
>Today, this is no longer the case. Sussman pointed out that engineers now routinely write code for complicated hardware that they don’t fully understand (and often can’t understand because of trade secrecy.) The same is true at the software level, since programming environments consist of gigantic libraries with enormous functionality. According to Sussman, his students spend most of their time reading manuals for these libraries to figure out how to stitch them together to get a job done. He said that programming today is “More like science. You grab this piece of library and you poke at it. You write programs that poke it and see what it does. And you say, ‘Can I tweak it to do the thing I want?'”. The “analysis-by-synthesis” view of SICP — where you build a larger system out of smaller, simple parts — became irrelevant. Nowadays, we do programming by poking.

LOW LEVEL LANGUAGES ARE DEPRECATED
>>
Biggest memes ITT so far:
>C is low-level
>goto is bad
>>
>>54379217
>low level languages are deprecated because people don't read API documentation
you fockin wot lad? I'll mess you up swer on me nan
>>
>>54379219
Biggest cancer so far:
(You)
>>
File: smug00015.png (169 KB, 400x480) Image search: [Google]
smug00015.png
169 KB, 400x480
What are some programmer "red flags"?
>he uses setters/getters in his code
>he only knows C
>he complains about inverting binary trees
>"you should never use goto!"
>>
>>54377924

i wrote a 4chan image downloader in /dpt/ favourite language

import sys, json, os, urllib
from urlparse import urlparse

URL = 'https://a.4cdn.org/'
IMAGE_URL = 'http://i.4cdn.org/'
allowed_types = ['.jpg', '.png', '.gif']

if len(sys.argv) == 2:

url = sys.argv[1]

if 'boards.4chan.org' not in url:
sys.exit("You didn't enter a valid 4chan URL")

split = urlparse(url).path.replace('/', ' ').split()
board, thread = split[0], split[2]
url = URL + board + '/thread/' + thread + '.json'
response = urllib.urlopen(url)

try:
result = json.loads(response.read())
except ValueError:
sys.exit("No response. Is the thread deleted?")

try:
os.mkdir(thread)
print 'Created directory...'
except OSError:
print 'Directory already exists. Continuing. '
pass

os.chdir(thread)

print 'Downloading...'

for post in result['posts']:
try:
a, b = str(post['tim']), post['ext']
if a and b in allowed_types and not os.path.exists(a + b):
urllib.urlretrieve(IMAGE_URL + board + '/' + a + b, a + b)
except KeyError:
continue

print 'Done!'

else:
sys.exit('No URL provided.')
>>
>>54379217
>taking programming advice from an academic
>>
>>54379415
I'm going to go ahead and filter any posts with this image, as I haven't seen it too much and it's likely to be you when used.
>>
>>54379415
>he actively uses design patterns
>>
>>54379415
>dynamic typing is bad
I've used several dynamic languages in professional work with no issues the scale of which /dpt/ describes
>>
>>54379415
I'll add one
>has more than 0 of 'smug' anime pictures saved on his pc
>>
File: 1453648836231.png (681 KB, 840x720) Image search: [Google]
1453648836231.png
681 KB, 840x720
>>54379462
>more than 0 of 'smug' anime pictures
>>
>>54378237
Thank you very much for using that pic. I bless your computer my son.

Ask a Saint of The Holy Church Of Motherfucking Emacs anything!
>>
>>54379523
Please leave

>>54379462
Newfag
>>
>>54379446
What kind of issues?
>>
>>54379557
>error-prone
>can only find out on run-time
>makes it hard to reason about code
etc

Off course, conceptually, these issues exist, but practically, they are not issues the scale of which /dpt/ describes, even in a professional piece of software which contain a team's individual messy practices
>>
Even the web dev jobs have stopped contacting me.

I'm screwed
>>
>>54379580
Ah I see. I've used dynamic langugaes in professional work too, and worked with many programmers who were certain these were not issues.

The reason you didn't notice these issues is because you are a poor programmer.
>>
>>54379605
>The reason you didn't notice these issues is because you are a poor programmer.

*tips keyboard
>>
>>54379217
That quote has nothing to do with any deprecation of low level languages. There are such large libraries for "low level" languages (I assume you mean 3rd generation languages, not 2nd).
>>
>>54379602
Keep working on your portfolio anon. You'll get something.
>>
>>54378669
>
cin>> a >> s


That almost certainly doesn't do what you think it does, and is probably the best example I've seen of absolutely terrible built-in operator overloading.

<< or >> is overloaded as a stream extractor/inserter ONLY when the left-land argument is a stream.

So you're inserting a value from cin to a, but a is not a stream so the next >> operator is a bitshift right.
>>
>>54379605
>The reason you didn't notice these issues is because you are a poor programmer.
I said nothing about 'noticing', and considering I primarily fix bugs, 90% of the time the issue is in the other dev's logic over some dynamic typing-related issue. The other 10% are not sizable issues and with the likes of a decent debugger, like Pycharm's, debugging is as easy as with statically-typed languages, and quick in today's age of fast computers, and TDD practices
>>
>>54379659
>> for streams returns the stream by reference
it's left associative
>>
>>54379659
I agree that it's a retarded use of operator overloading, but it works here.

http://stackoverflow.com/questions/7425318/multiple-inputs-on-one-line
>>
What are some decent meme languages?
>>
>>54379662
>90% of the time the issue is in the other dev's logic over some dynamic typing-related issue
I've heard people say the exact same thing in jobs i've had before. and I've had to point out how more like 70% of the bugs have some origin in an issue related to dynamic typing (or weak typing, python isn't so bad there). Some programmers are just not smart enough to consider what the causes are. I've has some people me that static typing isn't that useful because it's rare that you pass the wrong type by mistake, which is maybe 5% or less of the bugs that static typing prevents.

Even 50% of the bugs in C# are null exception errors. Which is effectively a dynamic typing issue.
>>
>>54379716
D, F#, MSWLogo
>>
>>54379662
debugging might be as east but spotting a bug in the first place (i.e. while you're implementing a specific function, before it's able to be tested) is much harder in a dynamically typed language
>>
>>54379716
>>54379732
OCaml, TypeScript, CoffeeScript
>>
File: that high.jpg (30 KB, 450x407) Image search: [Google]
that high.jpg
30 KB, 450x407
>>54379676
>>54379687
That makes sense, admittedly I've not done much with meme++ and generally avoid the cin/cout clusterfuck.
Well at least it's consistent with << chaining I guess, but holy shit.

So including "functionless" extra parentheses to try to make the ordering clearer can actually completely change the operator, jesus christ.
>>
>>54379729
Well it seems our thoughts are on individual practices. I've worked with static typing moreso than dynamic typing professionally, and the issues are largely the same. I can tell when something is a dynamic typing issue, and I've rarely experienced those
>>
>>54379777
>are on individual practices
are based on individual experiences i mean
>>
File: eg3.png (18 KB, 674x352) Image search: [Google]
eg3.png
18 KB, 674x352
>>54379759
<</>> is not that bad imo, but what do you mean by the last bit? using parentheses is meant to change the order, and operator overloading also supports ad hoc polymorphism (function overloading) so it can depend on the type too
pic related
>>
>>54379729
>Even 50% of the bugs in C# are null exception errors. Which is effectively a dynamic typing issue.
>>
>>54379729
>50% of the bugs in C# are null exception errors
You could not meme harder
>>
>>54379759
Yeah, I use my own I/O classes for sepples.
>>
>>54379777
>I can tell when something is a dynamic typing issue, and I've rarely experienced those

Maybe you've just been lucky. Ever large dynamic codebase I've worked on always has lots of
>TypeError: Object of Undefined is not a function
>TypeError: Object of Undefined does not contain member "sheeeit"
>strings appearing containing the word "Undefined" like: "Welcome back Undefined!". This is all over the web.

And a shit load of other stuff, but this is one of the most prominent ones that is impossible with static typing. I've had people tell me dynamic typing does not cause many problems, and not realise these bugs are only possible with dynamic typing. This becomes extreme hassle in large projects especially when refactoring shit. Try renaming a few function and classes that get called 100 times in different ways in a dynamic code base, and when something fucks up have fun figuring out why.
>>
>>54379847
>>54379868
According to C# creator Anders Hejlsberg. His biggest regret in C#'s design is not making variables non nullable by default.
>>
>>54379830
What the fuck.
I thought I had seen all of C++'s fuckery. This is new to me. (the pic)
>>
>>54379959
>His biggest regret in C#'s design is not making variables non nullable by default.

Meh
>>
>>54379830
Well it would only happen if the parens were put in the wrong order, different to how the compiler interprets the line on its own.
So for example if someone used
cin >> (a >> s)
instead, but then that's trying to insert a value into a constant so will error anyway.

>> being left associative makes complete sense, but it kinda just looks odd having << also left associate, since a chain looks like a load of appends instead of a single IO write when the whole string is parsed.
Of course, output chaining wouldn't work otherwise, but it just doesn't seem to fit with the low-level application.
>>
>>54379940
Those are all related to Undefined objects, which is achievable through statically-typed languages when null
>>
>>54379830
C++ is infected with the slice/iter/foldr meme shit too? fuck me
>>
>>54380023
>basic functionality is a meme
end your life
>>
>>54379996
meh? It's the cause of an enormous amount of bugs in programming. Even they guy who made the first language with nulls says they were a mistake.

http://www.infoq.com/presentations/Null-References-The-Billion-Dollar-Mistake-Tony-Hoare
>>
>>54379974
this is user defined, most people wouldnt allow this
>>
>>54379959
>C#
>ever caring about not being shit
>caring about this retarded thing
it's like he's misunderstood everything
>>
>>54380023
iter is retarded but fold and slice are not
>>
>>54379959
and how that's related to dynamic typing ?
>>
>>54380018
>which is achievable through statically-typed languages when null
null is different than undefined anon. Undefined means the field was never defined at all. null means it was defined, but never given a value.

null reference errors happen in statically typed languages like C# and Java, but they are dynamic typing errors. They are basically holes in the type system, when the compiler cannot tell what the type of a variable will be until run time, is might be an object, or it might be null. This is the essence of dynamic typing.

It's also why langugaes like OCaml don't allow nulls, and F# and Swift try to ban their usage.
>>
>he took Computer Science
>>
>>54380038
>It's the cause of an enormous amount of bugs in programming.

I think we all know the real culprit of most programming bugs: C users.
>>
>ITT: people who think C is a high-level language
I've never felt so much autism in my life
>>
>>54380102
Does C stand for Computer?
>>
>>54380093
>is might be an object, or it might be null
Objects can be null in most languages, nice try though
>>
>>54380110
I am pretty sure they are trolling, this is /dpt/ after all
>>
File: fluffy jar.png (412 KB, 869x868) Image search: [Google]
fluffy jar.png
412 KB, 869x868
Anyone have any ideas why my program is seg faulting? It's pretty basic, I'm just trying to make_unique<> an object and assign it polymorphically into a unique_ptr<>, something like this:

class Z;
class A
{
A(Z* z) { .. }
virtual ~A() {}
void foo() = 0;
};
class B
{
B(Z* z) : A(z)
virtual ~B() {}
};
class C
{
C(Z* z) : B(z)
~C() {}
void foo() override { .... }
};

class Z
{
unique_ptr<A> a;
void foo() {
a = make_unique<C>(this); //seg fault
}
};


I made a point of showing the virtual destructors above because I was stuck on this for about an hour then realized I was missing a virtual destructor in an inheritance level and thought it would work, but it didn't.

gdb output looks like this:
Program received signal SIGSEGV, Segmentation fault.
0x000000000040cbbe in std::default_delete<A>::operator() (
this=0x6abd58, __ptr=0x4327d0 <vtable for Z+16>)
at /usr/include/c++/5/bits/unique_ptr.h:76
76 delete __ptr;


pls halp, I'm running out of ideas. I'm about to just remove the unique_ptr for a raw pointer but surely there will be a leak or undefined behavior somewhere in there still, no?
>>
>>54380110
The main purpose of c is to be an high level language abstracting the underlying architecture.
>>
>>54380121
>Objects can be null in most languages
Yes, that's literally what I said.
>>
So I'm trying to get a JSON file from mySQL via PHP.

$Recordset1 = mysqli_query($query_Recordset1, $RemoteDB) or die(mysql_error());

$rows = array();
while($r = mysqli_fetch_assoc($Recordset1)) {
$rows[] = $r;
}

echo json_encode($rows);



This results in me getting:

[]

Any fixes? I'm should return 1 or 0 rows. And I can successfully get the URL variable.
>>
File: compscidegree.png (66 KB, 691x682) Image search: [Google]
compscidegree.png
66 KB, 691x682
decided I need to learn java because so many algorithms books and online resources use it

should I just stick to command line programs or is there some cool shit written in java? web frameworks, gaymz etc?
>>
>>54378851
Bump
Anyone got some C++/C commercial apps too?
>>
>>54380110
It is classified as a high-level language no matter how low-level it feels
>>
>>54380139
That does not make it a dynamic typing issue then. If something does not hold a reference, you can't use any non-static functionality. It's not dynamic typing because "this reference which points to this type isn't pointing at anything". It's not a type issue, it's a reference issue
>>
>>54380110
where do you draw the line? is C++ a high-level language? C might give a js/py shitkid the illusion that he's some kind of epic hacker with the manual memory management and shit but C is basically just fizzbuzz tier stuff which is in any C-derived high level language
>>
>>54380147
>web frameworks
Spring
>games
a meme

Use a different language if you care about fun
Do webdev if you care about money
>>
>>54380132
You're joking right. I mean, python is considered a high level language, ruby is a high level language. And you really think C is a high level language?
C is low level because it is close to the hardware. That's why kernals are written in C.
>>
>>54380180
>it's not a type issue

type 't option = None | Some of 't
let bind f = function | Some x -> f x | _ -> None
let map f = bind (Some << f)
>>
>>54380110
>only 4GLs are high level
That is the true autism.
>>
>>54380199
C works can run on pretty much any computer hardware
>>
>>54380199
https://en.wikipedia.org/wiki/High-level_programming_language
>>
>>54380199
>C is low level because of my arbitrary definitions
It's high-level no matter how close to the hardware it is compared to python
>>
>>54380180
> It's not a type issue, it's a reference issue
Yes, it's a *dynamic* type issue.

All dynamic typing means is that types are resolved at runtime, not compile time. Not everything in almost any statically typed langugaes is always resolved at compile time. Casting types can only be done at run time for example, and determining if a variable has a reference to an instance of it's type, or a null can often also only be checked at run time, as it is in C# and Java.
>>
>>54380240
>All dynamic typing means is that types are resolved at runtime, not compile time.
Yes, and a reference is typed, it just doesn't have to point at anything. Just admit you're retarded
>>
>>54380258
C++ references can't point to nothing
>>
>>54378072
Exceptions
>>
>>54378072
setjmp + longjmp
>>
>>54380274
I already said monads and he was already talking about goto
>>
>>54380281
there is literally no legitimate use for setjmp longjmp, at all.
>>
>>54380263
A C++ pointer can
>>
>>54380258
>it just doesn't have to point at anything
Which is what makes it dynamic. So you can't tell until runtime weather or not it's pointing to something. Just like in any dynamic langugaes you can't tell if a variable if pointing to nothing, if it was never defined, if it is a number or if it is an object. It creates the same problems. When your variable can only refer to an instance of the defined type or nothing, then you narrow the potential for bugs at least. But you don't gain much, which again, is why more statically typed langugaes don't allow null references.
>>
>>54380312
Yes. So you do a null check as soon as possible and pass it as a reference, or use a Maybe, Error or Exception monad
>>
>>54380324
>Monads
>C++

u wot
>>
>>54380300
to implement exceptions, obvioualy
>>
Is it useful to learn ruby if I don't know html/css ? I really don't want to learn html/css.
>>
>>54380323
You can't tell what a lot of things are at runtime. It doesn't automatically make it a typing issue.

Oh a variable is 0 instead of 4 at this moment of time? Must be a dynamic typing issue.

It's essentially the same as a reference, since they hold values.

If anything, what you're referring to is a dynamic referencing issue. There is nothing to do with typing in this issue you're referencing, and this whole argument has only fortified my initial experiences in that dynamic typing isn't the issue people make it out to be
>>
>>54380340
>what is programming
>>
>>54380324
Whatever action you take against it does not make it a dynamic typing issue
>>
>>54380352
Can't tell if b8 or legit confused but I'll bite

Ruby is a general scripting language, it can be used for much more than web dev. You're thinking of Ruby on Rails, a web development framework written in Ruby.

So yes, it might be useful to learn Ruby even if you do not know HTML/CSS.
>>
>>54380362
>Oh a variable is 0 instead of 4 at this moment of time? Must be a dynamic typing issue.
But both are the same type anon. Are you stupid?

DatabaseConnectionManager and Null are not the same type. You cannot call the same methods on them, you cannot change the same fields. 0 and 4 are the same type. Do you even know what a type is? I hope your not the anon from before. It makes my head spin how retarded some people on this thread are sometimes, even ones with jobs.
>>
>>54380392
Well thanks. Actually I knew that, but I wanted to check because everytime I'm looking for Ruby resources, this RoR son of a whore is all over my face, so I never found a good general Ruby since they're all about the framework
>>
>>54380400
Are you stupid? An instance is merely a pointer to an address. That address can be null. It makes my head spin how retarded tripfags are
>>
>>54380427
general Ruby book*
>>
>>54380377
Yes they do, because there's no point in your program at which you can say that it's safe to pass by type alone. In a static language you can do this:

Divide(Integer Numerator, NonZeroInteger Denominator);
>>
>>54380434
>It makes my head spin how retarded tripfags are

Don't rope me into this.
>>
>>54380453
Still not a typing issue, since you're passing type in in both cases
>>
>>54380427
>>54380441
The Well Grounded Rubyist
Ruby in a Nutshell
The Ruby Programming Language
>>
>>54380471
What are you talking about?
In a dynamic language you can't fucking do this

Divide(LiterallyFuckingAnything Numerator, LiterallyFuckingAnything Denominator)

So if you want to be safe from the callee's point of view alone, you need to do EVERY fucking check. Type, nullable, etc.
>>
>>54380485
Yes I've seen those
Thing is, they cover Ruby 1.8 or 1.9, and the latest stable release is 2.3.1

Are they still relevant ?
>>
>>54380498
Still not a typing issue

Types can be addresses, the thing referred to by that address can be null

An object's function is stored in an address, and an object you're referring to won't even know that address if you're point at data not initalized yet.

This is an issue of referencing and data. You can even increment/decrement points and all of a sudden it's garbage, the type didn't change.
>>
>>54380546
>anon points out a problem a programing style that can be fixed with static typing
>LALALA its not a typing problem I cant hear you nulls exist you can increment pointers
????
>>
File: tumblr_nbjj2zZDOY1qjnxico3_500.gif (747 KB, 500x375) Image search: [Google]
tumblr_nbjj2zZDOY1qjnxico3_500.gif
747 KB, 500x375
>>54379427
>allowed_types doesn't include .webm

i mean, lol all in all this is a solid python program. You pass.
>>
>>54380585
Whether or not it can be solved by static typing does not make the initial issue a typing problem, it is still a referencing issue

and fyi, dynamically typed languages also have null check functionality so you even fail at arguing from that viewpoint
>>
>>54380608
>dynamically typed languages also have null check functionality
We're telling you that's a bad thing anon. Removing nulls removes the need to checking for them, without causing any problems.
>>
>>54380129
> I don't always destruct my Zee, but when I do, I also destruct my Zee

You can't give ownership of an object to a ptr that lives inside this exact object m8, your code doesn't make any sense whatsoever. The destruction of the Z triggers the destruction of the a pointer inside, which then tries to deallocate and destroy the Z, a process which is already going on...

>I'm about to just remove the unique_ptr for a raw pointer
Another thing that makes no sense: you already have access to "this", which is basically a raw pointer to the object itself already, just FYI...
>>
>>54380721
I don't care what kind of functionality you want to be safe, it's still not a typing issue
>>
>>54380532
Well Grounded Rubyist 2nd Edition covers up to 2.1, so probably
>>
>>54380747
It is a typing issue anon. But whatever, it is a problem fixed by static typing. That is the core point.
>>
>>54380781
Nope, it's not, and non-nullable functionality is not even conceptually tied to static typing

>>54380783
You too
>>
>>
>>54380814
>non-nullable functionality is not even conceptually tied to static typing
yes it is, as only static typing can make null and undefined impossible. Dynamic typing requires at least one of these.
>>
>>54380865
>as only static typing can make null and undefined impossible
Nope, there is functionality in dynamically-typed languages to check against these, and there exists potential for static type languages to have variables of type x pointing to nothing (which isn't of type x). Nice try though
>>
>>54380732
I think you misunderstand how pointers work. They aren't auto deleted, so having a raw pointer to Z in the A/B/C series will only delete the POINTER upon destruction of A/B/C, not the object itself (note that I did not type delete z; in any of my destructors)

I made it work, the Z's were being constructed in an array but they weren't being default constructed. I had to do Zarr = new Z[size](); Basically it looks like my unique_ptr was incomplete and it cascaded down a whole bunch of fuckery.

This being despite the fact c++ is supposed to guarantee non-primitive's default constructors are called upon array construction, oh well.

Thanks for reading and responding tho m8, seriously. Hopefully we both learned something.
>>
>>54380893
>there is functionality in dynamically-typed languages to check against these
at runtime, not compile time. That's the point.
>>
>>54380915
Again, even in static-typed languages, you still have runtime issues, variables not pointing at anything. The fact that there exists free memory to allocate automatically means your language will have runtime issues, and possible null values for whatever datatype. Regardless, it's not a typing issue
>>
>>54380948
>you still have runtime issues
No shit. You're still fucking wrong, but clearly the claim that nobody has fucking made has now been contradicted.
>>
>>54380948
>variables not pointing at anything
Not in all static langugaes anon. Some langugaes make this impossible.

>The fact that there exists free memory to allocate automatically means your language will have runtime issues, and possible null values for whatever datatype.
100% untrue.
>>
>>54380948
Static language:
int add(int a, int b) { return a + b; }

Dynamic language:
add(a,b) {
if a is not null
if b is not null
if a is an int
if b is an int
a + b
}
>>
>>54380968
Nope. I'm right. It's a referencing issue. Just because you don't know if something is referring to anything at runtime doesn't make it a typing issue.

>Some langugaes make this impossible.
So it's not something static typing fixes. Nice try though. And in those languages when something is still referred to, it doesn't mean it's anything that matters or is intended, making it, again, a referencing issue
>>
>>54380849
>infinity contributors
uh
>>
>>54381028
No, in a dynamic language ANYTHING could be an invalid reference or the wrong type
In a static language this is not the case, only SOME things can be invalid references - and you can tell that from the TYPE
>>
>>54381028
>So it's not something static typing fixes
??? Some statically typed langugaes make this impossible, with help from the type system. How the fuck did you even reason that a good reply? Dynamic typing advocates are the worst.
>>
>>54381010
Not sure why you're replying to me considering int can initially hold converted values of types that convert to int, making a + b return something entirely pointless. And it's also not relevant to our argument

>>54381050
>only SOME things can be invalid references - and you can tell that from the TYPE
So static typing is only good if you don't create new types dynamically? (and not dynamically as in typing) Got it

>>54381059
However the type system helps, it doesn't make it a typing issue. Even if it's impossible for something to not refer to null or undefined, in the case you use it in the same way you do in another language that did let you refer to null or undefined, you're referring to something unintended and thus worthless
>>
>>54381101
What are you talking about? Have you ever used a statically typed language?

Int can ONLY HOLD INTS.

>so static typing is only good if you aren't doing dynamic typing
no shit, but dynamic typing can be implemented in a statically typed language
>>
>>54380894
>They aren't auto deleted
Kiddo, if anything you're the one who doesn't understand pointers: unique_ptrs are auto deleted by definition, altho raw pointers aren't.

>Basically it looks like my unique_ptr was incomplete and it cascaded down a whole bunch of fuckery
Ok. Plausible if you're sure that the destructor wasn't being triggered.

>This being despite the fact c++ is supposed to guarantee non-primitive's default constructors are called upon array construction, oh well.
You sure about all of that?

>Thanks for reading and responding tho m8, seriously. Hopefully we both learned something.
Yeah maybe. Come back soon!
>>
>>54381101
>However the type system helps, it doesn't make it a typing issue.
You said
>variables not pointing at anything
I'm simply pointing out this is wrong. Whether you want to call it a "typing issue" or not, static typing makes this errors impossible.

>in the case you use it in the same way you do in another language that did let you refer to null or undefined, you're referring to something unintended and thus worthless
In a static language, your code won't compile and the compiler will tell you the exact part of the exact line that you made a mistake. That's the entire point. In the dynamic language the code will run and it will often take a long time to discover the mistake, and figure out what causes it. You are dumber than dirt not to know this already.

Imagine having to work with deadweight like this..
>>
>>54381166
>Int can ONLY HOLD INTS.
Have you? Type promotion is a thing in statically typed languages

>so static typing is only good if you aren't doing dynamic typing
Nice try rewording my post. If you really think sticking to primitives is the only good practice for using static typed languages, you definitely don't know what you're talking about

>>54381192
>You said
>>variables not pointing at anything
Variables that you don't make point to anything are equally useless

>your code won't compile
Has nothing to do with the initial issue
>>
>>54381209
>Variables that you don't make point to anything are equally useless
and your point is?

>Has nothing to do with the initial issue
Which was?

You sound like a lunatic. You're rambling about different points that have fuck all to do with each other. You have some kind of serious mental disorder.
>>
>>54381209
>sticking to primitives
What the fuck are you talking about? Languages with boxing?

>
That's type CONVERSION. Whatever it was before, it is NOW an integer. The conversions follow STRICT RULES that are USEFUL.
int x = 4.f; // integer variable, float literal
x is NOT A FLOAT
>>
>>54381248
>You're rambling about different points that have fuck all to do with each other.
You'd know considering you've been confusing typing issues with referencing issues this whole time

>>54381256
> it is NOW an integer
Can still hold something entirely pointless which is the actual point, since it was casted from its original type
>>
>>54381293
>can still hold something
it HOLDS AN INTEGER

>could be pointless
Except in 99% of the cases it isn't, and if you really don't want ANY implicit casts you can often enable that on compilers. VC++, by default, flags unsafe implicit casts.

Even if casts were a bad thing, you could literally just avoid them.


Oh, and nobody's even fucking mentioned performance.
>>
>>54381209
>Type promotion is a thing in statically typed languages
Type promotion only makes an int out of a value of a suitable type, whereas your dynamic typing allows to put any value anywhere unchanged. It's very limited in its applications, and if it's used mistakenly there will be a compile time error, it doesn't amount to subverting the type system entirely, if so what would be the point?

>If you really think sticking to primitives is the only good practice for using static typed languages, you definitely don't know what you're talking about
No one's saying that. User defined types are still static in statically typed languages, and the compilation process enforces the exact same guarantees about values of these types than about primitives.

All of this makes me ask: have you ever actually programmed?
>>
Why does Hime have wide shoulders? :/
>>
>>54381325
>it HOLDS AN INTEGER
Yep, a potentially useless integer

>Except in 99% of the cases it isn't
That's up to the dev who uses it.

>>54381334
>and the compilation process enforces the exact same guarantees about values of these types than about primitives.
And it makes no mention of what happens when a reference points to something useless at run-time

>have you ever actually programmed?
Shouldn't matter considering the only thing that matters here is that reference issues are not typing issues, but if you want some validation so you're not buttblasted about being shown wrong by a newbie, I've been programming in C, C++ and Java for the past 15 years
>>
>>54377924
I want to marry Himegoto
>>
>>54381423
k fag
>>
>>54381423
shut the fuck up fag
>>
>>54381443
>>54381443
You guys just don't understand how cute he is
>>
>>54381398
>potentially useless
You are literally retarded.
This is what you're fucking saying:

>int x = 5;
>x = 382757293578;
>SEE? STATIC TYPING IS SHIT

Do you know what a fucking compiler warning is?
Do you know that you can program statically without any fucking casts? Do you know there are probably languages where you CAN'T implicitly cast?
Do you know how retarded you'd have to be to fuck that up?
Do you know that there might be occasions where that functionality could be fucking useful?
Do you know that the compiler/interpreter has no idea what's useful and what's useless without types?


You're fucking crazy and literally everyone else is telling you so.
>>
>>54381386
because it's a boy pretending to be a girl for the money
>>
>>54381483
No, what I'm saying is
>int x = 5.5;
>x = 5;
>oh shit, let me meme about integer averages on /dpt/ due to this retardation!

Yes
Yes, not the point. Also not the point
About as retarded as you'd have to be to fuck up in a dynamic language, and I've experienced this professionally first-hand
Yes, still not the point
Exactly

So nothing so far has said anything about the initial issue not being a referencing issue, because it still is, no matter how adamant you are about how much you know your types
>>
>>54381398
>And it makes no mention of what happens when a reference points to something useless at run-time
So you're bitching about null pointer dereferencing? Again, in most statically typed languages (not Java I know) nullability is the exception and not the rule and you get shouted at when you don't initialise variables, so useless values are very rare.

Please explain your point about user-defined types and primitives.

>reference issues are not typing issues
They are. Enjoy your everything-can-"potentially"-be-null-or-undefined perfect world.
>>
I'm making a program that groups files on the cwd and the moves them to the desired folder. You cant choose the folder yet, I made it for my personal use that's why it doesn't ask where is it going to be moved.

It's completely made in python.

Who feels like contributing ? :D

also

I need to see if it works on win 10

can anyone try for me please? I don't have a windows 10 machine and my connection speed will take weeks to download an iso
>>
>>54381483
And it wouldn't even matter if you were that fucking dumb.
Typed parameters don't guarantee "the input is useful to the caller" or whatever. They don't care about the caller. The type tells them that the parameters are useful to THEM. That THEY can operate on the parameters. And the return type tells the caller what the result will be. No language can determine what's "useless", because as far as it knows everything is useful.

>>54381513
Some static languages don't allow this. What then?
>Not the point

>I believe all statically languages have this crucial flaw because of feature x
>statically typed languages which don't have feature x aren't relevant

It's much easier to fuck up in a dynamic language because the compiler knows a lot fucking less. The compiler can't say "you're casting a float to an int", it doesn't fucking know.

>nothing has been about referencing
99% of static typing has NOTHING TO DO WITH REFERENCES
C++ has NON-NULLABLE REFERENCES
Functional languages have OPTION TYPES
>>
Jesus H. Christ.
>>
>>54381482
kill yourself
>>
>>54381546
>So you're bitching about null pointer dereferencing? Again, in most statically typed languages (not Java I know) nullability is the exception and not the rule and you get shouted at when you don't initialise variables, so useless values are very rare.
Isn't completely caused by uninitialized variables, and in most cases when dealing with dynamic data, it isn't

>They are
They aren't

>>54381569
So.. you still can't refute that the reference issue is a reference issue and not a typing issue?
>>
>>54381594
What are you fucking talking about?
It IS a fucking typing issue

1) If you have static types, you can check a nullable reference ONCE and then convert it to a non-nullable reference. Then you can do whatever the fuck you want with it KNOWING IT'S SAFE.
(simplified GC or shared_ptr example)

2) NON NULLABLE REFERENCES CAN'T BE FUCKING NULL
DYNAMIC LANGUAGES CAN'T HAVE NON NULLABLE REFERENCES

3) Option/maybe types allow encapsulating the idea of absence or nullability and provide higher order functions (e.g. map and bind) that perform actions if it's there and no actions if it isn't
>>
>>54381594
>you still can't refute that the reference issue is a reference issue and not a typing issue?
The issues a reference potentially referring to a null is a typing issue. It is an issue with not knowing the type of the reference at run time. Is it a reference to an object, or is it a null reference? 95% of the time you only want it to be one or the other in actual code, so why not let the compiler know which one it's intended to be at compile time as many langugaes do?
>>
>>54381672
>>54381682
It's not a typing issue.

A type describes a format of data
What it refers to is the data
>>
>>54381594
>Isn't completely caused by uninitialized variables, and in most cases when dealing with dynamic data, it isn't
Fuck does it come from? Is it nullability or not? Dynamic data has to be sanitised whatever if the typing is static or dynamic, that's for your 15 years of experience, and even then I don't see how you can break the type system...

>>54381569
>C++ has NON-NULLABLE REFERENCES
>Functional languages have OPTION TYPES
Agreed, ty bro

Personnally, I'm going to argue that "reference issues" are a typing issue in the sense that most types are safe against them and that the ones that aren't are clearly marked, but I'm not the same anon. Regardless, you still seem not to read half the stuff that's written in your direction.
>>
>>54381702
A type is a lot more than a fucking format

You know what? A NULLABLE reference being NULL is NOT AN ERROR, and NOT AN ISSUE. That's what NULLABLE means. If you wanted to ensure it isn't null and it never becomes null, you should use a NON-NULLABLE reference, which DOESN'T EXIST IN A DYNAMIC LANGUAGE.
>>
>>54381736
Doesn't matter where it exists, it isn't a typing issue
>>
>>54381750
Yes it is
>>
can I do something like this, is it undefined behavior?

class Base {
bool x;
int work1() { return 4; }
virtual int work2() = 0;
int foo() {
if(x)
return work1();
else
return work2();
}
};

class Derived {
int work2() { return 5; }
};

Base* b = new Derived();
int x = b->foo(); //x should be 5, is it?
>>
x = 0
while x < 1:
print ('FUCK OFF NORMIES REEEEEEEEEEEEEEEEEEEEEEE')
>>
>>54381750
Literally any issue can be turned into a typing issue and avoided with types
>>
>>54381788
>>54381760
isnt
>>
>>54381761
looks like completely defined behaviour
>>
Can I get a programmer job with no computer science qualifications and a degree in an unrelated STEM subject?

I need to know because of reasons
>>
>>54381761
Totally defined as long as the effective type of *b is Derived, see? Otherwise what would be the point of abstract virtual methods?
>>
>>54381840
if you have experience you don't need a degree
Thread replies: 255
Thread images: 28

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.