[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: 333
Thread images: 19

File: prog.jpg (105KB, 473x496px) Image search: [Google]
prog.jpg
105KB, 473x496px
What are you working on, /g/?

Previous thread: >>61634151
>>
>>61639037
Great OP
>>
>>61639037
Why is Ruby so /comfy/?
Also, first for Ruby
>>
Writing a CV.
I wish I was a NEET ;_;
>>
>>61639077
>I wish I was a NEET ;_;
Don't.
>>
>>61639091
>collect welfare
>whole day free to do what ever you want
Being NEET is pretty awesome
>>
>>61639091
If I was a NEET, I wouldn't be able to go on inane holidays. That's my driving force.
>>
File: i3psz.png (178KB, 651x1201px) Image search: [Google]
i3psz.png
178KB, 651x1201px
SHOULD I LEARN PYTHON OR C++ OR ASSEMBLY PLEASE
>>
File: euphoria.gif (11KB, 332x126px) Image search: [Google]
euphoria.gif
11KB, 332x126px
Why aren't you programming in Euphoria, /dpt/?

http://openeuphoria.org/docs/quick_over.html#_3_quickoverview
>>
>>61639135
Since you're asking learn python.
>>
>>61639135
Buy breast implants and sell yourself.
>>
>>61639137
>A high-performance, state-of-the-art interpreter that's significantly faster than conventional interpreters such as Perl and Python.
When you have a bullet point "fast" and it's about you comparing yourself to Perl and Python I don't have much faith in your language.
Nobody chooses this language because it's fast if it's on that scale.
>>
Started learning Haskell using haskellbook (seems to be much better than LYAH so far).

GHCi:
*Main> :t (* 9) 6
(* 9) 6 :: Num a => a


But if I load the same (* 9) 6 from the file:

fun = (* 9) 6


I get:

*Main> :t fun
fun :: Integer


Why?
>>
>>61639108
Until depression kicks in.
>>
>>61639027
If it does die, it will die only because of the lack of developer friendliness
>>
>>61639177
>literally all the time in the world to do anything
>get depressed
You can only choose 1
>>
>>61639058
mruby is the comfiest Ruby.
>>
I wrote my own implementation of the quicksort algorithm. Right now I'm working on some visualization in SDL. It's my first time doing graphics so it may take some time.

Also, what do you guys think of my implementation? i posted it yesterday evening, but the only reaction i got was to change the pivot.
void qsort(void* base, size_t num, size_t size, 
int (*compar)(const void*,const void*)){
size_t pivot = num - 1;
size_t i = 0;
while(i < pivot){
if(compar(base + i * size, base + pivot * size) > 0){
size_t j = size;
char tmp;
char *a = (char *)base + i * size;
char *b = (char *)base + pivot * size;
char *c = (char *)base + (--pivot) * size;
while(j--){
tmp = *a;
*a++ = *c;
*c++ = *b;
*b++ = tmp;
}
i--;
}
i++;
}
num = num - pivot;
if(pivot > 1) qsort(base, pivot, size, compar);
if(num > 1) qsort((base + pivot * size), num, size, compar);
return;
}


And here is a slightly shorter version, but for int[] only.
void qsort(int *arr, size_t size){
size_t pivot = size-1;
size_t i = 0;
while(i < pivot){
if(arr[i] > arr[pivot]){
size_t j = pivot-1;
int tmp = arr[i];
arr[i] = arr[j];
arr[j] = arr[pivot];
arr[pivot] = tmp;
pivot = j;
i--;
}
i++;
}
size = size - pivot;
if(pivot > 1) quickSort(arr, pivot);
if(size > 1) quickSort(arr + pivot, size);
return;
}
>>
>>61639200
You don't understand how your brain is wired.
>>
>>61639237
>void* base
>compar(base + i
>>
>>61639217
Oh shit, that is actually pretty cool. I hope it does well.~
>>
>>61639166
This is called the Monomorphism Restriction
You can disable it using the compiler flag
-XNoMonomorphismRestriction
or the pragma (at the top of the file)
{-# LANGUAGE NoMonomorphismRestriction #-}

This is done by default in the REPL, as of a certain GHC version (I forget which).
Basically, it stops the compiler from inferring polymorphic signatures.
(You could explicitly give it a polymorphic signature.)
>>
>>61639261
I don't get what you're trying to say.
>>
>>61639306
You can't do arithmetic on void pointers. The only the reason this works is that gcc treats sizeof(void) as 1, this is not standard.

It should really warn you on -Wall, but only does with -Wpedantic.
>>
>>61639294
>>61639166
And here's a more in-depth explanation:
https://wiki.haskell.org/Monomorphism_restriction
https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-930004.5.5

It isn't a big problem, since you can disable it, or provide an explicit signature.
>>
>>61639343
So i should cast it to a char pointer before doing arithmetic then?
>>
>>61639408
Yes, at the top of you function just do something like:

char *bptr = base;


Then use bptr instead of base in your function, you can also remove all those (char *) casts.
>>
File: 133984337.jpg (107KB, 1920x1080px) Image search: [Google]
133984337.jpg
107KB, 1920x1080px
Why don't you listen to eurobeat while koding, /dpt/?
>>
>>61639135
>Assembly as a first language
Truly the patricians way
>>
>>61639452
Because I have much better taste in music
>>
>>61639452
>*faint 'running in the ninties' plays in head*
I should.
>>
>>61639037
why is she shouting?
>>
>>61639452
>had a 17gb eurobeat folder
>accidently deleted the wrong partition while reinstalling windows and deleted it
>channel I pulled them from got killed
LOST INTO THE NIGHT
>>
long time;

heehheehehhe
>>
>>61639505
 long long DICK; 

teehee
>>
Are there some ghetto, fast, easy to write, somewhat effective copy protection schemes for windows executables?

I've been thinking about appending the hardware id to the end of the executable and just checking for it at runtime
>>
>>61639521
short BENIS;
>>
>>61639521
float likeAButterfly;{/code]
>>
>>61639526
>I've been thinking about appending the hardware id to the end of the executable and just checking for it at runtime
Yeah that seems quick and dirty enough. Very inconvenient for users though.
>>
>>61639530
dumb camelCase poster
>>
File: 57689739[1].png (728KB, 1048x740px) Image search: [Google]
57689739[1].png
728KB, 1048x740px
>>61639521
short dick;

mmheheh
>>
>>61639540
DUMB FORTRAN POSTER
>>
>>61639531
well theres gonna be like 5 users in a 100km radius so it wouldn't be that inconvenient to "reinstall" the application in case their os crashes or something. yeah i think im going with that
>>
>>61639058
Because it sacrifices performance to maximize abstraction. That's why it's so fucking slow.
>>
>>61639658
maybe ruby should try some of that ZERO COST ABSTRACTION
>>
What's a good name for languages like: XML, JSON, HTML and CSS? Markup languages?
>>
>>61639698
Yes.
>>
>>61639692
>>61639658
Don't forget the FEARLESS CONCURRENCY
>>
>>61639698
programming languages
>>
>>61639452
If I wanted to listen to the same shit over and over, I would just do that.
>>
hax my anus
>>
Okay so people writing web apps because it's the easiest way to write cross platform applications and they can also run on browser so people don't have to install them.
We need to create standardized platform which can be used to run applications without installing them and provide way for people easily browse available applications.
How do we implement it?
>>
File: 000026-Twitch.png (44KB, 126x142px) Image search: [Google]
000026-Twitch.png
44KB, 126x142px
>>61639799
sounds like a job for javascript
>>
for i in range(1, 101):
print(i)
if not i%3:
print("Fizz")
if not i%5:
print("Buzz")
>>
>>61639799
.NET
>>
>>61639819
why would you limit yourself to one language?
>>
File: 000037-Twitch.png (21KB, 79x106px) Image search: [Google]
000037-Twitch.png
21KB, 79x106px
>>61639848
why wouldnt you want to code in javascript
>>
>>61639799
Hmm, sounds almost like a virtual machine.
I've heard of some language that based itself on portability through a virtual machine.

But I think you're missing a major reason people like webapps. They limit the attack surface to the browser and not the system.
>>
>>61639891
You could run somekind of sandboxed executor on top of the vm
>>
>>61639920
Or we could just sandbox the VM.
Some googling found me this little project:
https://www.java.com/en/
>>
>>61639949
Wow, and that language is pretty fast too!
http://benchmarksgame.alioth.debian.org/u64q/which-programs-are-fastest.html
>>
Reminder that no non-Lisp dynamically typechecked language has ever surpassed a Lisp
>>
>>61639986
Man I hate how people cite that as if it's a measure of performance. Even the authors disagree
http://benchmarksgame.alioth.debian.org/why-measure-toy-benchmark-programs.html

If you want to get a hint from this look at how the implementations differ from naive solutions outside of algorithmic optimization.
If you look at C you find that most of it is just as you'd normally write C (ignoring some local stack declarations that'd be global or passed in by pointer). If you look at python they write code that's far from what you'd expect real code would be like in Python.

That's what bothers me the most. We need benchmarks that compare normal styles.
>>
>>61640148
After all, what's the point in using Python if you're only going to awkwardly write C in it?
>>
>>61640103
Surpassed in being shit?
>>
>>61640187
Lisps are fast and powerful

Non-lisp dynamic languages are less fast and less powerful
>>
>>61640177
Less curly braces and semicolons
Easier to find an online compiler/interpreter
Python is a good scripting language
>>
>>61640177
Exactly.
>>
>>61640198
JIT'd Assembly?
>>
>>61640200
>Less curly braces and semicolons
The same is true of Haskell and Lisp
>Easier to find an online compiler/interpreter
The same is true of Haskell and Lisp
>Python is a good scripting language
The same is true of Haskell and Lisp
>>
>>61640200
What is a "scripting language"?
>>
>>61639135
c++ all the way. after that any other language will feel like a joke.
>>
>>61640270
>Haskell
>scripting
lmfao
>>
>>61639037
Asking because I have no fucking clue at this point: Why does this C++ code lead to the error "Expected Expression" ?

    int ind;
char token;

char num_digit_array[MAX_DIGITS];

std::queue<op> Operator_Queue;
std::stack<double> Number_Stack;

int op_ind = 0; /*Keeps track of the index on the operator stack */

/* iterate while there are characters to be read */
for(ind = 0; (token = expressions[ind]) != '\0'; ind++)
{
if( isdigit(token))
{
printf("Found number: %c\n", token);
int num_array_ind;

/* Iterate while you find more digits of the same # */
for(num_array_ind = 0; isdigit(expressions[ind]); ind++)
{
num_digit_array[num_array_ind] = expressions[ind];
}
Number_Stack.push(s_to_double(num_digit_array) );
>>
>>61639137
This actually looks all ri
>Euphoric
>A remarkably simple, flexible, powerful language definition that is easy to learn and use.
why.jpeg
>>
>>61640381
Spotted the IDE babby.
Why not use gcc or clang which literally tells you compile-time errors instead of using shitty jetbrains.

FUCK i hope you're not a CS major.
>>
>>61640270
Haskell has less annoying punctuation, but Lisp is an endless sea of parens.

Also, neither are good scripting languages.
>>
>>61640436
>tfw Java dev and not being able to compile from CLI
>>
>>61640307
I thought the term had enough of a negative connotation that no one would care. Basically I use it when I want to calculate something that Google calculator can't handle. I'm saying it's good for that.
>>
>>61640460
Java is excusable...I mean you're using Java, so chances are you're a Pajeet. Totally understandable.
>>
>>61640460
It's just javac input_file.java -cp some_library.jar:some_path_with_class_files
>>
>>61640372
>>61640454
Yes, you can script in both.
If you really wanted a weak type system, you could do that too - create a type that can represent everything you're interested in, like a python value or a lisp value or a lua table.
>>
import random

def total(hand):
return sum(hand)-10*(21/sum(hand))

deck=[1,2,3,4,5,6,7,8,9,10]
playerHand=[]
dealerHand=[]
score=False

playerHand.append(deck[random.randint(0,9)])
playerHand.append(deck[random.randint(0,9)])

while True:
print(playerHand)
if input("Hit? (0/1)"):
playerHand.append(deck[random.randint(0,9)])
if sum(playerHand) > 21:
print("Bust")
break
else:
while True:
if sum(dealerHand)<11 or total(dealerHand)<total(playerHand):
dealerHand.append(deck[random.randint(0,9)])
if sum(dealerHand) > 21:
print("You win")
break
else:
score = True
break
break

if score:
if total(playerHand)>total(dealerHand):
print("You win")
elif total(playerHand)<total(dealerHand):
print("You lose")
else:
print("Push")

print("Player hand:")
print(playerHand)
print("Dealer hand:")
print(dealerHand)
>>
>>61640502
I figured that out after a quick lookup, but I was spoiled by my IDE.
>>
>>61640372
>>61640454
>>61640518
Oh and I'm not saying that a weak type system is better for scripting.
>>
>>61640518
The entire point of a scripting language is to be fast and easy without being unpredictable. There is a reason Perl letting people write programs as line noise didn't prevent it from being adopted.
>>
>>61640518
You can create a DSL using the metaprogramming facilities of both languages. It's disingenuous to suggest they're scripting language. Could be a troll tho, so have an ebin upvote friend! xD
>>
>>61640528
import math

print(math.factorial(100))
>>
>>61639452
feels good listening to 140gib of flac super eurobeat while editing some scripts
>>
>>61640539
Yes, and Haskell is faster than scripting languages and more predictable.
You could even write a library that is closer to what you want.

>>61640546
Library, not DSL.
>>
c++ tho
>>
>>61640575
>Haskell is faster than scripting languages
Fast as in writing, you idiot, not executing.
>>
Reminder that it's only thanks to Apple that we're not all stuck writing apps in Flash and using ActionScript.
>>
File: bait-but-nevertheless-correct.png (17KB, 522x384px) Image search: [Google]
bait-but-nevertheless-correct.png
17KB, 522x384px
>>61640623
Haskell is faster to write, too.
>>
>>61640626
but Actionscript is comfy
>>
>>61640646
well memed
>>
how would I go about a tetris clone
>>
>>61640646
>dude lazy evaluation lmao
No. It's supposed to be annoying to write in exchange for being reasonably sure that it works correctly when it builds without an error.
>>
>>61640750
import tetris
>>
>>61640750
I think you missed a present participle.
>>
>>61640623
Yes, it's fast in writing.
>>
>>61640626
people seemed to like the developer experience. everyone else about it was bad though
>>
>>61640758
Nobody mentioned lazy evaluation.

Haskell is faster to write than C because you can write much more abstract, composable, concise code in it that just fits together. Haskell is faster to write than Python because you can get away with far fewer unit tests, and the compiler will spot bugs more quickly than you can hunt them down after they become apparent at runtime.
>>
>>61640623
>>61640804
As an (overly-simplistic) example, there was a palindrome thing the other day.

(readable)
palindrome s = (s == reverse s)

(not readable to someone who doesnt know Haskell)
palindrome = (==) <*> reverse


Now this itself isn't the point, the point is that someone then said
>It's supposed to also work on upper/lowercase
Very quickly, the response was
palindrome `on` map toLower


>and ignore spaces
palindrome `on` (map toLower . filter (not . isSpace))
>>
>>61640760
>>61640766
I guess I could do it pygame
feels like a waste to learn it though
>>
>>61640842
This holds true for toy programs, but not 1M+ codebases.
>>
>>61640899
>1M+ codebases
I thought this convo was about scripting and toy programs?
>>
>>61640899
It absolutely holds true for large codebases.

The tool support for refactoring alone makes it far, far more usable "in the large" than most dynamic languages.
>>
>>61640899
In Haskell it wouldn't be a 1M+ codebase, and the very fact that there's less code means it's easier to change.
>>
>>61640949
Well, it GENERALLY means it's easier to change.
You could have some really entangled concise code, but pure FP discourages entangling.
Though Haskell does have problems like orphan instances.

Haskell got even better recently, with the release of Backpack.
>>
>>61640932
Full type inference is a nightmare. Especially when written point-free.
>>
>>61640977
Type inference is great. Look at the noise you have to write in Scala to see what happens when you do FP without full type inference.

Point free is great. It allows more readable code. Again, look at Scala to see what happens when a language doesn't support it properly.
>>
>>61640977
Not in Haskell it isn't, and Haskell is based upon HM, which is one of the most flexible fully inferable systems.
Most of the extensions break this, but most of the code written using them is also inferable.

Inference is GOOD in Haskell and in cases like >>61640842.
What don't you like about inference?
>>
>>61641028
There's no way to figure out what the input and (optional) output is of a function without reading it or checking the type in GHCI.
>>
>>61640842
>scripting
>posts a toy palindrome checker that doesn't even have IO
fucking summer.
>>
>>61641046
:t functionName


Really, what's so hard about that?

Even then, that's assuming the function has no type signature. Most top-level functions in libraries do.
>>
>>61641046
How does inference change this?
And in Haskell you CAN tell a great deal about a thing's type from it's name, or vice versa.

>>61641075
>As an (overly-simplistic) example
>>
>>61640842
>>61641028
How the hell is a purely functional language useful for scripting? Something that inherently requires some concept of changing state and mutability?
>>
>>61641088
>Really, what's so hard about that?
Imagine a shit codebase handed over to you. Do you really want to :t every function?
>>61641095
>How does inference change this?
In most languages you can guess what the function does by looking at its signature. This way you don't have to rely on the function name.
>>
>>61641132
got u covered anon

State
STRef
IORef
MVar
>>
C is a great scripting language
int sum(int a, int b) { return a+b; }

Pretty sweet
>>
>>61641132
Scripting doesn't inherently require changing state and mutability, but you can embed that anyway.

>In most languages you can guess what the function does by looking at its signature.
In Haskell this is doubly so, what's your point?
What does this have to do with inference?
>>
>>61641139
You can make your editor add a type signature for a function you want to know the type of. Not difficult.
>>
>>61641155
in Haskell you'd just use (+) or (uncurry (+)) if you wanted one that operated on tuples.
You could do a definition too
sum = (+)


The main problems with writing concise Haskell are
A) needing a bunch of imports
B) needing a bunch of pragmas
C) prelude could be done better
>>
>>61641155
0/10 doesn't safeguard against overflow
>>
>>61641173
>having to rely on an editor to make code understandable
Great.
>>
>>61641217
Do you write all your code in Notepad?

The point is that there are solutions to the problem of poor readability of a crappy codebase. You have the same problem in a language like Python except the REPL/editors cannot help you figure out what input and output types a function has. They can only show you the function.
>>
>>61641257
Question: what's the largest Haskell codebase you've ever worked on that's being used?
>>
>>61641202
It's modular arithmetic
>>
>>61641160
>Scripting doesn't inherently require changing state and mutability, but you can embed that anyway.
Don't be disingenuous. Why the fuck would I use Haskell for a task traditionally suited for Perl, Python, Ruby, etc? Aside from webdev bullshit obviously.

Hint: performance is irrelevant here because you are usually just calling libraries written in a fast language anyway.
>>
>>61641202
>safeguard
lol you gonna exploit my integer overflow to pwn my system lil' hack nigger.
>>
>>61641296
being this mad because he can't write correct code
>>
>>61640327
>every other language will feel like a joke
code bare-metal stuff in muh c++
>>
>>61641275
About 20kloc. It's a bit ugly in places, sure. But the worries you're describing? Complete non-issues in practice, in my experience.

Haskell isn't like dynamic languages when it comes to large codebases, and that's because even though type signatures are optional in it, static typechecking still happens.
>>
>>61639692
Reminder that zero cost abstraction is genuinely possible
Here's how you do it:
>write a compiler that unfolds all the abstraction as it compiles, leaving none to be dealt with at runtime
>as icing on the cake, write an assembler that converts the assembly to an intermediate algebraic representation, uses algebra to compress it to its shortest possible representation, and assembles that instead of the original assembly
>your language is now both faster and higher level than C, it takes an eternity to compile but that doesn't matter
>>
>>61641295
>Why would I use Haskell?
Because it is an excellent functional language with a great type system.
If you really require everything to be IO-like, and can't handle do-notation or monadic combinators, then you can just write a library in which everything is IO-like.
Admittedly that isn't very Haskelly, but the language has many features beyond purity.

>you're just calling libraries written in a fast language
Yes, libraries written in Haskell.
No doubt you can call even faster C libraries if you are handling demanding requests, and simply want it to be the "control unit" if you will, but Haskell will still be faster.
>>
>>61639830
>not posting fizzbuzz in arm assembly
>>
>>61641361
>No doubt you can call even faster C libraries if you are handling demanding requests, and simply want it to be the "control unit" if you will, but Haskell will still be faster.
That approach works for Python users. It's the only way they can claim their language is competitive.
>>
>>61641320
I'm using this for qemu tests on a cortex m3.
https://github.com/DISTORTEC/distortos
>>
I'm pretty happy! Just finished implementing a Shunting Yard algorithm in C++! (I might implement it later in C to avoid all the overhead, but for now I'll work with what I've done)
>>
>>61641320
extern "C" {
>>
>>61641388
I really like that font

>>61641374
I thought the goto Python excuse was to compile it to C?
Compiling Python is un-pythonic!
>>
>>61641345
Haskell is an example of an overengineered product that serves a very specific niche of developers. Idris is more interesting from an academic perspective because of theorem proving.

The reason why nobody uses Haskell is that it doesn't do one thing great. It does many things better than average (FRP, but not purely functional, etc) sort of like an all-in-one power tool that gathers dust on the shelf of your garage.
>>
>get good project idea
>start thinking about what I need and how to get shit done
>realize how much work it actually is
>get depressed again and abadon that project
>tfw
every fucking time the same shit. make it stap.
>>
>>61641345
>20kloc
Great, so now I know you're talking out of your ass.
The real world isn't an ivory tower occupied by Haskell gods with an IQ of 140.
>>
>>61641401
and with static type assertions, at that
>>
>>61641401
Thanks! Me too!
It's called "GohuFont" if I recall correctly
>>
>>61641404
Are you the same guy, every time?
The one that assumes all of Idris' features were invented well before Haskell came around?

Idris is a budget Agda.
And a bad one at that!
>>
>>61641412
Get a programming job. You'll never want to program (let alone look at a computer) in your free time again.
>>
>>61641384
>>61641392
>wrapping basically everything into
extern "C" { ... }

what's the point of using C++ for low-level stuff without the use of a large external library? you can't use most, if not any, non-c features.
>>
>>61641415
A 20kloc Haskell project is probably equivalent to a 200kloc Java project. As one anon said earlier, you simply don't get Haskell projects as big as the biggest Java/C++ projects because the language is so much more concise.
>>
>>61641436
Idris has space invaders

Where's Agda's space invaders?
>>
>>61641436
Smalltalk was the original OO language.
How many Smalltalk developers are there today?
It's undeniable that it had great influence on Ruby, Java, and Objective-C. But it never reached the same level of fame, because again, it didn't do one thing great.
>>
>>61641486
Don't all OOP developers (not that you should listen to anything they say) complain about how Smalltalk is so much better and shit?

>>61641478
Haskell has parts of facebook
>>
>>61641456
>A 20kloc Haskell project is probably equivalent to a 200kloc Java project. As one anon said earlier, you simply don't get Haskell projects as big as the biggest Java/C++ projects because the language is so much more concise.
200kloc is still a complete joke. Imagine the amount of lines of code produced by 20FTEs for a year.
>>
>>61641361
Again, you aren't really answering my question. Haskell being a good language doesn't automatically mean it's ideal for all tasks. In the case of scripting, I fail to see how you are appealing to the language's strengths and not fighting with its weaknesses; you won't be writing bad software, but you will certainly be writing more complex software.
>>
>>61641513
Haskell is by far one of the best programming languages out there. But my point still stands, it doesn't have a killer feature like the more popular languages out there.
>>
>>61641550
What "killer feature" does Python have? Or C#? Or Go?

They have none, and they do fewer things well than Haskell does.
>>
>>61641550
>it doesn't have a killer feature
Being an (almost) all-around good language is a killer feature

>>61641560
Being for faggots, retards, dykes and webdevs.
That's Python's killer feature.
>>
>>61641560
>What "killer feature" does Python have? Or C#? Or Go?
The ability of mutating state without killing yourself.
>>
>>61641530
If you have a single project that's 1M+ loc then your technical architect should be fired.
>>
>>61641534
Because people familiar with it write concise code, can easily familiarise themselves with libraries via strong typing, can write generic code that is also type safe (and compile time type checking speeds up error detection), etc.
It is also incredibly flexible, both semantically and syntactically.
It is a very expressive language.
These things all make it a good scripting language.
Plus things like monads and ADTs let you do a kind of intentionally limited scripting.
>>
>>61641595
Pfft..... HAHAHAHA
>>
>>61641578
I already posted that Haskell has you covered.

State
STRef
IORef
MVar

You can combine State with lenses and pretend you're writing Python, if you really want.
>>
>>61641358
This is the worst idea.
This is the worst fucking idea holy shit.
You know what. Go ahead and fucking HAVE your pure functional shitlang that's faster than C.
You'll have earned it a thousand times over by the time you've fucking suffered enough to get a hello world program working in it.
>>
>>61641560
What "killer feature" does Python have? Or C#? Or Go?

Python basically created RAD as a paradigm shift from waterfall (i.e. quick prototyping in REPL). C# (.NET really) abstracted away the shitty and downright scary parts of legacy Win32API. Go is meant to be a concurrent/parallel replacement for Python.
>>
>>61641609
It's true, though. Monoliths that large represent a complete failure of architecture and design.
>>
>>61641619
That's the theory, in practice you end up in monad hell.
>>
>>61641637
>Python basically created RAD as a paradigm shift from waterfall (i.e. quick prototyping in REPL).
Lisp did that first.

>C# (.NET really) abstracted away the shitty and downright scary parts of legacy Win32API.
Java did that first, and was cross-platform first too.

>Go is meant to be a concurrent/parallel replacement for Python.
At the expense of usability, thanks to its ridiculously limited type system, so Go is not a replacement for Python.
>>
>>61641648
Yeah bro, we should have microservices and nanoservices. Basically every subroutine should send protocol buffers over TCP because I'm a braindead retard.
>>
>>61641648
>Monoliths that large represent a complete failure of architecture and design.
Depends on what they do.
Pretending you're writing a library when you're not is worse.
>>
>>61641648
brb, deleting the Linux kernel
>>
>>61641690
That's not what I was implying and you know it isn't.
>>
Can someone post the image with a bunch of coding ideas?

I think it's used as the OP once in a while.
>>
>>61641653
What exactly is monad hell?
All of this seems to be stuff only people who haven't fully learned Haskell talk about.
>>
File: coq.png (5KB, 112x180px) Image search: [Google]
coq.png
5KB, 112x180px
who /coqlover/ here
>>
>>61641745
<-
>>=
>=>
<=<
<*>
And whatever weird operators Haskell has. Not ever programmer is an expert in category theory.
>>
>>61641775
You don't need to know category theory to understand those functions.
>>
>>61641775
How is this hell?
You can just use do-notation if you don't understand them.

This is the opposite of hell to me, because 90% of the time those operators simply make code slightly more concise:
(<- isn't an operator btw, it's part of do notation syntax, but
you can't have known that)

do x <- a
f x

=
a >>= f


do x <- a
y <- b
return (f x y)


f <$> a <*> b
>>
why do we talk about haskell so much
>>
>>61641755
I dont see the point of Coq, is it just for for /sci/ nerds?
>>
>>61641845
some people really love it
some people really hate it
>>
>>61641854
>>61641755
Agda seems better, but I'm a Haskellfag
>>
>>61641845
Its the unfortunate poster child of FP, even if its its shit. It has the most library support because its the most popular so more people use it.

Its a sad cycle.
>>
>>61641601
Your code will be concise anyway if you aren't an idiot. The point of scripting is that it is mostly the automation of existing tasks, not the creation of new ones aside from the script itself.

Learning Haskell is pointless if you don't want to make full use of the language because it's one of the hardest languages to learn. People used to regular imperative languages will feel their brain melt.
>>
>>61641876
Agda isnt for proofs.
>>
>>61641794
>>61641831
There's no way to tell what the fuck >=> is supposed to do.
>>
>>61641878

>>61641897
Not automatically, but you become familiar through use or by reading documentation.
There are plenty of API functions that "seem obvious" but aren't.
>=> intuitively is supposed to look similar to >>=
>=> connects Kleisli arrows, you can consider the symmetry of the operator as relating to that, i.e.
(a -> m b) -> (b -> m c) -> (a -> m c)
If you look, these are very similar
let K a b = a -> m b

K a b -> K b c -> K a c


>>61641895
It's more useful
>>
>>61641897
https://hackage.haskell.org/package/base-4.10.0.0/docs/Control-Monad.html#v:-62--61--62-

(>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c

Left-to-right Kleisli composition of monads.


Seems straightforward to me.
>>
>>61641878
I don't think Haskell is actually "one of the hardest to learn".
It's different from imperative, and so I think that's the difficulty.
If you had begun with Haskell I don't think you'd have this problem.
Stuff like pattern matching and ADTs are really simple.
>>
>>61641924
Oh im not arguing that, its just silly to compare the two because they have two different purposes.

I really need to try Agda though.
>>
>>61641937
Good for you, the rest of the world doesn't. Have fun working at MacDonald's.
>>
>>61641451
I've experimented with bare metal C++ and you mostly just need a libc for it. Newlib-nano is pretty good and quite small. Most C++ containers depend only on malloc, and you can provide custom allocators if you don't want that.
>>
>>61641897
You've also got to remember that some of these operators come from papers.

If you wanted a name for (>=>), try
forwardCompose

or
chain

It's similar to (.), but on kleisli arrows and not regular functions.

>>61641974
How am I supposed to know what a quarter pounder big mac with xyz is?
Probably by looking at the menu!
>>
>>61641974
This brainlet mentality is why try-catch and exceptions POO still exist.
>>
>>61641974
i'm already gainfully employed as a software engineer and use haskell as a hobby
you seem mad you can't comprehend basic fp concepts
>>
>>61641994
I'd like some fries and coke, please.
>>
>>61642004
>you seem mad you can't comprehend basic do concepts
You sound just like a Rust faggot defending its special snowflake language.
>>
>>61641974
Let's break down the type signature.

Monad m => (a -> m b) -> (b -> m c) -> a -> m c


Monad m =>

If m has a monad instance

(a -> m b) ->

and you have a function from a to m b

(b -> m c) ->

and a function from b to m c

a -> m c

then you can make a function from a to m c.
>>
>>61641878
Don't bother anon. It's a lame troll. There's another one who shills D. Just igrnore them.
>>
>>61642061
i rest my case
don't hate the player, hate the game
if you're too dumb to understand a programming language, let the adults use it and stay away
>>
>>61642061
So what language do you use?
I'd guess youre a Python artisan.
>>
>>61642105
I'm sure he only uses the finest JS
>>
>>61641942
>It's different from imperative, and so I think that's the difficulty.
That's part of it, but Haskell and similar languages are radically different from most others in a lot of ways. Lazy evaluation and the type system are major examples, the former of which is still heavily criticized.

Anything is easy if you are accustomed enough to it. Difficulty is about how hard it is before that.
>>
>>61642092
I honestly don't care. Save the effort.
>>61642098
Please don't put ice in my coke.
>>61642105
Whatever I feel like. Java, C++, Clojure...
>>
>>61642130
lazy evaluation is criticized because mental midgets can't understand it
>>
>>61642092
>Monad m => (a -> m b) -> (b -> m c) -> a -> m c

using TypeOperators and ConstraintKinds, and currying it

type To a b = a -> b
type Given a c = c => a

forall a b c m.
(((a `To` m b,
b `To` m c`) `To` (a `To` m c))
`Given` (Monad m))
>>
>>61642148
>Java, C++, Clojure...
Ah yes, only the finest POO, no wonder you have trouble with Hasklet.
>>
>>61642148
>Java
>C++
confirmed for poo in loo
>>
>>61642130
Lazy evaluation did nothing wrong.
Those thunks deserved it.

>much better performance from composed functions
>occasionally slows things down
>occasionally speeds them up
>encourages pointfree composition
>infinite data structures

codata might be a good alternative
>>
>>61642172
>>61642177
Clojure shows that (s)he's not completely boring.

>>61642148
>I honestly don't care.
Kinda sad that you don't want to understand what these things do and why they are useful, anon. I assume you posted >>61641775
>>
>>61642177
>"confirmed for poo in loo" said the NEET virgin for the 1000th time this week to feel better about his pathetic life
>>
>>61642172
>>61642177
Yeah, really sucks knowing languages that are widely used throughout the industry.
>>
File: 1236818.jpg (113KB, 960x720px) Image search: [Google]
1236818.jpg
113KB, 960x720px
Is "Clean Code" by Uncle Bob any good? The fact it's written in Java kinda puts me off.
>>
>>61642231
>clean code
>java
and what did Uncle Bob mean by that?
>>
>>61642213
I like Clojure because it's a powerful language without the theoretical bullshit. It's like Python on steroids.
>>
>>61642231
Uncle Bob should not be listened to.
>>61642230
>if my corporate overlords arent pushing X language i dont want it
>>
>>61642246
>he can't write clean Java code

t. brainlet
>>
>>61641775
No this isnt monad hell, monad hell is when you find out you need a monad stack for all your functions and now suddenly everything is 4 monad transformers deep and you have to resort to using these weird arrows just to apply functions like you would in any normal language
and you think to yourself, "why cant i just use ocaml and actually mutate a ref once or twice instead of wrapping *everything* in a monad?"
>>
>> zpoller_new (void *reader, ...);
>>
>> Is there a way with ctypes to emulate this signature?

>The short answer, unfortunately, is "no".
Holy shit ocaml C interface can't even wrap variadic C functions.
SAD
>>
>>61642269
>why cant i just use ocaml and actually mutate a ref once or twice
So use OCaml and stop whining about Haskell enforcing referential transparency most of the time.
>>
>>61642152
>>61642187
It's easy to understand, but still makes it annoying to reason how a program works under the hood.
I also like what >>61642269 pointed out. Programming in purely functional languages can easily end up being more of a hindrance than a benefit.
>>
>>61642268
Nobody can

>>61642269
Just use MTL, you don't need to worry about transformers until it's time to run them. (Or until you use something like Zoom)

>those weird arrows
If you do literally anything monadic you use them.
You can use do notation if you're a brainlet.

This is like complaining about having to use "weird semicolon operators" in C
>>
>>61642329
its pretty amazing that they even got c-style format strings to work in ocaml
>>
>>61642329
Stop using OCaml, its the language of disappointment.
>>
>>61642342
>Programming in purely functional languages can easily end up being more of a hindrance than a benefit.
See >>61642347

Just use mtl. Don't listen to the extensible effects crowd either, they're pushing bullshit
>>
>>61642329
>This type of function is rather tricky to wrap. This isn't due to a limitation of ctypes; it's because there isn't a way to write wrappers for variadic functions in standard C [0, 1].
Interesting.
>>
>>61642374
>extensible effects
These probably won't make it to any mainstream languages, but you have to admit they're pretty neat. I love my continuations
>>
File: code.png (39KB, 887x471px) Image search: [Google]
code.png
39KB, 887x471px
Not sure if post this on here or on SQTTDDTOT.

I'm working on a microcontroller and I want to remove the fist 4 bits of a byte before sending it to the PORT, for example, if I have 11111111 I want the result to be 00001111, but I can't get my mask to work.

Why does this work...:

      nibble1 = lcd_Data << 4;        //Deletes upper nibble by moving it, example: lcd_Data = 0001 0010 -> nibble1 = 0010 0000
nibble1 = nibble1 >> 4; //Moves the byte back nibble1 = 0000 0010


...but this doesn't? :

      nibble1 = lcd_Data & 00001111;      //This should delete the first four bits using an AND mask 


I'm perplexed, shouldn't a 00001111 AND mask delete the first 4 bits leaving the 4 last ones untouched?

Pic related is the context, it's just some code to display characters on a HD44780U display, it works fine with the first piece of code, but the second doesn't works.
>>
>>61642388
>If you're not too concerned by portability you can use the fact that
some C implementations (e.g. GCC on Linux) have the same calling
convention for variadic and regular functions. Here ctypes offers an
advantage over handwritten bindings: since C types are exposed as
OCaml values you can construct a signature dynamically according to
the number of arguments you want to pass to the function. For
example, you might call the function using any of the signatures
>>
>>61642425
>I love my continuations
So use Cont/ContT
>>
>>61642456
*forall m. MonadCont m =>
>>
>>61642437
Are you using the BitMonad?
>>
>>61642496
please stop false flagging
>>
File: nes.jpg (7KB, 300x228px) Image search: [Google]
nes.jpg
7KB, 300x228px
I'm working on an emulator right now, but I'm puzzling over how the parts should communicate.

How do you usually get objects to talk to each other?
>>
Someone pls give me a good and somewhat simple programming project to work on.
>>
>>61641595
>>61641648
that's not even particularly large..
>>
>>61640557
flac is an autistic choice of audio encoding
>>
>>61642535
Lambda calculus + REPL

Extension: simply typed lambda calculus

Extension: simply typed lambda calculus with Y combinator
>>
>>61642535
IRC shitposter using Markov chains
>>
>>61642496
>BitMonad
What is that? I'm using byte as the variable type for everything except the lcd_menu array, which uses char, the program takes single chars one by one and stores them into bytes, then divides them in two and sends them to the display, that's why I need to delete the first 4 bits.

I don't know why using AND doesn't deletes the first four bits.

...10101010
& 00001111
__________
...00001010

Is this right? Why " nibble1 = lcd_Data & 00001111; " doesn't works?
>>
>>61642535
to-do list on the command line

features you can add:
- task categories
- coloring based on priority
- due dates and maybe even alerts based on due dates (look at libnotify if on gahnoo linuks)
- storing tasks to a file on any change and reading it at program startup

etc.
>>
>>61642535
Think about something common you use that you think is shit or needs improvement.
>>
>>61642659
Ignore him

&ing with 0 does "delete / unset" (set to 0)
Are you sure you've got the correct sizes? i.e. if it isn't one 8-bit byte, then &0000xyzw won't delete the first 4 bits
>>
>>61642659
Create a BitMonad for the value and the mask like so:
Bits <insert bits>

and use the &=& next for AND'ing the values. The result is a Maybe BitMonad in the category of endofuctors.
>>
>>61642732
What's your fucking problem dude?
Are you this fucking butthurt that there are people that like Haskell?
>>
will
>Proficient in Haskell
on my resume land me a job?
>>
>>61642742
>xe doesn't know the BitMonad
>>
>>61642755
No, many people say they can use Haskell on their resumes but cannot, interviewers will ask you to prove it
>>
>>61641595
>>61641648
t. expert fizzbuzzer
>>
>>61642786
so it'll get me an interview at least?
>>
>>61642797
No, you need other stuff on there too
>>
>>61642797
If it guarantees you an inteview that you'll fail, then it would be better not at all
>>
>>61642797
Or you could actually become proficient in Haskell, but only for CV purposes
>>
Idiomatic Fizzbuzz in C++

#define List _
#define Integer __

template <int Condition, typename A, typename B>
struct If;

template <typename A, typename B>
struct If<true, A, B> {
typedef A result;
};

template <typename A, typename B>
struct If<false, A, B> {
typedef B result;
};

struct Nil {};
struct Fizz {};
struct Buzz {};
struct FizzBuzz {};
template <int N>
struct Integer {
static const int value = N;
};

template <typename Head, typename Rest>
struct List {
typedef Head head;
typedef Rest rest;
};

template <typename Container, typename Value>
struct PushFront {
typedef List<Value, Container> result;
};

template <int N>
struct IntToFizzBuzz {
typedef typename If<
N % 15 == 0, FizzBuzz,
typename If<N % 3 == 0, Fizz, typename If<N % 5 == 0, Buzz, Integer<N>>::
result>::result>::result result;
};

template <int N>
struct DoFizzBuzz {
typedef typename PushFront<typename IntToFizzBuzz<N>::result,
typename DoFizzBuzz<N - 1>::result>::result result;
};

template <>
struct DoFizzBuzz<0> {
typedef Nil result;
};

template <typename T>
struct Print;

Print<DoFizzBuzz<100>::result> ___;
>>
>>61642755
Sure. MacDonalds is always hiring!
>>
>>61642833
Grapes are sour
>>
>>61642833
the salt
so much
>>
>>61639799
like webassembly or asm.js?
>>
>>61642851
>>61642858
You can start Monday at 7.15 AM.
>>
>>61642871
Maybe if you repeat it often enough, it'll become true. Probably not, though
>>
>>61642707
It turns out I had declared my masks in binary (00001111), but the rest of the byte variables in hex, so there was a conflict when operating with hex and bin at the same time.
I converted my masks to hex and everything works fine now.

Thanks kind anon.
>>
>>61642871
imagine being this butthurt about a programming language
>>
>>61642898
I think he actually works at McDonalds.
>>
>>61642928
You're right. I should stop being so mean, he might be very lonely and depressed there.
>>
>>61642851
>>61642858
But you can use Monads at MacDonalds.
The Maybe monad is a box of chicken McNuggets. If the customers requests a box of 12 chicken McNuggets but you only have two boxes of 6 chicken McNuggets, you can use the fmap function to combine the two boxes into a single big box!
(+) <$> Just 6 <*> Just 6
>>
If you're making a forum, is PHP or javascript better for making posts or showing replies?
>>
>>61642968
(++) <$> Just "A good post between people who like Haskell" <*> Nothing -- No good reply
>>
Why is it so hard to set up opengl? I just want a list of what to download from where and how to include and link everything. How are there not a million resources for this when we've been using opengl for decades?
>>
>>61642999
javascript at least has a future
>>
>>61642999
Don't use PHP
>>
>>61643015
apt-get build-dep mesa-demos

Done.
This is why developers love GNU(+Linux).
>>
>>61643019
>>61643028
What's wrong with PHP?
>>
>>61642999
PHP is for losers.
>>
>>61643054
The link is banned here but search the Internet for:
PHP Fractal of Bad Design
>>
Reaskin this: I'm actually learning C, I got this code to learn how to manipulate files and struct data type.

So assuming I have a book, with codes and names, and there can be several names with the same code.

When I want to read the names, I want to organize and list them by codes.
The thing is, that listing only works if I insert all the codes in order beforehand.

So my question is, is there a way I can rearrange them in an ascending order, into the code, so that even if I insert them in disorder, they are still listed the way it should be.
The struct database is not memorized in an array, they are saved directly into the file, and I make the program read them one by one.

struct sNames{
int code;
char name[50];
}rNames;


int main(){

FILE* filex;
int cod;

filex = fopen("names.txt","r");
if(!filex)
{
printf("File doesn't exist");
}

fread(&rNames,sizeof(struct sNames),1,filex);

while(!feof(filex))
{
cod=rNames.code;
printf("\nCode %i\n",cod);
printf("\nCode \tName\n");
while((!feof(filex))&&(cod==rNames.code))
{
printf("%i \t%s \n", rNames.code,rNames.name);
fread(&rNames,sizeof(struct sNames),1,filex);
}

}
return 0;
}
>>
>>61642862
There no point to have full html+css renderer, http client and javascript interpreter included in every app, so no, nothing like webasm.
>>
File: angry koding.jpg (50KB, 539x546px) Image search: [Google]
angry koding.jpg
50KB, 539x546px
>>61639452
because I listen to this
>>
>>61642437
The 00001111 probably isn't interpreted as 15 in binary but 1111 in decimal.
Try
nibble1 = lcd_Data & 15;
>>
>>61643091
you've thought of passing through the file first and doing all the grouping and sorting before printing? if you don't want it all in memory then you will have to work a bit
>>
>>61643051
I don't want magic to happen in the background. I want to know what is actually happening. What files are being used, loaded, compiled, linked, included...
>>
>>61643019
kek

Funny how people has been sentencing PHP to death since the early 2000s.
>>
>>61643054
an example: the function to find the index of a character in a string returns false if the character is not in the string. indexing a string with false is the same as indexing with 0, therefore if you chained these two you would get the character at position 0 instead of being notified that the character is not in the string. it's a stupid language for stupid people
>>
>>61639490
My music is backed up in the cloud. :)
>>
>>61643207
Webshit takes atleast twice as long to die as regular programming shit which already takes 4-5x as long to die as they should.
>>
>don't remember BASIC
>create own compiler
>>
>>61643176
libGL.so
libGLX.so
and the OpenGL headers.
>>
hello guys I am super newbie and I was watching a video from that fat guy from thenewboston about calling functions from the main function and I did everything the fat fuck said and it won't compile. I'm using code blocks. I know I'm retarded, but it isn't my program's fault, please help him,

[Code]#include <iostream>

int getp(int argc, char* argv[])
{
std::cout << argv[0] << std::endl;
return 0;
}

int main()
{
getp();
return 0;
}
[/Code]
>>
How do you subtract these bit strings?
1000 - 0110

When you hit the second column, you want to borrow a one. I'm assuming that's alright to pull it over two columns (i.e. borrow to the adjacent column, and then again to the current column).

However, then we've run out of ones. Any examples on YouTube deal with simplistic problems.
>>
>>61643270
install linux on a virtual machine and read K&R and The Unix Programming Environment alongside one another instead
>>
>>61643288
they're not bit strings, they're numbers in binary. if you don't understand basic terminology you don't understand core concepts. you subtract them the same way as you do in decimal. 1000 becomes 111 + 1. 111 + 1 - 110 = 1 + 1 = 10. convert to decimal to double check: 8 - 6 = 2. 10 base 2 is 2 base 10.
>>
>>61643288
you borrow across
imagine it this way

1000 - 0110 = 1000 - 0100 - 0010

you want to subtract 0010 from 1000
1000 = (0001 + 0111)
(0001 + 0111) - 0010
= (0001 + 0101) = 0110

0110 - 0100 = 0010
>>
>>61643325
>A bit string is a sequence of bits.

How does this differ from a number in binary?
>>
>>61643345
I think his point is, do you often refer to integers as digit-strings?
>>
>>61643300
so you're saying there's nothing wrong with my code?

this is what codeblocks say:

error: too few arguments to function 'int getp(int, char**)'|
>>
>>61643345
Strings are zero-terminated
>>
>>61643270
>int getp(int argc, char* argv[])
This function has two arguments

>int main()
>{
>getp();
You are calling it without any arguments here.

Try reading your compiler's error messages next time.

also,
>int argc, char* argv[]
this part should be the arguments for the main function.
>>
>>61643358
Nah bro, I call them number-words like everyone else
>>
>>61643362
didn't even look at your code m8, but don't learn programming from some youtuber and starting with C++ for gods sake. learn from based old white guys who were part of the clique that invented the craft
>>
>>61643379
that's numberwang
>>
>>61643207
it'll certainly be around for some time, but if i had to choose one of those two i think it's easy
>>
>>61643364
>Strings are zero-terminated

This is not true.
https://www.gnu.org/software/mit-scheme/documentation/mit-scheme-ref/Bit-Strings.html
>>
>>61643396
DAS IST NUMBERWANG
>>
>hey, cool post! here's a JS version of the code that's 20x as long and completely misses the point
Why do people do this?
>>
>>61643119
Thanks, you're probably right, either it was being recognized as a decimal or the binary number was having problems with the variables already declared in hex, I saved it all in hex and it worked flawlessly. See >>61642922
>>
Why do C++ programmers love boilerplate and useless get/set code so much?
>>
>>61643731
blame california
>>
>>61643731
Lenses are better than getters/setters
>>
>>61643522
Webshits want their autistic shit languages to be universal so they don't have to learn anything else.
>>
>>61643776
I see it done with Python and Go too, I don't think it's just webdevs.
>>
>>61643800
its shitlangs in general
>>
File: 1498698835066.gif (2MB, 460x259px) Image search: [Google]
1498698835066.gif
2MB, 460x259px
>>61643800
In their case, it's equally unwarranted, but the actual code is usually much better.
>>
>>61643764
>google "C++ lenses"
>first result has this example:

template <typename G,
typename S,
typename T = std::decay_t< typename function_traits<S>::result >,
typename F = std::decay_t< typename function_traits<G>::result >
>
class Lens {
private:
G getter;
S setter;
public:
// Constructor - provide getter and setter
Lens(G&& g, S&& s) : getter(std::forward<G>(g)), setter(std::forward<S>(s)) {}

// getter
F operator()(T holder) const { return getter(holder); };

// setter
T set(T holder, F&& value) const { return setter(holder, std::forward<F>(value)); }
T set(T holder, const F& value) const { return setter(holder, value); }
};


What the fuck is this rubbish? What's the rationale for its existence? Why would one use it?
>>
>>61643822
I meant Haskell lenses but I guess someone autistically tried it in C++ or something?
>>
>>61643822
The mentality of " C++ can do anything even if its unusable trash".
>>
>>61643857
See >>61643800 >>61643522
>>
>>61643822
>I can't understand extremely basic C++
>It must be rubbish
>>
>>61643878
>Why do C++ programmers love boilerplate and useless get/set code so much?
case in point
>>
>>61643878
Understanding != quality code
>>
File: consider.jpg (29KB, 600x600px) Image search: [Google]
consider.jpg
29KB, 600x600px
new thread
>>61643903
>>
>>61643875
If C++ were better you could embed the lens library in it.
It's much better than getters/setters.
You can compose them and everything.
They're first class values.

>>61643822
>>61643857
type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t


or in concise C++ code

template<typename s, typename t, typename a, typename b, template <typename> typename f> // the f is because we cant do forall
using Lens = std::function<f<t>(functor<f>,std::function<f<b>(a)>,s)>
>>
>>61643764
You know what's really fucking neato though? Modifying member variables directly and succinctly.
>>
>>61643916
Real concise.
>>
>>61643927
in a C like language I agree, but Lenses are much better and more generic

>>61643946
C++ is awful
>>
>>61643952
What could be more generic, I ask of you, than "p->n += 1234"?
>>
>>61644004
I can't think of a direct analogy since I don't know libraries that interface STRef/IORefs with Lenses, but if you're working in a state monad (you can imagine this as like having a single variable which is the entire environment) then you can do
p.n += 1234

in C code this would be like

environment.p.n += 1234
but the first bit is implicit
>>
Just saw that binary subtraction problem a few posts up.

Is it always fine to represent a binary number in two's complement form and just add, in order to solve a subtraction problem?

It should be fine, right?
>>
>>61644072
sounds like a load of old shit if you ask me

just like write program
>>
>>61644098
>just like write program
this attitude results in unmaintainable balls of mud
>>
>>61644098
it's not just mutable either though
you can say "create a new value which is the same as the old one (v) but with n set to 3"
set n 3 v
or
(n .= 3) v

or say
apply the sine function to the n member of the p member

p.n %= sin
>>
>>61644110
well it's not like i'm riffing off the idea of the flurry of boilerplate code that we saw in the above linked article, "lenses in C++14"

just like write program, i just want to write simple and clear code that does something useful. no mindwank, no C++ madness, no haskell bullshit.

>>61644142
wow this sounds like a really hot concept i have to get my hands on.
>>
>>61644186
>just like write program, i just want to write simple and clear code
Simple and clear code requires judicious planning, good understanding, and sensible choice of libraries/tools
>>
>>61644229
i know, friend. it requires the use of as many oddly-named concepts from category theory as possible.
Thread posts: 333
Thread images: 19


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