/dpt/ - Daily Programming Thread

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

Other urls found in this thread:

github.com/MariusMacijauskas/maze/blob/master/maze.c
sarabander.github.io/sicp/
linux.die.net/man/3/system
lua-users.org/lists/lua-l/2008-11/msg00008.html).
philipnilsson.github.io/Badness10k/posts/2017-05-07-escaping-hell-with-monads.html
youtube.com/watch?v=9ae9m_WT6xM
web.stanford.edu/class/cs106b//assn/
en.wikipedia.org/wiki/Libavcodec
twitter.com/AnonBabble

i want to POUND an anime BUTTHOL

T-Thank you f-for anime picture! ....
A-Also, ... first for Ruby is the /c-comfiest/ language ....
...
・゚。(///>﹏

>ruby is the comfiest language
only a girl would post this

It is slightly disturbing that the above image brought that to mind for you. Hakase, a savant in engineering and AI, is just a little child, and her robot sistermom Nano is only in high school.

a robot is a robot faggo

hands OFF my sexbots

>her robot sistermom Nano is only in high school.
why is a robot in highschool
why does a robot have an age
why does a robot have a child
so many questions

Maze generator.

Source code:
github.com/MariusMacijauskas/maze/blob/master/maze.c
Compile and run with no input.

user $ gcc main.c -O2 -o maze


The output is a number of .ppm files.
To convert the .ppm files to .gif (with ffmpeg), use the following:

user $ ffmpeg -i maze%05d.ppm maze.gif

rude
it'll be on YOUR guilty conscience to have to lay such a sick burn as "I fucked your mother" upon a hapless unsuspecting child who doesn't even know what fucking is

def biggest_guy(num1, num2, num3):
if num1 > num2 and num3:
return num1
if num2 > num1 and num3:
return num2
if num3 > num1 and num2:
return num3


Why does it recognize num1 or num2 being larger but throws a bitch fit when num3 is?

Have you done your SICP today, /dpt/?

Literally what?

planning on it
my bookmark fell out and it's been a while so I have no idea where I'm at in it

lurk moar, nibba

Nano is like 1 year old you sick fuck

Some irrelevant meme book /dpt/ seems to have a boner about.

I-I like S-Scheme more >.<
Ruby i-is not that bad t-though.

We are both c-cute g-girls *blush*

kys retard

sarabander.github.io/sicp/

>why does a robot have an age
Nano does not actually have a real human age but Hakase made her to look and feel that way
>why is a robot in highschool
Nano saw other (real) girls who looked her "age" going to high school and wanted to do it too to learn and make friends
Hakase reluctantly allowed it
>why does a robot have a child
Hakase was sad and lonely without a family and wanted someone bigger, more adult, and more capable to look up to and to love and take care of her
It quite nearly threatens one's already tenuous suspension of disbelief to think she was somehow able to engineer a sentient mind as mature as that of a high school girl without being anywhere near that mature herself
An emergent consequence of more innocuous parameters is clearly the only explanation

no u

*read

But he is right you fucking creep.

>Hakase was sad and lonely without a family and wanted someone bigger, more adult, and more capable to look up to and to love and take care of her
I call bullshit, she wanted a cute oneechan to dom.

>creep
kys retard

What is the difference between the red and the green ones

Which scheme do you use?

probably edition?

python is a broken language so this doesn't throw an error when you try to use a "duck type" as a boolean. this statement is

if (num3 > num1) and num2

R-Racket and s-sometimes guile when I get too upset with it >.<
B-But I am making my own in C

Reading it is not sufficient. You must complete the exercises too.

in Haskell this is just

(max . ) . max

There's so much mystery surrounding the Shinonome household, really makes you think

One has the kanji for 'above' after the title and the other has the kanji for 'below' after the title. What did he mean by this?

Stop stuttering. You have a backspace key.

Oh, maybe it's like beginner and advanced?

Yeah but that looks like a pair of tits so it's fucking stupid.

Friendly reminder that Hakase was a grown up professor working for the University of Tokyo.

Tried S7 Scheme? It's easy to hack into whatever you need it to be.

or it might be front and back, maybe it's split into 2

nips are truly mysterious

Thank you, that is what I needed to figure it out.

I-I heard the same about Tiny and Chibi Scheme b-but I never used them ;_;

>he doesn't use the tits operator

Surely it must be some Japanese ordering thing. Like how first and last name are called the below name and above name

Is it weird to like both Idris and C?
I like Idris because it's a true pure functional language with an elegant and expressive type system.
I like C for an opposite but weirdly similar reason.
It's almost like a "pure imperative" language if you can imagine such a thing.
It doesn't hide any complexity from you, what you write is exactly what gets done with nothing extra going on. Or rather, just enough extra going on to let you actually get anything done, and nothing more. Prototyping is a bitch, but once it's done, you can optimize and prioritize to your heart's content, all while maintaining a complete and purely self evident understanding of exactly what you're changing, without any invisible changes that will fuck you over in the long run. (Unless you use malloc, which you shouldn't.)
Its type system sure as hell isn't expressive, but for what it is, it's weirdly elegant anyway. Just like everything else in the language, it just stays out of your way and lets you crunch the numbers.

Tiny Scheme is like 4-5K LOC in C and very easy to hack, but it has a shitty macro system. S7 is like a mature version of Tiny Scheme that's updated to R7RS. Chibi is meh.

Tiny or S7 is what you want to use when you want to embed a Scheme interpreter into a C or C++ program... or conversely, make it very easy to embed a bunch of C code into a Scheme program. Think Lua, but not shit.

Thanks! I will check them out!

>without being anywhere near that mature herself
user this is what neural networks are for. It's how you create things with capacity beyond your own.
It's a very good anime user you should watch it instead of spoiling it for yourself. I'm disappointed that shit like Gintama is still around while Nichijou is over.

actually I could probably just ask here.
does anyone know where the part where it's just introduced cdr and lists is?

>Is it weird to like [...] C?
It's weird to not like C.

>good
>anime

wew

I think something similar about C. I just wish we had a language like C but without all that weird old cruft which pisses me off so fucking much

What about CHICKEN?

That's early in chapter 2.

nevermind

What do you dislike about Lua, Ruby-senpai?

kek, a bit late, but thanks

>it doesn't hide complexity from you
Well it does, quite a bit. But I get what you're saying. It's all about your perception though.

Brotip, use the index in the back of the book.

It's pretty great for embedding C in Scheme, although I've never tried the reverse.

It's definitely a larger scheme though. And the source code is un-fucking-readable. Felix is a madman.

Why not execute ffmpeg from your code so the user doesn't have to do anything. I remember being able to call ffmpeg from Java code so there has to be a way to do it from C code.

Because he knows its better than his shitlang.

>Unless you use malloc, which you shouldn't
Why not?

Its not my code.

Arrays are just tables
Arrays start at index 1, not 0
String + Integer = Integer is allowed and other weak typing shenanigans
Numbers are all floating point, just like JS

Do you think CHICKEN is practical for building an entire program? e.g. a (not very graphically intensive) game?

so qt creator is saying that no valid kits were found
the kit auto-detect says "Cmake has a path to the qmake bianary even though the kit has no valid qt version"

how do I fix this?
I'm on linux mint KDE if it matters

>Arrays are just tables
>Arrays start at index 1, not 0
Those are good things
>String + Integer = Integer is allowed and other weak typing shenanigans
>Numbers are all floating point, just like JS
Fair complaints

What do CS students do in college ? Like, what kind of assignments do they get.

Not him but malloc can often be a crutch and you can end up with memory fragmentation if you abuse it.

It's just system("echo Easy.");

linux.die.net/man/3/system

LOO-uh is utter garbage

While web-development is plagued by PHP/Perl/JS/Ruby/Python scourge, video game development too has its share of bad languages. Most hyped and infamous of them being Lua:

Broken lexical scoping: assignment acts as declaration, clobbering global variables. Even worser: access to undeclared variable doesn't produce error, but silently returns nil. Bad scoping is the single biggest source of bugs and confusion (lua-users.org/lists/lua-l/2008-11/msg00008.html). Moreover, every variable access goes through hashtable system, producing several L2 cache misses in process, making Lua slower than comparable alternatives, like Lisp. Lua has no standard way to do OOP or define a module, leading to numerous incompatible and badly designed solutions, resting on top of already deficient hash-table system with a.b[i]:c(d) style scope resolution. Like in all badly designed languages, Lua pollutes global scope with _ prefixed identifiers, instead of keeping them in a separate package.

[cont]

rather than relying on system calls, arent there ffmpeg library bindings?

does nichijou ever explain how a 5 year old managed to build a robot with feelings?

>e.g. a (not very graphically intensive) game?
nibba, there are OpenGl and SDL bindings

Hash-Table as a primary data structure has overwhelming issues. There is no simple and safe way to implement Lisp-like FIRST and REST functions: either you have to copy whole Table or modify it, and sequential access is somewhat slow. There is no easy way to remove an element from a list. Even worse, the size of a list may not be what you expect: "b={'x'};b[2]='y';print(#b)" prints 2, but "b={'x'};b[3]='y';print(#b)" prints 1. Table indexing starts from 1, acting as a source of errors and confusion, when interfacing with external APIs or converting algorithm from Lua to C/C++, while 0 still acts as a dangling pointer. Lua Tables don't provide advantages of immutable catenable queues - a silver bullet data structure, you'll find in modern Lisps and Haskell; Lua Tables are mutable and encourage modification, instead of creation, meaning there is no easy way to do functional programming with Lua. REPL wont pretty-print tables, but dump something like "table: 0x807e978". Table-list features some of the scariest kludges: program can modify the behavior of the length operator for any value but strings through the __len metamethod, while table construction syntax and semantic are impenetrably confusing, like { [f(1)] = g; "x", "y"; x = 1, f(x), [30] = 23; 45 }

Lua uses floating point values to represent integers, so 9999999999999999999==10000000000000000000. In general, Lua's logic seems odd: "nil+1" produces error, while "(not nil)+1" gives 2. Things could be unequal to itself: t={[{1,2,3}]="abc"}; print(t[{1,2,3}]) wont print "abc", meaning that {1,2,3} != {1,2,3}.

[cont]

Reminder that monads solve many programming solutions in better ways than common approaches

philipnilsson.github.io/Badness10k/posts/2017-05-07-escaping-hell-with-monads.html

>e.g. a (not very graphically intensive) game?
Considering I'm the minecraft clone guy, yeah lol.

System isn't a system call. It just spawns a process. It's part of libstd.

Lua is unstable: API changes frequently, functions are being added and deleted continuously, table.foreach being a good example of to be deleted function, and then there is table.unpack, which present only in some versions of Lua.

Lua's GC is a naive mark-and-sweep implementation, which stores the mark bit directly inside objects, a GC cycle will thus result in all objects being written to, making their memory pages dirty and Lua's speed proportional to the number of allocated objects. Lua simply was not designed to support hundred thousand objects allocation per second.

Lua was built as a glue language, and it shows. Much of Lua hype comes from it's usage as a simple integrated scripting language in video games industry. That makes typical Lua user a teenage gamer with little expectations or taste for computation features and productivity.

Just because a language has bindings doesn't mean it's practical to build something in it with them.

>It just spawns a process
On glibc it calls fork/exec which both are syscalls.

>Bullying a skid lang
>This hard
You people should stop

I fucking love monads

>Hakase was sad and lonely without a family and wanted someone bigger, more adult, and more capable to look up to and to love and take care of her
really reminds me of this music for some reason
youtube.com/watch?v=9ae9m_WT6xM

Well of course. Everything ends up using a system call at some point. Half the point of stdlib is to wrap system calls in something portable.

I believe most of the hype comes from luajit being fast

>muh "moan ads"

muh LOO-uh Jeet

It's implied that she's just miraculously really fucking smart. You know, like those kids who scrawl crazy equations all over their bedrooms and don't talk to strangers.
It doesn't go into much greater depth about it than that.

see for yourself
this directory has Stanford CS assignments (C++)
they all use a library specifically made by Stanford for these assignments
web.stanford.edu/class/cs106b//assn/

Actually, numbers are split into integers and floating point in Lua 5.3

>numbers are all floating point
Not true. They're a special float int combination. Which imo is way worse.
>arrays are just tables
They treat inserts with integer keys differently. But sort-of yeah.

>a special float int combination
Well then.

I mean, ffmpeg must have a core library that does all the shit and a CLI wrapper. Why dont they release that core library so other programs can call it without relying on ffmpeg being installed in its entirety?

>luajit
>loo pajeet

loojeet

kek

>ints are floating point numbers
>you try to access a specific member of an array and you end up accessing another due to floating point fuckness

I take it back, there actually are good use cases for it. But they're limited. In fact, they're limited in a surprisingly predictable manner: specifically I always say only use malloc either if you need to use realloc as well or if you have a recursive data structure like a linked list or a linked tree. Anything else can be achieved by more portable, less unpredictable, less complicating means. Want to pass something to a function by address? Just declare it on the stack in the calling environment. Want to share information mutually / recursively between two records? Just find some early point before which neither of them have to exist and declare them both on the stack at that point. If there is no such point, just declare them as globals. Worried about globals because they're supposed to be bad? Just declare them as *statically scoped* globals, and everything bad about them is suddenly gone. Really just do anything. But for the love of god don't dynamically allocate them, unless you have a really good reason like not knowing how many of them you're going to need and being unable to place a logical upper bound on the matter.

do it then, ffmpeg is free software, isn't it?

Unless your array has 2^23 elements, you're going to be okay. please learn how floating point numbers work.

did some googling, it already exists - en.wikipedia.org/wiki/Libavcodec