[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: 403
Thread images: 21

File: 1489696040481.gif (3MB, 278x296px) Image search: [Google]
1489696040481.gif
3MB, 278x296px
What are you working on, /g/?

Old thread: >>62140954
>>
making pearl relevant again.
>>
first for crystal
>>
>>62147918
>Actually Crystal is much faster than Java. It's faster than Go, and Go is faster than Java, so there you go. Granted, pictured here is only a single design problem being tackled, and the graph is being shown from a biased source (the Crystal project itself), but if you search for yourself "is go faster than java" you'll find the general consensus is that it is, and if you search for yourself "is crystal faster than go" you'll find the general consensus is that it is. (I just did this myself just now to make sure.) However, if you search "is crystal as fast as c," which it claims to be, you'll find it usually isn't, actually.
To elaborate, Crystal is as fast as C if it's written like C, but obviously not if you use any of the features that actually make it good.
>>
File: 1486854282119.png (1MB, 790x960px) Image search: [Google]
1486854282119.png
1MB, 790x960px
>>
>tfw haven't programmed in over 15 years
>tfw most complex program I made was a text-based calculator in Pascal

Which language would you recommend for someone who wants to casually write programs?
>>
>>62147960
Just pick a language suitable for your interests.
>>
>>62147953
I never understood the point of the original quote.
>The Jew is immunized against all dangers: one may call him a scoundrel, parasite, swindler, profiteer, it all runs off him like water off a raincoat. But call him a Jew and you will be astonished at how he recoils, how injured he is, how he suddenly shrinks back: “I’ve been found out.”
I am a jew. (By descent and cultural heritage, but not by faith; I'm actually an agnostic deist.)
I just called myself a jew and it sure didn't hurt. And yet, if anyone called me a scoundrel, parasite, swindler, or profiteer, I certainly would be hurt, especially because I don't actually make money, at all, doing anything.
Can someone explain this to me?
>>
>>62147949
Well, good for them then, but I still think it has more with the Java/D/C#/Go/Kotlin cluster of GC-based statically-typed OOP languages than with C/C++/Rust in terms of its niche.
>>
>>62147992
>>>/pol/
>>
>>62147992
Are you sincere?
Because there's a lot of stuff I'd regard as obvious from that original quote.
>>
File: 1486024652652.png (488KB, 1000x1050px) Image search: [Google]
1486024652652.png
488KB, 1000x1050px
>>62147992
>there're Jews who don't have to deal with the irrationality of anti-Semitism every day
Feels good.
>>
>>62147992
youre calling yourself a jew in the declarational context. The connotation is neither positive nor negative. The context of that quote is more in the connotation of being a kike. Just like how druggies get offended when you call them druggies in a negative connotation or alcoholics.

Calling a jew a jew for being a jew because he does jew shit is an insult.
>>
File: 1483543721292.png (87KB, 853x621px) Image search: [Google]
1483543721292.png
87KB, 853x621px
>>62148083
> Calling a go-fag a go-fag for being a go-fag because he does go-fag shit is an insult.
Makes sense.
>>
#ifndef _WIN32
namespace std
{
template<typename T, typename... Args>
std::unique_ptr<T> make_unique(Args&&... args)
{
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
}
#endif


I don't have access to c++14 features. Is extending namespace std like so undefined behavior?
>>
>>62147960
I was in your situation and I started with C, and then just anything you need to know for the things you want to do, specifically... (In my case, it was LUA and then C++ and I'm currently just building up more practice with those)
>>
>>62148119
std is a reserved namespace, don't do that.
>>
>>62148115
Rob "Faggot" Pike needs to divorce or stop letting his wife draw mascots for his projects.
>>
>>62148119
The standard allows extending the std namespace for stuff like std::hash specialization, otherwise it's prohibited, but I'm not sure if it's UB. Still, don't do it, just put it in your own namespace.
>>
>>62148131
>>62148153
Got it, thanks.
>>
>>62148153
what's std::hash for?
>>
>>62148180
to get an object high on hash
>>
>>62148180
It's the standard way to compute hashes for use in std::unordered_map and likes, so your types can be used as keys.
>>
>>62148119
Why do you not have access to C++14?
>>
>>62148083
Oh okay thanks. That makes more sense. It's offensive because it's in the context of the irrational worldview that all jews are money-grubbers, which is itself offensive, especially if you happen to be both a jew and a money-grubber, because in that particular case you have no grounds to raise a counterargument.
>>
File: Watermelon_Sprite.png (27KB, 163x163px) Image search: [Google]
Watermelon_Sprite.png
27KB, 163x163px
>>62147863
This thread will devolve into language v language within the first 30 posts.
>>
>>62148500
Golang a shit
>>
>>62148500
Not quite. Something even worse has happened: >>62147953 >>62147992 >>62148036 >>62148051 >>62148076 >>62148083 >>62148115 >>62148431
we're being invaded by israel
>>
you are currently experiencing the synthesis of summer and leftover us election hype
>>
>>62148516
+1
>>
Is there a way to get a maximum without branching?
>>
>>62148630

r = x ^ ((x ^ y) & -(x < y))

bitwise magic is fun
>>
>>62148662
>
(x < y)

What operation is this if not comparison?
>>
>>62148674
compare doesn't imply branch
>>
why define a type of a function in haskell if ghc can infer the minimum required type bounds for you better than you?
>>
Top tier:
ASM
C
C++
Rust

Okay tier:
D
Go
Java
C#

Slow as fuck/skid tier:
Python
JS
Ruby
Lua

Autism tier:
C
C++
Rust
Hasklel
Scala
OCaml
Erlang
FORTRAN
Clojure
Coq
Agda
etc

Emerging tier:
Elixir
Nim
Crystal
>>
>>62148685
Ah yes of course.
>>
the GOAT language: the best one for the task at hand
>>
>>62148688
Sometimes it can't and sometimes you don't need overly generic code.
>>
>>62147863
How do I write a proper makefile that compiles a lot of similar files? Like:
lvl0: ../rsc/0.lvl ../rsc/0.frames ../rsc/0s.frames
./lvlgen.py < ./rsc/0.cfg > ../rsc/0.lvl
./flgen.py < ./rsc/0.cfg > ../rsc/0.frames
./sflgen.py < ./rsc/0.cfg > ../rsc/0s.frames

and so on (50 of them).
>>
>>62148716
Anon you really can't say that.
>>
I know C#, Java, JavaScript, and PHP.
What other languages should I learn to round out my skill set? I hear a lot of good things about Pythong and Rust.
>>
>>62148724
i know being reasonable is out of favour these days but still
>>
>>62148735
Learn C and a Lisp.
>>
>>62148736
It's not reasonable to have a programmer learn a new language to niche himself perfectly for the project. Far more unreasonable than sticking to just one language.
>>
Compile time variables or runtime variables for configuring your application?
>>
>>62148721
You can use variables in Makefiles, read the documentation.
>>
>>62148764
Depends on what kind of variables they are. If they're 'constants' that are used deep within math routines then you absolutely want them to be compile time settable.
>>
>>62148735
I would suggest spending some time in Rust or LISP.

Rust will give you a whole different world of idea, and will clear up any memory related confusion you might have. It's a very good training ground.

LISP will introduce to you the power of macros. Plain and simple. Never underestimate macros.
>>
>>62148772
Yeah, I know, but do I still have to declare 50 blocks for each level target? Can I do a for loop, listing every dependency?
>>
>>62148743
Why C and not Rust?
Why Lisp? What does anyone use that for?
>>
>>62148796
>Rust
Because nobody uses it.
>Lisp
Learning FP I guess
>>
systems level programming languages:
C (only as glue between languages and to old code)
Rust

in-the-middle programming languages:
Common Lisp
C++

rapid prototyping languages:
Racket/Scheme
Python
Visual Basic botNET

network backend languages:
C++
Go
Python

web languages:
PHP
JavaScript (backend and frontend)

niches like compilers and parsers:
Haskell

embedding languages:
Lua

research languages:
Haskell
Racket
Rust

native mobile:
Swift
Objective-C
Java

don't know where you'd use them:
Ruby
C#
>>
>>62148820
>Lisp
>Learning FP I guess
kek
stop posting
>>
>>62148796
>Why C
A good reason is because most languages have some sort of foreign function interface and writing certain things in C makes them go fast.
FFI with C++ is just not sensible, not unless you're gonna actually dig into it. Doesn't sound like you are.
>>
>>62148796
Lisp is great because of the macros, otherwise it's just decent dynamically typed general purpose language.
It is also very easy to implement so lisps are generally used as embedded scripting language.
>>
People learn C because they gotta do FFI

prove me wrong
>>
>>62148891
I can't...
>>
>>62148823
>rapid prototyping languages:
>Racket/Scheme
>Python
>Visual Basic botNET
Prototyping implies it's just a quick proof of concept thing. What do you use afterwards when you want to make the final software?
>>
>>62148891
C has occupied a niche that only now is being filled by a new language (Rust)
>>
>>62148891
https://github.com/nothings/stb
Counter example.
But yes of course there's people who do learn C for that reason.
>>
File: mccarthy on lambda calculus.png (40KB, 546x317px) Image search: [Google]
mccarthy on lambda calculus.png
40KB, 546x317px
>>62148820
>Lisp
>Learning FP
Wew, lad.
>>
>>62148906
#if defined(STBI_ONLY_JPEG) || defined(STBI_ONLY_PNG) || defined(STBI_ONLY_BMP) \
|| defined(STBI_ONLY_TGA) || defined(STBI_ONLY_GIF) || defined(STBI_ONLY_PSD) \
|| defined(STBI_ONLY_HDR) || defined(STBI_ONLY_PIC) || defined(STBI_ONLY_PNM) \
|| defined(STBI_ONLY_ZLIB)
#ifndef STBI_ONLY_JPEG
#define STBI_NO_JPEG
#endif
#ifndef STBI_ONLY_PNG
#define STBI_NO_PNG
#endif
#ifndef STBI_ONLY_BMP
#define STBI_NO_BMP
#endif
#ifndef STBI_ONLY_PSD
#define STBI_NO_PSD
#endif
#ifndef STBI_ONLY_TGA
#define STBI_NO_TGA
#endif
#ifndef STBI_ONLY_GIF
#define STBI_NO_GIF
#endif
#ifndef STBI_ONLY_HDR
#define STBI_NO_HDR
#endif
#ifndef STBI_ONLY_PIC
#define STBI_NO_PIC
#endif
#ifndef STBI_ONLY_PNM
#define STBI_NO_PNM
#endif
#endif

What a joke the language is.
>>
>>62149042
>using the preprocessor
What a joke you are.
>>
If you want to write a Linux GUI application, what's your default language?
>>
>>62149042
It's actually pretty nice. Allows you so many things in the user-code.
>>
>>62149070
C++/Qt
>>
>>62149070
C#/WPF
>>
Trying to get into basic graphical stuff.
What are some good reading materials/tutorials for SDL?
>>
>>62149070
python and gtk for just linux stuff.
But if I were to write GUI application I wouldn't limit myself to just linux so I would choose something like
python / kivy
java / javafx,javafxports
scheme, lambdanative
>>
>>62149058
any alternatives to the preprocessor? do tell
>>
I don't know what to fucking make. I'm fine at work or school when assigned shit but I can't come up with any ideas for stuff to make.
>>
>>62149150
traits
>>
>>62149162
you mean unreadable metaprogramming hell?
>>
File: 1503597398469.jpg (61KB, 1000x800px) Image search: [Google]
1503597398469.jpg
61KB, 1000x800px
>just started CS
>first program teachers made us write wasn't "Hello world".
>>
>>62149208
> go to college for CS
hope you're happy, spending all your money to be taught PHP for 4 years.

show me one example of code you did in college that isn't worthless. post an excerpt.
you cant
>>
>>62149227
>PHP
more like Java
>>
>>62149227
>go to college for CS
So, you are telling me that it is better to be self-taught, when it comes to CS? What about the companies that won't even give you the time of the day without a Bachelors?
>>
>>62149227
m8 it's only the first day and I already knew C before starting CS.
Education is free here and I just want to get a degree.
>>
>>62149276
>I already knew C
pfff
>>
>>62149208
dumb frogposter
>>
>>62149276

>>first program teachers made us write wasn't "Hello world"
>> m8 it's only the first day
>which one is it anon. got any of those juicy (((college))) examples to show me or not?

>>62149272
not true. no company will ignore you if you don't have a degree. only if you fuck up the interview.
>>
>>62149227
>Implying that going to school for CS won't bring your attention to things that you never would've thought of looking at being self taught
>Implying that having a BcS wouldn't be worth it because "pfft just teach yourself anon!"

If you're self taught you're going to fly through the first year of CS. Take that time to properly network with people in your cs department. You'll get references for jobs, and learn a bunch that you didn't know. You'll get a leg up over everyone else whose having to learn it for the first time.
>>
>>62149312
#include <stdio.h>
int main( )
{
char name[20];
printf("What is your name?\n");
scanf("%s",name);
printf("Hello %s!\n", name);

return 0;
}
>>
>>62149070
For performance sensitive application I would use C++ with GTKmm.

Don't fall for the Qt memers, it may look flashy but it's really brings out the true horror of C++.

GTKmm is fundamentally more modern than Qt ever will be.
>>
>>62149319
if you're self taught and miss a lot of topics its your own fault. its stupid easy to find references; esp when most universities post most of their work online for anyone to see.

example
http://web.stanford.edu/class/archive/cs/cs110/cs110.1176/spring-2017/

Took me 10 sec to find

stupid simple to find info to learn from.
here are the steps

1. find resources from 'top tier' universities
2. look at assignments/data/presentations/tasks etc
3. learn if you dont understand something research it
4. done

too hard? if you cant do this, then no university will help you sorry
>>
>>62149347
But my name is longer than that.
>>
There must be a better way, right?
/*Write a program that asks for a user first name and last name separately.
The program must then store the users full name inside a single string and out
put it to the string.
Modify the program so that it then replaces every a, e, i , o, u w/ the letter
z.
Modify the Program so that it reverses the users name
*/
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

auto sanitize(string& name) {
for (size_t i = 0; i < name.size(); i++) {
switch (name[i]) {
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
name[i] = 'z';
case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
name[i] = 'Z';
default: {}
}
}
}

auto main(void) -> int {
string firstName, lastName;
cout << "Enter your First and Last name:\n";
cin >> firstName >> lastName;
string fullName = firstName + " " + lastName;
sanitize(fullName);
reverse(fullName.begin(), fullName.end());
cout << fullName << "\n";
return 0;
}
>>
>>62149374
Then kill yourself for being a filthy Tamil.
>>
>>62149385
rude
>>
>>62149347
> i know C
> buffer overflow
> perfect for American universities
>>
>>62149363
That's certainly true, but what about the other things that university has to offer other than just coding. You have peers that you can reference for help on certain topics, you have professors who are always there to help, and you take other classes than just coding on CS.

Another thing, at the end of the day [spoiler]no one fucking cares that you're self taught[/spoiler]
>>
>>62149407
>>62149408
>ask me what teachers made us write
>post exactly that
>lol u suck anon
>>
>>62149379
what the fuck is that?
>>
>>62149379
That's about as good as it gets, you could replace the loop in sanitize with a range-based one.
>>
>>62149440
>what the fuck is that?
learn to read
>>
>>62149379
use std::transform
>>
>>62149441
What's there to sanitize.

C++'s iterators are so traumatizing that I rather stay away from them. C++ isn't really meant for modern functional style.
>>
https://www.youtube.com/watch?v=YQs6IC-vgmo
>>
>>62149506
Traumatizing, how?
>>
>>62149407
Diferent anon.
What should i use to learn C? 1 year left before uni and slightly interested in embedded systems.
>inb4 C programming language
>like 50 bucks plus shipping to yuroop
>>
>>62149522
not an argument
>>
>>62149562
libgen.io
>>
Hi guys, I am working through K&R, and I am currently on exercise 1-21. I have a question about this part of the official answer.

#include<stdio.h>
#define TABINC 8

else
{
for( ; nt > 0 ; --nt)
putchar('\t');
if( c == '\t')
nb = 0;
else
for( ; nb > 0; --nb)
putchar(' ');

putchar(c);

if(c == '\n')
pos = 0;
else if ( c == '\t')
pos = pos + ( TABINC - (pos -1) % TABINC) - 1;
}

return 0;
}

I understand the first part, this is the part the confuses me the most. So, if anyone could explain to me what it does in detail, I would appreciate it. Especially what this part does
 
if(c == '\n')
pos = 0;
else if ( c == '\t')
pos = pos + ( TABINC - (pos -1) % TABINC) - 1;

does. I would post the full code, but for some reason, I am getting connection errors. Thanks in advance.
>>
File: 1472502436670.png (491KB, 1920x1080px) Image search: [Google]
1472502436670.png
491KB, 1920x1080px
>>62149567
Stay rectally shattered
>>
>>62149591
if c is a newline character (i.e. a line separator)
set pos to 0 (new pos because new line)
else if c is a tab character
increase pos to the next tab location (using modulo because it goes up in the tab increment, i.e. a tab = 8 spaces)
>>
File: weedmang.jpg (9KB, 318x159px) Image search: [Google]
weedmang.jpg
9KB, 318x159px
where my high level programming bros at?
>>
How the fuck does anyone into contributing to open source?
>>
>>62149379
Hmm, this doesn't seem to work actually.
Fucking C++
>>
>>62149670
Look for the ``contribution guide`` in the project mainpage
>>
>>62149686
And strictly following the code of conduct.
>>
>>62149699
Yes, you have to remember not to shitpost like a mindless 12 y/o outside 4ch*n
>>
>>62149686
How does one find a suitable project to begin with? Lots of these have huge codebases, or they're super small and specialized
>>
>>62149724
>How does one find a suitable project to begin with?
The one thing you would like to be fixed.
>>
>>62149379
Amazingly, the identical program would work in D
>>
>>62149750
No it wouldn't.
>>
>>62149667
Here. Professional OCaml developer.
>>
File: 1474761315398.jpg (31KB, 400x400px) Image search: [Google]
1474761315398.jpg
31KB, 400x400px
>>62149835
>>
>>62149835
lol, enjoy your GIL
>>
>>62149675

std::array<unsigned char, 5> chars { 'a', 'e', 'i', 'o', 'u' };

unsigned char f(unsigned char c)
{
if(std::isupper(c))
{
unsigned char t = std::tolower(c);
if(std::find(chars.begin(), chars.end(), t) != chars.end())
return 'Z';
}
else
{
if(std::find(chars.begin(), chars.end(), c) != chars.end())
return 'z';
}
return c;
}

int main(int argc, char** argv)
{
std::string first, last;
std::cout << "Enter your First and Last name:\n";
std::cin >> first >> last;
std::string full = first + " " + last;
std::transform(full.begin(), full.end(), full.begin(), f);
std::reverse(full.begin(), full.end());
std::cout << full << "\n";
return 0;
}

Here you go autist, you can make it more efficient, but thats irrelevant,
>>
>>62149851
>>62149870
I seriously don't give a fuck. And Jane Stteet make millions with multi ocanl processes.
>>
>>62149883
Stop trying to be functional, C++ will never be half decent as D, Rust or Nim
>>
>>62149883
kek
>>
Seriously thinking of quitting with C and just using java because compiling and deploying is easier. Just compile the .class files and you are done, if you want to be fancy you make a .jar out of them.
Fuck compiling native libraries.
>>
>>62149631
Thanks for the reply. So, let me get this straight:
The first part of the code is required only to get all the spaces printed out, and the character (putchar(c)) typed? And the second part is to determine what position # we will end up?

Also, can you please elaborate on the "increase pos to the next tab location (using modulo because it goes up in the tab increment, i.e. a tab = 8 spaces)" part. I remember that we used this
 nb = TABINC - (pos -1) % TABINC 
on the previous exercise to determine the number of blanks required to get to the next tab stop. However, does that mean that, for example, if we are currently on position 7, after this calculation
pos = pos + ( TABINC - (pos -1) % TABINC) - 1;

we will end up on position 8?

Thank you for taking your time to answer my retarded questions.
>>
I still don't understand why str[i] should be equal to both A and a ?!
>>
>>62149913
none of those languages are functional, neither is C++
>>
>>62149954
none of those languages are functional
They are way more ``functional`` than C++.
>>
>>62149934
Try Nim
>>
>>62149950
who are you replying to
>>
>>62149967
they are more obscured than C++.
that doesn't make them functional at all.
lisp = functional
Rust/Nim/[anything else] = not functional
>>
>>62149938
Presumably, I haven't done the exercise, most of this I can determine from the fact it's checking if they're "\n" or "\t" and adjusting a variable named pos
So it has something to do with the sort of x position of the cursor, if you want to think of it that way.
>>
>>62149984
> lisp = functional
> Rust = not functional
How can a person be so wrong? Rust is basically Haskell without GC, and Lisp is Python with weird syntax.
>>
>>62149984
>lisp = functional
Stop posting
>>
>>62149984
>Nim not functional
>Rust is not functional
>LISP is functional 0/3
>>
>>62150022
>Rust is basically Haskell without GC
>still no HKTs
>>
>>62150046
And no GC
>>
>>62150046
>every language that has HKT is now Haskell
Peak /g/
>>
>>62150046
They're working on it. ML is functional but it doesn't have HKT either.
>>62150060
GC is orthogonal to being functional.
>>
>>62150088
Too bad having no GC is more desirable than HKTs
>>
>>62150075
Who are you quoting though
>>
>>62149992
Thanks for the answer answer. It is a bit clearer for me now.
>>
>>62150116
ur mum
>>
>>62150107
If someone wants HKT and doesn't mind GC he would just use Haskell. The point of Rust is being as functional as possible without compromising on performance.
>>
>>62150116
Are you that gatekeeper?
Did they let you go?
>>
>>62149117
WPF doesn't run on Linux, does it?
>>
>>62150043
Lisp is the actual definition of a functional language. Rust is an abomination which shouldn't exist.

>>62150022
Neither of those statements are true.
>>
>>62150163
it doesn't, he was talking out of his ass. Like this one here: >>62150166
>>
>>62150186
Show me one example where either of those languages display functional programming properties.
Tip: you can't because theyre not
>>
>>62150166
> Lisp is the actual definition of a functional language.
See >>62148926
>>
>>62150231
https://pastebin.com/Q80H5f8y
>>
>>62150242
so? what does that have to do with rust
>>
>open thread
>rust is now an fp language
inane
>>
def f(cond):
while(True):
if(cond):
g()
else:
h()

f(True)


Is there a language that will identify at run-time that h() will never be executed and therefore will remove the branch from the loop above?
>>
>>62150262
You can stop shaming yourself any further.
>>
>>62150276
There are people that are calling CL a functional language
>>
>>62150280
rust != lisp

prove rust is functional or BTFO
>>
>>62150278
yes C++ or C
>>
>>62150262
Nothing? It's about Lisp not being a functional language. Ironically, the creators of Rust knew more about Lambda Calculus and were more influenced by it, than McCarthy.
>>
>>62150291
>rust != lisp
Who knew.

>BTFO
Lurk more or fuck off back to 9gag

>rust is functional
It's not purely functional but read http://science.raphael.poss.name/rust-for-functional-programmers.html
and
http://blog.madhukaraphatak.com/functional-programming-in-rust-part-1/
>>
>>62150289
Can CL into referential transparency?
>>
>>62150259
again this doesnt prove that rust is functional you moron.

by your definition C is functional since

compile Rust -> assembly -> insert into C with asm -> compile -> run
>>
>>62150327
https://mmstick.gitbooks.io/rust-programming-phoronix-reader-how-to/content/chapter02.html

>moron
Rich coming from a kid calling LISP functional
>>
>>62150326
>referential transparency is the defining feature of a functional language
>meanwhile pure FP is a minority of FP
>>
>>62150342

ok.
so C is functional too?
since compile Rust -> assembly -> insert into C with asm -> compile -> run?
right?
>>
>>62150302
>at run-time
I'm thinking about something like interpreted language that does static code analysis at some sections of the code before choosing what to execute.
>>
>>62150342
>https://mmstick.gitbooks.io/rust-programming-phoronix-reader-how-to/content/chapter02.html

every single one of those is doable in C++/C#
are they functional?

face it Rust isnt functional and you have to back paddle to save your life.
>>
>>62150356
C is not lazy, Rust is. Plain and simple
>>
>>62150377
see >>62150319
>>
>>62150347
???
I consider a language functional if it is centered around referential transparency.
>>
>>62150366
probably python or a jvm language if you want it done at runtime. test and see

you can try with scala(a functional language unlike rust)
>>
>>62150393
That's absurd
>>
>>62150377
C++ doesn't have lazy collector, stupid fucking twat
>>
>>62150410
And neither has C#

I use C++ myself, that guy doesn't know what he's on about
>>
>>62150407
And why is that? There's no clear definition for functional programming languages.
>>
>>62150393
So C++ or java?
according to /g/ every language is functional.
>>62150390
again rust isn't functional no matter how hard you try to make it functional. you still havent posted a single concrete code snippet where you demonstrate func. prog. in Rust which isn't doable in Java/C++/C# etc.
>>
>>62150430
Functional programming languages are based on the use and manipulation of functions, beyond the concept of a simple procedure call like you'd see in C
The best example is the lambda calculus.

What people call lambdas today (anonymous functions) are a functional feature. They are primarily used with higher order functions, or in a way that blurs the line between a function and a "regular value".
>>
>>62150446
>So C++ or java?
C++ and Java don't have immutable data structures, so they're not functional.
>>
>>62150446
>again rust isn't functional no matter how hard you try to make it functional. you still havent posted a single concrete code snippet where you demonstrate func. prog. in Rust

You are deliberately trying to deflect any actual, well documented articles that voids your claim, aren't you
>>
>>62150410
it absolutely does, stupid fucking twat
requires you to manually make it though.
>>
>>62150476
>requires you to manually make it though.
Yea by that logic Rust has HKTs too
>>
>>62150467
https://github.com/arximboldi/immer

what about this
>>
>>62150446
Java/C++/C# doesn't have pattern-matching
>>
>>62150494
https://en.wikipedia.org/wiki/Boehm_garbage_collector
OMG C is now a garbage collected language!!!11!
>>
>>62150494
Immutable data structures should be the core of the language, not some library.
>>
>>62150502
It it rather a feature of a language with a decent type system, rather than a functional one
>>
>>62150473
no i'm not.

i read every single thing posted, my rebuttal is you can do all of those things in C++/Java. by your definition they are functional too, yet they aren't.

Face it Rust isn't Haskell/Lisp/Scala/etc.
>>
reminder that lisp is a punctional frogramming language
>>
>>62150467
>>62150527
>C++ and Java don't have immutable data structures
"I don't understand the concept of const/final keyword" - The post.
>>
>>62150531
>It it rather a feature
FP paradigm is a feature itself
>>
>>62150527

the C++ STL is a library too. Rust has its standard library.
what is part of the core language is more or less irrelevant.
>>
>>62150538
>my rebuttal is you can do all of those things in C++/Java
Which one of those have pattern matching, lazy evaluation and lazy collectors?
>>
>>62150567
by default, or by extending them with libraries?
by default: none
with libraries: all - lazy eval is a bit tricky to do fully in C++ though.
>>
>>62150551
const/final doesn't make the data structure immutable. It prohibits you from reassigning the variable.
>>
>>62150551
these people think Rust is functional and Lisp isn't.
they probably haven't used C apart from basic functions.
>>
>>62150538
>i read every single thing posted,
You didn't, the two article I posted is pretty big and a brainlet like you can't finish reading them under 15 minutes
>>
>>62150591
>with libraries:
With libraries, C++ is a garbage collected language
>>
>>62150608
No one ITT uses C
>>
>>62150601
is there a difference?
what does immutable mean to you?
>constexpr const int variable = 5;
^ is that immutable?
>>
>>62150561
>what is part of the core language is more or less irrelevant.
I disagree, a functional programming language should come with functional constructs out of the box.
 #include <scheme.h>
Doesn't make C++ a Lisp, does it?
>>
>>62150637
Speak for yourself
>>
File: 1499952468689.png (228KB, 3316x1896px) Image search: [Google]
1499952468689.png
228KB, 3316x1896px
>>62150446
/g/'s favourite program
fn main() {
for x in 1..100 {
match (x % 3, x % 5) {
(0, 0) => println!("FizzBuzz"),
(0, _) => println!("Fizz"),
(_, 0) => println!("Buzz"),
_ => println!("{}", x)
}
}
}
>>
>>62150601
>const/final doesn't make the data structure immutable. It prohibits you from reassigning the variable.

Uhm, what the hell?

>an immutable object is an object whose state cannot be modified after it is created

You cannot change a const/final object after it's declaration (aka creation).
>>
>>62150652
#include <scheme.h>

Makes sepples LITERALLY LISP!
You heard it here first folks!
>>
>>62150659
No really, no one here really uses C. If they were thou would fix the file picker meme a long time ago
>>
>>62150609
i read every single word.
they basically talk about how you can force Rust into being a functional language. abuse of features doesn't make something functional.
Lisp/Haskell are functional in 2 lines of code. Rust isn't.

https://mmstick.gitbooks.io/rust-programming-phoronix-reader-how-to/content/chapter02.html

every single one of those things is doable in C++ line by line. doesn't make C++ functional.
>>
>>62150646
final List<Item> items = new ArrayList<>();
items.clear(); // mutates the list, so it's not referentially transparent

const/final tells if you can reassign the VARIABLE, but the VALUE can still be modified. Obviously, primitives are an exception.
>>
>>62150682
see
>>62150693
>>
>no, no, no, I mean the """"core"""" language, not using the standard library

The standard library is part of the language. If you make arbitrary distinctions like that, you should at least be honest: basic arithmetic operators in Haskell are defined in the standard library, and not as part of the core language.
>>
>>62150669
/g/ experts tell me
is this functional?
because it's doable line by line in C++.
>>
>>62150689
>https://mmstick.gitbooks.io/rust-programming-phoronix-reader-how-to/content/chapter02.html
Read http://science.raphael.poss.name/rust-for-functional-programmers.html
Dumb fucking brainlet
>>
>>62150669
dumb frogposter
>>
>>62150715
It's called matching patterns, something C++ can't do.

Obviously your single digit IQ will differ
>>
>>62150715
C++ has matches? Really?
Show me please.

And consider suicide of you think switch statement is matching
>>
>>62150430
>>62150459
Oh, and most would say that referential transparency makes for better FP, but I think the people who say referential transparency is part of FP are wrong.

You could, I suppose, say that many PLT ideas have been classed as "FP", due to the flirtation between lambda calculus and type theory, so you might put purity under that.
>>
>>62150693
>>62150710
I'm not well-versed in Java, but in C++ this gives a compilation error.

#include <list>

int main()
{
const std::list<int> list = {1, 2, 3};
list.clear();
}


const.cpp: In function ‘int main()’:
const.cpp:6:16: error: passing ‘const std::__cxx11::list<int>’ as ‘this’ argument discards qualifiers [-fpermissive]
list.clear();
^
In file included from /usr/include/c++/5/list:63:0,
from const.cpp:1:
/usr/include/c++/5/bits/stl_list.h:1366:7: note: in call to ‘void std::__cxx11::list<_Tp, _Alloc>::clear() [with _Tp = int; _Alloc = std::allocator<int>]’
clear() _GLIBCXX_NOEXCEPT
^

>>
>>62150715
Are you actually false-flagging C++ users? If so, it's working
>>
>>62150710
>I don't understand what a reference type is
>>
>>62150739
Bump. I am new to C++. Does it really have matches? I'm genuinely interested
>>
>>62150711
this.
according to their definitions C++ is also functional.
>>62150693
final != const

const List<Item> items = new ArrayList<>();
items.clear();
is invalid and wont compile.
>>
>>62150787
>C++ is also functional.
C++ doesn't even evaluate lazily
>>
>>62150752
I'm no C/C++ master, but I guess you're right.
int main(int argc, char *argv[])
{
int foo[] = {1,2,3};
foo[0] = 5;
return 1;
}

gives me this (gcc)
foo.c: In function ‘main’:
foo.c:4:9: error: assignment of read-only location ‘foo[0]’
foo[0] = 5;
^

I wouldn't say that it makes C/C++ functional, but at least it supports immutable data structures.
>>62150787
>const List<Item> items = new ArrayList<>();
There's no `const` keyword in Java. What the fuck are you talking about?
>>
>>62150752
this.
>>62150774
C++ has pattern matching by definition. it's part of the STL see <algorithm>
>>62150739
what do you think match() is doing under the hood?
>>
>>62150823
>what do you think match() is doing under the hood?
1s and 0s. Why should I care?
>>
>>62150823
>it's part of the STL see <algorithm>
Can you link me to there? The cppreference doesn't mention any such language construct.
>>
>>62150813
that code is valid C++ with typedefs and aliasing.
how long have you been using C++?
>>
>>62150835
https://github.com/solodon4/Mach7
>>
>>62150860
What is that link supposed to establish? People are trying to bake pattern matching into C++ because it doesn't have one?
>>
>>62150856
>that code is valid C++ with typedefs and aliasing.
Not an argument. That code is valid Haskell with aliasing.
>>
>>62150850
This is for type-matching, similar (but more elegant) than C11's _Generic

http://en.cppreference.com/w/cpp/utility/variant/visit
>>
>>62150877
That match has a performance overhead, even though it's "1s and 0s" under the hood, and why you definitively should care.
>>
>>62150877
it literally proves C++ has pattern matching. what it has by default is irrelevant. rust can't pattern match without std either FYI..
>>62150850
find, mismatch any_of, search, includes, for_each etc.
>>
>>62150897
I don't think you understand the idea of pattern-matching at all, anon. You should stop spreading FUD
>>
>>62150882
List is std::list
ArrayList is class custom_class : public std::list{};

how isn't it valid C++?
>>
>>62150918
>rust can't pattern match without std either FYI.
Elaborate. match (a,b,c) {} construct is built right into the core
>it literally proves C++ has pattern matching
No it doesn't. C++ is not a garbage collected language
>>
>>62150918
>find, mismatch any_of, search, includes, for_each etc.
Why did you reply to me?
>>
>>62150958
You implemented your own class. We were talking about the standard library and the core.
>>
>>62150366
c and c++ will both remove the branch at compile time
if you trick the compiler into keeping the branch, and you put the branch in a loop so that it is called many times, it will be optimized to always go down the correct path during run time (branch prediction)
>>
>>62150938
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3449.pdf
>>
>>62151003
>The library is available at http://parasol.tamu.edu/mach7/
Why do you keep posting that 3rd party library? If C/C++ has a garbage collector in a 3rd party library does that make the languages garbage collected?
>>
>>62151034
>Why do you keep posting that 3rd party library?
>that third party library
I'm making a case that type matching is pattern matching, and that you can implement this with C++17 visitor pattern (which is part of the standard library).

Kill yourself.
>>
>>62147863
Where can I learn C# online? Or any good books?
>>
>>62150938
Visitors and pattern matching are functionally the same; pattern matching is just more convenient.
This screenshot is from the paper "Colored Local Type Inference"; match is just a method which is passed a record (a visitor) with two fields, caseNil and caseCons
>>
>>62151062
I'm a Java dev, but I've heard good stories about The Yellow Book.
>>
>>62151061
You can make a GC in C, C++ or in ASM as well, so are those languages garbage collected?
>>
>>62151068
>Visitors and pattern matching are functionally the same; pattern matching is just more convenient.
So is if statement. What point are you trying to make here?
>>
>>62151082
C++ is actually garbage collected
>>
>>62151100
If done correctly, visitors can be a suitable replacement for pattern matching without introducing new syntax. Basically the entire point of C++ is implementing everything in the language itself, except for the language itself. It's like a really shitty Lisp
>>
>>62151082
>being this intellectually dishonest

Look, you fucking nigger. This poster (>>62150850) asked to be linked to where in the standard library matching exists. I linked him the visitor pattern. You came along and claimed that it isn't pattern matching, I posted a paper proving that it actually is (and so did this guy: >>62151068), and now you're rambling on about third-party GC implementations.

Just fuck off with your weasel tactics and kill yourself.
>>
void function (void) {}

why is this still a thing? Shouldn't the second void statement be assumed? Why doesn't C just switch it so () is (void) and the other case (identifier list) requires something in the brackets? Seems inefficient to always write out the more popular usage.
>>
File: 1502326352003.jpg (39KB, 638x638px) Image search: [Google]
1502326352003.jpg
39KB, 638x638px
>>62150669
>functional programming
>loops
>>
>>62150739
#include <algorithm>
#include <vector>
#include <iostream>
int main()
{
std::vector<int> v(100);
int n = 0;
std::generate(v.begin(), v.end(), [&n]{ return n++; });

for (auto x : v)
{
bool a = (x % 3 == 0);
bool b = (x % 5 == 0);
if(a && b) std::cout << "FizzBuzz" << std::endl;
if(a && !b) std::cout << "Fizz" << std::endl;
if(!a && b) std::cout << "Buzz" << std::endl;
}
return 0;
}

line by line
>>
>>62151137
>Shouldn't the second void statement be assumed?
No.
void legal()
{
}

void illegal(void)
{
}

int main()
{
legal(2, 3, 'c'); // produces a compiler warning
illegal(2, 3, 'c'); // compiler or linker error
}
>>
>>62151137
Switch to C++.
>>
>>62151133
You are getting upset. I think you are starting to realize the fault of your ``argument``. Now let's go over the rest of the rumbling you just made:

>asked to be linked to where in the standard library matching exists. I linked him the visitor pattern. You came along and claimed that it isn't pattern matching, I posted a paper proving that it actually is
Actually, none of them are pattern matching. You are trying hard to make a point, it's similar to claiming C has a garbage collector because:
1. It can be implemented
2. Other peple have done it (see a 3rd library X)
>>
anyone do any pen testing/bug bounty/vulnerability searching type stuff ? I want to get into it if the pay is ok but it seems like it would be a lot more work and pays a lot less then if you are just working on some software projects instead ? confirm/deny ?

i have a degree in CS and conformable learning just about anything.
>>
>>62151166
You can do that without loop too. Rust isn't purely functional, you see.
>>
>>62151172
>bool a = (x % 3 == 0);
> bool b = (x % 5 == 0);
> if(a && b) std::cout << "FizzBuzz" << std::endl;
> if(a && !b) std::cout << "Fizz" << std::endl;
> if(!a && b) std::cout << "Buzz" << std::endl;
aww you are so cute
now go match this:
(0, _, 0,0,_,_,_)
>>
>>62151133
don't bother these morons don't understand shit about functional languages. They hate on C because they don't understand what const even means. nor do they understand the concept on libraries.

>>62151129
on par with lisp.

lisp is an actual functional language, C++ is low level imperative. effectively the only languages you need to know.

>>62151034
actually it means you can make it garbage collected. just like how you can make C++ 'look' function when it isn't
>>
>>62151201
>Actually, none of them are pattern matching
I'll take the word of an academic paper (>>62151003) over you any day, so fuck off. Just face it, you lost. You making a big fucking fuzz about it is not helping your case, and honestly it's making you come off as ignorant and stupid.
>>
>>62151243
>lisp is an actual functional language
These people browse /g/
>>
>>62151243
If only C++ had legitimate metaprogramming instead of being a tower of hacks.
>>
>>62151243
>LISP
>Functional
What's this new meme?
>>
>>62151257
The academic paper is not about pattern matching.

I'm am noticing you are increasingly getting angry. Is that coming from the frustration of losing an argument?
Thought so.
>>
>>62151201
pattern matching is comparing memory at different addresses you fucking ape. the language syntactic sugar is irrelevant.
>>62151232
if(!a && b && !c && !d && e &&f && g && h);
also it's more efficient than your 'functional' language.
at the end of the day the only people who need functional languages are those who can't break down programs properly into the way machines think and they still depend on human languages.
>>
>>62151243
Lisp is not functional. Stop talking about things you CLEARLY don't know about
>>
>>62151286
>if(!a && b && !c && !d && e &&f && g && h);
oops you for got to make d, f, g,h

I wonder how many more functions are you going to make inside that loop
SAD
>>
>>62151286
Anything, ANYTHING you do is comparing/manipulating memory. If the sugar didn't matter everyone would be using ASM right now
>>
File: Screenshot_2017-08-29_20-40-19.png (62KB, 360x347px) Image search: [Google]
Screenshot_2017-08-29_20-40-19.png
62KB, 360x347px
>>62151280
>The academic paper is not about pattern matching.
Except it's literally just that, and Bjarne Stroustrup is a co-author.

I just linked the fucking paper, everyone can read it.
>>
>>62151262
yes, ones who haven't touch C, and think Rust is functional.
>>62151271
it's by definition more functional than any other languages
>>62151280
it is about pattern matching. read it. pattern matching in C++ is referred by different terms.
>>
>>62151206
the pay can be good
but the entire industry is sketchy as fuck
and your clients are always unsatisfied with your performance
>he didn't find any problems?
>how can I know this guy did anything at all?
unless you find a huge exploit
in which case your clients are about to be even more upset because you're gonna tell them that they've leaked all of their customers financial details
>>
>>62151286
>if(!a && b && !c && !d && e &&f && g && h);
cute. Now match
(0,_,0,_,_,0,_,_,0,_,_,0,_,_,0,_,_,0,_,_,0,_,_,0,_,0,_,_,0,_,_,0,_,0,_,_,0,_,_,0,_,0,_,_,0,_,_,0,_,0,_,_,0,_,_,0,_,0,_,_,0,_,_,0,_,)
:^^)
>>
>>62151166
Here, I gave it a shot.
fn main() {
let mut text = String::new();
text.extend(
(1..101)
.map(|n| match (n % 3, n % 5) {
(0, 0) => format!("fizzbuzz\n"),
(0, _) => format!("fizz\n"),
(_, 0) => format!("buzz\n"),
(_, _) => format!("{}\n", n),
}));
print!("{}", text);
}
>>
>>62151316
>ones who haven't touch C
C is literally CS101, even pajeets use C
>>
>>62151315
Dude, don't bother. You're obviously arguing with a retard.
>>
>>62151334
>let mut text = String::new();
I'm a special snowflake: the language.
>>
>>62151308
that code wasn't in reference to my previous post you moron.
/pol/ is that way.

>>62151291
it is
proof (more functional than Rust or Python)
(defun is-mult-p (n multiple)
(= (rem n multiple) 0))

(defun fizzbuzz (&optional n)
(let ((n (or n 1)))
(if (> n 100)
nil
(progn
(let ((mult-3 (is-mult-p n 3))
(mult-5 (is-mult-p n 5)))
(if mult-3
(princ "Fizz"))
(if mult-5
(princ "Buzz"))
(if (not (or mult-3 mult-5))
(princ n))
(princ #\linefeed)
(fizzbuzz (+ n 1)))))))
>>
>>62151315
>>62151316
Why are you two brainlets still doing that mental gymnastics? Just give up: C++ does NOT have pattern matching.
>>
>>62151318
I am not talking about being a salaried worker. I am talking about the programs where you get paid only if you find something.
>>
Functional is a "style", not an absolute. Purely functional is not the only functional.
>>
>>62151364
Lisp is not functional.
https://letoverlambda.com/index.cl/guest/chap5.html
>>
>>62151173
I get that it works that way now, but why not change it? The void legal() gets used how often vs the more standard void legal (void)? It seems stupid to type out the extra void when it could just be switched around so you type out something for the other case instead.

>>62151185
I am actually doing C++, but the reference I'm reading through also deals with a lot of C. I get that C++ doesn't require the extra void, but it still seems like a good idea to write C++ code so it would still work in C as much as possible (for the parts that do translate to directly to C anyways) so it would be easier to switch between them.
>>
>>62151364
>proof (more functional than Rust or Python)
Calling functions is not functional programming, brainlet
>>
File: dmr-jmc.jpg (52KB, 595x335px) Image search: [Google]
dmr-jmc.jpg
52KB, 595x335px
>>62151291
>>62151262
>>62151271
>Lisp is not functional
mfw
>>
Dear lispers, brace yourselfs, stinging damnation is coming forthwith!

the more i learn about Common Lisp, the more i think it's one fckedup soup. (setf, rotatef, are recent examples)

also, the more i code in lisp (elisp), the more i find it non-functional. Only the outer program skeleton can be comfortably functional. Innards of functions usually cannot be.

lots, lots, of mutations built-in in the lang in a way that forces you to be non-functional. Quick 1 minute typing:

• destructive sort.

• setq setq setq.

• tons of global vars, not just for emacs environment such as buffer, mode states, etc, which are arguably necessary. But, for things like “match-string”.

• lisp's list, of cons, is one DAMNATION. Along with it comes rampant use of pop, push. Any non-trivial coding in lisp is fcking like perl now, except that dealing with list and nested list in perl is actually much more easier than in lisp.

there's a good solution to lisp's non-functional ways.

BAN lispers from using list or cons. Everything should be vector/array instead.

everytime a cons is involved, lispers should get a electric shock.

that will immediately fix majority of lisp's non-functional programing in practice.

though, i'll have to say, the more i read about Clojure, the better it seems. It is very functional, the savior of the lisp name.
>>
>>62151397
It isn't. You are confusing macros with functions, like a typical retard of /g/
>>
>>62151395
>I get that it works that way now, but why not change it?
Because that would break the way stdarg works and would be an issue with casting function pointers.

>The void legal() gets used how often vs the more standard void legal (void)? It seems stupid to type out the extra void when it could just be switched around so you type out something for the other case instead.
Well, the Linux kernel for example is pretty consistent on always adding the void.
>>
If your language doesn't support outputting native code for ARM, MIPS, and PowerPC, then it is deficient.
>>
>>62151404
Lisps are dead anyway, move on.
>>
who cares
>>
>>62151429
ME
>>
>>62147928
Nice
>>
>>62151404
What about Scheme?
>>
>>62151373
Fuck off retard.
>>
>>62151334
still uses a loop through Rusts stdlib. nogo.
>>62151327
fold expressions can do it for an inf. number of args too lazy to type it out now
>>
>>62151397
lurk more, newfag
http://wiki.c2.com/?WhyWeHateLisp
>>
>>62151448
That's not a loop
>>
>>62151449
lurk even more, newestfag

http://wiki.c2.com/?WhyWeLoveLisp
>>
>>62151397
See >>62148926
>>
>>62151427
>powerpc
>>
>>62151455
Still says LISP is not functional
>>
>>62151455
Why did you post that in response?
>>
>>62151396
and what are you doing in Rust you fucking ape?

>>62151387
it is. Rust isn't functional.

>>62151373
it does. the paper proves it. it's possible to do it. where's your rebuttal?
>>
>>62151423
So it's basically about keeping things the same so as to not mess with code already written and implemented?

Also, why so many special snowflake languages? Wouldn't programming be 100% simpler on everyone if there were fewer languages?
>>
>>62151471
You'd have to be a Haskell programmer on anabole steroids to think that Scheme isn't functional.
>>
(define (multiple-of? k n)
(zero? (remainder k n)))

(define-syntax-rule (define-fizzbuzz name ([mod str] ...))
(define (name n)
(for ([i (in-range 1 (add1 n))])
(displayln
(cond
[(and (multiple-of? i mod) ...) (string-append str ...)]
[(multiple-of? i mod) str] ...
[else i])))))

(define-fizzbuzz standard-fizzbuzz
([3 "fizz"]
[5 "buzz"]))

(standard-fizzbuzz 100)


>>62151448
>still uses a loop
tail calls are implemented using loops
check mate
>>
>ITT: autists who took CS 201 argue about inane shit no one cares about so they could avoid the fact that they don't actually program anything
>>
>>62151454
it indirectly is a loop. regardless every loop can be unrolled so your argument is pointless.
>>
>>62150711
>basic arithmetic operators in Haskell are defined in the standard library, and not as part of the core language.
Wait, is this true?
>>
>>62151489
>it is. Rust isn't functional.
Now that my dear, is a weak denial. Do you happen to be weak? I think so, because
1. You didn't read the article because it continually shatters your rectum
2. You are too afraid to admit to your juvenile stupidity

Good luck out there, you will face even harder public embarrassment
>>
>>62151462
Problem?

https://forge.rust-lang.org/platform-support.html

If Rust can support all these platforms then your language should have no problem doing the same
>>
>>62151497
because programmers cannot program properly that's why. they don't understand computers or computing theory. every single language invented since 2010 is proof of this.
Look at javascript. Look at Rust. Look at Swift. Look at F#. unnecessary
>>
>>62151489
>and what are you doing in Rust you fucking ape?
Functional programming
>>
>>62151508
Indirectly it's just 1's and 0's
There is no paradigm XD
>>
>>62151522
yes
>>62151528
i did read it. If Rust is functional then C++ is also functional. There isn't a single piece of code you can do in Rust that you can't in C++. This is fact. You just proved my argument.
>>
>>62151497
You might think, but the case is that there are many languages right now, so we might as well try to come to terms with that and try to make it easier for them to interop instead of just whining about there being too many.
Domain specific languages can be very useful, but I don't think it's an adequate explanation of the number of languages today, since they all seem to be "multi paradigm general purpose languages", hence all solving the exact same problem.
>>
>>62151548
you're calling functions. look at the assembly. >>62151556
you just proved my point.
saying im going to call map(...) isn't func
>>
>>62151522
the compilers will have a builtin primitive int-addition, double-addition etc

but the Num typeclass (like an interface providing +, -, *, etc) is part of the standard library, implemented for primitive types using that
>>
"Functional" is not black and white. You all need to put your fucking ideologies aside for a damn moment and look at yourself
>>
>>62151583
>i did read it.
NO you didn't. If you read before you would not dare say LISP is functional. And if you are going to say you just read it, it's nearly impossible to read a 10 page long article within 4-5 minutes.
>>
>>62151597
Fuck off centrist cunt.
I absolutely hate people like you.
>it's not white and black
>therefore it is all the same and not meaningful to talk about
>>
>>62151590
>look at the assembly
Why?
I'm not writing assembly, I am writing higher level language constructs. Why are you demonstrating your autism?
>>
>>62151600
found the slow reader
>>
>>62151583
>If Rust is functional then C++ is also functional
Yes?
>>
>>62151583
>There isn't a single piece of code you can do in Rust that you can't in C++.
You are proven wrong already.
Also, can C++ lazily collect into a vector?
fn main() {
let mut teams = [
[ ("Jack", 20), ("Jane", 23), ("Jill", 18), ("John", 19), ],
[ ("Bill", 17), ("Brenda", 16), ("Brad", 18), ("Barbara", 17), ]
];

let teams_in_score_order = teams
.iter_mut()
.map(|team| {
team.sort_by(|&a, &b| a.1.cmp(&b.1).reverse());
team
})
.collect::<Vec<_>>();

println!("Teams: {:?}", teams_in_score_order);
}
>>
>>62151615
I already explained. Functional is a STYLE, not a black&white property of a language. You can program functionally. You can program some modules functionally but others imperatively. You can use a language that encourages functional programming. You can program functionally in a language that doesn't encourage functional programming. It's still meaningful. If anything, reducing it to "if it isn't haskell/agda, it's NOT FUNCTIONAL" makes the term much less useful than allowing it to be more subjective.
>>
>>62151648
Rust is really neat, but that syntax is more cryptic than C++ template metaprogramming from the seventh circle of hell.
>>
>>62151648
Based Rust
>>
>>62151616
C is assembly. by definition. C++ is a compilers viewpoint of C. it allows higher level constructs of C.

you can pattern match in C++ without directly using loops.
proof

https://github.com/solodon4/Mach7
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3449.pdf

Therefore according to your logic, C++ is functional?
>>
>>62151658
>I already told you what to think
>Everything is the same
>Do not even consider that maybe functional might change the language
>Everything is the same
>>
>>62151672
That's not cryptic at all, any FP fag would easily pick it up
>>
>>62151658
>"if it isn't haskell/agda, it's NOT FUNCTIONAL" makes the term much less useful than allowing it to be more subjective.
That's the point, though. To reduce pure functional programming to a useless joke, so we can finally end the "object-oriented programming is shit" meme once and for all.
>>
>>62151648
Yes you could design a C++ API that allows you to do this. I wouldn't be surprised if it exists, given the large quantity of C++ libraries.

>>62151690
What?
You don't have to agree with me, but I laid out why my reasoning is more useful than yours. So I hope you'll at least listen
>>
>>62151648
first off, that syntax proves Rust is horribly designed.
second, YES it can..
https://github.com/arximboldi/immer
use that library in conjunction with
https://github.com/solodon4/Mach7

and you can achieve the same thing
>>
>>62151685
>C is assembly. by definition.
No, it's an abstraction over assembly.

>you can pattern match in C++ without directly using loops.
proof

>https://github.com/solodon4/Mach7
>http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3449.pdf

>Therefore according to your logic, C++ is functional?

No. Again, you can implement Garbage collector in C. Does that mean C is garbage collected? Because that's how stupid you sound
>>
>>62151692
I don't know what |stuff| does, I guess & is a reference operator, why is there a ! after println, what is the _ operator?
>>
>>62151722
https://github.com/solodon4/Mach7

no direct usage of loops. same as rust.
>>
>>62151721
So you have to implement such trivial things before doing those? Might as well not using C++ then
>>
>>62151716
You had no intent to participate in discussion, you were only here to shut discussion down
>>
>>62151750
>no direct usage of loops. same as rust.
ANSWER MY QUESTION
you can implement Garbage collector in C. Does that mean C is garbage collected?
>>
>>62151729
because Rust is a garbage language designed by morons that's why the ! is there.
>>62151716
https://github.com/arximboldi/immer
https://github.com/solodon4/Mach7

there's a perfectly valid C++ API that does just that.
>>
>>62151648
> |&a, &b| a.1.cmp(&b.1).reverse()
|&(a, _), &(b, _)| a.cmp(&b).reverse()

is cleaner IMO.
>>
>>62151716
>Yes you could design a C++ API that allows you to do this.
Ironically C++ fags mock Cniles for implementing everything before being able to work.

Evolution.
>>
>>62151729
|x| e is lambda syntax (λx.e)
& is reference operator, and can also be used to sorta derefence if you're using it in pattern matching
let x = 3;
match &x {
&y => println!("{}", y), // prints 3
}


! means that it's a macro call, not a function call.

_ is a pattern that discards the value.
match ("foo", "bar") {
(x, _) => /* we don't care about the second element of the tuple. but we care about the first, so x = "foo" */,
}
>>
>>62151768
IF you implement a valid garbage collector in C.
THEN yes it has the possibility to be a garbage collected language but by default it isn't. just like rust isn't by default functional.
>>
>>62151777
>there's a perfectly valid C++ API that does just that.
external, does not count
>>
>>62151813
>C is now a GC'd language
Sad

Too bad I use a non-GC language
>>
>>62151814
Hey, don't get too carried away with those goalposts.
>>
>>62151814
>external
It's written by Stroustrup + some others for fuck's sake. Why are you niggers so full of arbitrary distinctions?
>>
>>62151814
when it gets added into the standard will you cry? will be added in C++20 guaranteed.
>>
>>62151835
>It's written by Stroustrup
I don't care, it's not standard C++
>>
>>62151838
That's even more pathetic LMAO
>>
>>62151838
Will modules get implemented in C++20?
>>
>>62151839

define 'standard' C++.
>>62151846
why is it pathetic?
>>
>>62151839
Boost isn't standard C++ either
>>
>>62151835
>It's written by Stroustrup
D O A
O
A
>>
>>62151855
>define 'standard' C++.
C++ with standard library

>>62151857
True
>>
>>62151855
>define 'standard' C++.
Learn how to use your search engine
>>
>>62151855
>why is it pathetic?
C++ has no visions
>>
>>62151854
it's already usable in C++17 although experimental (Technical Specification). You just need an up to date compiler.
Paper:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/n4610.pdf
>>
>>62151888
>it's already usable in C++17
literally working draft
>>
>>62151882
of course it doesn't it's a language. C++ has made massive improvements with C++17 FYI
>>
>>62151916
>of course it doesn't
Yeah, I know
>>
>>62151915
literally experimental TS.
>>62151857
most boost libs get implemented into the standard. see filesystem
>>
>>62151882
>C++ has no visions
The curse of backwards compatibility. At least C++11/14/17 was a massive improvement, even though they should have added everything from 17 to 11 already.
>>
>>62151929
>most boost libs get implemented into the standard.
I know, that was my extended point. Basically, 80-90% of the good parts in C++11/14/17 comes from boost in the first place.
>>
(define (make-obj state methods)
(letrec
([state-key (gensym)]
[self
(lambda (method . args)
(cond
[(eq? method state-key)
(case (length args)
[(0) state]
[(1)
(let ([found (assoc (first args) state)])
(unless found
(raise-arguments-error state-key
"no such field"
"field name" (first args)))
(cdr found))]
[(2)
(set! state
(cons (cons (first args) (second args))
(remove (first args) state
(lambda (a b) (eq? a (car b))))))])]
[(eq? method 'def)
(unless (= (length args) 2)
(raise-arguments-error state-key
"wrong number of arguments to define a method"
"arguments" args))
(set! methods
(cons (cons (first args) (second args))
(remove (first args) methods
(lambda (a b) (eq? a (car b))))))]
[else
(let ([found (assoc method methods)])
(unless found
(raise-arguments-error state-key
"no such method"
"method name" method))
(unless (procedure-arity-includes?
(cdr found)
(+ 2 (length args)))
(raise-arguments-error state-key
"unsupported number of arguments"
"method name" method
"arguments" args
"method arity" (procedure-arity (cdr found))))
(apply (curry* (cdr found) self state-key) args))]))])
self))
>>
>>62151962
actual example of functional programming
>>
>>62151971
Except that's just macro magic though.
>>
>>62151987
it isn't. you're moving goalposts.
you're being BTFO every post
reddit is that way --->
>>
>>62152024
>it isn't.
It literally is, have you learned nothing this thread? Fucking moron.
>>
>>62152024
>crying this hard
>>
>>62152034
> it isn't
you're eternally BTFO
>>
>>62152024
kek
>>
>>62151962
>>62151971
>being so sore loser you literally have to samefag pretending to be two different posters

>>62152024
>>62152061
I know you made both posts, faggot. Get the fuck out.
>>
>>62152170
i didn't. i don't even use lisp.
>>
>>62152170
kek
get wrecked claim samefagging.
>>
>>62152170
>>being so sore loser you literally have to samefag pretending to be two different posters
see: >>62152280
>>
File: 1483839258001.gif (424KB, 533x468px) Image search: [Google]
1483839258001.gif
424KB, 533x468px
Has anybody tried cello (http://libcello.org) before? Looks pretty fun to fuck around with.
>>
>>62152346
Looks p gross desu.
>>
>>62152403
>oh no someone emulated some easy to use language constructs
>>
File: 1452365789104.png (118KB, 485x500px) Image search: [Google]
1452365789104.png
118KB, 485x500px
>>62152403
Explain.
>>
>>62152420
>>62152438
Eh, it just feels uncomfortably close to Python for me.
>>
>>62152468
You have to admit it's pretty neat though.
>>
>>62152497
i doubt it's functional (has loops)
>>
>>62148153
You don't need to specialize std for things like std::hash. Just use ADL.
http://en.cppreference.com/w/cpp/language/adl
>>
Alright, so I'm wanting to get into programming as compsci is something I'm kinda looking into as a major in college but my programming knowledge is kind of minimal. I know a little bit of Ruby and that's about it. Would it be a good idea to get back into Ruby or is there a better starter language?
>>
>>62153085
Start with Java to learn babby's first OOP.
Then you'll find it easy to move to C#, and easier to learn C++.
Just tank Java: The Complete Reference by Schildt and you'll literally know all the fundamentals and more.
>>
File: dlang_chan.jpg (139KB, 470x545px) Image search: [Google]
dlang_chan.jpg
139KB, 470x545px
>>62153085
https://dlang.org/
It's a general-purpose language allowing you to transition to other languages with ease. And it's cute!
>>
Question. I want to make a basic website that allows user authentication.

I know a little PHP but really don't like it's structure. I feel like it's worth more of my time to learn node.js and express.js for this use. Should I focus on one or git gud with both?
>>
Having some problems with C++/SDL. /sqt/ are too stupid.

I can't compile this because the compiler "can't see" the OnInit() function.
I get the error "No OnInit() member function declared in class CApp".

What the fuck is going on? It's in the class so why can't the compiler see it? It compiles fine with just the constructor and OnExecute().

Code: https://pastebin.com/Xn3Sy1FR
>>
>>62153205
Alright, sick. Thank you!!

>>62153238
I would be up for it but it doesn't seem too adopted so I'm prolly gonna pass on it.
>>
>>62153205
I found a PDF of the Seventh edition online. Does it matter which edition I use?
>>
>>62153349
I don't think there's too much different with them. The only important thing I can remember from the ninth edition is the coverage of Lambda expressions, but that's pretty in depth considering it's Java.

Here's the ninth edition on some github:
https://github.com/PlamenStilyianov/Java/blob/master/JDK8/Java%208%20The%20Complete%20Reference%20Ninth%20Edition/Java%208%20The%20Complete%20Reference%20Ninth%20Edition.pdf
>>
>>62153205
Not him but perhaps you can help me too. I have experience programming (two semesters of intro to programming; we used java). I'm now wanting to learn some lower level stuff so i started with pic related. I have pretty much finished chapter one, a tutorial introduction to the language, and most of it has been easy (save the text IO section; I rummaged around the web, asked for some clarification on here and other boards, and was able to overcome my knowledge deficiencies). When I get to chapter two I am instantly bombarded with numerous terms and concepts entirely foreign to me (significant characters of function and external variable names; loaders; stuff like this).
I guess my question is, what all do I need to know about hardware, operating systems, assemblers, compliers, loaders, linkers, toolchains, external variables, etc., before I will be fine proceeding with learning the actual langauge. I googled all of these terms, but out of context I feel barely better equipped than when I first encountered them. Do you recommend any resources for learning about this stuff so I can remedy my knowledge deficiency in one read, or would it be more efficient to learn this stuff as I go by using a search engine when I come across a foreign word or concept?
>>
>>62153440
Excellent, thank you!!
>>
>>62153460
whoops, forgot to attach pic
>>
>>62153460
I actually tried getting into the language with that book too but I ran into the same problems. A lot of stuff that didn't seem entirely necessary to use the language to how I wanted to apply it.
There are always books that are better suited to how you learn though. I found that Herbert Schildt writes well and covers literally everything you'd need to know, but not much that you don't really need to know.

While some of the earlier editions have been written off as "nonsense", try the latest edition of C: The Complete Reference. They're excellent introductions to the language I've found.
>>
File: tfwbrainlet.png (25KB, 837x391px) Image search: [Google]
tfwbrainlet.png
25KB, 837x391px
Right now I'm attempting to do this problem
I'm new to c++
I can't get it to where I can print out a list
I'm using vectors
>>
File: compiles_fine_for_me.png (1MB, 1920x1080px) Image search: [Google]
compiles_fine_for_me.png
1MB, 1920x1080px
>>62153302
Compiles fine for me.
What IDE and/or compiler are you using?
>>
>>62153628
Where are you getting stuck?
Can we see your code?
>>
>>62153772
Yeah I deleted a .gch file which was like 20MB and it compiled fine.
What gives? What's a .gch file?
Thread posts: 403
Thread images: 21


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