/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

pastebin.com/9qLRCTs7
github.com/enfiskutensykkel/ssd-gpu-dma
twitter.com/SFWRedditGifs

import std.stdio, std.string, std.conv, std.random, std.range, std.range, std.algorithm;
struct Node {
int element;
Node * left;
Node * right;

void insert(int element) {
if (element < this.element) {
insertOrSet(left, element);

} else if (element > this.element) {
insertOrSet(right, element);

} else {
throw new Exception(format("%s already exists",
element));
}
}

void print() const {
if (left) {
left.print();
write(' ');
}

write(element);

if (right) {
write(' ');
right.print();
}
}
}

void insertOrSet(ref Node * node, int element) {
if (!node) {
node = new Node(element);

} else {
node.insert(element);
}
}

struct Tree {
Node * root;
void insert(int element) {
insertOrSet(root, element);
}
void print() const {
if (root) {
root.print();
}
}
}
Tree makeRandomTree(size_t n) {
auto numbers = iota((n * 10).to!int)
.randomSample(n, Random(unpredictableSeed))
.array;

randomShuffle(numbers);

/* Populate the tree with those numbers. */
auto tree = Tree();
numbers.each!(e => tree.insert(e));

return tree;
}

void main() {
auto tree = makeRandomTree(10);
tree.print();
}

Don't create duplicate threads, even if the other OP is retarded.
Delete this shit.

It's up to users to support or not support retardation.

Is that D?

Looks liek C++ with import, so probly.

>no ideal programming language
What do?

>import std.stdio, std.string, std.conv, std.random, std.range, std.range, std.algorithm;

Learn Lisp.

>no O(1) access time to lists
Why even try?

aref, elt, nth

Lisp actually can use arrays and vectors. It's just that it's not the preferred method of programming.

How does O(1) access time to lists even work?

>this is what lispfags really believe

what is your ideal programming language

Nth element of the list is available at offset+(N-1) address.

Lisp is so shit, the only advantage is that you can turn it into a different language

ActionScript is the only language you need

Trash.

use a few different semi-ideal languages

Oh that makes sense, why doesn't Lisp have this?

It does

/* mixin.h */
#pragma once
#include
#define mixin(base, derived, body) \
template class derived: public base { \
body \
public: \
virtual bool includes(std::type_info mixin_id) { \
if (mixin_id == typeid(derived)) return true; \
return base::includes(mixin_id); \
} \
}; \
template class derived { \
private: derived() {} \
};
class empty_mixin_receptor {
public:
virtual ~empty_mixin_receptor {}
virtual bool includes(std::type_info mixin_id) {
return false;
}
};

... So in other words, lists are just vectors with list interfaces grafted onto them to facilitate recursive programming?

C++ is truly has one of the ugliest syntax, almost as ugly as rust.

No, vectors are just lists with magic algorithmic properties because of how memory works

go fuck yourself it's beautiful

And how am I supposed to do them from CAR, CDR, CONS, EQ, ATOM, SET, EVAL, ERROR, QUOTE, COND, AND, OR and LIST?

So, lists AREN'T just vectors with list interfaces grafted onto them?

In other words, storage of list elements is not contiguous?

In other words, the thing you said before wasn't true???

What?

>Nth element of the list is available at offset+(N-1) address.
This claim is equivalent to saying list element storage is contiguous. That claim is in turn equivalent to saying lists are internally vectors. I then asked if lists were internally vectors, to which you replied they were not--which contradicts the claim I quote above. I'm confused, which is it?

I don't know what you're talking about?
A language could implement lists by using vectors, but the concept of lists doesn't depend on the concept of vectors

>Nth element of the list is available at offset+(N-1) address.
You said this. Is it true? If it is, then lists are by definition actually dynamic arrays. If lists aren't actually dynamic arrays, then it's not true.

No, it does not. Otherwise cons would be an O(n) operation, and there would be no need for the vector type.

I didn't say that and it's language dependent

I was assuming he meant to refer to vector but misspoke.

See: If you're that guy, yes, you did. If you aren't, what are you even doing butting in.

you asked a question about lists and vectors and i answered

lads I've been wondering
for a couple years now I've never really thought of going to grad school

so i just relaxed with my grades for shit outside CS getting Bs or Cs and whatever, GPA kinda went down

I keep wonder if that was a bad decision and maybe I should care about it

How relevant is grad school if you want to make 6 figures some day?
Is undergrad just not enough?

I don't feel that grad school matters much unless you want to go into academia, which notably pays less than industry anyway.

$ time ./test3.sh
142913828922

real 222m59.277s
user 41m53.744s
sys 101m19.524s
Is bash just a slow piece of shit, or is there fundamentally something wrong with this script?
#!/bin/bash

primes=2
for i in $(seq 3 2 2000000); do
isPrime=true
for ii in $(seq 2 $(bc

>what are you even doing butting in.
Butting in is fun.

h-homu please

>intermediate pleb programmer here

I still feel like such a dumb cunt when it comes to programming.

>dangerous dave written from scratch in 1990
>~27 years on and something like that feels next to impossible to write unless you use some shitty scripting game engine (which I'd probably fuck up and take forever to learn how to use)

who said this?

What's the problem?

The only annoying part is actually figuring out how to get shit to show up on the screen. Everything else is up to you and can be programmed with the very simplest methods.

Who said what? I said it.

>figuring out how to get shit to show up on the screen

Even games like lemmings/etc. It feels so achievable.

I guess what my problem is, is that there are these turbo nerds writing shit in C/C++/etc with no graphics frameworks/etc (talking out my ass I don't know what they actually used) and I feel like I'm flat out getting hello world to show in the console (exaggeration).

Why aren't I a turbo nerd :(

>My 1988 version of Dangerous Dave was the Apple II version. The scrolling was done by moving all the screen bytes over then drawing a new tile on the edge of the screen - repeat 20 times for a full screen shift. The Apple II version was written all in 6502 assembly language.

>On the PC, the 1990 version, I wrote graphics code in 80x86 assembly language for all video modes at the time: CGA, EGA, VGA. Dangerous Dave PC is the only game I know of that has all 3 video modes in it and switchable at any time (F2), even in the middle of a jump!

>To scroll the screen quickly, it was all in assembly language and I used a similar technique as I used with the Apple II version - quickly move bytes in video memory and draw a tile on the right side. In EGA it was trickier because to do anything quickly in EGA mode required the use of Latch Mode for memory moves. I remember teaching Todd Replogle how to do that so Duke Nukem 1 would be a fun game (a slow Duke Nukem would not have been cool).

>The game code for Dangerous Dave PC was written in C, in the Borland C 3.0 IDE. Most debugging was done in Turbo Debugger on a 12" amber monitor plugged into a Hercules card.

Fucking boreland

Here is a tip that will take you far if you have the balls to grasp it.

You will never be 'ready' to move on to the next stage or next step. There is no series of tutorials or practice programs that will get you to where you are now to where you want to go. You just have to embark towards your destination.

Go learn how to get shit to show up on the screen in opengl or SDL or even from 'scratch' with xwindow or with whatever windows uses. If you don't have the prerequisite skills you will learn in the process.

You could fuck around with toy programs for a million years and never learn how to get graphics on screen because the only path from toy programs in the console to getting graphics on the screen is to actually buckle down and learn how to get shit to show up on the screen.

...

>drawing simple graphics on a screen
>not a toy program

>intermediate pleb programmer here
>dangerous dave written from scratch in 1990
>~27 years on and something like that feels next to impossible to write unless you use some shitty scripting game engine (which I'd probably fuck up and take forever to learn how to use)
Who said this? This is the first time these messages have appeared in this thread.

>:(
look into some other website more appropriate for your kind.

...

Die in a bus fire.

...

Die in a river.

...

Just jump off a bridge already.

...

Die painfully okay?

...

>graphics, histograms, GUIs
>toys

toy programs

I'm submitting this to my professor to show that I am not a java super retardo at his request
please let me know if I did anything incredibly stupid, I actually am a java super retardo
pastebin.com/9qLRCTs7

Anyone might care to explain how CRUD is supposed to be made in a Rest based design website.

Let's say for example I have my repository with a method(query) that deletes something in my database and that I want to make an http request that calls that method. How should I proceed ?

They aren't.

If I make my own templates in my own language and process them into C file, will my language be considered as some other language or it will be a set of C macros?

Who knows?

Why use templates at all?
Implement proper polymorphism

"Polymorphism" in the way most people think of it is shit.
All we need to use are tagged unions.

I don't mean inheritance

I want to make a python application that will need a database, I think sqllite should be fine.

Where exactly is my code supposed to install to and put the database etc? Is there some standard way this is done in unix? All my googling gives me web related stuff.

By templates I mean something that serves as a pattern to fill other C commands, not C++ templates.

He said polymorphism, not "polymorphism"

That's D

you would use opengl to make that nowadays

I have made my gibmodulus script portable to my Windows VM by using Ruby libraries!

#!/usr/bin/env ruby
# A simple script to copy the modulus character to my keyboard
# Because my fucking 5 key doesn't work.

require 'clipboard'
Clipboard.copy 37.chr

>What are you working on, Sup Forums?
Managed to hack together a working solution, need to clean stuff up and implement a real workload.

github.com/enfiskutensykkel/ssd-gpu-dma

tl;dr version: I've implemented a NVMe SSD disk driver in userspace and I'm able to control it from a CUDA kernel. The benefit of this is that I can do I/O between a GPU and a disk without having to involve the CPU or the system memory at all.

It's called a percent sign.

@--------
Epic post.
Epic reply.

Why tying certain kinds of procedures to certain kind of values is considered a bad thing?
Doesn't that make programming easier? Isn't it easier to have a list of functions with certain types, so in case you've forgot some function, you could just call a list of subroutines of some kind of values?

>posting your github on Sup Forums

May I ask why are you replying to an attention whore?

Probably getting a job writing Clojure. Pretty excited about it. Not sure about the whole JVM platform thing, but Clojure sounds nice as fuck. If that sticks, I'll be going over SICP later this year.

I've posted my github profile here before. I've seen lots of other people post their github profile here before.
Nobody gives a shit about who you are. Nobody is out to get you on here.

You know why they call it clojure?
Because you close the door and walk way.

This

Only haskell and fizzbuzz allowed here

he didn't even imply that let alone say it

Shit dud.
Reminds me of that malware that loads itself to VRAM to avoid detection.

Why did you want to become a programmer?
How many years ago you wrote your first programs?

I have a good grasp on C and C# and now I'm working with C++, got the basics and OOP figured, but am lacking in the templates and language intricacies.
What is a good book I could pick up /dpt/?

Is there a better book fo Erlang than learn you some erlang for great good?

I am struggling to understand SWGEmu's code (A Pre-CU Star Wars Galaxies emulator).

I built and can run the server without problems, and now I want to contribute. But there is barely any documentation besides coding style guidelines, and for a beginner like me it is hard to understand the structure of the code.

Anyone here with some experience with it?

The only docs I've found are for scripting themeparks and things like that.

I just thought it looked interesting.

Trying hard to fit in I see.

Compiling to C is a valid strategy. It is for instance what the first version of C++ or OCaml did.

Nim does it.

I thought it was the only real way that I would be able to Hack the Gibson.

Where can I read about compiling to C if my language is very different from C?