/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

facebook.github.io/reason/mlCompared.html
labyrinth.pythonanywhere.com/
youtube.com/watch?v=OLPxxTCnuqU
twitter.com/SFWRedditImages

>How can I split up a string based on commas or something
import std.stdio;

void main(){
string target = "ceial,ceiwu,382u";
string[int] splits;
int splits_count;
foreach(character; target){
if (character != ','){
splits[splits_count] ~= character;
}else{
splits_count += 1;
}
}
writeln(splits.values);
}

First for OCaml. It's fast.

It's fast but not as standardized as standard ml. Also the syntax sucks compared to sml.
Also fuck GIL.

OCaml confirmed for slow.

Rip. But yeah OCaml is my favorite language and ecosystem.

One tier slower than C++ is a pretty good assessment of OCaml's perf.

I never got why she's wearing a Fez.

#!/usr/bin/awk
BEGIN {RS = "," }
{ for (i = 0, i < NR, i++) { print $(i) }}

The Sussman.

>Also the syntax sucks compared to sml
True enough. It's the reason I unironically like Facebook's Reason, even with its heretical curlies.

facebook.github.io/reason/mlCompared.html

Oh, ok. Why is *he* wearing a Fez, though? Shitskin-loving leftist academia?

OK so how does Node.js actually work? Why does it even exist since V8 can apparently be embedded into any application?

Wrong board

/wdg/ is not here

It's an actual programming question about the internals of the program you moron. It's not about web pages. It's a C++ question.

That wasn't C++.

I haven't used node.js, but V8 is just JavaScript. As I understand it, node.js is an HTTP server implementation in JavaScript, quite simply. Just like Apache is an HTTP server implementation in C.

I used to think Sup Forums was a satire board until they started doing this other places. What gives?

If you keep pretending to be stupid, eventually you end up attracting actual stupid people.

What else should I do with this to make it more interactive without spending money for hosting it?
labyrinth.pythonanywhere.com/

can someone please explain to me what and how java works?

Find the biggest common substring between two strings. Let's see how beautiful your codes are.

Generating random map using Perlin noise.

How do I make my own programming language?

dragon book

Why do people keep asking this question?

I submitted a video recording of my project to my teacher with an anime background. It was super late and i was super tired, i didn't even think about it until i woke up

Am i fucked?

Yes. Anime is totally forbidden in academia. Now you need to learn how to eat nuts and leaves while you build bombs in the woods.

What?

I think he's asking about the JVM.

You ain't.

Alright what is some very easy to implement from scratch hashing algorithm? Doesn't have to be super secure, but should be giving completely different hash for each input.
I was thinking of doing MD5 but after reading a bit about it, seems a bit complicated (or poorly explained).

Yes user, the only way out is to send him your whole moe folder to make him understand you do have a special case of autism that justifies such a background picture.

>but should be giving completely different hash for each input
That's impossible for as long as you accept inputs longer than the hash (pigeon hole principle).

I wrote a *nix shell in D. The code looks beautiful in comparison to Bash. But seeing it's worthless I deleted the project.

Also, I'm officially a criminal now (tax evasion). Guess I have to disappear for a while.

Having an anime background is indicative of a deviant mind that must be purged

What I mean is that at least they don't look similar. Like for example:
'Test' in MD5 is 098f6bcd4621d373cade4e832627b4f6
'Test! will be c4d354440cb41ee38e162bc1f431e99b
Small difference in input, but the hash is very different.

In what shithole is that a """"'crime""""'?

No, he is probably an anime lover as well.

Are you implying that tax evasion has some connection to the shell you wrote?

All of them?

Not in mine certainly, although it's not """"""""officially"""""""" recognized or whatever.

I think your substitute greentext key is broken.

It's raining outside although the sun is up. I'll start packing my stuff after I finish my breakfast.

State your purpose. Do you want to detect corrupt data?

Why would you think so? I'm just pissed off.

I think my algorithm is correct.
It's a pretty typical dynamic programming solution.
#include
#include
#include

const char *lcs(const char *a, const char *b, size_t *out_len)
{
// +1 for the empty string column/row
size_t a_len = strlen(a) + 1, b_len = strlen(b) + 1;
size_t (*sol)[b_len] = calloc(a_len, sizeof *sol);

if (!sol)
exit(1);

// Coordinates to the best known solution
size_t max_x = 0, max_y = 0;

for (size_t i = 1; i < a_len; ++i) {
for (size_t j = 1; j < b_len; ++j) {
if (a[i - 1] == b[j - 1]) {
size_t len = sol[i - 1][j - 1] + 1;
sol[i][j] = len;

if (len > sol[max_x][max_y]) {
max_x = i;
max_y = j;
}
}
}
}

*out_len = sol[max_x][max_y];
const char *ret = a + max_x - sol[max_x][max_y];

free(sol);
return ret;
}

int main()
{
size_t len;
const char *s = lcs("Hello my name is Chris Poole.", "name is Poole.", &len);

printf("%.*s\n", (int)len, s);
}
It's using size_t for a lot of things, which is pretty wasteful on memory space, but it's more "correct".
Changing them to "unsigned" would probably be appropriate.

what esoteric programming language is that?

I like this post

Is it actually viable to be able to get some freelancing jobs as a programmer? I keep seeing articles all over the place about how programmers are in huge demand and it's not like the demand is going to be any smaller as long as computers and the internet exist

trying to code up a binary search algo on C, but I keep fucking it up. The search function takes a target value, an int array and the size of the array. Then I set up start end and mid points, and then I start going through the array.

Problem is, start end and mid get fucked up first run into the search and then it never finds the target. What am I doing wrong?

>size_t (*sol)[b_len] = calloc(a_len, sizeof *sol);
wtf

Haskell

bool search(int value, int values[], int n){

int target = value;
int startx = 0;
int end = n - 1;

while (true){
int mid = (end - startx)/2;

if (values[mid] == target){
return true;
} else if (values[mid] > target){
end = mid - 1;
} else {
startx = mid + 1;
}
}

ugly

and I know the function is not done, I need to add restraints to determine what happens when end and start coincide etc, but this is the first step and it's not working...

>C programmers find this difficult
type String_Access is access constant String;
type String_Args is array (Integer range ) of String_Access;
function Test (Items : in String_Args) return String is
Size : Natural := 0;
begin
for I of Items loop
if I /= NULL then
Size := Size + I'Length;
end if;
end loop;
declare
S : String (1 .. Size);
Index : Positive := 1;
begin
for I of Items loop
if I /= NULL then
S(Index .. I'Length + Index-1) := I.all;
Index := Index + I'Length;
end if;
end loop;
return S;
end;
end Test;

It's a pointer to a VLA.
Jesus christ, do you not even know C?

What IDE is this?

>difficult
>anything with script kiddie syntax like visual basic

why aren't you making a next gen watch paint dry video game?

youtube.com/watch?v=OLPxxTCnuqU

cs50.io, from edx online courses. just register for free to the cs50x course and you're in. But it's a bit slow, imo. It's all cloud-based

Real programming languages look sharp like a knife. Because you might cut yourself trying to use them.

>Test
What does it do?

I don't even know what you meant by that

Is there anything more soul-destroying than having to work with a shitty build system?

Hey guys, I'm now trying to learn programing at codecademy.com!
What am I in for?

Exactly

Basic string concatenation, from the looks of it.

That might actually be your problem
If you need an IDE with breakpoints so badly, you might want to try codeblocks, or visual studio code with C/Cpp plugin, or emacs/vim + gdb

Sick burn, dude

I think the breakpoints on the debugger are fine, they've worked before. And even if I run the thing without the debugger, it still won't work.

>looking for program to do a not-quite-trivial-that-I-want-to-write-it-myself task
>promising SO link
>some guy has written something
>it's in fucking Python
Fuck Python, fuck pip, fuck the prevailing anti-intellectual programming culture, fuck shitty garbage langs

Imagine yourself as a royalty. You will know how to knock with a hammer but you wouldn't know why the fuck should i hammer a nail.

After learning from codeacademy, be sure to actually learn from source codes and stuff.

talking from experience myself, i knew how to do stuff in the terminal but transitioning to creating a program i just hit a wall because you have to pull out everything you have learnt

rude

Having to use Windows.

I don't want to delet my gay mens though

I mean it, Python is fucking cancer garbage

Python is fine for stuff that doesn't require high performance.

is there a "research" in programming? im in software engineering but i realllllyy love math so i thought it would be neat.

...

Skip using their weird debugger, just sprinkle in some printf's until you find where that value is getting changed

python is disgusting as hell. at best you would use it for one-off quick little scripts, not for viable commercial software applications

Nice ``argument", faggot. Let me guess, you're one of those people that think while loops are a ``leaky abstraction" and insist on using gotos and bitshifts to write your fizzbuzz programs?

so do you use assembly to write webpages faggot?

>math
I thought we were just overglorified puzzle enthusiests

Python isn't good for anything.

I'm working on volumetric 3d rendering right now for these clouds.
What would be my best option for preventing rendering / reducing operations in the empty spaces? All of the algorithms that I can find use structures that would only be efficient at the CPU level, or that would result in excessive branching.

Also, is it possible to compile shaders that have early termination for optimization in a reasonable amount of time? Mine always take ages to compile due to all the branches that need to be made.

Yet you're apparently okay with ``commercial software applications" being written in Java, Javascript, and PHP...

>write webpages
do you know which thread you're posting in? fuck off to

>Python is fine for stuff that doesn't require low memory usage or speed
ftfy
Even doing a bunch of string manipulation can cause pythons memory manager to go fucking nuts and eat up GBs of memory

Yes, a ton actually. Get in touch with your university and see what they've got going on, data scientists are always in demand.
Also, learn R. And Matlab. Probably Mathematica.

So then what would you use when you want to write something quickly and don't care about performance?

>Java
absolutely. java isn't nearly as bad as you autistic memers want to think it is

>Javascript, and PHP
for webshit, yes

...

>"research" in programming
A few things my department does related to programming itself:
>Lambda calculi (mathematical background behind one of the computational model)
>Formal systems (Mathematically define types and semantics and other things)
>Formal verification (Use formal systems to confirm programs behave correctly, includes formal proof like Coq and Isabelle)
>Parallel compilation (manage to vectorize non-trivial program source codes)
Quite a bit indeed.

Lisp.

idris, haskell

Ruby has fast development.
Go has good performance. Not C/++ good, but better than Java or what-have-you.

Python has nothing.
Nothing at all.

You'd be surprised at how well sparse octrees work on the GPU.