/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: dpt3.png (1000x793, 717K)

Other urls found in this thread:

phaiax.github.io/rust-cheatsheet/
twitter.com/AnonBabble

Go is good.

No, it's bad.

>take a Formal languages class
>students: "So what does any of this have to do with programming?"
>mfw

Attached: 1541876122696.png (512x512, 80K)

Academicucks BTFO

Name a good language then.

Scheme.

Fortran

based & redpilled

what are some other ways to do collision on tetris game which has super rotation system. Pic related it is my code for collision but i can't figure it out how to do left and right collision.

Attached: n.png (733x318, 33K)

>muh language, muh other language shit
>muh paradigm muh other paradigm bad

How to tell absolute retards I'd never hire. The exact last thing you should ever be concerned with as an Engineer. I could accomplish any task with any language using any approach. Its all about your own ingenuity not what you're using

me agree, go many good.

Attached: brainlet.jpg (749x846, 328K)

php

t. Python user

>function called canPlace
>doesn't return a boolean

{ (define fizzbuzz (@ x
(case
(= x 101)
x
(= (% x 15) 0)
(or (print (string (Buzz))) (fizzbuzz (+ x 1)))
(= (% x 3) 0)
(or (print (string (Fizz))) (fizzbuzz (+ x 1)))
else
(or (print-num x) (newline) (fizzbuzz (+ x 1))))))


r8 my language
yes, it is compiled

>{
>(@ x
What lisp is this?

Python is a perfect example of a seemingly limited language that intelligent and successful people use because it can get amazing shit done despite its apparent faults

it's not a lisp per se
it's just an untyped GCed functional language that also uses brackets

It sucks.

it suppossed to return boolean. I change the return type but forget to change the name.

another example

{ (define Ycombinator (@ X
((@ procedure
(X (@ arg ((procedure procedure) arg))))
(@ procedure
(X (@ arg ((procedure procedure) arg)))))))

{(define fibonacci (Y (@ func (@ x
(if (

>lol bro who cares just get le job done, doesn't matter how shitty the process and the results are as long as I get my money, you see I'm a very important professional
I dislike pretentious faggots like you

void main()
{
const char *S = "FIZZBUzz";
int n = 8;
int size = (2 * n - 1);
int a = 0, b = 0;
for (int i = 0; i < size * size; i++)
{
a = i % size - (n - 1), b = i / size - (n - 1);
a = (a >= 0 ? a : -a);
b = (b >= 0 ? b : -b);
printf((i + 1) % size ? "%c," : "%c\n", S[a > b ? a : b]);
}
}

What the fuck do those curly braces even do? Also is is the newline after @ significant, if not how do you have more than 1 parameter?

>write a recursive function
>feel pretty smart
>run a test
>causes stack overflow

>rewrite it to be iterative
>uses mfw

Attached: 1535923562173.jpg (591x716, 28K)

>lol bro who cares just get le job done

Imagine having a problem with this.

I want to pair program with a loli

Why are you surprised? Recursion is a meme and almost always the inferior approach

You aren't smart or productive for not having an eye for detail, you're just a passionless NPC.

Nah its called context awareness.
Performance within large range of exponents unironically does not matter for the vast majority of applications what matters foremostly always is achieving a goal with code that can be used for later applications with any code available from previous applications

Yes, but I was referring to complete disregard of programming techniques. If you don't care about language selection and such, you don't care about the results of your work and you most likely produce just awful spaghetti code. I hate idiots like that who pretend they're smart and don't just care.

you should only really use recursion for traversing trees, not for algorithms with enough iterations to cause stack overflows

recursion is just education only, no reallife application

YOU GUYS SAID JAVASCRIPT WAS BAD

YOU DIDN'T SAY IT WAS THIS BAD

FUCK
MY
ASSHOLE

Attached: 200 mad.png (900x775, 440K)

makes it easy to split the definitions to compile them one by one, just look for the { and split there

is a temporary solution :}

the (newline) function prints a new line
the new line is not significant and neither is white space generally

it has only 1 parameter, and uses currying
(if predicate consequent antecedent) gets translated into (((if predicate) consequent) antecedent) but it's generally a special form and the only thing that's lazily evaluated

the currying is a consequence of it being just a lambda calculus compiler in the beginning, but i added integer support later and some special forms

tl;dr multiple variables to functions = currying

Javascript isn't bad.

This

So what techniques did you use for parsing and code generation?

Also how long did making the thing take?

But it's fun

How is the Rust borrow checker not ridicolous when 99% of the memory you are allocating will not cross thread boundaries?

took about a month, it beats the mit-scheme interpreter in terms of speed but it's slightly slower than python - not a ringing endorsement, but python really is a compiled language anyway

haskell creators officially earnt my respect though, for creating a FAST garbage collected high level language, that is also functional

i compile recursively
for example

(f (g x))

first x gets compiled, then g, then g x, and the result is in some form returned to f

>99% of the memory you are allocating will not cross thread boundaries?
then you're not writing very advanced things.
t. not a rust cultist

Soo, do you have a separate backend and a fronted? What's the target language?

Unironically this. The modern dialects (Fortran 90+) are nearly as comfy as C.

>Soo, do you have a separate backend and a fronted?
yes
a tree-like structure
target lang is C

Cool

>shallow copy in java
is what happens when you copy an object: the copy points to the same reference the object points to
>deep copy in java
is what happens when you copy a primitive type like int: a real copy of the value assigned to the int is copied and a new int is created
is this correct?

>ask a basic question on IRC, I already know the answer now
>it was a silly question but I tend to forget small details every now and then
>some faggot on the room goes "oh the big arrays are too hot to delete hehe"
>this refers to a previous conversation I had in the room
>I say "really, nigger? That's your idea of funny?"
>get kicked out

Attached: 1544106141743.png (264x274, 35K)

nah, shallow copy means copying a composite structure like an object and having its inner references still pointing to the same data. say, you have an object reference inside an object, after shallow copying the outer object the copy will point to the same inner object as the original. a deep copy copies the entire structure.

>be rude
>be surprised when you're kicked out

It's called feeling the room lad.
don't know why people have such an issue with it, I'm an absolute autist, but even i realize i can't freely and casually say shit like that to normal people outside Jow Forums.

I hope you're not surprised

It wasn't meant to be so rude per se, it was just my retort to his banter. I think I should distance myself from Jow Forums.

what if you use an explicit stack?

I'm learning Rust. Any tips?

Attached: 346104959.png (1920x1080, 420K)

What shitlang are you using that doesn't tail optimize?

learn Nim

phaiax.github.io/rust-cheatsheet/

I guess I got it, thank you

If you end up doing now labor intensive tasks avoid the stdlib implementations. I saved so many resources by just dropping in different versions of stdlib modules (parking_lot for channels + locking).

doesn't matter. normalfags are triggered by literal keywords no matter the context.
And do what you want, but completely cutting off X because it causes you to do or be Y is really just a sign of weakness and inability to control yourself.
Ironically, you're living up to your NPC shitpost gimmick

>avoid the stdlib implementations
the absolute state.

>itt people taking the npc meme seriously

if he's just roleplaying a retard i honestly can't tell because it's his avatar at this point.

Learn the ownership/borrowing system as fast as you can. Also get to know cell, refcell, box etc. There's only a couple idioms to know when using rust but they're essential to make anything useful.

Not him but
is it possible to emulate inheritance with procedural macro?

Can I do GUI with it?

no idea. never had to use macros before

No

I wish I was good at Rust, I really do. Nothing else would increase my epeen than being a skilled Rust fag.

C# development and linux
tell me about this topic, hopefully what you tell me is 'it's absolutely fine, no problems whatsoever'

Can I do websites with it?

Any platform but windows is a second class citizen with .NET.
Why use C# when there is C++?

No

Can I fizzbuzz with it?

>Why use C# when there is C++?
a lot of job offers are for C#

i could learn C++ and hold a job, but i am self taught (no CS degree) and i won't be able to get in through the door at a C++ job

Surprisingly, yes

>i won't be able to get in through the door at a C++ job
You never know :)

i desperately need the money
i am so sick and tired of being poor
i want to live in a place with more than 1 room, not have disgusting ape neighbors that are just constantly banging on the walls, eat somewhat expensive food, buy nice clothes, have a bathroom where i can take a shower and not freeze to death, a nice new bed, a driver's license, a car
i need to be useful

besides i am incredibly furious, envious and jelous at webshitters for having jobs when they can't even write anything meaningful in C

i know, i just know i am at least as good as the average CS bachelor out there and for a C++ job i reckon i might need some job experience to show first

Attached: 71999.jpg (620x348, 49K)

Studying computer science is so weird, you can always hear "I have been working as a programmer for years and didn't know this!"

Imagine if a doctor said "I have been a doctor for years and never knew mumps had a cure!" or a lawyer saying "I have been practicing law for years and never knew that law existed"

Albiet that ends up being true for a lot of languages, but the rust cases are literally just drop in replacements.

It can do wasm though. And in another 5 years when they finish tokio async io.

Tighten those bootstraps, walk in the front door, firmly grip the manager's hands, look in his eyes, and say I want a job!
;^)

If I want to use C++ move semantics to move something from A to B, is this the right way to do it or will it do an unnecessary move step?
void something(thingy &&bar)
{
if (condition)
baz = std::move(bar);
}

...
something(std::move(foo));

>besides i am incredibly furious, envious and jelous at webshitters for having jobs when they can't even write anything meaningful in C

Lmao why do aspies in here cling so hard to C

sounds like you need to move from that shithole. I used to make enough to afford a nice two bedroom apartment in a Sydney suburb just flipping burgers.

You usually don't want to use && as a function parameter.
What is it that you are trying to accomplish exactly?

It's more typical for the function to take by const-lvalue reference.

Just for learning purposes: I am making a LIFO data structure and want to push items that are RAII. Currently I have this:
bool stack::try_push(T &&p)
{
if (this->top == len)
return false;
arr[this->top++] = std::move(p);
return true;
}

>>RE-INVENTING THE WHEEL

Attached: 1506094793496s.jpg (233x250, 8K)

>has no support for CMake or Meson
Lmao. Did they really think people will make a non trivial pure nim project? Nim's best use case could be a replacement for lua, integrate with a C++ project effortlessly. But the faggots got too cocky.

It's possible to emulate inheritance using composition and the Deref trait. It's also completely pointless unless you're interfacing with foreign code that absolutely needs it. Traits are a more powerful abstraction and Rust isn't alone in totally discarding inheritance in favor of explicit interfaces. Modern language design has been steadily moving in that direction for years.

If you think about it, you actually WANT a copy of the value. Take by value and move that into your stack.

Why would a language that has its own native build system and package manager support Cmake or Meson?

>Imagine if a doctor said "I have been a doctor for years and never knew mumps had a cure!" or a lawyer saying "I have been practicing law for years and never knew that law existed"
actually, doctors don't know basic shit all the time, especially if it's not in their specialization

That being said, you can also have an overload for T&&. That takes care of move-only types.

wtf I hate nim even more now.

Same with Lawyers. That guy is an absolute fuckhead