[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: 319
Thread images: 31

File: K&R hime2.png (1MB, 1280x720px) Image search: [Google]
K&R hime2.png
1MB, 1280x720px
old thread: >>56055124

What are you working on, /g/?
>>
File: &&.png (7KB, 272x130px) Image search: [Google]
&&.png
7KB, 272x130px
Haskell
>>
Still working on my C imageboard.
The actual web page displaying part isn't written yet.
>>
>>56061510
Why C?
>>
>>56061516
I don't want to learn PHP to write CGI scripts.

And node.js is gross.
>>
>>56061461
The correct sentences would be:
Why are you using malloc if you want to write C++?
>>
>>56061543
>it's another Cfag jealousy episode
>>
>>56061461
kill yourself
>>
>>56061534
>not using spring boot with h2 database and angularjs
Die
>>
File: 1467398868589.jpg (475KB, 852x973px) Image search: [Google]
1467398868589.jpg
475KB, 852x973px
>>56061626
You're >>56061475 , aren't you?
Do you not realise what the premise of this website is?
>>
>>56061649
>premise of this website
there's no such thing

every board is different
>>
I'm learning C. I get that other languages are easier, but realistically is there any reason I *shouldn't* be learning it? I'm hoping to go into game development but general software dev is fine as well. I figure the skills I learn are pretty language agnostic.
>>
>>56061668
>every board is different
All I see is shitposting anywhere I go so no. This is the thread where we shitpost about programming.

oop is good
>>
File: 1421164417027.png (342KB, 714x738px) Image search: [Google]
1421164417027.png
342KB, 714x738px
This thread is older and therefore legit
>>
>>56061649
>You're >>56061475 → , aren't you?
no
>>
>>56061818
(if i were, i would call it fag shit instead of weeb shit)
>>
File: tfw.png (427KB, 514x662px) Image search: [Google]
tfw.png
427KB, 514x662px
So what are you working on, /g/?
>>
>>56061682
Game development is usually C/C++(more C++) but there is stuff like Unity which uses C#.
>>
>>56061682
Learning C will make you hate other languages because they're so easy.
>>
>>56061510
I was going to write an imageboard in rust but got bored.
>>
>>56061682
C++ is more common for game dev and software in general
>>
>>56061893
>Learning C will make you hate other languages because they're so easy.
Wut? C is one of the easiest languages in existence.
>>
>>56061682
>>56061902
also the skills you learn in C are not very language agnostic because you'll be stuck in the C mindset and you probably won't understand the benefits of things like OOP
>>
>>56061921
Honestly, I dig learning new things/ways to make my programs more efficient or look cleaner, so I think I'd be fine if I moved to an OOP language.

Only one I've used before this is Python, and I wasn't taught "OOP" so much as I was taught "this is a class".
>>
>>56061976
>OOP
meme
>>
Can someone link me to a good article/book that explains corotuines in C++? I need to use them in my program, and I don't want to install a massive, bloated library.
>>
>>56062070
Visual studio has an experimental, non-standard extension for coroutines that microsoft are going to propose for C++19/20
>>
File: Kill me!.gif (2MB, 445x250px) Image search: [Google]
Kill me!.gif
2MB, 445x250px
>>56061461
Beginner.
Made a prime decomposition program in Python.
It first worked like a charm but then things started randomly breaking and I blindly added more stuff until I got this mess.
print('Lists all prime numbers in a number.')

negativeNumber = False

correctInput = False
while correctInput == False:
correctInput = True
n = input('Enter a number: ')

if n == '':
correctInput = False
print('...')
print('You didn\'t enter anything.')
print('Try again.')
continue

n = n.strip()

while n[0] == '-':
if negativeNumber == False:
negativeNumber = True
else:
negativeNumber = False

n = n.replace('-',' ',1)
n = n.lstrip()


for x in n:
if ord(x) == 44 or ord(x) == 46:
correctInput = False
print('I haven\'t implemented finding \
reciprocal prime numbers of decimals yet.')
break

if ord(x)<48 or ord(x)>57:
correctInput = False
print('Not a number.')
print('Try again.')
break

n = int(n)

if (n == 1 and negativeNumber == False) or n == 0:
print(str(n) + ' is ' + str(n) + '.')
print('What am I supposed to do with it?!')
else:
if negativeNumber == True and n != 0:
print('-1 (1)')
if n>1:
i = 2
counter = 0

while i <= n:
if n%i == 0:
counter = counter + 1
n = int(n/i)
else:
if counter != 0:
print(i,' (', counter, ')', sep='')
counter = 0
i = i+1

print(i,' (', counter, ')', sep='')

if n>1:
print(n, '(1)')

Also, why aren't there shortcuts for code and math tags?

Also been reading my SICP. Got stuck on exercise 1.5.
Miffed that I had to look up the answer. I sort of get it now but not really.
>>
Why is the ternary operator ?: not more popular?
>>
>>56062116
More limited use than if/else if/else, as it can only really do if/else which is less common in larger programs (you're more likely to want else if as well).
>>
>>56062083
>things started randomly breaking and I blindly added more stuff until I got this mess.
And thus you learned the value of versioning. What breaks exactly?
>>
>>56062116
Because people abuse it.
>>
>>56062083
>It first worked like a charm but then things started randomly breaking and I blindly added more stuff until I got this mess.
P Y T H O N
Y
T
H
O
N
>>
>>56062083
is the gif 60 fps or 30? looks smooth
>>
>>56062083
>ord(x) == 44
Fucksake this is harder to read and to write, just use
x == ","
pls.
>inb4 yes it's legit in Python
>>
File: patrick-star-hammer-jpg.jpg (8KB, 184x274px) Image search: [Google]
patrick-star-hammer-jpg.jpg
8KB, 184x274px
>>56062082
But I'm using Code Blocks.
>>
>>56061488
Haskell confirmed a table of truth
>>
>>56062083
>
negativeNumber  = False

Fuckssake, int does this builtin
>>
>>56061510
Way C, use a real language, Moo! language
>>
>>56062168
30 ms per frame according to gimp so 33 fps
>>
>>56062083
SICP 1.5:

We have:
(define (p) (p))

(define (test x y)
(if (= x 0)
0
y))


Now the question is what would be the difference in evaluating
(test 0 (p))
under applicative order and normal order.

Applicative order means that you evaluate the arguments and then substitute the results in the definition. Normal order means you just subtitute, no evaluation.

So under normal order we get:
(if (= 0 0)
0
(p))

The 'if' statement will evaluate the first argument, and depending on the result evaluate either the second or third argument and have that be the result of the 'if' statement. 0 is indeed 0, so it evalutates to the second argument of the 'if' which is 0.

However under applicative order, something else happens. The arguments are first evaluated before they are substituted. The first argument is 0 which evaluates to 0 and is substituted. The second argument is (p) which evaluates to (p) which evaluates to (p) which evaluates to (p) etc.

So the arguments are never evaluated because evaluating (p) is an endless cycle, and the command will never be fully evaluated.
>>
>>56062133
>What breaks exactly?
Well, it's basically the printing of answers: I originally had it just spew out 2s, 3s, 5s and the rest of the prime numbers before clumping them in a primeNumber (numberOfOccurences) fashion.
When I decided to change it, the last prime wasn't printing. I didn't give it much thought, changing this, that and the other.
And then, after a while, I changed the
while i <= halfN:
to what it is now, for less needless computing, which threw a similar spanner in the works again.
In the end, it makes sense why it didn't work later on but it now makes me wonder how it ever worked in the first place.

>>56062168
It's 33.333...fps.
Or, rather, 30ms per frame.

>>56062185
Sorry. Bad habit from trying to cycle through characters with for loops.
>>
>What are you working on, /g/?
just finished type inference (minus some of the more advanced features, which come later down the pipeline)
i guess it's time to make the lexer and parser? ill probably hold off until later today to work on that, but it feels nice having this much of my compiler done so far. plus im extra happy because i cleaned up all the really ugly parts of my type system with the last couple commits, so it should be a lot nicer to extend in the future
>>
File: gdt.png (19KB, 281x41px) Image search: [Google]
gdt.png
19KB, 281x41px
So close
>>
Coding is fun and challenging
I am right now learning about value methods in java.
I have not always the time to sit down and code.
Nonetheless I want to learn more about programming better and understand it more deeply.
As I am learning Java, I really want to concentrate myself on this language for now and get used to the new features, I am looking for something I can read on the go.

Do you have any good texts and links I could inform myself?
>>
>>56062417
are you messing with ASLR or something?
>>
>>56062657
Trying to generate proper GDT entries for a kernel.
>>
>>56062644
k&r, you fucking pajeet
>>
File: Whoa_Keanu Reeves.jpg (16KB, 299x274px) Image search: [Google]
Whoa_Keanu Reeves.jpg
16KB, 299x274px
>>56062224
>int does this builtin
Would that be the __ge__(0) method? I don't see one specifically dedicated to giving a boolean depending on whether the integer is positive or negative.
Regardless, at that point, I was still working with the input as a string (because I'm too stupid to try/throw/catch exceptions to check user input): it's easier to scan the beginning of the string for dashes and weed out non-numerals further along than to... I don't know how else to do it.

>>56062332
>In applicative order evaluation, you evaluate the arguments and then substitute the results in the definition
>you evaluate the arguments (the x y of (test x y)) before substituting
>In normal order evaluation, you substitute first
>Which means, when running test under normal order evaluation, you don't get to (p)
I think I get it now although I'll likely need to reread the bit about applicative-order and normal-order evaluations again.
>>
File: gdt2.png (19KB, 283x48px) Image search: [Google]
gdt2.png
19KB, 283x48px
>>56062417
and, bingo!
>>
Xinu based OS project. Porting a lot of old code from OSDev followings. Probably going to do PE instead of elf as I have a PE bootloader finished.
>>
>>56061461
>2016
>putting the burden of memory management on the programmer

Absolutely disgusting.
>>
Is it realistic to use IPFS as a video streaming platform?
>>
File: 1458139789336.jpg (105KB, 640x480px) Image search: [Google]
1458139789336.jpg
105KB, 640x480px
i = 100000000

while i:
i -= 1


$ time python test.py
python test.py 12.07s user 0.00s system 99% cpu 12.092 total


kore i wa 100000000 desu

while i
{
kore i wa i - 1 desu
}

$ time ./interpreter test.fs
./interpreter test.fs 7.90s user 0.92s system 99% cpu 8.823 total


>tfw even your shitty inefficient toy language is faster than Python
>>
How do i write c++ code in c style? I need a static global variable, but i really don't want to make any ever again.
>>
>>56062905
>$ time python test.py
>python test.py 12.07s user 0.00s system 99% cpu 12.092 total
that's not how you benchmark a script, you dumbass
>>
>>56062905
Noice, weeb.
>>
>>56062905
Well you're talking about the language that had to iterate over an array of numbers in a for loop at one point.
>>
>>56062935
I know.
I just implemented while loops and wanted to get some idea about the performance of my interpreter.
>>
Hey lads I'm learning C right now and got confused by something involving main.

How come I can write main() { ... } without int or void and have it compile fine?

I can't tell if I'm using C90 or C99 which are different apparently or if they affect anything
>>
>>56062958
But that's the proper way to iterate over arrays.
>>
>>56062972
convenience
sometimes you just want to write a shitty toy program and the function declaration would be longer than the program
>>
>>56062860
...And I lost the code to the bootloader.
>>
>>56062983
i think he's talking about it actually creating an array of numbers which it then iterated over, just having a for loop could make it crash from running out of memory
>>
>>56063039
Oh, lol.
>>
>>56062993

It's technically not allowed but GCC isn't strict because it kept compatibility to compile stuff from before C89 back in K&R C. The standard only explicitly states two signatures and any equivalent as long as it doesn't break the standard is also allowed.
>>
>>56062983
Most languages:
>int i = 0; int i < 5000; i++
>checks if i < 5000 and increments it

Python:
>for i in range(0,5000)
>creates an array [0,1,2,...,4998,4999] and iterates over it
>>
>>56062070
Anyone?
>>
>>56063095
kek
>>
>>56063095
It actually doesn't do that anymore in 3.x, unless you specifically ask for it
>>
>>56063095
up to version 2, but that's a good point.
just use xrange, but that's a stupid default. And python is pretty stupid in general.
>>
>>56063084
this compiles even with -std=c90 -pedantic
main(i)
{
i = 100000000;
while (i--);
}
>>
>>56063105
do you know what google is, you fucking retard

>google for me pls
>>
Can you do an algorithm thingy even if you are not inside a data structure packet container linked to the server client model server asynchronously?
>>
>>56063105
That's because there are no builtin coroutines in C++. You can have coroutines, but only with a huge library that leverages platform-specific shit. If you want to read about this, the doc for Boost.Coroutine explains what it's doing under the hood very well IMHO, so go read that, it's most probably the best you can get.
>>
>>56063206
Fuuuuuuck. I don't wanna use Boost.
Oh well, thanks anon.
>>
File: lao-tzu.png (135KB, 300x273px) Image search: [Google]
lao-tzu.png
135KB, 300x273px
>>56063215
Boost it a tool, therefore using it isn't automatically bad ; abusing it is.
>>
>>56063095
Hahaha oh wow
>>
>>56063250
Using boost is the same as abusing boost.
>>
File: Untitled.png (48KB, 1366x651px) Image search: [Google]
Untitled.png
48KB, 1366x651px
Nothing right now. Kind of "finished" consuming an api a week ago. It does what it does(Searching jobs in Sweden via the swedish employment office).
What do you think about the user interface?

I'm aware that the dates in listview aren't formatted. Just too lazy for that.

The method populating the listview is embedded in another thread because the frame freezed when consuming the api.

This is created in JavaFx.

Do you have any advice what to do next? Something thread heavily and useful would be great.
>>
>>56062905
>not using recursion
>>
Who /codetriage/ here?
>>
>>56062972
It's a leftover from pre-standard C.

Functions with no return type used to mean int, but I think that since c99 this is not the case?
>>
>>56063462
Please, it's not THAT much of a toy language.
>>
>>56062983
map
>>
>>56063499
map isn't iteration, you want fold
>>
>>56063484
The fact that you have implemented while loops as a basic functionality just shows that it is a toy language
>>
>>56063525
>while loops
>toy
Go back to "programming" your recursive fibonacci in Haskell please.
>>
>>56063555
Nah, too easy.
>>
if i install a debugger plugin on sublime text that calls itself a ruby debugger, does that mean that it won't work at all for other languages?
I'd like a debugger for C, C++, Java and/or python that allows me to click on the line number to set breakpoints and that shows me the value of each variable for every step.
>>
>>56063584
Just use an IDE.
>>
>>56063555
in Haskell loops et all are just higher order functions
>>
>>56061534
You know, this is why Ken Thompson, Rob Pike and Robert Griesemer created Go.

Each individual writes better C than all of /g/ combined several times over, but they know it isn't the best tool to write web servers and that all other alternatives are bloated shit, overengineered or incomplete.
>>
Fun fact: Go literally has no reason of existence.
>>
>>56063584
>it won't work at all for other languages?
The plugin? No it won't. Sublime? Yes it will. It can handle it; don't be stupid. Also note that it deprives you of your freedoms.
>>
>>56061921
>and you probably won't understand the benefits of things like OOP

Which kind of OOP? Inheritance-based OOP is only really useful in a very, very limited amount of situations, and 90% of that is UI and video games (things where you have clear-cut entities, and even then that's no excuse to use it everywhere in those types of software).

Functional and imperative people usually recognize that OOP can help in those situations, while OOP people try to hammer OOP into every fucking thing out there.
>>
>>56063613
Go was designed for people who aren't capable of understanding better languages.
>>
>>56063666
>Which kind of OOP?
Java and C#, duh. OOP is the best solution to 99.993% of programming problems.
>>
>>56063715
this
>>
Anybody here use Geany for Python and C++?
>>
>>56063735
No, what is that?
>>
>>56063735
sounds g a y
>>
>>56063735
why would you? there are plenty of better text editors
>>
>>56063735
Use emacs or vim, I don't even care which
>>
So where do I start with programming
>>
>>56063903
put on a skirt and read K&R
>>
>>56063876
nvim is definite GOAT
>>
>>56063903
What do you want to do with programming
>>
>>56063640
>languages needs reasons to exist
I could argue that langs need to be productive, and that haskell would dissapear overnight.
>>
>>56063945
>languages need reasons to exist
Correct!
>>
I have these two functions written in Java and i'm looking for PHP implementations for both such that data can be encrypted/decrypted by both PHP and JAVA interchangeably.
public static String encrypt(byte[] publicKey, String data) throws Exception {
Cipher cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.ENCRYPT_MODE, KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(publicKey)));
return DatatypeConverter.printHexBinary(cipher.doFinal(data.getBytes(Charset.forName("UTF-8"))));
}

public static String decrypt(byte[] privateKey, String encrypted) throws Exception {
Cipher cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.DECRYPT_MODE, KeyFactory.getInstance("RSA").generatePrivate(new PKCS8EncodedKeySpec(privateKey)));
return new String(cipher.doFinal(DatatypeConverter.parseHexBinary(encrypted)), Charset.forName("UTF-8"));
}
>>
>>56063945
Haskell is more productive than go will ever be
>>
>>56063929
Make shitty games for fun
>>
>>56063925
evil mode, friend
>>
>>56063964
>>>/vg/agdg
>>
>>56063956
http://lmgtfy.com/?q=php+rsa
>>
Anons what is the best resource for learning C (including advanced stuff idk t b h)?

I tried the second edition book but it felt useless and unnecessary.

I already know the basics, but never went past structs or pointers
>>
>>56063964
C++ or C# are good for that. Couldn't rec any good resources because I don't know either, but they'd be a good start
>>
>>56063994
cs50 has some stuff about data structures as well, after that idk
>>
>>56063994
learn about data structures and algorithms and start some projects that sound difficult
>>
File: helm-spacemacs.png (31KB, 1600x374px) Image search: [Google]
helm-spacemacs.png
31KB, 1600x374px
>>56063978
Slow and buggy. Not joking, I have used and venerated Emacs for a long time, but it's irremediably unsalvageable with regards to that. We just need to let go and move on. And I did. May Gnu bless your computer my child.
>>
Still doing sicp again to brush up on lisp.

Yawn.. Definitely haven't done anything lisp related in a long period of time.

(define (f n)

(define (f-process n)
(+ (f (- n 1))
(* 2 (f (- n 2)))
(* 3 (f (- n 3)))))

(if (< n 3)
n
(f-process n)))

(define (f-iterative n)
(define (f-iter a b c count)
(if (< count 3)
a
(f-iter (+ a (* 2 b) (* 3 c))
a
b
(- count 1))))
(if (< n 3)
n
(f-iter 2 1 0 n)))
>>
>>56064067
Are you using MIT/GNU Scheme, Racket, or something else?
>>
File: 1440279254349.jpg (131KB, 1280x720px) Image search: [Google]
1440279254349.jpg
131KB, 1280x720px
What university are you studying/plan to study at?
>>
>>56064096

Racket currently
>>
>>56064119
Is it comfy?
>>
>>56064108
I studied System Science at Lund University.
Working as a programmer.
>>
>>56064108
Illinois State, got enough credits to graduate a year early
>feelsgoodman.jpg
>>
File: ;D.png (57KB, 800x334px) Image search: [Google]
;D.png
57KB, 800x334px
>>56064108
nichijou university
>>
>>56064130
Kevin?
>>
>>56064127

It's simple and trivial to set up. Kinda wish I had vim configured to do highlight the scope of parenthesis like Dr. Racket does instead of just the starting + ending brace.
>>
>>56064162
Naw
I'm going into InfoSec and am going to graduate this year
>>
>>56064179

to do highlighting of the scope of parenthesis*

I am apparently not able to write my native language today.
>>
>>56063957
hahahHAAHHAHA
oh man, /dpt/ is surely fantasy land
>>
>>56064217

No /dpt/ is full of haskell shills that worship the language like a religion.

If they like monad that much then gnosticism might be the answer.
>>
File: 084.png (102KB, 300x256px) Image search: [Google]
084.png
102KB, 300x256px
>>56063957
>Haskell is more productive than go will ever be
>>
>>56064108
Stumbled my way to a Bachelor's degree through Georgia Southern's CompSci program. Jesus FUCK that department was unorganized. Came out feeling very insecure with my skillset, and I'm still kicking myself for not realizing how important it is to get an internship before graduating. So now I'm trying to build up a portfolio while hunting for a part-time job.

Speaking of, can anyone recommend a good book on computer grafics, preferably one that's language-independent?
>>
There are a few people in this thread that do nothing but talk about how much they hate Haskell

Imagine being so deprived
>>
>>56064287
stay delusional
>>
>>56064297
Stay delusional
>>
>>56064297
The fact you replied proves my point, that you exist
>>
>>56062224
Here. Condensed version.
print('Lists all prime numbers in a number.')

correctInput = False
while correctInput == False:
try:
n = int(input('Enter a number: '))

if n == 1 or n == 0:
raise ValueError

correctInput = True
except ValueError:
print('Not having that input, sonny Jim.')
print('Try again.')

if n<0:
print('-1 (1)')
n = -n

i = 2
counter = 0

if n>1:
while i <= n:
if n%i == 0:
counter = counter + 1
n = int(n/i)
else:
if counter != 0:
print(i,' (', counter, ')', sep='')
counter = 0
i = i+1

print(i,' (', counter, ')', sep='')

if n>1:
print(n, '(1)')
>>
>>56064287
daily programming general != haskell hate general
>>
>>56064312
(You)
>>
>>56064316
>python

>>56064321
it's not general it's a daily thread
there's a huge difference

>>56064326
You're doing it wrong
>>
>>56064217
>>56064249
>>56064260
Haskell has generics, HKTs, typeclasses, type inference, tail call optimization, along with many other things. Go doesn't. You're forced to write many more lines of code in go than in Haskell.

I think go should never have existed. It has brought nothing to the table but misery, anguish, and woe.
>>
>>56064287
>There are a few people in this thread that do nothing but talk about how much they hate Haskell
are you stupid? the only ones spewing hate are the ones criticizing other langs for existing. just look at this: >>56063640
idgaf if you use go, haskell or whatever the shit, but telling other people to not learn/use certain lang because you don't like it and therefore no one should is absolutely retarded
>>
>>56064337
>it's not general
Then stop trying to make it into one.
>>
>>56063957
>liking Haskell

Enjoy your non-googleable hieroglyphs that you can't even read out loud to yourself, or anybody else. Even if Haskell could have been this great, pure savior of functional programming languages, those bullshit operators are standing in the way of Haskell gaining any meaningful usability.
>>
>>56064348
just because you write fewer lines of code in haskell doesn't mean it isn't shit

>>56064337
>>python
so hating on python is better than hating on haskell? protip: they're both shit
>>
>>56064352
>just look at this: >>56063640 (You)
It's fact however, there is no reason to use Go at all.
>>
>>56064348
Go wanted to be a systems programming language. Now it tries to be a web server language. Too bad the language and standard library are complete shit. Look at all the 3rd party replacements for the net/http package and you'll realize how bad the standard library is.
>>
>>56064352
Maybe you should read my post again, your reply doesn't make much sense. It's like you're trying to argue with me by agreeing

>>56064367
Yes, there are a variety of reasons to dislike Python which I've gone over again and again and again and again and again, but the people that come here to hate on Haskell ONLY do it because it's a running meme. They don't actually know anything about Haskell.
>>
>>56064365
Nobody still can explain what monads are, lol.
>>
what do the people who use haskell use it for?
>>
>>56064401
they write python compilers
>>
>>56064398
For instance, if you wanted to attack Haskell you'd start by complaining about performance. Not productivity. Haskell can be a very productive language, and the low LOC count shows that.
>>
>>56064401
Posing about it on /g/
>>
Should I stick to an 80 character limit?
>>
>>56064422
yes
>>
File: 1463053894024.gif (1022KB, 640x480px) Image search: [Google]
1463053894024.gif
1022KB, 640x480px
>>56064414
>Haskell can be a very productive language, and the low LOC count shows that.
>>
>>56064422
no
>>
>>56064444
Nice argument, I really like all the points you made in this post
>>
>>56064365
>non-googleable hieroglyphs
That's what hoogle is for.

>read out loud to yourself
Do you read your code out loud to yourself?

Symbolic operators in Haskell are no different to the ones you're used to in other languages, like +, &&, ^, etc. You learnt those, you can learn others too. Nobody going into programming for the first time knows what || means.

>>56064367
Less code means fewer places for bugs to reside, and also, why would I do work that I get the compiler to do for me?
>>
>>56064422
in most cases, yes, but i think going up to 120 occasionally is fine, for example if it's obvious from the context what the line is doing so that it doesn't need to be super-convenient to read.
>>
>>56064456
kill yourself idiot
>>
>>56064399
They're monoids in the category of endofunctors.

Alternatively, they're a typeclass with some associated laws.
>>
File: monads.png (13KB, 300x225px) Image search: [Google]
monads.png
13KB, 300x225px
>>56064399
Monads are applicative functors with a join operation, you can think of them as types of effectful computations
>>
>>56064485
>kill yourself idiot
Excuse me?
>>
File: haskell.png (12KB, 225x321px) Image search: [Google]
haskell.png
12KB, 225x321px
>>
>>56064287
You guys love feeling persecuted, huh
>>
>>56064401
i used it for text manipulation when was beginning learning it, it has nice functions for that :^)

it's really great for interpreters/compilers because of algebraic data types and pattern matching
>>
>>56064414
Haskell's performance is often better than languages such as Ruby and Python, though. It can't quite compete with C and C++ in many cases yet, but it comfortably beats many dynamic languages.
>>
>>56064526
so true fâm!! 100
>>
>>56064542
>performance is often better than languages such as Ruby and Python
So it runs like trash?
>>
>>56064564
Nope. I would suggest that you actually try Haskell, but you would need to learn to read first.
>>
>>56064526
They're right about people resorting to memes to attack Haskell
>>
There are a few people in this thread that do nothing but talk about how much they love Haskell

Imagine being so deprived
>>
>>56064589
damn...
>>
>>56064589
I do program in Haskell

>>56064598
No, we talk about what we're doing in Haskell
We don't write posts that are just "haskellfags btfo xd #rekt"
>>
>>56064598
People often shit on Haskell and later end up copying its innovations, and this thread is no different.
>>
>>56064614
>>56064618
the delusion is real
>>
>>56064637
Once again a condescending post with no points whatsoever. What are your grievances with Haskell?
>>
File: sad penguin.png (120KB, 284x339px) Image search: [Google]
sad penguin.png
120KB, 284x339px
Moving to new city for a job.

I'm scared of being alone ):
>>
Just revive the functional programming general and fuck off.

This shit is becoming unbearable.
>>
>>56064618
>Haskell invented all the good things that other languages stole!

Amazing.
>>
>>56064655
You're the fucking problem, all you do is spam the thread with your bullshit and then cry when people actually reply to you and ask you to defend your position

What is wrong with Haskell?
>>
>>56064655
There's no need, functional programming is programming.
>>
http://www.strawpoll.me/10985214
>>
>>56064681
Who are you quoting?
>>
>>56064647
>What are your grievances with Haskell?
Its users are pedantic, autistic, and on the whole quite irritating.
>>
>>56064688
Oh, a strawpoll
Wow, well done
Congratulations

You couldn't even think of one point, could you?
>>
>>56064652
*Sends internet hugs*
>>
>>56064681
I didn't say that, though. That's a strawman.
>>
>>56064703
>pedantic
such as?

>autistic
where do you think you are?

>irritating
i find the anti haskell posters irritating
>>
>>56064618
>this thread copied haskell
wat
>>
>>56064703
Not an argument
>>
this thread is so fucking shit fuck off with your fucking haskell and trap fag shit
>>
>>56064652
you have us anon, don't be sad.
>>
Also
>basing an entire community off of /g/
It's just like Arch Linux
>>
>>56064725
Anti-Haskellers copied and adapted a pro-Haskell post, presumably because it was better than anything they could come up with by themselves.

It's amazing how today's mainstream language features were last decade's impractical academic ivory tower curiosities.
>>
>>56064652
>I'm scared of being alone ):
you're with you, though.

you're not alone.
>>
>>56063250
boost abuses YOU. A massive library that you only need 1 fucntion from
>>
File: 1455217692734.jpg (121KB, 2032x820px) Image search: [Google]
1455217692734.jpg
121KB, 2032x820px
>>56064782
>>
>>56064764
Your post, on the other hand, contributes greatly to the thread.
>>
Neat pthread macro for gcc:

#define thread(ARG) ({ \
pthread_t _inpar_thread_temp; \
auto void* _inpar_thread_func(void* arg); \
pthread_create(&_inpar_thread_temp, NULL, &_inpar_thread_func, (ARG)); \
void *_inpar_thread_func(void* arg) \

#define endthread _inpar_thread_temp; })


Example:
int main(void) {
pthread_t foo = thread("foo") {
char* str = (char*) arg;

printf("Thread #%u says: %s\n", pthread_self(), str);
return NULL;
} endthread;

pthread_join(foo, NULL);

return 0;
}
>>
>>56064815
(You)
>>
>>56064812
TIL noticing patterns is autistic
>>
everyone please stop replying to each other

unless you're contributing to this fucking thread

>>56064828
>auto void*
What does this do?
>>
File: 1426782082333.jpg (26KB, 500x600px) Image search: [Google]
1426782082333.jpg
26KB, 500x600px
>tfw to smart for OOP
>>
>>56064838
>TIL
fuck off back to r/haskell fucking shit tard
>>
>>56064847
You might be illiterate, but you are indeed too smart for OOP.
>>
File: anime.png (201KB, 335x365px) Image search: [Google]
anime.png
201KB, 335x365px
>>56064847
Are you part of the procedural master race?
>>
>>56064861
nice meme smug fag
>>
>>56064846
Literally nothing, no idea why that's there. auto is implicitly there in all declarations in C
>>
>>56064855
TIL how to trigger 4chan
>>
>and now instead of admitting they had no legitimate points against Haskell, they're just going to continue thinking the Haskell community is just full of pretentious fags for defending their language
>>
>>56064697
>>56064714
>y-you made that up!

Sure thing, fuckheads. It's exactly what was implied.
>>
>>56064847
>tfw 2 smart 4 every paradigm
>>
File: existentially quantified types.png (8KB, 555x202px) Image search: [Google]
existentially quantified types.png
8KB, 555x202px
>>56064876
please fuck off and stop ruining our reputation


t. haskellfags
>>
>>56064828
// file.c
// compile with gcc file.c -lpthread

#include <stdio.h>
#include <pthread.h>

#define thread(ARG) ({ \
pthread_t _inpar_thread_temp; \
auto void* _inpar_thread_func(void* arg); \
pthread_create(&_inpar_thread_temp, NULL, &_inpar_thread_func, (ARG)); \
void *_inpar_thread_func(void* arg) \

#define endthread _inpar_thread_temp; })

int main(void) {
pthread_t foo = thread("foo") {
char* str = (char*) arg;

printf("Thread #%lu says: %s\n", pthread_self(), str);
return NULL;
} endthread;

pthread_join(foo, NULL);

return 0;
}
>>
>>56064872
Enjoy your dying paradigm, Pajeet
>>
>>56064894
this, even haskellfags can be ok if you don't act like such insufferable spergs about it
>>
>>56064873
doesn't compile without it

>>56064846
Not sure entirely, but if you take it out it gives this error:
error: static declaration of ‘_inpar_thread_func’ follows non-static declaration
void *_inpar_thread_func(void* arg) \
>>
>>56064887
He didn't say Haskell created every good language feature like you were implying though, just that other languages tend to take features from Haskell
>>
>>56064898
you're pathetic

>>56063666
>Functional and imperative people usually recognize that OOP can help in those situations
>>
>>56064887
No, it wasn't. You're being delusional again. I stated an existential, you are inferring a universal.

>>56064894
I'm on your side, friend.
>>
File: JUST.png (56KB, 625x333px) Image search: [Google]
JUST.png
56KB, 625x333px
JUST
>>
>>56063666
>Just use OOP family
>666

>>56064927
>I'm on your side, friend.
no you are not
>>
>>56064935
nice meme
>>
>>56064925
You can't write English properly.

OOP is snake oil and only helps bad programmers. I'm sorry you wasted part of your life on it.
>>
>>56064946
here's your (You)
>>
how do you become a better programmer? leetcode is tough as fuck. I guess I am looking to be a better algorithm solver.
>>
>>56064927
>I stated an existential, you are inferring a universal.

This is a conversation, not a logic proof. What you said and what you meant are two different things.
>>
>>56064967
he wasn't alone
>>
>>56064961
Thank you, good fellow. Every little helps in the battle against ignorance.
>>
>>56064967
lots of practice and research
>>
>>56064946
>I'm sorry you wasted part of your life on it.
Is this how haskellites think? No wonder they're so quick to defend their useless lang.
>>
>>56064967
By not doing those problems and actually making things.

You don't often run into complex algorithm problems with most software.
>>
>>56064987
huh.. excuse me?
>>
>>56064976
Your paranoid fantasies are getting the better of you. >>56064921 has the right of it.
>>
>>56064987
He didn't even say if he used Haskell
>and somehow they're the issue
>>
>>56064987
I hate to see human potential wasted fighting against useless, crippled tools.
>>
>>56065000

None of haskell's features are unique, so it can't be that features are "taken" from haskell.
>>
>>56064946
That's not true. OOP with caution is actually quite helpful. As long as you stay away from things like multiple inheritance and bad practices its nice. You put OOP development in the hand of a bad programmer and you get a cluster fuck. So no, it really isn't for bad programmers.
>>
>>56065033
type classes
>>
>>56065033
are you 28 years old?
>>
>>56065053
classes
>>
>>56065066
they're not the same thing
>>
>>56065077
i was just following directions
>>
File: sht just got real_.gif (1MB, 300x214px) Image search: [Google]
sht just got real_.gif
1MB, 300x214px
>>56065060
>>
So. When Trump fixes the H1B (lol) will I be able to get hired in the US instead of the Indians? Because it's clear you need better software devs. And I'd be interested in working there. But with the current state of things you need specialist knowledge to get a job.
>>
>>56065033
They assuredly can. A feature can be invented somewhere, popularized by Haskell, than copied from the Haskell implementation by another language.

I'm not saying Haskell doesn't copy from further up the chain. The difference is that Haskell users aren't so inconsistent as to decry a feature as useless only until it comes to their language.
>>
>>56065103
Are you retarded? The indians that work for US companies don't live in the US.
>>
How to get the memory address of the metadata of some file? What C++ libraries and methods are available for that?
>>
>>56065112
>The difference is that Haskell users aren't so inconsistent as to decry a feature as useless only until it comes to their language.

Does anyone do that? I'm always happy when C# gets new functional features (which are, assuredly, not from Haskell).
>>
>>56064995
This.
Making real software teaches you more than random algorithms do. Even in trivial software you have to architect it well. Which is a process where you challenge yourself more as you get better.
>>
>>56065129
Depends on the file. Learn the file format. Usually you have a header which defines a chain of links (in the case of wav) or offsets in the file. Somewhere there you should find a way to find the metadata.
>>
>>56065179
OH and if it's Id3. http://id3.org/id3v2.3.0
>>
>>56065137
I congratulate you on being open-minded, and not obviously falling victim to the Blub paradox.

But yes, there were, let's say, mixed feelings regarding adding Optional (inspired by Haskell, either directly or indirectly through Scala) to Java, and also adding lambdas (certainly not inspired by Haskell, because its are much more pleasant to work with). Unfortunately, due to disagreements, neither feature has been implemented satisfactorily in my opinion.
>>
>>56065129
I wrote a memmem() function for this express purpose.

Usually, these metadata tags have a magic number, which is a sequence of bytes (usually ASCII characters) that identify the start of the tag.

ID3 tags are identified with 0x73, 0x44, 0x33 at the start.
>>
>>56065042
>OOP
honestly I think people in support of OOP mainly just mean OP. object programming. Being object oriented is hell and I can't sympathise with anyone who argues it's OK.
>>
File: vectormerging.png (31KB, 820x295px) Image search: [Google]
vectormerging.png
31KB, 820x295px
I have a quite complex problem trying to merge two vectors in O(n log n). (Pic related)

Just asking if anyone would be interested in trying to help me solve this. Basically its a C++ implementation of the algorithm outlined in this paper.

https://www.researchgate.net/publication/220089386_Improved_Dynamic_Programming_in_Connection_with_an_FPTAS_for_the_Knapsack_Problem

I feel like I'm pretty close to finishing it but there are some things I still struggle with.

I managed to implement a version that does calculate the solution but takes O(n^2) instead of O(n log n)

Gonna dump the rest or whatever if someone replies to this post. Maybe with e-mail/contact info
>>
File: 1430853197680.png (331KB, 474x432px) Image search: [Google]
1430853197680.png
331KB, 474x432px
>>56065227
>muh lambdas
>>
>>56065299
wtf I hate lambdas now
>>
>>56065273
There's no difference and you're an idiot.
>>
The origins of haskell

https://gnosticteachings.org/glossary/m/2635-monad.html
>>
>>56065299
Shit, guess I better go write Ruby or some shit
>>
why are these threads so shitty
>>
>>56061534
Better ideas: Go, Python, Java, C#.

I can totally agree with wanting PHP to fuck off.
>>
>>56065352
Your post is the shittiest part, kid
>>
>>56065335
In one case you couple your data with methods sometimes. You use this pointers sometimes.

In the other you plan your software from the view of there being objects which are pieces of data which act upon themselves alone, you rely on objects for encapsulation, you write managers, you pass messages, you do a lot of stuff. If you don't do that stuff you're not doing OOP.

Maybe you should consider if you're the idiot.
>>
>>56065361
Even better: Haskell
>>
Another text for the truly dedicated Haskell user!

http://www.sacred-texts.com/chr/herm/hermes4.htm
>>
>>56065352
you're on 4chan
>>
>>56065383
Even betterer: Elm
>>
Explain to me why Python is bad.

>>56065383
...for web? I haven't heard of that being a thing.
>>
>>56065295
well what have you done so far?
>>
>>56065352

A thread's value is directly related to the amount of haskell posts.

Generally the more haskell there is in a thread the more shit posts and useless junk increases.

I blame the average haskell user's insistent urge to forcibly convert anyone around into their religion.
>>
>>56065371
It seems we're solely talking about the semantics of the word object oriented now. You must love haskell.
>>
>>56065396
I assume he's writing server-side code, given he originally mentioned C.

>>56065408
There's Spock and Scotty:

https://github.com/scotty-web/scotty-starter
https://www.spock.li
>>
>>56065227

Optional is a nice addition, but like streams, a bit half baked.

I think Rust did a much better job of it, despite a considerable portion of language being nightmarish.
>>
>>56065444
Nah I haven't even used it. But OOP is well defined, there's plenty of books on the programming principle. Maybe you can look at Wikipedia and educate yourself.
>>
>>56065435
DESU the reason I'm annoyed by Haskell fans is they'll, on a regular basis, shit on other languages for just not being Haskell.

Like, people will say "I wanna use C#, is that a good idea?" and they'll get at least two responses saying
>no higher-kinded types
>no functional purity
>no Tail Call Optimization
>mutable state everywhere
"might as well use Brainfuck senpai"

I get it, your language is cool and you like it. Don't try to imply that it's literally the only language that could be considered good, though. That's bullshit.
>>
>>56065480
Agreed. The bit that drives me nuts whenever I have to deal with Java code is that they didn't make Optional serializable. (Yes, I know, Java serialization is bad, I'm not always in control of whether I have to use it.)
>>
>>56065411
Basically implemented the Pseudocode or whatever given there. But it doesn't seem to make any sense as it assigns values like this (might check that algorithm out in figure 2):
a[1] = 1
b[1] = n
last = 1
for (i=2;i<n;i++) {
if(somethingthatistruesometimes) {
j=a[last];
}
while(j>=i aka never) {
}
if(j>=i aka never) {
} else {
b[last] = i-1
a[i] = i
}
last = i
}
end for



So j will always be < i as a[i] always gets assigned the value of the previous iteration
>>
>>56064687
No it isn't.
It's just stupid monkey wankery.
>>
>>56064935
>is bad reddit
yes and you have to go back
>>
>>56065523

I didn't know that (don't deal with serialization a lot, and mostly deal with null-everywhere legacy code), but I'm not seriously surprised by it, either. Apparently the Java Expert group considered and summarily rejected the idea.

Here's the rub:
>The JSR-335 EG felt fairly strongly that Optional should not be on any more than needed to support the optional-return idiom only.

I thought we were supposed to use these new fancy features on a design level? What happened to that?
>>
>>56065506

It's literally a religious movement.

I mean it couldn't be more obvious:
Monad,
Cabal,
Yesod

References to various "Illuminated one" / Gnostic / Kabbalah concepts are everywhere in the language and its community.
>>
>>56065568
I fucked up the indentation
a[1] = 1
b[1] = n
last = 1
for (i=2;i<n;i++) {
if(somethingthatistruesometimes) {
j=a[last];
while(j>=i aka never) {
}
if(j>=i aka never) {
} else {
b[last] = i-1
a[i] = i
}
last = i
}
}
>>
>>56065568
let me just ask this: why are you trying to implement this algorithm?

are you trying to solve a variant of knapsack problem, but it takes too much time and you decide to find a algorithm which performs better?
>>
>>56065587
Perhaps it's best not to know the possibly Lovecraftian answers to those questions.

What I do know is it means I have to convert to and from representations of classes that use nullable fields instead of Optional whenever serializing/deserializing. Thanks, Java.
>>
>>56065646
Just trying to implement a couple algorithm variants to solve it and then comparing their runtimes on different problem instances
>>
>>56065601
>Illuminated one
Ah, the great Kmett.
>>
>>56064894
>quantifying on show instead of showsPrec
Literally retarded.
>>
File: Screenshot_2016-08-13_22-24-16.png (73KB, 897x659px) Image search: [Google]
Screenshot_2016-08-13_22-24-16.png
73KB, 897x659px
>>56065674
which one is it that you're trying to implement?

cant find it
>>
I just want a language where I can define the input and output of a program. Write the steps in between and it optimises for me.

For instance. Imagine I have a rather large structure and in that structure I have an audio sample. I have a large number of these structures. I decide I just want to make a simple reverb using these samples and output it into a circular buffer which has an associated write and read pointer.

The process of writing the reverb is stupid simple obviously. But since the samples are stuck in this structure I either have to change my structure or do tons of work while I wait on the memory fetching to have a decent running program.

Why can't I just tell it 'I'm gonna be using this stuff here' (samples, local variable reverb time and strength etc) and it ensures it's cache line efficient? Just restructure the data. I don't give a fuck.

Likely it'd create a SOA instead of an AOS as I described.

Instead of me having to do that and write code changes all over.

What languages let me do that? None? If that's the case then you all suck for discussing anything else frankly.
>>
File: fig2.png (56KB, 822x748px) Image search: [Google]
fig2.png
56KB, 822x748px
>>56065714
Figure 2 which is the next one
>>
>>56065676

I wasn't really referencing a specific individual within the haskell community. However, I was drawing parallels to various cults and religions. In that specific instance it was referencing the mainly Jewish / Freemason group commonly called "Illuminati".

Yes I'm accusing haskell of being a religious cult or at least heavily influenced by them.
>>
>>56065730
Idris is probably the best language (that isn't a proof assistant) for that these days. You write the input and output types and it fills in as much as it can
>>
>>56065657

Do what everyone else has already done and switch to C#. :)
>>
>>56065746
alright. give me a few minutes
>>
>>56065763
Ah, I see.

In that case, I think the analogy can reasonably extended by having SPJ be Abraham, and Kmett be Maimonides.
>>
Made a new thread because fuck you :^)

>>56065832
>>56065832
>>56065832
>>
why is it using the double version fabs when i call fabs with a float for fuck's sake?
>>
>>56065798
There's no Scala or Haskell that runs on .NET yet, as far as I know...

The JVM has Scala and Frege, and I spend most of my time using them and not Java. Otherwise I'd have left the company years ago.
>>
>>56065827

That could be a reasonable way to extend the analogy.
>>
>>56065862

No, but there is F# is "fun"-ctional, as it were.
>>
>the best they can do now is call Haskell a religious cult and circlejerk over how much they dislike it
Amazing
>>
Bump :^)
>>
>>56065791
Il check it out. Thanks.
>>
>>56065875
No HKTs, man. I know they're a meme but I can't bring myself to go back to a type system without them.
>>
>>56065856
works with abs but not with fabs lmfao
>>
>>56065832
>>56065832
>>56065832
>>
>>56065435
Except this all started with a bunch of people shitting on Haskell for no legitimate reason
>bwaaaaaah why do Haskellfags keep defending themselves
>>
>>56065899
OMG WHAT ARE YOU DOING
>>
>>56065746
see >>56066048
>>
>>56064522
>>56064497
I'm not a autistically enough to understand this klingon speech.
Thread posts: 319
Thread images: 31


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