/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

pst.moe/paste/lcyblm
stackoverflow.com/questions/8026049/using-void-main-in-d
dlang.org/spec/function.html#main
dlang.org/phobos/std_process.html#.environment
twitter.com/NSFWRedditVideo

Please post an anime image next time.

No.

What if not?

I'm reading the opengl superbible to learn how to do offscreen rendering.

What books is /dpt/ reading?

I'll be disappointed.

yeah same error unfortunatley.
I put animals.txt into dos2unix.exe then ran script but same error. It looks fine here:
$ cat animals.txt
dog
cat
dog
dog
rabbit
dog
cat
mouse

>I put animals.txt into dos2unix.exe then ran script but same error. It looks fine here:
no I meant you should have ran the script through the dos2unix tool

Made the good-enough? function better, but removing both floating-point 2s makes it output fractions.

(define (sqrt x)

(define (good-enough? guess last-guess)
(< (percent-error last-guess guess) 0.0000001))

(define (improve guess)
(average guess (/ x guess)))

(define (sqrt-iter guess last-guess)
(if (good-enough? guess last-guess)
guess
(sqrt-iter (improve guess) guess)))

(sqrt-iter (/ x 2.0) 0))

(define (average x y)
(/ (+ x y) 2))

(define (percent-error approx exact)
(/ (abs (- approx exact)) (abs exact)))

>but removing both floating-point 2s makes it output fractions
So what? That's a good thing.

>implying an irrational number should ever be represented as a fraction

int pi = 3;

You not going to be able to represent in in floating point either.

My curiosity can't be contained anymore, I want to learn a functional programing language, but I'm not sure which one to go with. I'm thinking I should learn something practical and actually useful but I'm not sure if any functional language exists that is both useful and much different from a procedural language, if that's the case then I'd rather go all in and use something that may not have a practical application but may have an educational one, one that will force me to use a different style and tackle problems in a way I'm not familiar with.

In either case could people recommend me languages for both? i.e.
Practical: X, Y, Z
Academic: A, B, C
Y is good for... B is interesting because...

I would appreciate it.

what is the most efficient algorithm for finding the largest product of a set of numbers that is less than some other number D

I know. It's still a more intuitive representation than one that is the literal opposite of the definition of an irrational number, though.

>implying you should represent irrational numbers in cauchy sequence form on a computer for everyday uses
user I don't wanna buy a graphics card that does all its arithmetic in symbolic algebra. I don't think those exist.

It's probably some shit involving dynamic programming.

oh yes that's totally the implication I was making, you are correct, thank you for pointing that out my friend!

Is there a language that supports fast development, provides runtime safety, scalability, and a powerful standard library, without depending on significant whitespace?

D

AHAHAHAHAHAHAHAHAHAHAHAHAHAHA
Good joke.

Ok got it to half work in cygwin (bc didnt exist and I couldnt install for some reason) but I mainly want it working on linux where I now get error:
calculate.sh: 7: calculate.sh: Syntax error: redirection unexpected

D, except it's never going to take off so it's kind of a waste of time to learn. If you need performance, deal with the shittiness of C or C++. Otherwise, use a good (functional) language.

No joke senpai

>one that will force me to use a different style and tackle problems in a way I'm not familiar with

Haskell.

Good luck thinking with monads, finding out you have to refactor everything because of the typing, and wondering how the fuck will your shit run with lazy evaluation.

rust

Javascript

$dos2unix animals.txt >> animals.txt
or > i forgot which one overwrites and which one appends desu

learning go, sql and web protocols all in the same run I guess

pst.moe/paste/lcyblm

it compiles but says I have an error in SQL syntax, probably type errors. feel free to mockingly help a newb.

>fast development
>10 minutes later still compiling.

>powerful standard library.
>literally barebones and pushed everything out to cargo/crates.

nice.

There is no other way to represent an irrational number than through some kind of sequence or series or something. By definition. It's called the completeness axiom.

Everything else is an approximation of an irrational number with rational numbers. So those "floating point numbers" are still rational :^).

Scheme. It's practical because some distros are still very fast, compile to binary, and the language is very expressive. Good for prototyping and scripting. And the fast distros also let you embed scheme in your other code, and your other code in scheme.

It's academically interesting because it is "homo-iconic," the source code of a scheme program is literally an AST and macros are crazy powerful. There's a flow control primitive called call/cc that's also really cool and crazy powerful. Too powerful. It's like a goto for brainchads that you can use to build coroutines, green threads, amb, exceptions, and more. There's also optional lazy evaluation with delay/force which is pretty neat although really hard to think about.

Unlike the other lisp it makes no distinction between code and data, and its macros are hygienic, meaning you don't have to muddy your macro variable names up with ___'s and shit.

std::cin >> v1 >> v2;

I think C++ streams are the biggest mistake in programming history

the :^) makes me think you know you're retarded, but I'm going to tell you anyway:

you're retarded

then don't use them. just like all other misfeatures in the STL: you only pay for what you use.

wrap scanf/printf and friends and provide a less atrocious interface than *streams

Pretty much any language that isn't python? Nothing's stopping you from writing your code like you're writing it for a stock ticker.

What happened to Ruby? Why doesn't he post anymore, or as frequently as he did? ;_;

that's not the problem anymore. no idea why it isn't working desu.

He learned how to program in C and is still going through his "literally no other language is ever necessary" phase.

You're the one who thinks irrational numbers ought to be represented as floats.

There's nothing magical about floats user. They're just scientific notation.

or just avoid C++

because he was a dumb baka. i'm glad he's gone.

>INSERT Applications SET AppName=?, Description=?
That's update syntax. You want values syntax.
>INSERT Applications (AppName, Description) VALUES (?, ?)

You can't overwrite a file in place with redirections, generally speaking.

post script desu

Why even use sepples if you are just going to do 90% of it in C? Go find a decent C library, don't reinvent wheels.

Thanks for the recommendation, I forgot to mention the list that originally came to my mind, just by virtue of seeing them talked about a lot, not knowing much more than their names.
Common Lisp, Haskell, Smalltalk, and Erlang.

I've used Javascript but not extensively. People talk up Haskell like it's the most pure which made me wonder about using it academically. I watched some of the SICP lectures and Scheme is very very interesting to me, I might go with that, especially since SICP is a thing, it should be quite easy to get a handle on compared to other options.

I heard he got doxxed here.

Spaceship selection GUI

if 90% of your code is iostreams then you're either not doing much, or should be using tools that are more apt at handling that work load (i.e. perl -- which generally performs extremely well at data munging).

What's a good (functional) language?

scheme
haskell
clojure (good if you also want more practicality)
scala (good if you want dirty impure OO features as well)

for books, I can recommend "Learn You a Haskell" and SICP (for scheme).

Haskell is probably the language highest in the ivory tower and deepest up its own ass that will ever be created.

It is indeed the "purest" functional programming language because (1) it's lazy and lazy languages are just impractical and (2) it is impossible to violate referential transparency by design, and in order to mitigate the horribleness of that, they dug into the deepest malbolges of hell to dig out the most obscure pieces of abstract algebra, monads.

It's fruitless impotent mental masturbation for people with CS phds. But I won't judge you for masturbating user. Everyone does it.

have changed script permissions to executable.

my nigga what is that font

Did you ever make a webm user?

What about F#?

What's the deal with Haskell? It's like 30 years old yet languages that are newer than it are much more popular (especially Go). Yet people in the Haskell community are sing praises like it is the best language in the world with stuff like
>muh functions without side effects
>muh lazy evaluation
>muh typing system

import std.stdio, std.file, std.algorithm, std.range, std.conv, std.string;

void main(string[] args)
{

auto lines = args[1].readText().split().sort();

lines
.group()
.map!(t =>
t[0]
~ '\t'
~ ((t[1].to!double/lines.length) *100).to!string
~ '%'
)
.each!(writeln());
}

Hey Sup Forums, i want to make an app? What resources would you guys recommend? The app is a bluetooth comminucation app. Ive worked previously with android studio before. What does Sup Forums use to make apps?

Jesus christ, what is with that disgusting syntax?

Triggering

>disgusting
where?

Oh I suppose you could try that. I don't have much experience with Microsoft products so I don't know.

It's not as popular as Go because it's more difficult to learn than Go. It takes a good amount of effort to master Haskell. I (and many people in the community) love those features of Haskell because they allow for code which is more elegant and more fun to write, but it's not for everyone. I'd say "just give it a try," but you have to invest some time into it in order to reap the benefits.

>void main
>auto
>yelling
>~ everywhere

~ is the appending operator.

>app
>app
>app
>apps
>app
Kill yourself

There's no reason to use Haskell when OCaml exists.

It's a fun language to play with, but only that.

Enjoy your multithreading.

>I'm a mongoloid retard who keeps spouting Sup Forums memes without having any clue what I'm talking about XD

>void main
stackoverflow.com/questions/8026049/using-void-main-in-d
>auto
What's wrong with it?
>yelling
where
>~
it means concat

Imagine a language that can't do multicore

To be fair Go has the backing of a corporation. Marketing is really important.

Haskell is troubled though because its biggest proponents aren't socially all that great and honestly, it's just impractical. It's mental masturbation. They do it to get off, not to be productive. The meme is moanads for a reason.

The term app as shorthand for application existed and was in common use long before you were born, I'm not going to type out "application" or "program" every time because you have some weird aversion to the phrase because it's used by Apple or whatever.

dlang.org/spec/function.html#main

How does D get values from the environment?

Can you give an example? Not sure what you mean?

>where
You!re doing!it all over!the! place!

What do you mean?

! means template

The POSIX envp and its NT equivalent for example

So? The syntax is still fucking atrocious.
There is no point arguing with you necrophiles. You are the sort of retards who would defend deadlang's """"""""""""lazy evaluation""""""""""".

What do you mean?

D kinda looks like neat and shy c++ cousin

dlang.org/phobos/std_process.html#.environment

Thanks.

>The syntax is still fucking atrocious.
For autists like you maybe. I never saw anyone complain about D's syntax, especially C++ fags

>2017
>criticizing non-esoteric syntax
Confirmed for not a programmer

!, ~, '.', no :: and UFCS are all very intuitive once you actually write D.
Nothing ever feels awkward and what you probably assume syntax wise will most always be the case.

>Defending D
I really wish /dpt/ wasn't filled with such useless memesters.

>Era of 8 cores, 16 threads
>POOCaml stuck with 1
kek

>Lose arguments
>hurr durr I wish everyone would cater to my chronic autism REEEEE

t. useless memester

Theres really nothing to defend desu, the only thing /dpt/ can ever whine about are there highly performance-oriented fizzbuzzes being impeded by the GC.

post results
>>> import multiprocessing as mp
>>> mp.cpu_count()
4

D is unironically the only nonpopular language these days that deserves defending

their

>only one program can run at a time
You don't want to share address spaces when doing FP, you'd know this if you were actually programming and not just shitposting on /dpt/.

I like C

i see (C).

I like you