/dpt/ - Daily Programming Thread

Old thread: What are you working on, Sup Forums?

Other urls found in this thread:

learnyousomeerlang.com/content
chimera.labs.oreilly.com/books/1234000001642/index.html
elixir-lang.org/learning.html
fsharp.org/learn
en.wikibooks.org/wiki/Haskell
0x0.st/pbp.pdf
gigamonkeys.com/book
cs.cmu.edu/~dst/LispBook/book.pdf
braveclojure.com/foreword/
realworldocaml.org/
ocaml.org/learn/tutorials/
guide.elm-lang.org/
purescript.org/learn/
cs.cmu.edu/~rwh/pfpl.html
ccs.neu.edu/home/matthias/HtDP2e/
karczmarczuk.users.greyc.fr/TEACH/Doc/EssProgLan.pdf
bleepingcomputer.com/news/security/mongodb-apocalypse-is-here-as-ransom-attacks-hit-10-000-servers/
strawpoll.me/12023125
twitter.com/SFWRedditImages

FP > OOP

>go to make first post
>it's already made
>it's exactly what I wanted to post

>make love, not war
Use OCaml, do both.

procedural with FCF > FP > OOP

If you write OOP in OCaml then you're using OCaml wrong

I don't write OCaml at all.

I bet you don't even program

Good. Write Javascript.

Functional programming.
Last /fpt/: Resources:
>Erlang
learnyousomeerlang.com/content
>>Elixir
chimera.labs.oreilly.com/books/1234000001642/index.html
elixir-lang.org/learning.html
>F#
fsharp.org/learn
>Haskell
en.wikibooks.org/wiki/Haskell
0x0.st/pbp.pdf
>Lisps
>>Common Lisp
gigamonkeys.com/book
cs.cmu.edu/~dst/LispBook/book.pdf
Paul Graham's ANSI Common Lisp
On Lisp
Common Lisp Recipes
Land of Lisp
>>Clojure
braveclojure.com/foreword/
The joy of Clojure
>>Scheme
Little Schemer
The Seasoned Schemer
The Scheme Programming Language by Kent Dybvig
Realm of Racket
Lisp in Small Pieces
>OCaml
realworldocaml.org/
ocaml.org/learn/tutorials/
>Scala
Functional Programming in Scala (Chiusano and Bjarnason)
Atomic Scala (Eckel and Marsh)
Programming Scala (Wampler and Payne)
Programming in Scala (Odersky, Spoon and Venners)
>Web languages
>>Elm
guide.elm-lang.org/
>>PureScript
purescript.org/learn/

>Theory
SICP
Essentials of Programming Languages
Practical Foundations for Programming Languages: cs.cmu.edu/~rwh/pfpl.html
How to Design Programs: ccs.neu.edu/home/matthias/HtDP2e/
Art of the Propagator
An Introduction to Functional Programming Through Lambda Calculus

...

why?

I don't understand the for loop in Python dict.

Given the following code:

gegeven = {"Type": "PC", "Prijs": 550, "Merk": "Acer"}
for key in gegeven:
print (key, gegeven[key])


For each loop iteration, Python will automatically assign the first variable as the key and the second variable as the value for that key. That makes sense right?

For some odd reason, 'for x in gegeven' works for one value but 'for x, y in gegeven' does not work for two. In that case you'd need to do "for x, y in gegeven.items()" but whatever.

Since in this code the first word prints the first value, print (key) would print:

Merk
Type
Prijs


print (key, gegeven) would print everything because key prints only the first value, and gegeven prints everything. Code becomes

Prijs {'Prijs': 550, 'Type': 'PC', 'Merk': 'Acer'}
Type {'Prijs': 550, 'Type': 'PC', 'Merk': 'Acer'}
Merk {'Prijs': 550, 'Type': 'PC', 'Merk': 'Acer'}


but then why does print (key, gegeven[key]) also print the values? "key" was assigned to print only the keys.
I thought adding another word would print the values because Python always does "x, y", so giving it a random name would work but it doesn't.

Printing print(key, gegeven[key]) prints:

Type PC
Prijs 550
Merk Acer


where in the heck do the values come from? it didn't get assigned to anything.

Au contraire...

If you insist, but I'd rather write OCaml.
> var x = 3;
> '5' + x - x
50
> '5' - x + x
5

JavaScript isn't a programming language.

i made something

i dunno if i get what you mean, but

when you loop a dict you loop over the keys, you can also do
for x in y.keys():


and when you do dict[key] you access or assign the value of key in dict

also, when you declared keys in your dict, you have to give it a value, if you wish to assign empty values you do
gegeven[key] = None

or

gegeven = {key: None, key2: None, key3: None}

>> var x = 3;
> '5' + x - x
50
> '5' - x + x
5
This will be fixed with the upcomming use "use static".

Or so I'd wish. In reality JS will remain plebscript and all the decent web devs will compile to WASM.

It is a perfect example of what happens, if you design a programming language in 10 days.

What happens when he writes a program in his Notepad?

I never said it was.

But it is. Just a shit one.

>
The real reason Lua has .. for concatenating strings

It gets [spoiler]executed[/spoiler]

Fuck i'd sworn spoilers worked on Sup Forums before.

spoilers haven't worked on Sup Forums since 1993

I didn't read your post, but try:

for key, value in gegeven.items():
print(key)
print(value)

>declarative programing

'..' is inferior to ''.

...

Hey, given that the death note can make a person do anything that person is physically capable of doing before dying... does that make the death note turing complete?

No

Not unless it can run Python 2.

Here are your spoilers.
Take them.

...Any particular reason?

Yes.

Sorry you didn't understand, let me re-explain it.

The first variable in Python is assigned as a key. The second variable as a value for that key.

for x in dictionary:
print (x)

will only print the key.

for x, y in dictionary.items():
print (x, y)

prints as well the key as the value.

but so does:

for x in dictionary:
print (x, dictionary[x])


now it's obvious the key is assigned to x. but [x] prints the values, while I didn't assign the values to anything.
how does that work?

And that reason being...?

Well it could make Zed Shaw write a Python 2 program on his computer, run it, and then immediately go into cardiac arrest afterwards. So it must be turing complete!

Here.

Fuck, I dont know who I want to be anymore. Few months ago I have decided to be an computer scientist and started to read SICP, some math books, bought Arduino. And about a week ago I realised that I really want is to make games, I started to learn how to draw, play around in GameMaker. And now I have no idea in which way to proceed, cs or gamedev.

I feel like my school isn't challenging me enough. What are some good lectures/ocw to watch?

Both, make a new dwarf fortress.

GameMaker =/= gamedev

Everything's a fucking monoid. When you get some (slightly less hyperbolic) insight into the structure you'll understand why '+' gets abused to much in weakly-typed languages.

You could make him flip bits with a magnetised needle until he dies.

Just get hacking and decide on your speciality later.
And don't become a game dev; it sucks.

Read 'Essentials of Programming Languages':
karczmarczuk.users.greyc.fr/TEACH/Doc/EssProgLan.pdf

I want to display card images in JLabels. I'm putting the images into the labels like this
JLabel example = new JLabel();
example.setIcon(ic);
This means I can only have a limited number of cards displayed (as many as the number of labels I declare). Is there any way I can "generate" a label when I pull a card so that I don't have to set the number of cards that I want to display beforehand?

>understand why '+' gets abused to much in weakly-typed languages.
We were talking about '..' vs for concatenating strings..?

make a real thread mate

Interesting and creative ways the death note has not been used yet: death by starvation. Make a person carry out a task to the detriment of all other actions. Does not sleep, does not eat, does not drink, just does that one thing with every ounce of energy they have in their body.

Yup. The two things are not related.

You're just assuming they're related because they're similar. This is often called 'conflation'.

Although I could be very mean and point out that this all started with someone asking me to write some JavaScript, and my pointing out the potential horrors of weak typing, including using the '+' operator.

But that would be dishonest, since my statement about '+' was actually just offhand.

Now go learn about monoids, whose usefulness is the (essentially circular) reason that '' is better than '..'.

Also, you could make someone eat themselves to death like in 'Seven'.

use javaFX instead of swing

Last threads died early.
It is simpler now to keep posting the old OP instead of creating and failing to keep the thread alive again.
Maybe if people show enough interest to FP inside /dpt/, /fpt/ will be created again.
But then again, /fpt/ wasn't fast and usually outlived several /dpt/ threads.

>But then again, /fpt/ wasn't fast and usually outlived several /dpt/ threads.
is this supposed to be a downside?

Not in my book, but remember that the guy you're talking to is a turboautist.

make a method that returns a JLabel object and call it upon press or whatever you want to generate a card

Currently learning Go and GraphQL, fucking love them so far.
What are your opinions on them and what do you think of MongoDB?

It's a uni assignment, I have to build the GUI using Swing, unfortunately. Is there any way to do it without using javaFX?

Wow, somehow this didn't cross my mind. I'll try now and see if it works, thanks user.

I'm having problems with the qt example called calculator builder,
Everything else is the same (the code, the .ui file), except I'm using clion instead of qtCreator.
I'm always getting an error in this line
Q_INIT_RESOURCE(calculatorbuilder);
undefined reference to `qInitResources_calculatorbuilder()'
My cmake file has this
cmake_minimum_required(VERSION 3.6)
project(calculator)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

find_package(Qt5Core REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(Qt5UiTools REQUIRED)

qt5_add_resources(${RESOURCES} forms/calculatorbuilder.qrc)

set(SOURCE_FILES main.cpp CalculatorForm.cpp CalculatorForm.h)
add_executable(calculator ${SOURCE_FILES})

qt5_use_modules(calculator Core Widgets Gui UiTools)

Any help would be appreciated
Picture unrelated

Only languages worth anything of those are Erlang, F# and Scala. Others are just meme languages.

let me know what you come up with, i can help

Where is 'what have i done2.jpg'?!

WHERE IS IT?!

>Go
- GC.
- No generics.
- Outdated type system.
- No ADT.
- No pattern matching.
- Not enough functional stuff.
- No RAII/IDisposible/Context managers.
- Ugly syntax.
- The most retarded and unsafe error handling story after C.
- Structurally typed interfaces instead of proper interfaces/type classes/traits.
- NIH infrastructure with authors spending years reinventing stuff instead of using LLVM.
- Community comprised of mostly python-kiddies.
Overall the language was designed to be as simple as possible and then even more simple so Google can train code-monkeys on an industrial scale, the only good thing about it being coroutines.
>MongoDB
bleepingcomputer.com/news/security/mongodb-apocalypse-is-here-as-ransom-attacks-hit-10-000-servers/

Go is good for servers. Anyone advocating MongoDB for production should be fired on the spot.

The MongoDB thing is more of people being too stupid to configure the server safely, isn't it?

i'm the sort guy from a couple of days ago

plain bubble sort uses a lot more iterations than insertion sort so i didn't even bother to time it

i made my own cocktail shaker sort variation which i thought was pretty clever but it uses around twice the number of inner loop iterations and it takes about twice as long as insertion sort

but this is mostly just taking 1-3 microseconds per sort for 64 uint32_t so this is largely inconsequential, lel

sometimes the timing spikes to around 0.1ms for a sort but i'm guessing it's a timing error or some other app that's using resources at the time

>hackers have now hit around 10,500 MongoDB servers. That's about 25% of all MongoDB databases accessible via the Internet.
>The attacks don't target all MongoDB databases, but only those left accessible via the Internet and without a password on the administrator account.

GE 25% of internet-accessible MongoDBs don't have a password on the admin account? Jesus fucking Christ.

t. Rust gender fluid sucker
No. It is notoriously inconsistent and packed with data races. /dev/null is a faster option for sending your data into the void.

whats the difference between measuring and benchmarking?

ok, thanks.

Anyone ever heard of dgraph? Concept looks interesting.

What database should I go for my very small web app?

they're more or less synonyms but benchmarking implies a more thorough/scientific methodology and a measurement can be just putting timers in your program

I showed the first one to a friend and he told me to make this.

sqlite3

who is that mongolian carpet boy

What is your data?

I don't like it. Make more Sup Forums related ones.

This one is best one.

Japan's olympic swimmer trainer.

My Data is basically just some (very few, maybe Guest and Admin) users, a bunch of Anime and how far I've watched it, but I want to keep it easily expandable, so I can integrate Torrents and other things and am not limited to Anime.

>Read 'Essentials of Programming Languages':
looking more for a classroom setting than a book

Is the incompetence of the average web dev and Mongo user really surprise you?

If you can't make it through that book, you don't deserve to be in a classroom setting.

more with the same template? that'd get boring fast.
I'll get to making more memery in the future.
it's the god of the new world

Don't let your dreams be memes. Make the game you've always wanted to, but also learn some useful skills in case you need to get a job.

>tfw NEETing out this weekend instead of practicing programming

I'm designing a game engine because my language doesn't have a good one. What are some essential features of a component based engine?

Text editor poll continues

What your game needs. If you don't have a game you don't have any hope of making something that anybody will use if even you aren't going to use it.

strawpoll.me/12023125

Is Modern C by Jens Gustedt a good book?

Is the incompetence definitely surprise me, but mayhaps I should no surprise.

No, I can read a book. I read books all the time. I just want a classroom setting. I want to pretend like I'm actually at a decent college

Yes

NEETing?

...

I just tried it and it works, now I just have to set up the panel layout. Thanks again!

show me the code

being a NEET

what is 'fcf'

First-class functions.

I sincerely hope you're using Lisp and aren't trying to justify using Python