/dpt/ - Daily Programming Thread

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

Attached: 1354789686022.jpg (1311x1784, 626K)

Other urls found in this thread:

stackoverflow.com/questions/1957099/how-do-free-and-malloc-work-in-c
aphyr.com/posts/301-clojure-from-the-ground-up-first-principles
twitter.com/SFWRedditGifs

Lisp is the most powerful programming language

where's the fucking pastebin you anime nigger

learning haskell

I'm making a type/logic programming system for a systems language that combines ideas from separation logic and zippers. I'm going to call it zipperation logic.

There has never been any extra garbage like that which get put into the OP.

>functional programming

Imagine being unemployed

C++

Elixir

Do Language Server Protocol matters in webdev? Would it be possible to replace it with snippets?

>chapter about if statements and loops
>first exercise has nothing to do with if statements or loops
>in fact, it involves utilizing a function that it never taught you and straight up tells you "look it up yourself"

granted I'm understanding this correctly, there is absolutely no need for if or loop statements in this exercise, right? also, why does it say that finding the distance between two points is more advanced than finding the square of said distance? isn't that a thousand times simpler? I have a hunch there is something I'm not understanding from the way this exercise is stated

Attached: needful1.png (536x80, 7K)

it's just pythag, my dude. You remember maths don't you?

This is middle school math, user.

Oh that makes much more sense, thanks

Can someone explain me how free() works in C? How the fucks it figures out how many bytes to free just looking at the pointer?

stackoverflow.com/questions/1957099/how-do-free-and-malloc-work-in-c

I'm making a simple text adventure in python. So far I have implemented fighting, exploring, dying, leveling and events. It's really just a simple thing to test and explore the concepts I'm learning but I'm having great fun with it. My next step is to add a bit of depth to game, probably redo the combat to add some depth to it, and redo the fights to make it balanced and fun

Is C++ template engine sorta like C preprocessor?

Good book for begginer in lisp clojure? The one I've got is outdated.

no

How long after your first job did you start looking/get a second job? Was the process easier?

elaborate

they basically have nothing in common apart from being (bad) code generation tools

it's marginally more sophisticated but for the sake of reasoning about a template, you can look at it like a text insertion

is learning C++ is worth it

Attached: 1522078695100.jpg (1290x1052, 155K)

no

>69537595
not if you're a retarded frogposter

wow that was fast but as you have not provided any explanation, I will ignore you're input

depends what you want to do

Fuck off. Your retarded kind is not welcome here.

dumb frogposter

ur too dum
LMAO

like what, I dont want to do web dev or mobile

Attached: 1548363100725.jpg (400x400, 26K)

I'm trying to write a decent Lisp-to-C compiler and runtime in under 1000 lines. I cut the GC down from 200 lines to under 100 without losing any performance (counterintuitively) by switching from naive mark-and-sweep to Cheney's algorithm.

I managed to solve the second part of the exercise but now I'm stumped on the first part as I'm not sure if the formula I used is correct

#include
#include

int main(){
char input[100];
int sideA;
int sideB;
int sideAB;
float square;

printf("Enter the lengths of your sides: ");
fgets(input, sizeof(input), stdin);
sscanf(input, "%d %d", &sideA, &sideB);

sideAB=sideA+sideB;
square=sqrt(sideAB);
printf("The square of the two sides is %f", square);

return 0;
}

There are too many C++ developers. You will not get a job.

>How the fucks it figures out how many bytes to free just looking at the pointer?
Depends on the implementation. One may decide to use more memory than you allocate, such that you get
[size]
[your stuff]

>"LISP is worth learning [because of] the profound enlightenment experience you will have when you finally get it. That experience will make you a better programmer for the rest of your days, even if you never actually use LISP..." Eric S. Raymond, How to Become a Hacker

How legit is this?

Cringeworthily vague and unspecific

hello anime programmers, i have made a mistake and deleted my fork repository because reasons....now i cant pull this PR that I made and can't make any changes.....

any way to fix?

Attached: i fucked up.png (552x66, 11K)

wow it's really messed up to try to demotivate me

Attached: 1548251236510.png (657x527, 13K)

there is actually a bloody shortage of competent c++ devs

i can't close a fucking job opening for like a year

if there are too many c++ developers than literally every man and baby is a JS developer....there's no normal person who wants to get into c++

Is this real?

I think the best way we're going to get more people willing and able to write in C++ is to introduce large amounts lead into the water supply.

>in under 1000 lines
This is probably trivial if you’re using Python.

slow down raj

def compile_reduce():
global func_ctr
func_ctr += 1
definitions["reduce"] = "Reduce"
name = "reduce"
global_scope.append("""

function* reduce2(function* lst, function** env, memstruct* m){
function* op = env[0];
function* ret = env[1];
while(call(Isnil, lst, m) != Closure3){
ret = call(call(op, call(Closure11, lst, m), m), ret, m);
lst = call(Closure14, lst, m);
}
return ret;
}

function* reduce1(function* initial, function** env, memstruct* m){
env[1] = initial; env[2] = NULL;
m->Temp_closure->body = reduce2; my_memcpy(m->Temp_closure->env, env);
return m->Temp_closure;
}
function* reduce0(function* op, function** env, memstruct* m){
env[0] = op;
env[1] = NULL;
m->Temp_closure->body = reduce1; my_memcpy(m->Temp_closure->env, env);
return m->Temp_closure;
}

function* Reduce;

""")
main_scope.append("\tReduce = create_function(reduce0, empty_env, 0, m);")
GC_code(name)
return

been there
done that (kinda)
though my GC is shit and i'm just gonna use a library, fuck that shit
also my types are fat and dynamic, math is just inefficient as fuck

i'm ok with this, it's my first compiler and honestly it didn't even start as an actual lisp compiler(more like lisp-like), but just a lambda calculus compiler
so i took a lot of shortcuts

if i started over i'd do things differently, in more than one ways

what explanation is necessary that hasn't already been said in previous threads? Its syntax is hideous, it's so overengineered and complex that every shop uses a different dialect, and using its pseudo-features results in ridiculous compile times and an unmaintainable codebase.
Despite this, the supposed performance benefits it offers over its competitors seldom show up in any meaningful way in performance benchmarks.
Every other commonly-used language has at least one thing it can claim to be the best at, but C++ tries to be everything to everyone, and ends up being clunky and ineffective at just about everything.
Its type system was not made for the kinds of abstractions it tries to provide. It has half a dozen different syntaxes for initialization, two different kinds of references, one that's just a bare pointer, and another that doesn't play nice with core language features like arrays.

>tfw im an employed C++ dev
>I got hired and they're paying me fucking loads to keep me on because of the amount of webdevs and indians that apply to C++ positions thinking "I used C++ once during a class I got a B- in" as "knowing C++"

Being a C++ dev already puts you above a lot of the meme language fucks and webdevs that flood the job market right now

be honest, You're just scared of C++ because you were exposed to it when you were a brainlet that only found comfort in python or javascript or java and now you're just a fox making fun of grapes

be honest, You're just scared of functional programming because you were exposed to it when you were a brainlet that only found comfort in C or C++ and now you're just a fox making fun of grapes

be honest, You're just scared of proper computer science because you were exposed to it when you were a brainlet that only found comfort in python or javascript or java and now you're just a fox making fun of grapes

total bullshit

be honest. You're just scared of making an original joke because you were exposed to it when you were a brainlet that only found comfort in mimicking some retarded C++ shill and now you're just a faggot posting on the daily anime thread

this
just because it was popular (part of the reason it still is) doesn't mean it's good

>about to read a book on Clojure
>author starts off with saying he isn't straight and even if you're a woman or a non-white you can still learn how to code

aphyr.com/posts/301-clojure-from-the-ground-up-first-principles

Attached: 1540561812101.jpg (380x365, 73K)

>Despite this, the supposed performance benefits it offers over its competitors seldom show up in any meaningful way in performance benchmarks.
I agree with all your criticisms but the peformance and power of C++ is very important, "performance benchmarks" mean nothing

JavaScript rocks!

Attached: javascript rocks.png (1000x494, 134K)

white people shouldn't be allowed to code

So I made an auto clicker in python in like 20 lines of code. Why does Jow Forums hate python again?

typelets shouldn't be allowed to write

Python's where it's at. You can do almost anything with it.

import solution
solution.run()
Wow, user! You're such a good programmer!

Attached: 1547987422789.jpg (622x647, 75K)

because it's only good to make auto clickers?

>performance benchmarks mean nothing
>performance means nothing
if it's important, it should be formally measured. We have standardized and transparent benchmarks for runtime systems and compiler outputs, why should those be ignored?

>you didn't actually build your house because you didn't make the nails

wew lad

No, that's like saying you built the house because you got someone else to do all of it, but you were the one that painted it.

>decides that C is unsafe
>tries Ada, Go, Rust, Swift, Vala
>no standard bindings to C libraries especially X11 and win32
>back to C
How do I hackproof my programs?
Why experienced programmers create exploitable bugs that get discovered every day?

Just don't be shit. If you're actually good at C, it's very easy to spot potential problems.
>X11
>Not libwayland-client

oh please, half the US politicians want to deport any indian coder, confiscate his house, pull his kids from school and give it all to YOU, personally

I've graduated with a degree in software engineering, but I don't have any actual projects to show potential employers.
I guess I need to build a portfolio of some sort. Do you guys have any project ideas?

What's important is your use case not typical use cases.

C to C++ compiler

C to Javascript compiler

You basically just had a house built for you after looking through a catalogue.

Javascript to C compiler

The runtime is written in C and I figured I'd write the first iteration of the compiler in C, too. The final compiler will be written in Lisp and compile itself. I'd like to have under 1000 lines of C and get maybe 80% of the performance of a real Lisp compiler like Chicken.

>analogies
as always, never fails to disappoint how fucking shit using analogies is

How do I implement dynamic typing in a compiled language? Would I just have an extra byte somewhere to store the variable's type?

hey, you should try this online python course by Udemy

do it like python
everything is an object

python is basically compiled anyway

So my prof linked to a website using ssl.website.com instead of www.website.com

what makes a person use ssl? is it a special routing thing? private vpn?

>How do I implement dynamic typing in a compiled language?
by doing a ton of dumb shit
see groovy for a good example

ssl is a subdomain of that website.

the link he uses is broken....i mean, how the hell does someone copy ssl.website.com instead of www.website.com? I am pretty sure his computer is set up or some shit.

Functional programming is the future.

Attached: haskell_loli.png (708x1000, 709K)

Are Udemy courses worth it?

Alright guys, I completed all the useful projects on my list so now I'm finally going to do it. I'm going to make a compiler for a functional Lisp-like language but probably with reasonable syntax unlike (((you know what))) and then I'm going to rewrite the compiler IN ITSELF. Using Assembly as my target language btw so the training wheels are completely off. So what am I going to have to put on my feature todo list to get the language to the point of being capable of writing a compiler in? Here's what I have so far.
>obvious stuff like functions, variables, and conditionals
>vectors
>strings
>file IO
>structs
Anything I'm missing? Know any features that will make writing a compiler in it easier?

Attached: 1535380331362.jpg (600x600, 333K)

how would you design a secure system where a user enters a value, and you return a cookie to him to later restore the value he entered, but where the user can't fabricate a different valid cookie than the one you provided him?
>in a way which doesn't rely on security through obscurity, ie he knows how you made the cookie but not any secret keys

the only popular functional programming language is javascript

sign the cookie with a pgp key?
if you want to prevent him from using another user's cookie as his own you'll also need to include some kind of user id

oh yeah duh. ty

A preprocessor.

static double lastTime = glfwGetTime();
double currentTime = glfwGetTime();

can someone explain this? somehow its getting the time difference from when the function was last called but I dont understand why.
every time the loop runs they should just be the same right?

>Know any features that will make writing a compiler in it easier?
Algebraic data types and pattern matching.

Static functions are only initialized once, and their value persists across function calls. You don't casually want to use static because it might require keeping that info on the stack - it has to stick around somewhere.

Ada programming is the future.

Attached: 1547875971957.jpg (1052x1342, 402K)

would i also be able to achieve the same thing by xor'ing it with a key and then hashing the result? i'm asking this because of an overthewire level where the server just xor'd it with a secret which i then recovered, and i want to know how to do it correctly

Static values*

If you're using a C or C-like, inside a function the value sticks around, but outside it means something wholly different, that the function or value is only defined for that file (that the identifier is not exported to the linker or some technical shit)

AND HOW THE FUCK DO I AVERAGE TWO INTS IN C ?????????????