[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: 353
Thread images: 32

File: OOP strikes back.jpg (67KB, 1006x692px) Image search: [Google]
OOP strikes back.jpg
67KB, 1006x692px
What are you working on, /g/?

Previous Thread: >>57276439
>>
https://groups.google.com/forum/#!topic/golang-nuts/MHoI64RyRdY

need a new language. rust?
>>
New tripfag rolling in
>>
Are there any other concurrency-oriented languages similar to Erlang? Not just languages with some threading features, but ones designed with concurrency ingrained into the language itself.
>>
>>57281698
Go. But I wouldn't touch it for the rest of the language.
>>
>>57281654
>I'm having problems with one SJW language. Should I use another SJW language?
>>
>>57281637

making a framework to allow me to control my rpi alarm system from home, this includes viewing the livestream and setting the alarm (which will text me a screenshot of what triggered it).

i've learned to love/hate android but i've taken a liking to python somewhat. using virtualenvs is pretty nice once you get the hang of it.
>>
>>57281654
>>57281794
At this rate, if you want to avoid SJW-tainted languages you're going to be writing z80 assembly
>>
File: 1451421311035.png (129KB, 240x228px) Image search: [Google]
1451421311035.png
129KB, 240x228px
>>57281654
>code of conduct workers should work on adding generics to compilers
>>
>>57281915
>lol I'm such a nerd working on big name programming projects when I don't even have a programming degree
>*fires up notepad++*
>CODE OF CONDUCT RULE #1 NO BULLYING TRANNIES
>wow I'm so great, time to treat myself to 3 hams and then yell at people on reddit
>>
>>57281843

What's wrong with that? z80 Assembly is sweet.
>>
>>57281940
>i'm so hip with the oop and linq but also a really down to earth guy :)
>>
>>57281958

But that's true. I also like C, I just don't like insufferable Ctards.
>>
>>57281654
>need a new language. rust?
Just as SJW infested.
Avoid any language with an official 'community' (official website, logo, etc).
>>
>>57281843
I was talking to someone at a tech conference who works at Microsoft's devdiv, and he was refreshingly racist. We had a grand time discussing our comical dealings with pooinloos.

.NET languages confirmed for based devs.
>>
>>57282002
Thanks for the tip, my tumblr friends will have a field day with this. What was his name by the way?
>>
>>57282038
John Smith ;^)
>>
>>57282049
Sounds like a white guy. This should be good.
>>
File: AI Ethics.png (5KB, 470x102px) Image search: [Google]
AI Ethics.png
5KB, 470x102px
>>
>>57282038
started with an 'a', i think. anders?
>>
I have a small problem in learning with SICP in python.
I just can't seem to be able to import the .py file into the IDLE and work on the exercises and examples.
For an example, I have just skipped Chapter 1.6 because it is long and I can't just import the file I need to try out the examples.
How do you do it?
>>
>>57282248
idgi

Also you can use colours to do that directly through erasure:
data Maybe (A :i U) : U where
nothing : Maybe A
just : A => Maybe A

Bool : U
Bool = erase i (Maybe _)

Makes it very convenient when you want checks to also optionally give proofs. You write them such that they give maybe a proof, and erase to end up with just a boolean check.
>>
How to store hierarchical data in a relational database?
>>
>>57282394
I don't know what you just said but it sounds offensive. Consider this a CoC warning.
>>
>>57282404
What did he mean by this
>>
>>57282445
If you're gonna use an English imageboard you've got to learn some fucking English
see >>57281654
>>
>>57282482
what did she mean by this
>>
>>57281654
Use a language made for professionals
>>
Catching linux kernel signals and modifiying program responses to them.
>>
API-question.

I have an url like this:
http://api.site.com/files/id

which takes you to a specific file.

Now I want to provide a HTML representation of this which allows the user to create a file. Where should this be? Following REST, it should simply be posted at
http://api.site.com/files/


But with HTML, we need a place to set up the file before posting. Right now I'm thinking of setting up a HTML-only page at
http://api.site.com/files/create.html


which has a post form. This will be true for all data sets with the possibility to create.

Are there better ways? (Asking here because you guys know more than a certain other general)
>>
>>57282573
Resign and find a less bloated software company
>>
>>57281698
haskell has also parallelism
>>
File: haskell..png (7KB, 397x131px) Image search: [Google]
haskell..png
7KB, 397x131px
>tfw too intelligent to have real world applications
>>
>>57282573
The html create page has nothing to do with the api, it is a user of the api and hence can be located wherever you want.
>>
>>57282621
But that's demonstrably false.
>>
File: 1476523440953.jpg (43KB, 600x600px) Image search: [Google]
1476523440953.jpg
43KB, 600x600px
>tfw too handsome to write native code
>>
>common lisp
>multiple value return
who thought this was a good idea
>>
>>57281654
I got bad news for you
https://github.com/rust-lang/rust/pull/25640
>>
>>57282660
Those high cheekbones suggest someone ideally suited to writing native code.
>>
If X = X +1, then what is the value of X?

You should be able to solve this.
>>
>>57282677
>While I can see the value of positive discrimination, and am generally in favor ...
>>
File: 1475785898560.jpg (19KB, 222x293px) Image search: [Google]
1475785898560.jpg
19KB, 222x293px
>>57282677
>Also there were substantiated comments in the original PR about preferring she over they, which get un-addressed with this; not too fond of that bit.
That said, this has nothing to do with the language itself but rather a trivial part of the documentation.
>>
>>57282714
X
>>
>no mutable global variables in haskell
how the fuck am I supposed to keep some data around if not by adding the variable to every single function and passing it around (this is an ugly way tee bee age)
>>
>>57282714
Depends on its type.
>>
>>57282714
If X=X+1, then 0=1 (because X-X=1, and X-X = 0).
Therefore, since X = 1X, X=0X, and we can conclude that X (along with all other numbers) equals 0.
>>
>>57282746
put all the variables into one record called State or something
>>
>>57282595
This is for myself.

>>57282640
I'm aware, but I'm allowing it to exist on the same path as my page.

I really like it.
>>
>>57282714
the new value of X is the old value of X + 1
>>
How much of a difference does building with gcc 6.2.0 make over 5.4.0 and 4.9.0?

I'm using ffmpeg to encode about 4GB of videos to HEVC and it's taken like 5 hours on a i5 2.4ghz with 8GB RAM. Got me wondering if there were ways to make ffmpeg run faster for the same job.
>>
>>57282714
wtf i hate imperative programming languages now
>>
>>57282714
math usually does not incorporate a notion of time. variables don't update in any serious way
>>
>>57282714
X = 1 + 1 + 1 + ...
>>
>>57282714
(pic)
>>
>>57282848
wrong
>>
File: anal beads.png (10KB, 569x165px) Image search: [Google]
anal beads.png
10KB, 569x165px
>>57282677
"Whitespace" is fucking offensive and should be referred to as "Space of a Non-determinate, Genetically Equal Colour"
>>
>>57282714
>>57282792
Actually, it's even more general than that.
X = Y + 1 + 1 + 1 + ... for any Y.
>>
>>57282857
>python
>wrong
pick one
>>
>>57282714
The value of X is X, and your boolean expression is false.
>>
File: 1477319531144.jpg (13KB, 142x250px) Image search: [Google]
1477319531144.jpg
13KB, 142x250px
>>57282714
Technically the value of X is some unknown memory address. I think what you're asking for is that value stored at that memory address.
>>
>>57282768
example?
>>
>>57282714
>completely and entirely context sensitive question
>deserves no replies
>still gets replies
>>
>>57282931
what? literally just bundle it all up into 1 data type
>>
>>57282746
how haskell handle config files?
>>
so I'm wondering.
What prevents someone from making an IDE for a language inside a game like, say, wow? through a mod or addon. is it because they're too complex or because it's a security issue or something?
I am not a programmer so don't bully me too hard for my ignorance
>>
>>57282714
When I introduced programing to one of my friends who studied mathematics, an expression just like that blew his fucking mind. He couldnt accept that the statement was an assignment and not a solvable equation.
>>
>>57282979
reader monad?
>>
>>57282992
>blew his mind
probably because it's retarded
you've literally undone years of teaching

even pascal didn't make that mistake, they use :=
>>
>>57282992
Because programming faggots steal notation and terminology from mathematics and bastardize it to mean something different.
>>
>>57282981
Space Engineers allows you to write C# in-game to script out actions performed by various pieces of machinery and whatnot.

Unless you actually mean an "IDE", which would be an entire GUI application within the game itself.
>>
>>57282993
Monad?

What is that?
>>
>>57283024
have you ever had a burrito?
>>
>>57282968
I understand now.
Sorry for being retarded
>>
>>57283013
https://en.wikipedia.org/wiki/Assignment_(computer_science)#Assignment_versus_equality
>>
>>57283015
Yeah I'd like a full-fledged (or barebones, but still able to function as an ide) IDE that's integrated into the game GUI
>>
>>57283024
:^)
>>
>>57283024
A spacesuit full of nuclear waste wrapped in a tortilla. That is, a monoid in the category of endofunctors.

>>57283040
Okay?
>>
>>57283013
Do you really want to be typing weird unicode combinations to use special snowflake characters to satisfy your autism, or do you just want to re-purpose the existing keys on your keyboard and use a slight ounce of your own context awareness?
>>
>>57283064
See >>57283008, although I do actually prefer things like Emacs' TeX input method. Also ad hominem.
>>
>>57283064
>not following C
>special snowflake
>>
>>57283008
some mathematicians use := for initial definitions, to distinguish them from assertions about existing things. what we don't do very much is "update" variables
>>
>>57283064
You don't have to make the assignment operator an emoji to not have it be the same symbol as equality
>>
>>57282992
show him monads
>>
>>57281995
Tell me, can we make C great again?
>>
>>57283013
>Because programming faggots steal notation and terminology from mathematics
DAILY REMINDER programming originated from mathematics.
>>
>>57281637
Need a crash course in C++ for my assignment.

Only have Java and Python experience. What's a good book/course to get me started? Just want the syntax, do's and don'ts.
>>
>>57283147
>le not reading le whole post face
>>
>>57283147
False
>>
>>57283143

Maybe.
>>
>>57283147
False
>>
Church > Turing
>>
File: 1401867541206.gif (561KB, 625x626px) Image search: [Google]
1401867541206.gif
561KB, 625x626px
>>57282714
HOW

HOW COULD SUCH WEAK BAIT BE SO EFFECTIVE

TEACH ME YOUR WAYS MASTER BAITER
>>
>>57283167
>being this low-energy
Say it like you mean it, Jeb.
>>
>>57282992
If your friend had been any kind of advanced student of mathematics he would have had no problem with the concept of symbolic redefinition.
>>
>>57283197
>thinking this is at all trivial
>>
>>57283147
more directly originated from cryptography
>>
>>57283207
>how could the same symbol have different meanings in different contexts this is madness

He must've had a hell of a time figuring out the difference between "your" and "you're" and "yore"
>>
>>57283235
That's completely different
You fool
>>
What does /dpt/ think about yaml?
Is it a worthy json successor?
>>
>>57283238
yore mom is the fool
>>
>>57283143
C is already great
>>
/dpt/, where should I head?
Dynamically typed langs always will be an important tool for me, but they are hell to maintain, so I need a good, reliable complementary statically-typed language.
Languages with crippled type systems(Java et al) are not an option — they are not reliable, they are verbose, they induce boilerplate, etc etc, you know everything about them.
Languages with great type systems(Haskell, Purescript, Mercury, ATS et al) are great — until you want to hand your project to someone else. Yes, everyone is happy to see a project with no runtime exceptions and generative tests, bot everyone is ready to spend an awful lot of time just to understand how to use RWS and other monads for stuff that can be implemented in traditional langs without a single thought.
So, what language is expressive, reliable and easy at the same time?
>>
>>57283207
But it is trivial. You're literally just going
>this symbol means that concept. deal with it

You're not even introducing any new or unfamiliar concepts.

Experienced mathematicians can deal with it.
>>
>>57283243
protobuf or capnproto
json is for fags
yaml is for even gayer fags
>>
>>57283266
Rust. No joke.
>>
>>57283243
its the same as Vim vs Emacs

who gives a shit
>>
double cos(double userInput, double threshold)
{
double sum = 0.0;
int n = 0;
while (true) {
int equation = (2 * n);
double term = (pow(-1, n) / myFact(equation))*pow(cosx, equation);
sum += term;
if (abs(term) < threshold) { break; }
n++;
}
return sum;


>take weeks to try to figure out what was wrong with this code
>/g/ couldn't help me
>ask a classmate
>he gives me his code
>the only thing different was that he put a
abs(term) /*instead of term <threshold*/ 

>it works

Yep, I want to shoot myself in the head right now.
>>
>>57283306
/g/ did help you, they just didn't spoonfeed you. I remember someone giving a very strong hint towards that conclusion.
>>
>>57283306
someone told you this
you incorporated almost none of the feedback that you got. now it works but you've learned nothing
>>
>>57283306
Not even sure what you're trying to accomplish here but that's some pretty ugly code IMO
>>
>>57283306

Can someone tell me why I had to put an abs in term for it to work?
>>
>>57283283
I would prefer you to not make jokes, and then claim they aren't.
>>
>>57283287
It's a completely different thing.
Vim vs Emacs is personal preference of a tool used by a single programmer
json vs yaml is a more objective discussion which is very important, as choosing a standard data format impacts the way programmers all over the world deal with their data.
>>
>>57283337
In other words
>implying google (or any, really) api choosing json over xml is vim vs emacs type of discussion
>>
File: anal beads.png (4KB, 855x55px) Image search: [Google]
anal beads.png
4KB, 855x55px
>>57282714
depends on the type

pic related
>>
>>57283333
Doubles are by their nature ethereal and therefore do not abide by our laws.
>>
>>57283283
Doesn't Rust require to always think about memory/borrowing/etc? I have not used it yet so it may be actually a good language, but if it forces to think about low-level stuff it doesn't sound good.
>>
>>57283315
>>57283322
>>57283332

Jokes on you guys, I already know I'm a retard and couldn't deal with Engineering. I've already changed my major to accounting and only need to pass this course with a c or above. If I do or don't get my degree in accounting, I'll be shooting myself with a gun after my parents die.
>>
>>57283375
Can I have your stuff?
>>
>>57283373
Yes, but that's something you do anyways. It's not low level per se, it's about correctness in general. And it's also not difficult.
>>
File: standards[1].png (24KB, 500x283px) Image search: [Google]
standards[1].png
24KB, 500x283px
>>57283337
>>57283357
That's what I meant.

It accomplishes the same goal, with arbitrary differences and special snowflake features to differentiate it self.

We already have XML and JSON. Oh right I know what we need, Yet Another Markup Language

pic related
>>
i can't tell what's bait here anymore
some of my students are actually this dumb
>>
Real programmer use Bash. Feels good to be highest paid https://adtmag.com/blogs/dev-watch/2016/07/bash-salaries.aspx

find . -maxdepth 1 -name "hipster shit" -delete
>>
>>57282979
You're on the right track. The obvious way is to accept the state in your stateful functions and then return the new state in the end:
data State = Int 

-- counts the number of times its been called
statefullAdd :: State -> Int -> Int -> (State, Int)
statefullAdd state a b = (state + 1, a + b)

but that has the problem of being annoying to chain:
doItThrice :: State -> (State, Int) 
doItThrice state = statefullAdd newNewState 1 result2
where (newNewState, result2) = stateFullAdd newState 1 result1
(newState, result1) = stateFullAdd state 1 2
 
At this point, it is reasonable to define an operator that will automatically link stateful computations:

bind :: (State, a) -> ((State -> a -> (State, b)) -> (State, b)
bind a b = b initialState result
where (initialState, result) = a

doItThrice = (0, 2) `bind` stateFullAdd 1 `bind` stateFullAdd 1

This is basically the plumbing behind the state monad, so use that instead ;)
>>
>>57283243
I enjoy using yaml, it doesn't rape my eyes like json and xml do. I will keep using it whenever appropriate in the future.
>>
>>57283423
Please post some of your students mistakes
>>
>>57283427
Or one by one:

FAGS=($(find . -maxdepth 1 -name "hipster shit"))
for ((i=0; i<${#FAGS[@]}; i++)); do
rm ${FAGS[$i]}
done
>>
>>57283454
Not him but my class mate was using phonegap or some other framework to host his web app on AWS.

The tutorial he followed required him to host his .ppk for the AWS instance on github. The tutorial said to make sure it's private, well he didn't and left it public.

After about 2 months, someone got a hold of it, probably using a web crawler and used his instance to host Indian porn, creating a monthly bill of $5,000.

It was pretty funny.
>>
Why aren't there any good IDEs for Windows?
>>
>>57283419
But yaml is just a better json.
It's a superset of json, and adds many features on top of it plus is way more *readable*.
So why stick to bad standard if you can use a better one?
>>
Hi just learning c++, can someone post that 100 challenges thing because i seriously dont know what else i can code right now ( besides a textbased game).

Cheers
>>
>>57283482
visual studio is great
>>
>>57283482
VS studio is one of the best IDE's around on any OS.
>>
>>57283482
Visual Studio is the best IDE.
>>
>>57283482
For what language?

There are multiple great IDEs, obviously depending on the characteristics that you value in an IDE.

Visual Studio is an industry standard, and I personally love it. However, it sounds like you're the kind of person to have abnormal preferences on certain attributes, so I'm sure you think it's shit.
>>
>>57283482
Eclipse or Netbeans
>>
File: 1474544163649.jpg (314KB, 1261x1000px) Image search: [Google]
1474544163649.jpg
314KB, 1261x1000px
>>57283482
>JetBrains
>Visual Studio
What do you mean?
>>57283513
pic related
>>
>>57283439
sorry but i can't read haskell syntax
>>
>>57283482
Emacs works fine on Windows m8
>>
>>57283482
The best development environment is available also for Windows. GNU Emacs. Learn it. Love it.
>>
>>57283531
>>57283525
>>57283522
>>57283521
>>57283530
>>57283535
lol, got you guys good

Yeah, I know Visual Studio is good, but I'm a bit lonely right now so it feels nice to post an unpopular opinion and get responses in an attempt to substitute this basic interaction for more meaningful social connections that I fail to create through lack of charisma and a generally surly attitude.
>>
File: powersincos.jpg (29KB, 569x167px) Image search: [Google]
powersincos.jpg
29KB, 569x167px
>>57283333
a complete mathematical understanding is probably asking too much

look at the terms here. you are trying to bail out as soon as the terms get "small". you are trying to do this by checking term < threshold but the second term here is always negative, so this inequality is true at that stage

another way to put it is that i don't want to consider -2000 to be small

>>57283454
it's math. calculus recently, unfortunately. i don't think it would play well here

>>57283482
i can't think of many linux or mac-specific ides that people like besides xcode
>>
>>57283562

That's stupid. I would never do that.
>>
File: 1477322353236.gif (67KB, 600x400px) Image search: [Google]
1477322353236.gif
67KB, 600x400px
>>57283562
that's kinda sad anon
>>
>>57283507
It's not just better, having more features doesn't make it better. JSON is still faster.

But in the end as I said is like Vim vs Emacs as it's a matter of personal choice. JS dominates the web, JSON is part of it, all major API used, so to me it just makes sesne to go with JSON. Plus I'm not a fan of whitespace indentation
>>
>>57283535
Thanks, am i correct in assuming this was written with non oop languages in mind? Although i guess it can all be done in c++, it looks like im going to have to up my math game
>>
>>57283580
Yeah, but at least I'm not a tranny
>>
>>57283562
I know that feel anon.

Crack open VS and code yourself a digital waifu.
>>
>>57283596
neither am i anon
>>
>>57283535
rolling
>>
>>57283525
This
>>
>>57283596
most people also aren't trannies though
>>
>>57283593
Were you expecting problems that asked you to simply put together some architecture without actually accomplishing anything?
>>
>>57281637

Don't create an instance both in the declaration and on the constructor(there is no point). It's better to do it in the constructor.
//variables and objects should respect camelcase
private Die die1;
public TwoDice() {
die1 = new Dice;
}

Override toString().
>>
>>57283591
That's why I posted in the first place. To ask about /dpt/'s opinion.
I still don't think it's emacs vs vim, because that one is a holy war with no right answer.
This can be a healthy discussion about which format has more pros.
>>57283593
Why do you think that? Those are perfectly fine for OOP language. You have some bigger ones there too, which are very good for practicing them OOD skills.
>>57283598
>code yourself a digital waifu
I think I know what I'll be doing tonight.
>>
>>57283648
No of course not, these are for the most part beyond what i know, which is what i wanted. How else are you going to learn?
>>
>>57283664
>
new Dice();
>>
>>57281637
Why not just make a dice class with a constructor that accepts how many dies are in that group?
>>
>>57282714
+/- infinity
>>
>>57283015
>Writing in a compiled language inside a game on the fly
I don't even want to imagine the tomfuckery required to achieve this
>>
>>57283667
I just think JSON is so embedded in the web dev culture at least, even if YAML was proven to be the right choice, it would be hard for everyone to switch.

But yeah, JSON is faster, more structured, rigid and proven. I say, stick with it.
>>
>>57283667
Actually i genuinely dont have a clue, i thought moat look math related so isnt that more suited to a non oop language? Again im just starting and am only down with the basics right now. I sont even know much anout non oop languages, i just chose c++ for really quite a terrible reason and found it better to focus on other things. ( i initially started learning it to write csgo cheats then i quit csgo when i realised i can do better stuff with c++ than make a shoddy hacks
>>
Still on my python interpreter journey, made the lambda work somehow by using std::function.

Any other ideas on how to make it less ugly?
class BuiltInFunction : public Object {
public:
BuiltInFunction(std::function<Object& (const Object& right)> function) :
Object("builtin function"), function(function) {};
Object& call(const Object& obj);
private:
std::function<Object& (const Object& right)> function;
};

IntObject::IntObject (int value) :
Object("int"), value(value) {
std::function<Object& (const Object& right)> __add__ = [this](const Object& right)-> Object& {
IntObject* int_right = dynamic_cast<IntObject*>(const_cast<Object*>(&right));
if(int_right){
return *(new IntObject(this->value + int_right->value));
}else{
return *(new Object());
}
};
newName("__add__", *(new BuiltInFunction(__add__)
));
}
>>
>>57283669
What?
>>
>>57283699
C# has an interpreter
>>
>>57283720
I wanted hard stuff, im happy its difficult and not easy shit that does nothing
>>
>>57283745
Oh, it sounded like you were complaining. Carry on.
>>
>>57282981
it's possible on a technical level. i know they severely restrict what addons are allowed to do; that's probably the explanation
>>
in Haskell this is just

dice = uniform [1..6]

main = mapM_ (print.evalRandIO) [dice, dice]
>>
File: blazingly fast.jpg (318KB, 1025x690px) Image search: [Google]
blazingly fast.jpg
318KB, 1025x690px
This is what your zero overhead memes get you
>>
>>57283664
Firstly
>It's better to do it in the constructor.
Not true. It's a matter of personal preference, for me it's way more readable to do simple initialization in the declaration.
Secondly those are local objects in that constructor.
>>57283711
>Math and OOP are exclusive
I don't know where you got that stereotype from
>>57283710
I use json for rest (obviusly) but I just can't resist using yaml for local application properties or little things like that.
I'd really like it to get more popular, but I guess you're right
>>
>>57283774
>I don't know where you got that stereotype from

math == good programming
oop == bad programming

therefore you cannot do math in OOP, because my cognitive dissonance wouldn't allow it
>>
>>57283763
What was this website called?
>>
>>57283763
Yeah, the panicking upon overflow behaviour isn't optimal, but "safe Rust" is about safety (security) first, performance close second. Want to do arithmetic fast while taking responsibility for any overflow? Unsafe is your friend.
>>
>>57283807
https://godbolt.org/
>>
>>57283807
rust.godbolt.org
gcc.godbolt.org
>>
>>57283774
Because of some stuff i did a lomg time ago with java where all we did was work with guis and basic math, and i figure since non oop languages are low level theyre not good for guis, and only good for system and math stuff? What is the purpose then?
>>
I'm working on a javafx project right now. Can you put radio buttons inside of a combobox? I'm currently trying to implement the project this way but the program is not listening for my selections.
>>
>>57283763
>>57283809
Also, panicking is only in debug mode. In release, it overflows.
>>
Is it possible to delete e-mails after the FBI has already seized them? Please respond, it's urgent.
>>
>>57283816
Maybe you should reevaluate your decision to put radio buttons inside a combobox because that doesn't look like good UI.
>>
File: ok.jpg (199KB, 812x408px) Image search: [Google]
ok.jpg
199KB, 812x408px
>>57283809
>>57283822
Ok, that's better, a lot better
>>
>>57283816
>Can you put radio buttons inside of a combobox?
what did he mean by this
>>
>>57283823
https://www.bleachbit.org
>>
>>57283848
>tfw no ghc.godbolt
i want to see how many hundreds of instructions a polymorphic square would be
>>
>>57283830
It's not a consumer product. I'm just trying to kill two birds with one stone for the requirements.
>>
>>57283799
Again, stereotype.
>>57283814
Low level are good for performance critical stuff.
High level are good for developer time critical stuff.
That's all.
Math related stuff can be coded in both (e.g. heavy python usage for data science).
>>
File: hillposting.png (46KB, 521x181px) Image search: [Google]
hillposting.png
46KB, 521x181px
>>57283823
>>
>>57283848
> Unironically wanting overflow
Retard
>>
>>57283865
There's a reason why you're having so much trouble doing it: it's stupid and you should reevaluate your program flow.
>>
>>57283864
yeah, but there are also
d.godbolt.org
go.godbolt.org
You could always ask him if he would be interested in adding ghc
>>
>>57283774
>It's a matter of personal preference
Except it's literally more expensive to do it at the declaration, rather than on construction or (more ideally) right before you need it.
>>
What exactly makes recursion different from what I've been doing so far? Just seems like looping.
>>
>>57283905
>ask him
>social interaction
>>
>>57283814
>non oop languages are low level
Not true, even if you don't consider languages like C "high level" as it was in the traditional sense, you have things like functional languages which may not provide much in the way of OOP but are anything but low level.

>math stuff
Depends on what you mean by "math stuff". If you mean lots of highly intensive time sensitive calculations, then yes, but high level languages are better for general mathematics, i.e. the applications a mathematician might actually use them for, who has no desire to be bogged down with system programming details like memory management.
>>
>>57283872
to be clear: the number crunching is usually farmed out to c
most of the data scientists i know are godawful at programming
>>
>>57283909
It's equivalent in power to looping but is easier in a lot of scenarios.
>>
>>57283909
Looping is a specific form of recursion
>>
>not proving that there will be no overflow
>>
>>57283908
>it's literally more expensive
[citation needed]
>>
>>57283946
it's not though
>>
>>57283909
Nothing really. Most (read: Ackermann) recursion can be done with via loops. Recursion can be used to generate cleaner and more readable code. Recursion might cost more execution time / memory.

You should learn how to use recursion.
>>
>>57283929
>>57283946
Really? So far the assignments I've been given seem like they would've been way easier if I just use do while or for loops. Plus my professor's a cunt and spent like the last three lectures explaining bubble sort rather than this new thing which I have to use now.
Hasn't quite clicked yet but I'm sure it'll come to me eventually.
>>
>>57283993
goto is recursion
>>
good way to model file-systems in c
struct dir {
char ** files;
struct dir * children;
};
>>
>>57283823
You have to acid-wash it. It's a very expensive procedure.
>>
>>57284033
No it's not.
>>
>>57283991
private Die die1 = new Die();
private int num = 100;

public OneDie(){
die1 = new Die();
}

public RollDice(int times){
num = times;
for(int i = 0; i < num; i++){
die1.Roll();
}
}


Pretend you call the constructor. You've already done three calls.
1) The new die construction at declaration
2) Giving the int a value
3) Calling the die construction a second time

Now pretend that you never actually call the RollDice method. Maybe you call some other method in the class not seen, but never RollDice. You've uselessly taken up memory by assigning a value to num at declaration, when you really should have only done that right before you needed it.

This is a super light example but as you work with larger and more complex classes with more and more class variables it becomes more and more expensive. It's bad practice because you shouldn't assume every variable is going to be used.
>>
File: nbc corrupted my rectum.png (682KB, 1150x1202px) Image search: [Google]
nbc corrupted my rectum.png
682KB, 1150x1202px
>>57284038
woops, Wrong! picture
>>
>>57284052
it is though

or do you actually believe recursion has anything to do with C function calls
>>
>>57284008
Recursion is often taught very poorly. In a lot of mainstream languages, it's also implemented poorly (no tail call optimization) and it doesn't work well when everything's encapsulated (except internally).
>>
>>57284034
How do you traverse backwards, to parent dir?
>>
>>57284063
It has to do with functions yes. Doesn't matter what the machine code is in the end.
>>
>>57284066
you're right
struct dir * parent

shall be the third member
>>
File: 160928_3.jpg (1MB, 1000x1500px) Image search: [Google]
160928_3.jpg
1MB, 1000x1500px
>>57283920
i hope that in my lifetime a computer program proves something interesting (in my subfield, say) that isn't just "numerically verify a bunch of cases"
by and large we just use computers as latex and email machines. how long can that last?
no one is even willing to throw money at reasonable projects like "create an open-source alternative to mathematica"

>>57284008
it sounds like you don't have good examples yet
this is not a complete answer but: one concept to really take to heart is breaking a problem into smaller problems, solving those, and then combining the results in order to solve your original problem. that's a great reason to pull out recursion, even if you can later rewrite things as a loop
https://en.wikipedia.org/wiki/Divide_and_conquer_algorithms
>>
>>57284073
wow

i guess
for (int i = 0; i < 10; ++i)
x += a[i];


isn't a loop, because it isn't using function calls then
>>
Write a program to print a figure in the shape of a heart by the sign " o ".


string str =
@"
__ __
( o o )
o o o
o o
o o
o
";
Console.WriteLine(str);

>>
>>57284095
>i hope that in my lifetime a computer program proves something interesting (in my subfield, say) that isn't just "numerically verify a bunch of cases"
https://en.wikipedia.org/wiki/Four_color_theorem
>>
>>57284058
Someone call these dumb faggots and explain the concept of a metaphor.
>>
>>57284101
That's a loop you retard.

>isn't a loop, because it isn't using function calls then
What the fuck is your logic here? Are you literally retarded?
>>
>>57283864
it's harder to analyze assembly code generated by ghc because it doesn't use a the call stack at all. ebx is being used for multiple stuffs; sometimes for storing a pointer to a function specific memory frame, sometimes for storing a variable...
>>
File: 1475240177564.jpg (174KB, 500x600px) Image search: [Google]
1475240177564.jpg
174KB, 500x600px
>>57284111
>we /pol/ now
>>
>>57284103
>not adding
using static System.Console;
to your header
pleb
>>
File: 1477609068303.gif (845KB, 300x300px) Image search: [Google]
1477609068303.gif
845KB, 300x300px
>>57284114
IT HAS TO DO WITH FUNCTION CALLS, YES

DOESN'T MATTER WHAT THE MACHINE CODE IS
>>
>>57284135
recursion does yes. Don't know what that has to do with loops.
>>
>>57284135
You have to go back
>>
File: xml.png (26KB, 496x320px) Image search: [Google]
xml.png
26KB, 496x320px
>>57283419
>xml
pic

>>57283419
>JSON
json is a minefield.
http://seriot.ch/parsing_json.html
>>
>>57284151
>all programming is based on the C abstract machine
>>
>>57284056
Dude, what are you even talking about.
Firstly, we were talking about declaration initialization vs constructor initialization, not both, which is obviusly never ever used (except in funny anti examples like OP's pic).
Secondly, if you initialize something in a method (like integer num in your example), then what's the point of it being an instance variable? It should be local. So your argument is non-existent.
Thirdly if it was actually a justified instance variable shared across methods (like Die die1), then you have to initialize it somewhere. If you don't, you have to check if it was initalized in every method that uses it.
Such usage is justified only if you're creating a huge amount of objects but not calling their methods very often, and the initialization is actually expensive (in case of ints they're default initialized to 0 anyways), which is a rare use case, and not doing it like that is definitely not a bad practice.
So I'm sorry but you're simply wrong.
>>
>>57284167
Didn't say that
>>
File: acidwash2.png (14KB, 564x323px) Image search: [Google]
acidwash2.png
14KB, 564x323px
>>57284111

It's alright. I decided to write AcidWash.
>>
omega : A
omega = omega

This is recursion. Do you see a function?
>>
>>57284177
you think it
>>
>>57284181
I see every type of function and more
>>
File: hehe1.jpg (38KB, 640x635px) Image search: [Google]
hehe1.jpg
38KB, 640x635px
>>57284065
>>57284095
That makes me feel a little better. I know pretty much everyone in the class is either lost or pretending like they know what they're talking about
>y-yeah we just gotta derive an algorithm for this recursive from the memory address of the...
Thanks for the article, I'll read it in a bit. Got anymore resources for grasping this?
>>
>>57284190
Regardless, no function was needed to do the recursion.
>>
>>57284181
I see invalid code.
>>
File: DeepinScreenshot20161028214353.png (140KB, 1603x443px) Image search: [Google]
DeepinScreenshot20161028214353.png
140KB, 1603x443px
>>57284174
and as for the constructor vs declaration initialization see pic related.
Semantically they're exactly the same.
>>
>>57284214
I don't
>>
>>57284108
i am, of course, aware of this. maybe i'm downplaying the role of the computers here but my recollection was that they proved that either the theorem is true or a counterexample lies on a certain finite list. the computer checks the list
>>
trying to program a ranger like ncurses program written in c (for project points and to also make it tailored to my needs)

although its hard thinking up of a way how everything works together
there's too many things going on

how do you guys do big projects?
do you just start writing from the initial main (as if you were the program itself) and include whatever you need along the way?
>>
>>57284181
I see true
>>
>>57284219
That's because you are a poor programmer.
>>
>>57284190
>>57284210
Also, you could interpret A as being a concrete type.

>>57284214
Of course it's bad, but it's still recursive and valid in some inconsistent systems.

>>57284224
It's been formalized in Coq, which means it's valid. I mean, technically the role of the computer is always to just check things and sometimes run tactics or perform unification. But that's a gross oversimplification.
>>
>>57284190
>>57284259
Furthermore, you're not seeing the type of functions. In a system where this is admissible, it would actually be the type of "functions + infinite loops", and you would not have a function but rather an infinite loop, which fits into that not-quite-function type.
>>
>>57284259
>valid in some inconsistent systems.
Such as?
>>
>>57284229
It took me a few years and a number of badly organized projects to learn how to organize large projects well. Using a language suitable for a large project helps (java, c#) but you don't have to.
>>
>>57284229
Plan ahead. Try to separate everything into functions, and try to keep each function as general and reusable as you can. You probably wont get it perfect the first few times. that is fine.
>>
File: 71qCrpznG5L.jpg (181KB, 940x1180px) Image search: [Google]
71qCrpznG5L.jpg
181KB, 940x1180px
>>57284229
>how do you guys do big projects?
Read about programming structuring and shit.

This book helped me out a LOT.
>inb4 design patterns are a meme
Just reading about the patterns and when they are intended to be used and why gave me a good sense of how to break up dependencies in large projects. It's easy to apply this stuff to non-OOP programming.
>>
>>57284279
Haskell, if you modify the syntax a touch. It's still recursion, just not well-founded. Nor is it productive corecursion.
>>
>>57284232
How is this invalid?
>>
>>57284316
these covers are so weird
>>
to get back to the point

it is ridiculous to suggest that if C functions aren't involved it can't be recursion
>>
>>57284231
omega ≜ omega
>>
>>57284161
I didn't say json or xml is perfect. But c'mon. Why not fix the issues and make it better rather than make another language?
>>
>>57284316
>It's easy to apply this stuff to non-OOP programming.
It's unnecessary to apply this stuff to non-OOP programming.
>>
>>57284326
I'm not a haskel fag, but you're setting the value of "omega" as the value of a variable that hasn't yet been declared.

I don't see how this would be compilable.

Just how
int a = a;

would not be valid in C.

Am i missing something?
>>
>>57284356
the best already does exist: tagged s-expressions.
>>
>>57284362
Of course.

But useful.
>>
>>57284345
Goto is not recursion though. Neither are loops. They are equivalent in some sense, that is all.

>>57284356
>Why not fix the issues and make it better rather than make another language?
How do you propose fixing the issues without essentially making a new language? JSON doesn't have versioning and XML is so bad that fixing its issues would make it unrecognizable.
>>
>>57284181
yes, omega
>>
>>57284366
Yes, you are missing something.
It is almost valid haskell.

x :: a
x = x


>>57284371
For strenuous definitions of useful
>>
>>57284366
It's invalid with an imperative lens of the world. It's recursive with a declarative lens.

>>57284389
What makes it a function?
>>
>>57284393
>It is almost valid haskell.
That's what I'm saying. It's almost valid. As in, not valid at all.
>>
>>57284407
It's only invalid because he only used a single colon for the type signature
If he used two colons, it would be valid
the example I gave was valid

x :: a
x = x
>>
>>57284421
>it's only invalid because of this thing that makes it invalid
>>
>>57284421
I don't get it.
>>
Write a program that prints on the console a Right Angle Triangle which
sides consist of the copyright character "©".

int unicode = 169;
char copySign = (char)unicode;
string copyStr = copySign.ToString();
string triangle = copyStr + "\n" + copyStr + " " + copyStr + "\n" +
copyStr + " " + copyStr + "\n" + copyStr + copyStr + copyStr + copyStr + copyStr;
WriteLine(triangle);
>>
>>57284407
I wrote it as pseudocode anyways.
>>
>>57284434
are you having difficulty reading?

the only problem is that he used : (which is preferred) rather than :: (which is the actual syntax)

this is like saying "you wrote Int rather than int! ha!"

>>57284436
how about this

value :: Bool
value = False && value

What is value?
>>
>>57284446
Writing something in pseudo code doesn't somehow make garbage code logically sound.
>>
>>57284466
>are you having difficulty reading?
No, invalid code is invalid code, no matter how you look at it
>>
>>57284466
>What is value?
It's invalid code. It can't be compiled because "value" is not defined in the expression "False && value"
>>
>>57284486
Ok well I posted valid code

>>57284494
No it isn't, it's valid.
value = False
>>
>>57284475
Sure, it's invalid to interpret it as logic. But this is a programming thread so that's not the only possibility.
>>
>>57284506
>value = False
how do you figure that?
>>
File: recursive definition.png (4KB, 324x160px) Image search: [Google]
recursive definition.png
4KB, 324x160px
>>57284518
>>
>>57284508
That's only true in C+=
https://github.com/ErisBlastar/cplusequality
>>
>>57284438
>
int unicode = 169;
char copySign = (char)unicode;
string copyStr = copySign.ToString();


var copySign = ((char)169).ToString();


Or better yet, just use the character as-is.
>>
>>57284527
but how
>>
>>57284540
False && _ = False

You don't need to know what the second argument is
>>
>>57284366
Clang compiles that just fine.
>>
>>57284530
I don't think you understand the Curry-Howard isomorphism. A program can only be a proof of the proposition corresponding to its type if there's, for instance, a circular definition like that.

It is not invalid logic, it is invalid to interpret it as logic.
>>
>>57284546
oh, duh...

Still, i find it a bit off putting that Haskell let's code like that pass.

>>57284555
Clang a shit
>>
>>57284530
>>57284558
*no circular definition like that
>>
>>57284568
Why wouldn't it?
Haskell is lazily evaluated.

You can also do this:

ones :: [Integer]
ones = 1 : ones

ones is a list consisting of "1", followed by ones
(i.e. 1 is the head of the list, and ones is the tail)

ones = 1 : ones
ones = 1 : 1 : ones
ones = 1 : 1 : 1 : ones
...
ones = [1,1,1,1,1,1, ... ]
>>
wtf is recursion
>>
>>57284436
It defines x which is defined in terms of x which is defined in terms of x ....
It's an infinite loop. Haskell people call stuff that doesn't terminate or crash bottom.
And every Haskell type contains bottom.
Hence "x" can be of type "a".
"a", as well as all lower case types, denote a polymorphic type.

x never terminates so it can cheekily claim to return anything you'd ever want, because it never finishes and you can never actually get the return value.
It doesn't deliver on it's promise.
Needless to say that this isn't logically sound.

>>57284518
&& is lazy, like everything else in Haskell.
"false && whatever" is always false, regardless of what "whatever" is.
The && never evaluates "whatever" when the first argument is false.
If the first argument is true, then it has to evaluate whatever first to compute the result.
>>
>>57284592
https://www.recurse.com
>>
>>57284568
> Clang a shit
Kek, what? Anyway, you're statement was wrong.
>>
File: image.jpg (107KB, 800x1067px) Image search: [Google]
image.jpg
107KB, 800x1067px
>>57284536

thanks lad
>>
>>57284604
isn't this a scam?
>>
http://programming.witheve.com

have they done anything useful here?
>>
>>57284594
>If the first argument is true, then it has to evaluate whatever first to compute the result.
That's not really true. It doesn't evaluate the second argument, it just returns it. So:
x :: Bool
x = True && x

only gets stuck when you try to evaluate it. For instance,
False && x
will compute to False.
>>
>>57284585

For the same reason I feel
value :: Bool
value = True && value

should not compile
>>
>>57284667
That would infinitely recur and never evaluate.
You can write functions that do that when called in C and C++.

It would make Haskell a lot more awkward if you had to prove your definitions terminated.
>>
>>57284666
Will that actually compile?

Nice trips.
>>
>>57284675
>That would infinitely recur and never evaluate.
Is it not desirable for the compiler to catch stuff like this? That seems as important as catching any normal type error. Haskell was all about safety I though. I'd have thought warning you when evaluating a variable will take an infinite amount of time would be a good idea.
>>
daily tip: coding isn't the same as programing
>>
>>57284677
Yes. No different than
while(true) {}
being valid C or whatever.
>>
>>57284714
no it's not. "while(true) {}" is useful sometimes.
>>
>>57284698
It is desirable, and Haskell's safety is quite exaggerated. But proving termination of useful things is not always feasible, so Haskell has opted to not be conservative about it.

>>57284731
All of these definitions would be useful for the same reasons, then.
>>
>>57284731
> While(true)
Bravo C++
>>
            byte firstNum = 5, secondNum = 6;
byte? temp = null;
WriteLine("First: {0}", firstNum);
WriteLine("Second: {0}", secondNum);

temp = firstNum;
firstNum = secondNum;
secondNum = (byte)temp;

WriteLine("First: {0}", firstNum);
WriteLine("Second: {0}", secondNum);
>>
>>57284750
>All of these definitions would be useful for the same reasons, then.
how?

I don't see how a variable definition that can never complete evaluation is useful.
>>
>>57284764
What's wrong with it?
>>
>>57284650
No. Web hipsters discovered literate programming, which is dead or never actually lived.
Knuth invented it, but that doesn't change the fact that it never caught on.

They then decided to combine it with another meme language called Elm.

>>57284666
That's exactly what I said.
The && operator hast to evaluate it's second argument only if it's first argument is true.
So your definition of x is an infinite loop.
False && x terminates because && first argument is false and it never has to touch the infinite loop x.

>>57284698
Catching this generally means solving the Halting problem.
You just can't.
You can however restrict your language to a subset where you can prove termination, like in Coq or Idris.
But this is not useful in practice.
>>
>>57284438
var thing = ((char)(new int() 
-~-~-~-~-~-~-~-~-~-~-~-~-~
-~-~-~-~-~-~-~-~-~-~-~-~-~


-~-~-~-~-~-~-~-~-~-~-~-~-~
-~-~-~-~-~-~-~-~-~-~-~-~-~
-~-~-~-~-~-~-~-~-~-~-~-~-~


-~-~-~-~-~-~-~-~-~-~-~-~-~
-~-~-~-~-~-~-~-~-~-~-~-~-~
-~-~-~-~-~-~-~-~-~-~-~-~-~
-~-~-~-~-~-~-~-~-~-~-~-~-~


-~-~-~-~-~-~-~-~-~-~-~-~-~
-~-~-~-~-~-~-~-~-~-~-~-~-~


-~-~-~-~-~-~-~-~-~-~-~-~-~
-~-~-~-~-~-~-~-~-~-~-~-~-~
+0)).ToString();

var ayy = 5;
Range(1, ayy).ForEach(x => { Range(1, x).ForEach(y => Write(thing)); WriteLine(); });


>it thinks this post is spam

Fuck you, 4chan
>>
>>57284750
haskell is a meme, you can tell why any language is better for certain task, the only think you can say about haskell is "muh curry"
>>
>>57284667
>>57284675
>>57284776

Of course, you might want something that can never be fully evaluated, like >>57284585
Infinite data structures are neat

There was an example earlier for an anon implementing this open chest thing where you get

6/10 chance of nothing (0)
3/10 chance of gold (1)
1/10 chance of two chests

He was using a recursive function, where he'd get a random number, put it into one of those categories, print and then maybe call main again two more times (if you get two chests)

I showed him an alternative, which consisted of an monadic infinite data structure.
Basically, you can think of it as being a value which represents a choice (and some IO actions), and one of the choices is "the sum of two previous choices"

Ignoring the IO (printing "you got gold!"), it was similar to this:

result = chooseFrom [ 
(6/10, 0), -- 60% chance of nothing
(3/10, 1), -- 30% chance of 1 gold
(1,10, chests) -- 10% chance of 2 chests
] where chests = (+) <$> result <*> result
-- recursive, chests is the sum of two possible results



>>57284698
You can almost always tell when this stuff will happen if you're not working with some very high level stuff like parser combinatrics.
It would be incredibly awkward to prove termination, and it would make Haskell turing incomplete.

>>57284750
Haskell is extremely safe compared to most other general purpose languages, the unsafe functions are non-standard and almost certainly a mistake. I think SAFE should be enabled by default.

Non-termination isn't necessarily a problem because the function given bottom will never be called.
>>
>>57284770
>
WriteLine("First: {0}", firstNum);


>not
WriteLine($"First: {firstNum}");
>>
>>57284770
What are you trying to do here?
>>
>>57284776
>I don't see how a variable definition that can never complete evaluation is useful.
Being able to write infinite loops and have arbitrary recursions patterns is useful.
>>
>>57284820
Curry is delicious.
Fuck you.
>>
>>57284776
If
while(true) {}
is useful then
let x = x in x
is useful.

>>57284788
>But this is not useful in practice.
>>57284823
>Non-termination isn't necessarily a problem because the function given bottom will never be called.
It's extremely useful when you want to prove things. Necessary, actually. Now, if you're simply doing verified programming it's not STRICTLY necessary because getting stuck in an infinite loop is still probably better than launching the missiles.

I think I said this last night - it's not a backdoor or anything, but it's denial of service. If this matters to you (or you don't want some chucklefuck coming along and "proving" something with an infinite loop so he can call some function) then you probably want termination to be checked, which is being worked on.

How it is in these relatively mainstream languages (if Coq and Idris can be considered mainstream) is horrible.
>>
>>57284784
It's tedious and unoptimized implies you'll constantly be checking if true is true
>>
>>57284824
thanks again lad

>>57284825
Just swap the values of 2 variables.
>>
>>57284863
>It's tedious
how is it tedious? What's better?
>>
>>57284839
pajeet detected
>>
>>57284859
>>But this is not useful in practice.
It's not useful for programming.
It is useful for theorem proving, which is not what we are talking about.
>>
>>57284897
Something like loop{}
>>
>>57284859
Also there's codata and coinduction, which give you back your infinite structures while still being logically sound. So total is not at odds with Turing-complete.

And, of course, if you want to do anything useful at this point you have to do things that are not provably safe within the system. Best to have this stuff on by default but with a switch for when you really need to tell the computer "just trust me you dumb fuck". And a very visible light when the switch is on, metaphorically.
>>
>>57284174
>Secondly, if you initialize something in a method (like integer num in your example), then what's the point of it being an instance variable? It should be local. So your argument is non-existent.

There is no point initializing it as soon as you declare it. In your case with the num, it doesn't matter, but if it were an object, best practice is to initialize it when you need it.
>>
>>57284859
I feel like given bang patterns and such this is an overrated problem.

someFun :: Password -> IO (Maybe Key)

myFun :: Key -> SecretDocuments
myFun !k = ...


magic :: a
magic = magic

myFun magic

Unless you're just ignoring the infinite argument, you can't "really" call the function
>>
>>57284907
an entire new piece of syntax just for the very rare occasion when you want an infinite loop?

while (true) is really easy to understand and will be optimised out any any half decent compiler.
>>
>>57284933
>BangPatterns
We have Strict and StrictData now!
>>
>>57284934
>an entire new piece of syntax just for the very rare occasion when you want an infinite loop?
in Haskell this is just

forever x  = do
x
forever x
>>
>>57284917
>best practice is to initialize it when you need it
This is not best practice. Most of the time it's bad practice. The post explained why.
>you have to check if it was initalized in every method that uses it.
>>
>>57284839
Poo in the Loo
>>
>>57284906
>It's not useful for programming.
Maybe not in your opinion. Verified programming involves theorem proving. If you can prove false things because the system admits circular reasoning (i.e. an infinite loop of some kind), then you're not really going to break anything (depends on the scenario, though - you're not necessarily going to have an OS to fall back on to kill a stuck process), but you're also not going to be able to use the compiler/assistant to show you if, where, and how your logic is unsound.
>>
>>57284969
>in haskell it's just three lines of code instead of one, where repeat "forever" twice and "x" three time.
Haskell sure is cool.
>>
>>57284992
No, that's the DEFINITION.
You call it like this

forever $ do
putStrLn ">imperative programming"
--more stuff goes here
>>
>>57284992
one line in javascript, and javascript sucks less than haskell
>>
>>57284992
That's a definition that you write once and can use everywhere. It's also not very well-written.
forever x = x >> forever x
>>
>>57284934
You have the keyword "do" even though it's unnecessary. Why not loop. It's even clearer what it means.
>>
NEW THREAD

>>57285014
>>57285014
>>57285014
>>57285014
>>57285014
>>
Does anyone know of an equivalent way of the haskell init function in F#? I can only think of some list reversing followed by list.last
>>
>>57285042
>>57285074
>>
>>57284971
>>you have to check if it was initalized in every method that uses it.

No, you don't, if you have any idea of the flow of your program (what functions calls what).

Imagine building a heavy graphical application. There is no reason to do declaration initialization for every component, instead you can put them in a specific (private) function to do that for you, and call it in your constructor. That way you are sure the objects will be created before you use them, and you don't need to do it when you declare them. Your way seems the lazy way.
>>
>>57284988
I really don't understand your point. If you want to prove that some statement is false, you can perfectly do that without
having bottoms everywhere.
As soon as you invite bottom values into your proof system, you can't trust any of it's proofs.
It can "prove" arbitrary bullshit.

And this is bad, even if you use it for programming and say "well infinite loops aren''t THAT bad".
You can't trust it's proofs that say you never do integer overflow or have buffer overflows.

For general programming I think it's really cumbersome to convince the compiler that everything you do
terminates. I'd like to see a Haskell extension that does this positivity checking the Idris does
and see how much code on Hackage would break because of it.
I bet it's a lot.
>>
>>57285164
Is it true that Idris is _slower_ than Haskell?
>>
>>57285307
Probably. It rather new and performance is not really a concern right now.
It just doesn't have as many man hours poured into the optimizer like GHC has.
>>
>>57285356
I thought the point was to make it faster.
Anyway, there's a lot of stuff I'd like to see in idris that isn't there, like pattern synonyms.

I'm also pretty sure it has the same Haskell flaws with type synonyms, i.e.

type MyType = Integer -> Integer
f :: MyType
--f x = x + 1
-- error
f = \x -> x + 1
-- no error

type Identity a = a
data GADT where
x :: Integer -> Identity GADT
-- error
>>
>>57285383
>I thought the point was to make it faster.
I don't know to be honest.
I looked at Idris quite some time ago and it looked pretty rough to me.
And all the effort seemed to be going into new features and stuff, rather than having a good inliner.

Both of your Haskell examples work fine in GHC 8.
>>
>>57285486
>work fine in GHC 8

I had problems, I'll check again

Try with type families?
>>
>>57285486
aha

type Eg x = String -> String -> String -> x
data GADT3 where
C3 :: Eg GADT3
>>
>>57285510

>Try with type families?
No, just with the GADTs extensions.
And I renamed x to X because that's obviously a syntax error.
>>
>>57285553
Yeah, that fails for me too.
But I think it shouldn't.
Did you file bug for this (or looked up if it's already reported)?
>>
>>57285600
No, I haven't. I think there might be similar problems with patterns and type families.

I recall at one point wanting to write something that could generate N-parameter functions for me, like
Fun 6 Int String = Int -> Int -> Int -> Int -> Int -> Int -> String
>>
File: 3..jpg (50KB, 644x591px) Image search: [Google]
3..jpg
50KB, 644x591px
Ruby or Python?
>>
>>57286180
C
>>
>>57286276
seriously, if you want to avoid drama and CoC shit, this.
>>
File: 1452638004031.jpg (93KB, 1366x1156px) Image search: [Google]
1452638004031.jpg
93KB, 1366x1156px
>>57286293
>>57286276
Already done


I'm just doing this to then go onto more webdevvy things, it seems fun
Thread posts: 353
Thread images: 32


[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.