/dpt/ - Daily Programming Thread

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

Other urls found in this thread:

github.com/dbuenzli/tsdl
github.com/dbuenzli/tsdl/blob/master/src/tsdl.ml
en.wikipedia.org/wiki/Caesar_cipher)
pastebin.com/5F16Ejcp
gcc.gnu.org/ml/gcc/2017-06/msg00111.html
twitter.com/NSFWRedditGif

SDL2 interface to OCaml.

Making my Pascal compiler go from working to friendly.

nth for good thread and reimplementing Vulkan in Idris

I have always wondered this about OCaml:
Is it for camels?
Is it a programming language made for camels?
Are you a camel?

?

First for C.

its made for smokers

This is probably what C-chan looks like

>tfw no kawaii jp grandma to take care of me

CAMLprim value sdl_create_window_native (
value title, value x, value y, value w, value h, value flags) {
SDL_Window *window;
CAMLparam5 (title, x, y, w, h);
CAMLxparam1 (flags);
window = SDL_CreateWindow (
String_val (title),
Raw_window_position (x), Raw_window_position (y),
Int_val (w), Int_val (h),
convert_flag_list (flags, window_flags));
if (window == NULL) {
Report_error ();
} else {
CAMLreturn ((value) window);
}
}

>in C this is just

This is just what?

are there any genuinely good books on javascript programming?
also what precisely is modular JS?

too hot to program today. fuck.

kek
>"grandma can you cook me an array"
>off-by-one error
>c-chan: "oh shoot i have dropped the tray that just came out of the oven because i am old"
>house goes up in flames
>flames spell out "segfault"

There is already bindings for sdl in ocaml.
Also the C interface in ocaml sucks.

>he needs static typing

You mean something as simple as logging values or inspecting them is not done better through a tool intended for it?
Maybe on Linux. I tried ddd back in the day and it was a hassle I agree but I assumed it had improved by now.

>bindings for sdl in ocaml
Where? MIT or BSD license (ie public domain)?

Wow.
OCaml looks remarkably like C.

github.com/dbuenzli/tsdl
You should check out search engines sometimes...

It is a joke?

well just malloc a new house no biggie

github.com/dbuenzli/tsdl/blob/master/src/tsdl.ml
Obj.magic
No way.

trying to parse and analyze amazon reports from an ad campaign. What are these retards thinking? .txt format, none of the columns line up, the titles of each column overlap onto each other and get mixed up because they are two lines long. No wonder this company is so shit,

/dpt/ why doesn't a language like this exist yet?
>C except with garbage collection, lambdas, and closures
>still a compiled language
>still as low level as C
>no difference in syntax except as appropriate to distinguish these new features (e.g. a new pointer syntax to distinguish pointers that should be eligible for garbage collection when there are none left in scope vs pointers that shouldn't)

The bigger a company is the more likely they are to cut corners
literally D with very minor syntax differences.
And if you dont like something you can just call C directly.

>C except with garbage collection

Writting my own private version of reddit from scratch

if they just put commas between each item this would be a 30 second job

Which language? Do you need help? Is your private version open source?

I'm revising my standing on Go from Meme to Partial Meme since it's pretty comfy if you ignore the woman developer syntax

>private version of reddit
Literally why.
A website like Reddit is completely useless if you're the only user.

Why do something right the first time when you can spend more money breaking more things, and wasting time to fix the initial problem that shouldn't have eve been one in the first place :^)

Regular front end stack and Django for back end. I guess not it wont be open source,we dont need another voat.co more for learning purposes to brush up my web dev skills.

why do languages feel the need to have multiple prints instead of just having one intelligent and flexible one?

For learning purposes i am not trying to make another voat.co ,also i way to better organize my saved stuff, interesting resources on programming etc

Instead of cloning reddit just make a page where you can post things and assign them a score yourself to rank them

Anyone else here fall for the CQRS meme hard?

I'm not even using an event log, just a message queue. Right now i'm sharing data between both sides but I'm sure this is fucked. I don't want to have to parse an event log to rebuild the query datastore. Any tips?

What is man supposed to use when here's just no good statically typed and compiled language?
>sml
no good implementaion
>ocaml
sml with shitty syntax, also does not support native threads
>c
decent but manual memory management is annoying in prototyping phase
>sepples
cluster fuck that no sane person would touch
>d
can't decide if it wants to have gc or no
>rust
better stay away from it because it attract lot of crazy hipsters, also uglier than sepples
> any jvm/clr lang
requires huge vm
>go
Rob Pike is faggot, also no macros
>haskell
generates garbage 1GB/s
>chapel
cannot use libraries that was compiled with it...
>ats
Jesus Christ
fun{
a:t@ype
} list_length
{n:nat} ..

Pretty much just got past the introductory curve with JS, messing around with arrays right now and I wanna try to make a short chose your own adventure story with it.

Yes I'm a newfag at this pls no bully.

6..9
you

Just use Python

Then do it!

>statically typed and compiled
>python
Also fuck Guido for making python3.

We pray the prophet (Jonathan Blow, PBUH) will deliver us JAI soon.

>Also fuck Guido for making an almost good language to replace his shitty language
???

>$CURRENT_YEAR
>using Python 2 instead of 3

Jai 1.0 probably wont be for atleast another year or two.
And even then, why?
Ive watched all his streams and i still see no reason to use it.

His temp features are pretty neat though.

>better stay away from it because it attract lot of crazy hipsters
I don't think that's a valid reason to avoid a language. You don't have to interact with the community much except for reading their documentation, and the documentation for Rust is pretty spot on. The only area in it where shitty ideology might be leaking out would be in that one dining philosophers example where Karl Marx was used as an example string. But I don't really care about that, and neither should you, because I think we're better than a bunch of babies getting triggered by micro-aggressions.

Your point about Rust being uglier than C++ I might be willing to concede (I disagree, but this is a subjective evaluation), but I would question whether this is your honest opinion, or merely an excuse you came up with after a hasty conclusion from the first point. What part of its syntax do you find most revolting, and what would be the alternative C++ syntax that you feel, by comparison, looks better?

>I think we're better than a bunch of babies getting triggered by micro-aggressions.
And when you go down and remove Sky Sport or put something else on and even there residually, you will find, what a Marxist would call, “the reification of triumphant values,” in other words a soft left viewpoint put again and again and again, in every media, at every level.
...
And because conservatism is an anti-intellectual attitude anyway, often Philistine, often atheoretical, when a Marxist version of center-leftism comes along, they increasingly laughed at it, scorned it, accepted it a bit, accepted it a bit, moved to the side, said they were against it, pushed away an egregious bit, accepted a bit. Then another generation would accept a bit more. Then another generation would accept a bit more.
...
The one thing I would think, looking back on Marxism after a hundred and fifty years in all of its variants, is the extraordinary cowardice of some of the most privileged people in Western societies who would not stand up to this type of theory, which is how it always begins, and didn’t realize that in the end it would destroy everything they loved and everything they wanted.

>What part of its syntax do you find most revolting, and what would be the alternative C++ syntax that you feel, by comparison, looks better?
Rusts main issue is its BC makes every tiny thing 3x more tedious and complicated, and by syntax, more verbose.

Not him though.

kek

The borrow checker is the USP Rust is banking on. Without that, it's just another C++ killer ready to fail like the rest.
But it's already easy to write memory safe code simply by following RAII, so I feel like it's wasted effort.

D

>I watched all of it and still don't see a reason
Well I guess it might just not be for you then.

I feel like Rust is just like Haskell in that it'll be a learning language that will get improved on by future langs.
Its just a c flavor with a few extra bells. Why use it over an already established language that you lose next to nothing with?

That's how you inflate budgets effectively. Good job user. Tell me if you don't get your bonus by the end of next week.

>it's just
Well I thought you had watched all the demos. Clearly you haven't.
Every language is an iteration on another. If you keep saying "it's just this with that" you will never get anywhere. It's very difficult to find special languages unless you go to DSL or entirely different paradigm. But you didn't want either of those it seems.

which is faster in c#?
>500 or so switch cases each calling a specific method
>naming methods after switchable's value (i.e. a(), b(), c() etc) then dynamically compiling the string & calling it

first bash script, is there anything that screams "this is a terrible fucking script" or does it look ok? its a script to rename all my wallpapers in my cwd to randomized names.


#rename all files in the current working directory to a random string


#generate 1 random string of 6 characters
rand=$(pwgen -s 6 1)

for file in *; do
if [[ ${file: -4} == ".png" ]]
then
mv $file ${rand}.png
rand=$(pwgen -s 6 1)
fi


if [[ ${file: -4} == ".jpg" ]]
then
mv $file ${rand}.jpg
rand=$(pwgen -s 6 1)
fi


if [[ ${file: -5} == ".jpeg" ]]
then
mv $file ${rand}.jpeg
rand=$(pwgen -s 6 1)
fi

done

First one, obviously. Reflection is slow as fuck

Better, use a map to functions

Then what does Jai really do fundamentally different?
Besides being made with games in mind which i guess is one.

Only one, no, two, answers.

If I were to pick a few things I'd say it's a statically compiled language designed with low level machine interfacing in mind just like C with powerful metaprogramming facilities.
But why would a language have to be fundamentally different to be good? You're setting these superficial goals for no reason.

can it be done using ahead of time compilation with threading, in theory?

elaborate pls senpai

> I'd say it's a statically compiled language designed with low level machine interfacing in mind just like C with powerful metaprogramming facilities.

Then Ill just use D.

OK. Seems your reasons for disliking D were minor to begin with so it sounds reasonable.

Create a map from strings to actions
Look up the input in that map
Execute the resulting action

Im not the pasta user m8

>can it be done using ahead of time compilation with threading, in theory?
you are overcomplicating it. is right, just use a dictionary, something like this
var map = new Dictionary();

map.Add("a", a); // a is a method
map.Add("b", b); // ditto

// Then call a method
if (map.TryGetValue(methodName, out var action)
{
action.Invoke();
}

How about you split on the last period and use that to get the extension. Yeah the script is bad.

Why are you bandaiding the problem instead of asking why the fuck hes doing a 500 case switch

thanks anons, much appreciated.

How is that "bandaiding the problem"?
That's the proper solution.

>pasta
Oh shit you're right. I'm so forgetful I fall for it a lot.

To a problem of having a set of 500 different branches your program can go out into.
user wouldn't be asking here if his domain was actually that complicated.

THERE IS NO SANE USE CASE FOR A SWITCH OF THAT SIZE

its for emulation though, if i cant do it any other way i have to implement a switch/case based interpreter. that's the most sane way of doing it, ironically.

what kind of emu?

implementing a basic z80 cpu so i can "master" c#, im doing it to motivate myself to learn more "advanced" features of the language.

Should I bother learning Clojure? Are there many job opportunities with it?

writing a script to flood the chatroom of a pedo site making it impossible for others to talk by using all the bandwidth in node.js

>What are you working on
I'm studying C programming and just finished this little exercise. It's a program that simple asks the user for some text, encrypts it with the Caesar cipher and displays the result. (en.wikipedia.org/wiki/Caesar_cipher)

To try something a bit crazy, I decided to see if I could implement it entirely with functions that have void arguments and return types.

pastebin.com/5F16Ejcp

So GCC is going to include D runtime and front end soon.
gcc.gnu.org/ml/gcc/2017-06/msg00111.html

Why are they adding a dead language?

C++17 is superior to D in every way.

Even Java is better than *++

>C++17 is superior to D in every way.
D has modules

C++120 is still SHIT++120

C++ doesn't have a GC that it's been trying to shed for 16 years

[code[GC.disable

>pic
And people think C++ is worth dealing with.

C++ has garbage collection, pajeet

What's the matter? Is RAII too hard for you?

What a surprise, D fanboys can't even use code tags correctly

They may as well add a COBOL compiler at this point.

Shit++ has garbage collection since shi++11

>Is RAII too hard for you?
D has native RAII, you mouth drooling pajeet

Read my post again, more carefully this time.

C++ isn't for amateurs, that's all.