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

/dpt/ - Daily Programming Thread

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

Thread replies: 391
Thread images: 16

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

What are you working on /g/?
>>
First for tensorflow
>>
1st for alpha pureness
>>
>>56580442
>gets 2nd
beta asf
>>
>>56580427
>What are you working on /g/?
Trying to do a very fucking complicated task in SQL.

Will probably do it manually for now so I can finish this project, but I'm trying to essentially generate a set of queries to retrieve all the underlying rows from all the tables joined within a view.
>>
if const char *cuck[4] holds 4 pointers to strings(who aren't the same length) then how does the compiler determing (cuck + 1) if the storage units aren't the same
>>
6th for C-style syntax is ugly
>>
>>56580474
>SQL
are you also using php
>>
>>56580489
No.
>>
9th for c++
>>
>>56580484
Because the pointers have all the same size.
>>
>>56580484
>to strings
To arrays of chars. Not all char arrays are necessarily strings.
>if the storage units aren't the same
The pointers themselves are the same size.
>>
>mfw it's almost 2017 and all /g/ knows is C
>>
>>56580534
trudeaux pls go
>>
>>56580534
Sucks to have no face
>>
>>56580488

C function pointer syntax and macros are ugly. Most of C style syntax is fine though.
>>
Identifier : type = value
Vs
type identifier = value

Which do you prefer?
>>
>>56580593
it's the same
>>
>>56580534
https://en.wikipedia.org/wiki/Chronological_snobbery

it's the current year and haskell is still shit
>>
>>56580623
no it's not this extremely minor aesthetic difference is VERY important to me and needs to be discussed on my peruvian llama herding forum
>>
>>56580593

The latter is what I'm used to most of the time. I have no problem with either. I also have no problem with the Ada-style := syntax instead of using = for assignment. Unfortunately, Go has hijacked it, and Go is a shit language.
>>

void f();
...
f(1, 2, 3);


This compiles fine in gcc but clang throws a warning.
What am I supposed to do?
>>
>>56580719

What is the warning?
>>
>>56580734
too many arguments in call to 'f'

Although some versions of C are supposed to allow this.
>>
>>56580739
Wait, actually, >>56580719 does work, but my actual case is the exact same thing with a different name and an actual definition of the function.

long f()
{
return 0;
}

int main()
{
f(1,2,3,4,5,6);
return 0;
}


This won't compile in clang without warnings.
>>
>>56580739
are you compiling it as C++ or something? which version of C?
>>
>>56580777
I'm using clang 3.8.1, the file has a .c extension, I'm not passing any flags.

See >>56580772 for a practical example, my original post was off.
>>
>>56580719
>>56580772
The real question is: why the hell are you doing that?
I'm not sure if passing too many arguments to a non-varidaic function is undefined behaviour or not, but it's a really stupid thing to do.
>>
>>56580739
C11 made empty function parameter declarations obsolete (i.e they might be eligible to be removed in future versions).
Disable that warning in clang if you don't want it complaining about it.
>>
>>56580801
I just looked it up:
http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1570.pdf
>6.5.2.2 Function calls
>If the number of arguments does not equal the number of parameters, the behavior is undefined.
Yup. Don't do that shit.
>>
>>56580739

Okay, I see your problem.

Yes this is allowed in standard C.
No it isn't good practice.

This declaration:
void f();

Means that any number of arguments can be given to f.

Meanwhile, this declaration:
void f(void);

Means that f cannot take any arguments, and providing any is an error.

When writing standard C, you should prefer the latter.
When writing C++, you may prefer the former, as it is equivalent to the latter in C++.
>>
>>56580593
While I prefer
id : type = val
for single definitions multiple definitions in one statement are either just looking stupid or have unnecessary repetitions:
id1, id2 : type = val1, val2
id1 : type, id2 : type = val1, val2
>>
first of all i dont even know C
>>
>>56580900

Well are you going to learn it now, or are you going to pride yourself on not knowing it for a few years until you have to learn it, and then bitch about how much you hate it the whole way through?
>>
How can I become more like Grand Magus Jon Skeet?
>>
>>56580924
>until you have to learn it

Does anybody really NEED to learn it?
>>
File: Don'tEvenNeedATitleForThisOne.jpg (202KB, 910x822px) Image search: [Google]
Don'tEvenNeedATitleForThisOne.jpg
202KB, 910x822px
What are some good resources to learn OpenGL and/or Cocoa?
>>
>>56580983
Not unless they're in school.

Similar to a company telling me I have to mop the floors, I would also put in my two weeks if they informed me that I must use C in a project.
>>
>>56580987
opengl bibble
>>
>>56580934
>write a SO bot
>write a few more sock bots to upvote/ask questions your bot can answer
>???
>profit
>>
>>56580987
For online tutorials, the best one I've come across was http://open.gl/
>>
>>56581104
it's extremely basic it's good for getting started but you need to do a lot more reading after it
>>
>>56581104
>>56581048
Thanks!
>>
>>56580534
Except that's literally not true

>>56578834
stupid frogposter
>>
>>56580593
identifier := value // Type is inferred
and
var identifier type
for declaration only.
>>
Can I see a double int or a long double in action in c++? Who's variables go up to 15 goddamn digits? Is it used primarily for random generation or what?
>>
File: aoba code monkey.jpg (169KB, 1280x720px) Image search: [Google]
aoba code monkey.jpg
169KB, 1280x720px
fresh oc
>>
>>56581256
scientific computation and/or internal representation in numerical methods would be my guess, maybe something in fintech
>>
>>56581388
so, for a normal programmer all a double and long double are for is tracking fractional numbers? (1.163211) for storage purposes, otherwise it's for high level shit?

Isn't it possible to use only unsigned shorts as all your types? It seems much more efficient if you're not working with huge amounts of out-to-the-billionth variables
>>
>>56581439
>all your types?


By this I mean the ones which obviously aren't negative
>>
>>56581439
>Isn't it possible to use only unsigned shorts as all your types?
not if you want to work with fractions a lot.
>>
>>56581473
Is that a suggested way of doing things, though? Using unsigned types whenever you can?
>>
>>56581489
no
>>
>>56581489
Not really getting what you're saying. You use unsigned ints when it makes sense to. When it doesn't make sense, don't.
>>
>>56581456
of course not, you need to pick the right resolution for your work
>>
>>56581501
>>56581496
>>56581507

Isn't unsigned faster than signed, though? I'm only asking because the books I'm reading now imply they're easier on data allocation, so I'm mostly asking for myself
>>
>>56581518
I have no idea myself. But if you have a reason to specifically make an int a signed int, then there's no reason to make it unsigned. Unless you're maybe making some utterly insane sort of optimisation that I've never heard of before...
>>
>>56581518
for some things, like bit twiddling, you're supposed to use unsigned, but for many other things you should obviously use signed, and signed isn't (significantly) slower for most things
>>
>>56580593
identifier = value : type
>>
>>56580593
>>56581552
And, of course, the annotation can be omitted if the type can be inferred.
>>
>>56581552
Does any language do this? Looks more like a type casting.
>>
>>56581567
kill yourself
>>
>>56581587
Some functional languages do, but they also allow to separate the type annotation from the (often pattern-matching) definition.

>>56581595
datafag
>>
>>56581606
literal fag
>>
>>56581518
faster does not make sense in this context, the performance of floating point instructions vs integer depends on the cpu architecture mostly, but it has many factors and I would wager the actual calculation is not the dominant
>>
>>56581587
Haskell with ScopedTypeVariables or PatternSignatures
(x :: a) = b
x = (a :: b)
>>
>>56581631
*b :: a
>>
File: muhdebugging.jpg (425KB, 2543x946px) Image search: [Google]
muhdebugging.jpg
425KB, 2543x946px
So, pretty much a total newfag dipping my toes into OS shit so I can actually debug stuff in the real world

so I downloaded c:dda and started to build it

immediately hit with redefinition errors, supposedly something about time management is all fucked up.

Is this something that's safe to ignore? Isn't this bad practice?
>>
>>56580484
>If they're not all the same size
They are the same size though, even if the variables they point to aren't
>>
>>56580815
Even specifying C89 or GNU89 on the command line doesn't get rid of the warning.

>>56580855
>Means that any number of arguments can be given to f.

Yes I know the difference, that's on purpose. I have inlined asm in there that mess up with the parameter registers, so I don't need named parameters.
The only other way to have variable arguments are this and having a named argument + ..., but the prologue gets filled with irrelevant things I don't want.
>>
>>56581732
clang is trash lol just use gcc
>>
>>56581830
You can't how much I wish I could.
>>
File: 1436736846280.png (121KB, 1554x626px) Image search: [Google]
1436736846280.png
121KB, 1554x626px
My friend is starting java in uni in a month, I told him it would be a good idea to get familiar with it in this time, anyone got a good resource for learning java?
>>
>>56581890
https://docs.oracle.com/javase/tutorial/
>>
>>56581518
You should generally use your default data type for everything, that is, Int, unless you need autistic perfomance fains
>>
>>56581890
>My friend is starting java in uni in a month
May God have mercy on his soul
>>
>>56581946
I know right

He actually said he might be doing hasklel later though
>>56581915
I will have a look at all these links, but it seems like these are different tutorials for different areas of the languages, I was hoping for one which goes from basics like hello world to more complicated stuff like muh OOP, a start to finish tutorial if you will
>>
>>56581944
*gains
>>
>>56581984
>He actually said he might be doing hasklel later though
That was fast, God's already given him mercy
>>
>need simple string SHA1 function in JS
>stumble on package with 2K monthly downloads
>it's just two functions that wrap Node's stdlib
var crypto = require('crypto')

function sha1 (buf, cb) {
var hash = sha1sync(buf)
process.nextTick(function () {
cb(hash)
})
}

function sha1sync (buf) {
return crypto.createHash('sha1')
.update(buf)
.digest('hex')
}

module.exports = sha1
module.exports.sync = sha1sync
>>
>>56582062
JS has already overtaken Python?
>>
>>56581984
>I know right
nice meme
>He actually said he might be doing hasklel later though
why the fuck, even to a completely clueless person there is no compelling argument to learn haskell
>>
>>56582111
>there is no compelling argument to learn haskell
mind expanding
>>
>>56582071
JS is probably worse off than Python. Python may have the """enlightened""" pythonic crowd, but JS is swarming with retarded frontend web designers that couldn't program a fizzbuzz without importing a trendy hip library/framework.
>>
>>56582062
what's the problem?
>>
>>56582121
>where's the API?
>>
>>56582118
it's shit, very few people use it and even fewer people use it commercially and for good reason, it's obscure and irrelevant
>>
>>56582121
>JS is swarming with retarded frontend web designers that couldn't program a fizzbuzz without importing a trendy hip library/framework.
Just like Python
>>
>>56582130
That there are 2K people every week that import 15 lines of code, because they can't read 2 paragraphs of documentation.
>>56582135
You're looking at it. The entire API is 2 functions.
>>56582147
Fair point.
>>
>>56582142
Good concepts in it though, even if it is a shit language for real work.
>>
>>56582181
>Good concepts in it though
nope it's just a bunch of shitty memes
>>
Learned assembly and made an exokernel and unix like OS, did some hardware programming, decided I don't like this shit and now I'm doing webdev lel
>>
>>56582192
envy
>>
>>56582163
>That there are 2K people every week that import 15 lines of code, because they can't read 2 paragraphs of documentation.
Why bother when they don't have to? This is certainly something I'd use. I'm not even certain how the API it's wrapping works, and I don't care enough to bother learning. If I just want to encrypt a string and not spend long doing it, why not spend 5 seconds downloading a library that is tested by 2k people every day? Instead of learning an API i probably won't be using again anyways and then debugging my implementation and whatnot.
>>
>>56581003
b8
>>
>>56582205
looooooool k
>>
>>56582213
>looooooool k
hello facebook
>>
>>56582192
You sound like a nigger talking about how science class is racist and shit while he painfully remembers not being able to understand anything that all the smart kids understood with ease.
>>
>>56582206
kill yourself and fuck off to >>>/g/wdg
>>
How code rectangle xxxx
x x
xxxx pls
>>
>>56582228
>JS is only for webdev
my child...
>>
>>56582241
your child is right
>>
>>56582241
>using JS for anything but web dev
not sure if trolling or just retarded
>>
>>56582241
It is only for web dev, that's how it gets away with being such a shitty language.
>>
>>56582272
How is that programming?
>>
>>56582281
I'm correct.

>>56582293
no
>>
>>56582206
kys
>>
>>56582300
Yes.
>>
>>56582300
hope you're trolling, because js is awfully slow, not secure, and just awful in general compared to other languages, there is no reason to use js over something like C, C++ or even Python if you're not doing web dev.

I know I'm right because you can't give one good reason to use js other than webdev.
>>
Reading the HoTT book.
>>
>>56582343
Obviously anything more than JS is too complex for him to grasp and use anon
>>
>>56582302
>when your brain compiler keeps throwing errors
>>
>>56582353
got any insights to share?
>>
>>56582343
I'm saying it;s used outside of web dev these days. I'm not saying it's not a terrible language.

>you can't give one good reason to use js other than webdev.
you can make desktop apps for example and share a codebase and skill sets with a web project. There's not a lot of good reason to use JS outside of webdev, but there are some.
>>
>>56582359
Not true :^)
>>
>>56582372
If by front end you mean faggot web designers who make $35k then back end.
>>
>>56580714
>Ruby
>calling Go a shit language
kek
>>
>>56582378
Earlier an anon posted a text editor in NodeJS that took 500mb ram for a single tab, so JS is a bad option, I guess you just struggle with anything more than babby tier
>>
>>56582237
pls i have family to feed
>>
>>56582419
go is ludicrously bad tho
>>
>>56582421
I don't know why you're assuming I use JS a lot. My only claim was it's used out of web dev.

Pointing out that atom is a peice of shit doesn't counter that point.
>>
>>56582394
I see. Does that mean learning HTML + CSS is not worth the effort? It's been easy so far, but would I be better off learning Python or Ruby and then some sort of framework?

What do you do, guy?
>>
>>56580714
Haskell
>>
>>56582444
it has no legitimate use outside of web dev
>>
>>56582444
It wasn't atom tho, it was self-made using NodeJS and GTK, GTK doesn't have memory leaks. Also the multithreading model in NodeJS is awful. I guess you're just rushing to go back to ERPing being a hot girl and sucking cocks you dirty sissy fag.
>>
>>56582237
puts("xxxx\nx  x\nxxxx");
>>
>>56582485
What's you point then? Someone can make a text editor in C that leaks a lot of memory. Hardly proves anything.

>I guess you're just rushing to go back to ERPing being a hot girl and sucking cocks you dirty sissy fag.
No idea what you're talking about you strange nigger.
>>
>>56582504
nigge
>>
>>56580427
So I have project(a) on github and a friend ported it to android how does he go about adding it to my repo without me taking credit for it, does he just git clone, add the files git commit then git push or what?
>>
>>56582421
>Earlier an anon posted a text editor in NodeJS that took 500mb ram for a single tab, so JS is a bad option

Do you realize how completely moronic you sound?

>This one time there was a bad thing of class X so all things in class X must be bad.
>>
>>56582509
it will leak less than your anus after your bf is done with you you scarf wearing starbucks sipping hipster faggot
>i dont know what you're talking
sureeee
how does cock taste btw?
>>
>>56582453
You can learn HTML+CSS in a couple of weekends, it's more "art" than programming, that's why there are so many of them and thats why they make so little. If you actually study programing and data structures you can apply that in other places other than development like security, giving you much better career opportunities. Don't get a specialized degree either, if you think you want to be a software engineer don't get a software engineering degree, get a computer science degree, much more broad.
>>
>>56582557
>Do you realize how completely moronic you sound?
>>This one time there was a bad thing of class X so all things in class X must be bad.
>A single example of something that shows it in a bad light automatically means there's no flaw since it was a single example
just shut up and dont embarrass yourself anymore man
>>
>>56582573
>how does cock taste btw?
I don't know, I'm not flexible enough. Tasted my cum though once. Tasted like snot..
>>
>>56582586
Who was claiming JS hasn't a single flaw?
>>
>>56582586
Look, I know you're trolling at this point, but I've got to say that this is some next-level shit in the off-chance that you're actually being serious.

I'm not claiming JS is good, but to claim anything is necessarily completely bad based on one occurrence is just silly.

No one claimed JS doesn't have a single flaw, but you clearly made the argument that because that one application was poorly written, JS is "a bad option".

I think it goes without saying that I'm not going to bother responding to any more of this blatant bait.
>>
File: 1464500735854.png (842KB, 756x1080px) Image search: [Google]
1464500735854.png
842KB, 756x1080px
>write a big chunk of code
>compile it without errors
>program does exactly what you want
>>
>>56582619
>faggot still fell for it
ws and faye are some good ass libraries
>>56582592
you obviously didn't have the good kind, I'll eat some pineapples for you tonight babe.
>>
>>56582636
feels good man
>>
>>56582619
>No one claimed JS doesn't have a single flaw
JS has more flaws than average
JS has WAY more flaws than average
>>
>>56582636
When this happens, I end up second guessing myself and spending tons of time anyway writing logging logic or stepping through breakpoints in the debugger to prove it's actually doing what it says it's doing.

Feels weird, man.
>>
>>56582656
No one disagrees freindo
>>
*signs up for github*

heh... on my way to becoming a pro...
>>
File: 1446936010271.jpg (96KB, 790x1012px) Image search: [Google]
1446936010271.jpg
96KB, 790x1012px
>>56582712
Look at this pleb who doesn't self-host
>>
>>56582727
what if someone ddoses my server
>>
>>56582751
you die
>>
>>56582761
im a big guy
>>
>>56582779
for me
>>
>>56582779
for me
>>
Making a multi client simple chat server in C++ with boost::asio. Holy fuck that is a clusterfuck. I'm either too retarded to understand the boost asio async C++03 examples for http server or they are retarded. There is some strange std::move shit going on and I don't understand half the reason why they do some shit.

Currently looking at the C++11 example and it makes a bit more sense with lambdas. This is going to take me a few a days to wrap my head around the OOP around it.
>>
>>56582896
>multi client simple chat server
or you could just make it in Go
>>
>>56583078
No I can't because the aim is to refresh my 10 years old C++ knowledge due to a new job. The more strange C++ magic I see the better. I've realized I hate OOP though.
>>
>>56582712
m8, gitlab is the new github if you missed, better feature set overall + just raised a big fat funding, github with its sjw stuff is finished
>>
>>56583078
You say that as if it's some kind of sane obvious choice.
>>
>>56583184
What's the best online repo that provides private repositories? I have git on my VPS but the provider reliability is what one can expect from $5 biennially. It has happened that my instance got lost in the void with all data lost.
>>
Why doesn't the Rust project impose their ownership/borrowing/lifetimes rules into a C compiler, rather than making a new language?
>>
>>56583151
>I've realized I hate OOP though.
you don't even have a somewhat reasonable excuse like some people do, you just suck
>>
>>56582485
>the multithreading model in NodeJS
There is no multithreading. To leverage multiple threads in Node you need to write a C++ extension.
>>
>>56583184
>trusting some random new startup
uh no thanks
>>
>>56583239
gitlab offers infinite private repos afaik (and I have multiple GBs there, they don't complain)

I used bitbucket before it offered 5 private repos but Atlassian went all jew with their cloud accounts and I can't login anymore thus I don't know whether they have private repos anymore
>>
>>56583286
>you just suck
Yeah man doing PLC programming and C the past 7 years kind of do that to you when you don't code on your free time.
>>
>>56583274
Because C isn't built on top of a theory that makes it possible.
>>
>>56582545
There are two main ways how that can be done:
1. He forks the repo. This will create a repository under your friends account where he can do whatever he wants. When he is done he can create a pull request which gives you the option to add his changes to your repository.
2. You add him to the list of collaborators which should give him the option to push directly to your repo.
>>
>>56583184
>doesn't integrate with Travis
Meh.
>>
>>56583433
Travis is a cunt
>>
>>56583357
thanks
>>
>>56583443
What's a good alternative for free integration testing? Inb4 manually running tests in a virtual machine after each commit and on each pull request.
>>
>>56583470
functional programming
>>
I can't find a fast solution for this (other than simple traversing the array twice): https://leetcode.com/problems/two-sum/
can someone give me some clue?
>>
>>56583532
Are you fucking suggesting that FP does not need tests?
>>
>>56583561
If your types are good enough, it does not need tests.

For instance, in a dependent language, you can construct arbitrary conditions for the type checker and it will force you to prove them.
>>
>>56583569
Can your type system prove the state of an external database after running a function (or any I/O for that matter)?
>>
>>56583614
A dependent type system can prove it conditionally, saying
"if the initial state fits these conditions, then the final state will fit these conditions"
>>
>>56583614
Do you have the source to the external database system? Then yes. Do you not have it? Then it doesn't matter, you just assume that the database acts to its specification and any problems are not yours to deal with.
>>
Rate my non-portable curry implementation in C!

#include "curry.h"
#include <stdio.h>

long add(long x, long y)
{
return x + y;
}

int main()
{
t_2 addf = (void*)add;
// curry can curry itself
t_curryg cg = curry(curry, (void*)addf).p;
t_1 add10 = cg(10l).p;
long k = add10(4l).v;

// eat curry
eat(cg);
eat(add10);
printf("10 + 4 = %ld\n", k);
}
>>
>>56580427
Hey guys i just finished my first C++ practice problem, and it works! But I'm wondering if there's a way I can improve on this.

http://pastebin.com/KHbigWDk

The problem was:

>Create a program which takes a string, and then for >each letter in the string, skip forward two places in the alphabet, and for each number, add 2.

>For example - ABC => CDE
>or ABC123 => CDE345
>>
>>56583753
Is this a joke.

To detect if its a character/number can be done in the same check.
Strings are ascii chars, so just check the value of each char.
>>
>>56583802
I'm a newfag programmer so I probably did a buncha shit wrong. I'll try doing it all in one check.
>>
>>56583730
Little comment on what's happening there:

The curry function takes two arguments, a function and an argument, and returns another function that takes one less argument.

I create the function cg that curries the function add with an argument, and use it to create add 10, but I could have directly do 't_1 add10 = curry(add, 10);'

The implementation is excessively wasteful in ressources, I think you could guess how and you would be right.
>>
>>56583634
But how do you query the state of the database with the type system?
>>56583646
Assuming you do have the source, you'd have to live in a magical world where all software is written in your favourite FPL. Most you can prove is that your dynamically constructed query matches what you expect. You can not prove that this query will produce the expected result, when executed by the DBMS at a certain state.
>>
>>56583833
>But how do you query the state of the database with the type system?
you say "given x we can judge y", then query x and use it to determine y
>>
>>56583833
>Assuming you do have the source, you'd have to live in a magical world where all software is written in your favourite FPL.
You can prove externally if the language isn't fit to prove internally.

>You can not prove that this query will produce the expected result, when executed by the DBMS at a certain state.
Sure you can, either using the above technique or simply assuming that the third-party software is correct to its specification.
>>
File: asciifull.gif (27KB, 715x488px) Image search: [Google]
asciifull.gif
27KB, 715x488px
>>56583753
Dont make a list of each alphabet.
Dont use isdigit.

since chars are data, check the like.
if (c >= 'A' || c <= 'Z') { // Its a capitol. }
Same with digits, they are just chars
if (c >= '0' || c <= '9') { // Its a number. }
>>
>>56583549
Addition is associative and permutable, so you just have to traverse the list that constitutes the elements at the right of the one you first picked.

Should look like this.
for(int i = 0; i < nums.size(); ++i)
for(int j = i + 1; j < nums.size() - 1; ++j)
if (nums[i] + nums[j] == target)
return {i, j};

Assuming the returned indices can be the same, remove the +1/-1s.
>>
>>56583881
should be && not ||
>>
>>56583896
- 1 should be on the outer loop*
>>
>>56583881
>>56583901
Oh cool. Thanks Anon.
>>
swift is a meme language and xcode (4.43 GB mind you) is a shit ide

proof me wrong
>>
>>56583802
>Strings are ascii chars
>C++
Doesn't that depend on the locale your machine have? The backend might be implemented as char but that the encoding is ASCII is not guaranteed.
>>
>>56584021
maybe?
Anyway in the next post i told him to use 'A' instead of 65.
>>
File: qt_logo-e13046611964411.png (5KB, 416x475px) Image search: [Google]
qt_logo-e13046611964411.png
5KB, 416x475px
Is this thing useful to write a serious project in C++?
>>
>>56584055
No.
>>
>>56584055
The best C/C++ IDE around senpai
>>
>>56583858
That's a runtime assertion aka test.
>>56583874
>You can prove externally if the language isn't fit to prove internally.
See above.

>Sure you can, either using the above technique or simply assuming that the third-party software is correct to its specification.
This does not prove that the query language was used correctly.
>>
>>56584066
>>56584071
Ok, that's clarifier...
>>
>>56584071
if you like being taken by an 8 inch dragon cock on the daily then yes
>>
>>56584094
>See above.
External proofs =/= tests. It just means you aren't using types of the programming language as propositions that you prove.

>This does not prove that the query language was used correctly.
Elaborate.
>>
>>56584048
That depends on your machine's locale. Your example will most likely work but there is no guarantee. Strings in C++ are ugly and should be avoided unless you use a third party lib for strings as QT or ICU4C.
>>
>>56584055
The IDE is decent but visual studio with a few paid C++ plugins are better. If you ask about the framework then it uses macro magic. I'd probably do some extreme MVC to decouple the actual logic from QT if I wanted to keep the backend logic "clean".
>>
>>56582237
#include <stdio.h>
#include <stdlib.h>

#define MAX 80

int main(int argc, char* argv[])
{
if (argc != 3)
{
puts("Usage: rect width height");
return 1;
}

int w = atoi(argv[1]);
int h = atoi(argv[2]);
char row[w];

if (w > MAX || h > MAX)
{
printf("Error: rectangle dimensions exceed %d by %d\n", MAX, MAX);
}

for (int i = 0; i < w; i++)
{
row[i] = 'x';
}

for (int i = 0; i < h; i++)
{
printf("%s \n", row);

}

printf("\n");

return 0;
}


Hope you can get your family the curry they need pajeet.
>>
>>56583828
Excessively wasteful? You use a language's C API to generate functions in that language, concatenate the functions in that language and then call the interpreter to run the built up function.
>>
>>56584204
>puts("Usage: rect width height");
why not
printf("Usage: %s width height", argv[0]);
>>
>>56584204
Why there's always someone who is ready to make someone else's homework?...
>>
is there anyway to make a python script have a GUI?
>>
Woah, maybe strong static typing really is the answer to everything...
>>
>>56584269
yes
>>
>>56584094
>That's a runtime assertion aka test.
No.

It's basically the difference between a test (i.e. the kind of testing you were thinking of) and a check (validation).
A test is an attempt to show that your library does what it's supposed to, given valid input.
A check determines that the input is valid, and if so it uses your library.

A test is not necessary for a proven program.
Tests say "here's a very specific set of inputs that I will test. Technically you can still call my function even if you fail the test but whatever."

So you can, for instance, demand that your program does not put duplicate ids into your database.


Validation IS necessary, but testing is not.
I can write a function that says "given a number that is not zero, I can divide by it".
I don't need to test that function.
I cannot give that function an input that "might be zero".

If I get input at runtime, I have to validate the input in order to call the function.

Your function that requires valid input doesn't have to worry about invalid input ever.
If there's ever a situation where it might not get valid input, your program will not compile.


You can make any condition you want of your functions.
It has to be associative, commutative, reflexive, transitive, the input must be below x, it has to be monotonic, it can only give a list smaller than its input, whatever.
>>
>>56584279
It's the answer to higher productivity in large projects at least.
>>
>>56584220
Not exactly, but that's basically this without C and without an interpreter.
>>
>>56584269
Is google blocked in your country or something, nigger?
>>
>>56584297
how would I do it?
>>
>>56584304
And the constraints you give ensure the functionality.
For instance, "after I call insert k v, there should be a database entry with id k and value v"
>>
>>56584324
pyqt(5)
tkinter
>>
>>56584324
Write a script in python that interfaces with one of the many GUI frameworks.
>>
>>56584324
http://lmgtfy.com/?q=is+there+anyway+to+make+a+python+script+have+a+GUI%3F
>>
File: 1315067226688.jpg (61KB, 736x383px) Image search: [Google]
1315067226688.jpg
61KB, 736x383px
>mfw trying to understand decorators in Python

When are they useful?

I understand as far as "it's a function that returns another function", but fuck, I just cannot get my head around when I would use them
>>
>>56580427
I was modularizing what's going to be my file upload system for my website.

I've been putting too much stuff off, so I went and moved a bunch of shit and got it basically working. Currently, the only thing it doesn't do for at least this case is actually write to the database.

But, unlike my original, alpha whatever version, this is gonna be VERY modular. And, it uses jQuery
>>
>>56584365
thanks
>>
>>56584419
What are you writing it in?
>>
>>56584407
>understand decorators in Python
>decorators
What the fuck? Who named it that?

IDK Python, but that's retarded.
I assume it's the equivalent of a C/++ function pointer?
>>
>>56584407
Can you give an example?

A function that returns a function is a lot like a function taking two parameters.
In fact you can turn any "a -> (b -> c)" into an "(a,b) -> c" (haskell syntax) and this is how functions are declared in Haskell
f = \a -> \b -> a + b
f = \a b -> a + b
f a = \b -> a + b
f a b = a + b
(all the same)
>>
File: the skeeter.png (14KB, 515x289px) Image search: [Google]
the skeeter.png
14KB, 515x289px
>>56580934
>someone posts his answer from his blog
>he comments because wakarimasen lol
>gets more upvotes in his comment than the answer
>>
>>56584454
Not the same thing. Decorators alter the input/output of another function.
>>
>>56584130
Correct me if I'm wrong, but a type system is supposed to prove the functioning of a program at compile time. So how can a compile-time proof incorporate a runtime check through I/O such as changes in a database's state?

>Elaborate.
Let's say you have some complex enough query. For the sake of example it can be inserting backlinks in an imageboard. You give the DBMS a set of post numbers a newly-created post linked and it has to find all these posts, assert they still exist, weren't deleted or some shit, then insert a reference to the original post and it's thread into the linked post and append to some kind of replication log for tracking these updates. This can get plenty more complex, but you should see it is quite possible to mess up the logic for constructing the query to do this. The programmer can wrongly assume he is constructing a query that does what he wants. The correct use of the query language can not be proven by the client's programming language.

>>56584304
>>56584326
Yes, but how can you make an IPC assertion at compile-time? See above.
>>
>>56584441
PHP, MySQL, JS+jQ

However, after I launch and after however long it takes to actually get other people to join up, I'd probably start a project to port it to C/++ for backend application processing.
>but I'll be originally launching it on GoDaddy, not my own server.
>>
I think I wrote myself into a corner.

I wanted to implement a search box in my c# doohicky because certain entries I was getting back had a lot of results. However, I get my results from a database, and my method for getting the results I need to search takes a string argument that's passed from another in order to conduct the search at all, so I can't write another method that just returns a list, ether.

How do I get out of this? Am I fucked?
>>
>>56584524
Isn't PHP dead yet?
>>
File: 1470366634624.jpg (20KB, 424x308px) Image search: [Google]
1470366634624.jpg
20KB, 424x308px
>>56584501
Can anyone stop this madman?
>>
>>56584514
You can't make an assertion that the database IS in a correct state, but you can say "in order to do anything other than terminate the program immediately, it must be". Or you can say "this program will PRESERVE correctness in the database"
>>
>>56584513
So... is it... like formatting and/or casting it or something?
>>
>>56584539
What are you talking about?

you have a method that accepts a string and returns a list of search results?
>>
this bothers me
#ifdef __cplusplus
#include <cstdio>
#else
#include <stdio.h>
#endif

void flag_me(const char** param) {
puts(*param);
}

int main(void) {
char original[] = "Hi";
char* fucking_arrays = original;
char** ptrtoptr = &fucking_arrays;

flag_me(ptrtoptr);
}
>>
>>56584539
Post some code. I'm not entirely sure what your issue is. You can use the string from your search box to filter the data you've already retrieved on the application side to avoid more I/O from the database.
>>
>>56584565
It's a stupid and complex way of doing
foo(bar(baz(arg)))
>>
>>56584565
If you have a function that adds two numbers together, and you want to make it add absolute values together instead, you would use a decorator to return a new function which automatically converts negative inputs to positive ones. That's my understanding.
>>
>>56584513
>>56584602
So they're just higher order functions?
>>
>>56584514
As long as the programmer can write a specification for "does what I want", he can prove that the query he constructed will fit that specification.

All a test can express is "does what I want given this input", and passing the test doesn't prove anything about "does what I want". Tests are only meaningful when failed.

That said, it would be ideal if the query language itself incorporated a strong type system. Otherwise, you're limited to, well, performing external proofs that can easily get out of sync.
>>
>>56584616
Yes. Literally just sugar for passing one function to another then taking the result.
>>
>>56584407
whie this is C# it might be helpful reading the lower example:
http://www.dofactory.com/net/decorator-design-pattern

basically it's a wrapper that adds functionality to another function

in the example you can see the function of book/video uses a decorator to add the borrowable function without changing the original use - it's adhering to single responsibility principle essentially
>>
>>56584652
it makes sense in functional languages where you've got a lot of operators and built in currying but not really in multiparadigm languages

f x = ...
--g x = f (abs x)
g = f . abs

f2 x y = ...
--g2 x y = f2 (abs x) (abs y)
g2 = f2 `on` abs
>>
>>56584540
No, it's right up there in popularity with C and C++.

The only web languages ahead of it in this page I found from 2015 are Java, JS, and C# (I assume C# would be used for ASP.NET? IDK, I don't use C# OR ASP.NET)

I assume JS went up so much, though, because of Node and shit.

Regardless, PHP is here to stay, and with the official API that came out for it recently, it's probably gonna be like that for a while.

It's not bad, really. I just wish it was a LITTLE more like C/++

Java would be good, if it had a better way to implement MySQL.

On the other hand, I'm a bit leery of using Java if it contains sensitive information, so the re-architecting that will hopefully happen at some point would likely be in C/++.

>>56584593
>>56584602
>>56584616
Damn, that's it?

lmfao!! Calling it "decorator" was WAY more confusing than what the actual thing IS!

I do that all the time.
>>
>>56584689
>lmfao!! Calling it "decorator" was WAY more confusing than what the actual thing IS!
Welcome to the world of design patterns.
>>
>>56584574
http://pastebin.com/L1FvEvKS
If you're Pajeetslayer, the entire thing will probably look familiar.

>>56584570
More specifically, it makes a database query to return a list of search results.
>>
>>56584560
So that means you still need tests, even if considerably less. My point stands.
>>56584644
I see. So you basically need either a strongly typed query language (will never happen for anything meaningful) or to write a type system for the query language used that perfectly mimics the spec.
>>
>>56584685
Don't get me wrong, I think they're great.

But they really are just basic syntax sugar.

As an aside, Python's single-line lambdas are a huge mistake. Not that Guido would see it that way.

(because he is a moron)
>>
>his language has needs tuples for function application
fuck(me(in(the(ass(and(call(me(a(bitch)))))))))
>>
>>56584736
>So that means you still need tests, even if considerably less. My point stands.
No, you need validation, not tests.

>>56584738
In Haskell you do function composition a lot and you wouldn't really call it "syntax sugar" but in a non-functional language you don't do it enough to need it
>>
>>56584736
You could also write an embedded DSL that extracts to the existing query language.
>>
>>56584715
I don't understand your problem. Change the query method so it brings back a max of 200 results or whatever.
>>
>>56584689
>lmfao!! Calling it "decorator" was WAY more confusing than what the actual thing IS!
Blame OOP IN LOO pattern hell. Their languages are so fucked, they can't even do that in a reasonable manner.
>>
>>56584760
>validation, not tests
Same thing.
>>
>>56584802
No they aren't.
You were talking about integration testing.
That's nothing like input validation.
>>
>>56584812
Input validations can not validate output that concerns stateful IPC.
>>
>>56584689
>Calling it "decorator" was WAY more confusing than what the actual thing IS!

That goes for most things. CS is simple things shrouded in ridiculous nomenclature.
>>
>>56584832
>prove that program P, given preconditions A will leave postconditions B
>validate preconditions A
>run program P
>postconditions A now hold
>>
>>56584783
When the search box changes, nothing is actually filtered. My guess was that I was giving it an empty list but I realized that the reason why nothing was filtering was because I needed to pass a string from a selectionchange event to the method in order for it to actually return something. However, even making a near-duplicate method that returns a list and accepts the same string from the selectionchange event did not change anything.
>>
>>56584715
I am.

If you want a quick-and-dirty, just make the
countyTransfer
list accessible to both methods. Then, you could use that list in the filter textchange and reassign the filtered list as the
ItemsSource
.
>>
>>56584859
you a B* there
>>
>>56584856
>CS
Stop saying this, you're like the other guy who blamed "RAII" on academics

This is what happens when you let non-academics name things. You get "design patterns" and names like "Resource Acquisition Is Initialisation"
>>
is there any language that is purely structurally typed?
>>
>>56584905
What do you mean, like having (A, 1) = A = (A | 0)
>>
File: SICP is a meme.png (6KB, 480x278px) Image search: [Google]
SICP is a meme.png
6KB, 480x278px
>>56584889

We should stop saying CS in general. In reality, it's got nothing to do with computers and it's also not science.

t. Hal Abelson
>>
How do I Hadoop /g/
>>
wish i had an anime gf to pair program with...
>>
>>56584905
Calculus of constructions
Martin-Lof type theory
>>
>>56584932
>computer seance
I wish I could
>>
>>56584955
sorry, i meant to say programming language (something that has an actual implementation)
>>
>>56584859
Prove that program P after communicating with external process E written in programming language L with state A produces state B in the external process
>>
how good is handwriting recognition these days?

Would be really cool to have an automated proofer for calculus
>>
>>56585032
What do you actually want from your pure structural language?
>>
>>56585039
You have to either prove or assume that E meets its specification (including how it works with L). Or, if you're lucky, it will have been proven for you.
>>
File: 1473453312560.png (229KB, 480x402px) Image search: [Google]
1473453312560.png
229KB, 480x402px
more like this?
>>
>>56585117
>>>/wsr/
>>
>>56585032
>>56584905
Go is to some extent. What exactly do you want to use this typing for?
>>
>>56585126
Fuck off bigot.
We need more transexuals in the industry.
>>
>>56585117
>>>/kys/
>>
>>56585140
full type inference + full structural typing would allow me to not give a fuck
sure, it's not as type safe as a nominally typed language, but it behaves very similarly to dynamically typed languages while still checking shit at compile time
basically, for scripting
only go's interfaces are structurally typed, structs are not
>>
>>56585057
Probably not very good for math-specific symbols, but there are plenty of machine-learning APIs and frameworks that you can drop in to immediately start detecting letters and numbers.
>>
>>56585198
use Haskell and don't repeatedly declare the same structures

You can define type operators and everything.
>>
>>56585198
You might like OCaml.
>>
>>56580474

>retrieve all the underlying rows from all the tables joined within a view.

That sounds like you have no clue what you are actually doing..

Either all the tables have a relationship, then you can just do simple joins (or a lot of where statements).

Or the tables are not related, - than it's pretty stupid to join them.. How can you logically join unrelated objects? A full cartesian product?

Sounds bad, man.
>>
>>56585057
what do you mean by a proofer
>>
>>56585208
yeah I was thinking it'd be neat to write out a proof, take a picture, interpret everything and have it compile into formatted LaTeX (which is the easiest part actually)

far beyond my skill level, naturally, but would be cool grad project for somebody who understands machine learning algorithms and that sort of thing

>>56585265
well calculus runs on a set of rules, right? You have the chain rule, product rule, various theorems which dictate everything. You could basically check your proofs with enough fine-tuning and remove the slow middle-man (humans) from it
>>
>>56585260
>How can you logically join unrelated objects? A full cartesian product?
taking the HomSet :^)
>>
>>56585198
But all structurally equivalent types (including structs) are castable to each other, so that's not a huge difference.
>>
>>56585218
two types with the same structure are not the same in haskell, there's extra effort required to plug a type A into something that requires type B (even though A and B have the same structure)

>>56585224
wasn't ocaml's structural typing just about methods? what about composite types or sum types?
>>
>>56585260
You misunderstood my intention.

I realize the thing I'm trying to do is extremely specific, and hard to describe.

The idea is that you pass a view's name to a C# application, the application uses Smo to get the definition of that view, and then parse and examine the joined tables AND the conditions built-in to the view to only retrieve joined and filtered rows from the 20+ tables used to construct that view.

I'm sure this still doesn't make sense, so I'll have to construct an example with pictures to get some help on this.
>>
>>56585340
OCaml has records with row polymorphism as well as polymorphic variants.
>>
>>56585340
>two types with the same structure are not the same in haskell, there's extra effort required to plug a type A into something that requires type B (even though A and B have the same structure)
neither are they in C or Go or Ocaml etc

this is why i said don't define seperate identical types (it's easy to not do), use type operators


besides
https://hackage.haskell.org/package/base-4.9.0.0/docs/Unsafe-Coerce.html
>>
>>56585338
you're right, I wasn't aware of that
casting is done at runtime though, so it doesn't type check at compile time with a fully structurally typed language
>>
>>56585401
for some properties, they are (two seperate interfaces with the same methods are entirely equivalent in go)
if it's possible for methods, why not extend it for members?

>>56585371
i'll have a look at that, thanks
>>
>>56585446
there's unsafe coerce, esp. for newtypes (which are supposed to guarantee the same representation)
>>
well, this question just killed me:
https://leetcode.com/problems/permutations/
>>
>>56585472
>unsafe coerce
done at runtime too and basically equivalent to dynamically typed languages, not structurally types ones
>>
>>56585403
I think you are confusing casting with type assertion or reflection. Correct me, if I'm wrong, but casting non-interface values should be compile-time (except for some numeric conversions).
>>
>>56585511
>>unsafe coerce
>done at runtime too and basically equivalent to dynamically typed languages, not structurally types ones
What the fuck are you smoking?
Unsafe coerce is a no-op, equivalent to a pointer cast
Do you know what a structurally typed language is?
>>
>>56585490
what's the question?
>>
>>56585490
>>56585542
s/question/problem/
which is
Given a collection of distinct numbers, return all possible permutations.

For example,
[1,2,3] have the following permutations:
[
[1,2,3],
[1,3,2],
[2,1,3],
[2,3,1],
[3,1,2],
[3,2,1]
]
>>
>>56585490
wow that's difficult

controlling for duplicates has to be a real challenge

anyone want to give it a go?
>>
>>56585635
>distinct numbers
>>
>>56583470
>using a vcs service for integration testing

imo that is a bad practice

>>56585490
looks like some bullshit dp question, pick the first number + the permutation of the rest ad inf. Everyone just google these questions, you only need them for bullshit whiteboard interviews
>>
>>56585635
ah actually not that difficult maybe but it would be exponentially inefficient to go back through and filter out all the duplicates
>>
>>56585557
use recursion

think about it this way

fn permutations(array)
if array.len == 0
return <base case>, i wont tell you what it is
else
for x in array
prepend x to permutations(array without x)

ill post python code if you like
>>
>>56585649
Good practice is either a lot more manual work or running our own integration testing server, which I won't do for a personal project.
>>
>>56585648
yeah ok this problem is not that hard if they're distinct numbers

just a big tree, start at the first number and work your way down it getting each possibility

so
[1,x,x,x]
[1,2,x,x]
[1,2,3,x]
[1,2,3,4] #reached end, move up one and try different combo
[1,2,4,3]#move up one, change the number and try a different combo
[1,2,x,x]#exausted all possibilities, move up one

so each time you slide down the tree until there are no more combos to try, then moving up a rung


I don't know exactly how I'd implement it but that's the idea I think
>>
>>56585649
>looks like some bullshit dp question
It's basic recursion, nothing to do with DP.
>>
>>56585720
Also checking for dups is pretty easy - just throw some sorting algorithm on it and eliminate all the consecutive duplicates.
>>
>>56584593
There's a bit more, in that it is also allowed to decide to skip calling the wrapped operation at all. That lets you do things like caching/memoisation and auth checks.
>>
>>56585697
why is it hard to use a jenkins container/VM? If it is a personal project you can even install it locally
>>
>>56585524
you're right, what i said was bs

>>56585527
a language that ensures at compile time that two types are structurally equivalent
data Foo = Foo {a :: Int, b :: Int}
data Bar = Bar {c :: [Char], d :: [Char]}

foo :: Bar
foo = unsafeCoerce Foo 1 2

compiles
>>
>>56585823
Those types aren't structurally equivalent.
>>
>>56585853
that's the point
it still compiles
>>
>>56585823
It's called unsafeCoerce for a reason

Try
https://hackage.haskell.org/package/base-4.9.0.0/docs/Data-Coerce.html
>>
>>56585864
Oh, I see.
>>
>>56585776
But I need to also check pull requests and letting the other party know they failed tests is very convenient.
>>
>>56585867
does this work for any type?
i don't know much about haskell, so i quickly tried
data Foo = Foo Int Int
data Bar = Bar Int Int

foo :: Bar
foo = coerce $ Foo 1 2

which doesn't compile (i guess what i'm missing is that they aren't actually structurally equivalent as defined by the rules of coerce, how are they not structurally equivalent?)

either way, it still requires me to explicitly call coerce, which is a minor hassle (like explicitly having to cast in Go, although coerce is anonymous)
>>
>>56586058
it's got very complicated semantics, as far as I know it is basically like structural subtyping "are the representations the same?"

but really i question why you'd do
data Foo = Foo Int Int
data Bar = Bar Int Int

if you want structural subtyping
nevermind the outright duplication of the same structure, you could just be using an alias

type Foo = (Int, Int)
pattern Foo :: Int -> Int -> Foo
pattern Foo a b = (a, b)

add (Foo a b) = a + b


(PatternSynonyms)
>>
>>56586163
since we're using a nominally typed language, it shouldn't be unlikely that there are a bunch of types with a duplicated structure
now let's assume a library function expects a type Foo, but some other library is providing us with Bar. the two are structurally equivalent, but i can't put Bar into that library function.
in a dynamically typed language i could do this, at the cost of running into errors at runtime.
in my imaginary fully structurally typed language with full type inference (which apparently doesn't exist and maybe isn't possible?) i could mostly use the language like a dynamically typed language, but stuff that would otherwise error at runtime now errors at compile time
>>
>>56586262
also, i should clarify that i'm obviously just talking about simple type errors that occur in dynamically typed languages (foo has no method bar, can not divide int by string, foo has no field bar, etc.) and not about stuff dependently typed languages could prevent
>>
>>56586262
>since we're using a nominally typed language, it shouldn't be unlikely that there are a bunch of types with a duplicated structure
It's quite uncommon in Haskell, the only thing that comes to mind is that Ratio has the same structure as a pair of the same value

>library function expects a type foo
Then cast it if you want it to check the roles, or write your own wrapper function to convert. You could write your own "castable" type class if you wanted (and automatically make coercible instances castable).

>in a dynamic language I could do this
Not in a well founded fashion, "we both happened to name the same variables!". Your earlier example of records even fails at this - you picked different field names, so they're different.
>>
>>56586262
You can kind of do that with C++ by templating everything.
>>
>>56586262
This is called duck-typing(i think), and it(i think) is in C#
>>
>>56586262
Why would you want everything structurally typed?

Let's say you have a ID type, which is just a integer representing an id. You don't want that to be accepted in functions that are accepting a normal integer, or visa versa. It makes stuff less safe. Structural typing is a nice feature, but I don't see why you wouldn't want a way to avoid it at times.
>>
>>56586405
Duck typing is just Structural Typing without the static typing (i think).
>>
>>56586326
i know, but that's a lot of effort, has many downsides (like compile times) as well and definetly doesn't make it as easy as a scripting language otherwise would (i'm aware that templates support this, though).

>>56586325
i'm not looking to build my own eco system in a different language to enjoy full structural typing, though (from what i've seen, everyone using their own set of abstractions is kind of an issue in haskell already).
i was really just thinking about something simple that allows me to write scripts more easily in an ecosystem that is built around this idea while not abolishing all compile time type checking.
also - the record example was intended to be wrong (assuming you're referring to >>56585823).

i guess what i was looking for doesn't really exist, thanks for your patience, though
>>
>>56586262
Go does not have this problem.
>>
>>56586413
Not him, but as far as safety goes, nominal typing makes up for deficiencies in the type system. Clearly, if not every integer can be used as an ID, there are some invariants that the ID "class" enforces. With dependent types, for instance, these invariants could be moved to the type, and structural typing would be fine.
>>
>>56586431
>the record example was intended to be wrong
Even if they were the same types it would be wrong. They have the wrong names.

>i'm not looking to build my own eco system in a different language to enjoy full structural typing, though
I literally just told you that I can't think of many examples of differently named types that are the same
>>
>>56586405
You can do duck typing in C# with the dynamic keyword.

I think the argument could be made that interfaces are a form of duck-typing in a more explicit form.

Rather than passing to the function and the function finding out if you can be given fellatio when it tries to use you, you already have a tattoo on your forehead saying that you're "Fellatioable".

Or something like that.
>>
>>56584955
How are CoC and MLTT purely structural? HoTT+UA might give you a similar feel, but it's still isos underneath.
>>
>>56586440
>if not every integer can be used as an ID
but in my case ID can be any integer. And that would be normal in the real world too.
>>
In java, how would one go about creating a List of Stacks and then adding new stacks to it through a for loop, i.e.

List<Stack> stackList = new ArrayList<Stack>();

for (...) {

stackList.add(stack[i]);

}
>>
>>56586451
How are they not? Names carry no meaning in either of those theories.

>>56586452
Then what's the issue?
>>
>>56586413
>It makes stuff less safe
i know, but in turn it requires less code
using nominal typing everywhere is probably a good thing for big projects, but i don't see much of an advantage in overdoing it with this kind of stuff for scripts (dynamically typed languages are even bothersome in scripts, though)

maybe the way go does it (be fully structurally typed but requiring you to explicitly cast to say that you want to use structural typing instead of nominal typing) is actually a pretty good and pragmatic middle ground.
then again, go doesn't have sum types or a bunch of other stuff, so sometimes i'd have to replace structural typing with type assertions at runtime.
>>
>>56586472
List<Stack<type>> = new ArrayList<Stack<type>>();
>>
>>56586480
I'm not sure i understand you. If you have an ID type, which is just an integer, you don't want it mixed up with a Age type that is just an integer. You want the type system to know they are not interchangeable.
>>
>>56586472
>>56586489
>List = new ArrayList

Why does Java do this?
>>
>>56586487
>i know, but in turn it requires less code
Not true, and if you're casting everywhere you should rethink what you're actually doing

Plus nominative gives you stuff like type classes (though the newtype thing is an issue, if we could create named instances for explicit application it would be nice)
>>
>>56586262
>but i can't put Bar into that library function
Sure you can, if that function is written to allow duck typing.
>>
>>56586487
>i know, but in turn it requires less code
Sure, but if you are writing scripts that you can rely 100% on structural typing if you like. There's no harm in the language supporting nominal typing on the side.
>>
>>56586489
The constructor works fine, but I can't add anything to it. I think I've got the syntax wrong, I'm not sure


stackList.add(stack1);



results in a "Cannot resolve..." error from the IDE.
I can of course instantiate the the "stack1" before hand, but I need to create a new stack and add it to the list every iteration, which java does not allow.
>>
>>56586499
Java's design philosophy is
>The more verbose the better
>>
>>56586443
This gave me the giggles.
>>
>>56586533
stack1 should be a Stack<type>, not just "Stack" which is a generic type
>>
>>56586499
List < ArrayList

>>56586503
>if you're casting everywhere you should rethink what you're actually doing
i'm not sure where i implied that
can you explain further?
>>
I'm a babby's first coder trying to get into C++ and I have free access to Visual Studio 2015 for being a student. Is it a good beginner's IDE?
>>
>>56586541
Thank you. I don't think I'll be implementing the code this way, though, after rethinking it. I don't know why I was trying to hold multiple stacks when I can just pop it every time I need.
>>
>>56586563
pfffftt
>>
>>56586553
If you are constantly converting between things that would be named differently but have the same structure then it's a wonder what you're actually doing
There isn't some massive problem of a million isomorphic definitions

>>56586563
yes
>>
>>56586536
SimpleBeanFactoryAwareAspectInstanceFactory:
>>
File: 1473302904133.png (1MB, 1536x1536px) Image search: [Google]
1473302904133.png
1MB, 1536x1536px
>>56586576
I know literally nothing pls no bully
>>
>>56586563
yes
>>
>>56586582
What is a bean in the context of Java?

>>56586583
>worst girl
you really are a beginner
>>
>>56586563
>I have free access to Visual Studio 2015 for being a student
Anon, it's free regardless. Unless you're a 50+ person shop or making quite a bit of money as a company, Community is free to develop on and you likely don't need any of the enterprise features.

>Is it a good beginner's IDE?
Absolutely, but it can certainly spoil you after using it.
>>
>>56586609
>rem worst girl
subaru please
>>56586584
>>56586581
thanks yo
>>
>>56586584
>>56586581

yes?

BANE?
>>
>>56586563
yes, but it obscures the compile process so far that you probably should look that up. It makes avoiding some linker/compiler errors easier.
>>
>>56586515
it should be the choice of the caller whether to use structural or nominal typing.
scala has that issue iirc, the function itself defines whether it's structurally typed or not, and as a result of that, nobody can use structural typing anywhere.

>>56586525
>There's no harm in the language supporting nominal typing on the side.
what language are we talking about now, my imaginary one or an existing one?
if we're talking about my imaginary one - sure.
if we're talking about an existing one - i think we narrowed down the set of languages with relatively easy full structural typing to go and haskell now.
i'm still not sure why coerce in haskell didn't consider my types equivalent, though (because i know jackshit about haskell), and go lacks certain other things as mentioned before.
>>
File: Bane_TDKR02.jpg (1MB, 4256x2832px) Image search: [Google]
Bane_TDKR02.jpg
1MB, 4256x2832px
>>56586609
>What is a bean in the context of Java?
No one cared who I was until I put on the mask
>>
>>56586659
>it should be the choice of the caller whether to use structural or nominal typing.
that's absolutely retarded
>it should be the choice of the user whether to respect security protocols
>>
What's the best multi-platform GUI toolkit? I don't really mind what language or anything, I'd like to make a simple note taking application as a learning project, but have it cross platform for Windows and Linux (to run on say, Debian).
>>
>>56586581
depends on the language, i guess.
i'd assume this isn't the case in haskell (at least in the standard library, not sure what happens when you add many external libs that define their own types into the mix?), but there certainly are many equivalently structured types in go.
>>
>>56586691
What types did you have in mind?
>>
>>56586659
>what language are we talking about now, my imaginary one or an existing one?
imaginary. But I think OCaml fits the bill too?
>>
>>56586498
Why?
>>
>>56586659
>it should be the choice of the caller whether to use structural or nominal typing.
I suppose you can do that to if you attempt to resolve it to the type the method is requesting before passing it.

Otherwise, I simply disagree. That's insane. The method is written in a way that works on a certain structure of information, and it's a better design choice to allow the method to say
>Fuck it, I'll figure it out, just throw anything at me.
rather than just throwing anything at a method designed to monetary calculations.

A good middle ground is with interfaces, as stated above, where the method can say
>Fuck it, just throw something at me with a dick that can be sucked, because I'm designed to suck cock.
>>
>>56586721
because a function called
calculateDateOfBirth(age : Age) -> Date

should not be able to accept an ID without the compiler knowing something is wrong.
>>
>>56586674
i'm just saying that it's an issue in scala and because of it no one actually uses structural types there.
structural types benefit the caller in terms of ease of writing and make it potentially less safe (although in terms of the meaning of values, not in terms of actual type structure).
they don't benefit the author of a function in any way, so the author of a function will usually prefer nominal typing.
if you're going for that route, you might as well leave out structural typing entirely instead of having a language that supports both, because it'll just be unneeded complexity.
>>
>>56586750
It's not incorrect to do so, though. And it now means that you can't write a function that works for both IDs and ages without some machinery, even though they're structurally the same thing.
>>
>>56586784
>It's not incorrect to do so, though.
???

When would a pass an ID to this function and not have made a mistake in doing so? What the fuck?
>>
>>56586769
>they don't benefit the author of a function in any way
They benefit in many ways, not the least being knowing what the fuck is being passed in.

>>56586784
>a function that works for both IDs and ages
Which function would that be?
>>
>>56586769
>they don't benefit the author of a function in any way
It saves the programmer needing to formally define an interface.
>>
>>56586799
Does the benefit of helping prevent only the most stupid logic errors outweigh all the other benefits of structural typing.

>>56586805
Arithmetic could be useful for both.
>>
We are at 372 posts and no premature new thread. Did the faggot finally choke on a dick?
>>
373th
!!!
>>
>>56586825
>Does the benefit of helping prevent only the most stupid logic errors outweigh all the other benefits of structural typing.
In some cases, absolutely.

But more importantly, you can have both nominal and structural typing at the same time without any drawbacks to either. So why not have both?
>>
>>56586825
>Arithmetic could be useful for both.
Type classes.
>>
>>56586825
>most stupid logic errors
If you have a job in the real world, you'll find these are the most common and costly errors.
>>
>>56586885
>>
>>56586859
I suppose you could only have "newtype" and automatically make a newtype containing A a subtype of A.

>>56586861
>without some machinery, even though they're structurally the same thing.
>>
>>56586892
>>without some machinery, even though they're structurally the same thing.
That's completely different. Type classes are completely different.

You can have a monoid instance for integers and for lists.
They're not remotely structurally similar.
>>
>>56586892
>make a newtype containing A a subtype of A.
that's exactly what you don't want, because ID is not a type of Age or visa versa. So you want the compiler to know these are different and not mix them up. If you really want a method to accept both you can use a union, and maybe that can be structurally typed.
>>
>>56586707
simple pair types (e.g. (int, int)) are often duplicated in many different contexts, for instance.
i can't name any concrete ones right now, but i know that i've often created a pair of some sort and attached a meaning to it via the name, the structure actually being the same as many other pairs i created before for convenience.

>>56586717
might be, i haven't looked at what >>56585371 suggested yet.

>>56586815
this depends on whether there is type inference or not, not whether the function is using structural or nominal typing (unless i missunderstood you)
>>
>>56586977
>this depends on whether there is type inference
If the type is not inferred then it;s not structural typing.
>>
>>56586977
>simple pair types (e.g. (int, int)) are often duplicated in many different contexts, for instance.
>i can't name any concrete ones right now, but i know that i've often created a pair of some sort and attached a meaning to it via the name, the structure actually being the same as many other pairs i created before for convenience.
The most common form of pairs is just using built in pairs. Other than that, as I said, the only thing that comes to mind is Ratio.
>>
>>56586887
i don't think anyone would disagree with you on that, but we're (or at least i am) considering structural typing for a hypothetical scripting language that's about as easy to write as a dynamically typed one, but still runs a bunch of type checks to prevent dumb type errors at runtime

for applications that are intended to be maintained for a longer time, i'd pick nominal typing over structural typing for most cases, as conversions and a bunch of other things become explicit (which makes it less likely that the caller accidentally puts a B into something that requires an A and may also improve readability)
>>
new thread
>>56586889
>>56586885
>>
>>56586998
is there any type inference in this example?
https://play.golang.org/p/EECWp0cZT4
>>
>>56583307
Why would you care about trust for a git host? You think they'll tamper with your local repo hashes?
>>
>>56580427
Finally got my copy of "Programming Principles and Practices Using C++" by Bjarne Stroustrup in the mail yesterday. I just completed the chapter 1 review, terminology, and exercises. I can't help but feel like I got memed.

http://pastebin.com/eTtqn7WP
>>
>>56587785
>I can't help but feel like I got memed.
You did.
Thread posts: 391
Thread images: 16


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

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


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