/dpt/ - Daily Programming Thread

What are you working on?
Previous:

Attached: 431978.jpg (3768x1880, 3.62M)

Other urls found in this thread:

cs.unm.edu/~vasek/cs241/lab/lab8.html
mega.nz/#F!lZgAwZyZ!sxIZg6rZHVME2bcsAs6v2Q
freecodecamp.org/challenges/title-case-a-sentence
twitter.com/SFWRedditVideos

Doing cs.unm.edu/~vasek/cs241/lab/lab8.html
for bc I'm a poorfag and he said he would pay $50 for it.

programming loli bots using a combination of haskell and rust, we're going public next week valued at a billion USD.

>your favorite feature in your programming language of choice
>how many girls do you know

Attached: 1522717346279.jpg (1920x1080, 390K)

car and cdr from Lisp

does family count? if not about 8.

trying to read ML book i brought from HumbleBundle
does anyone know how to write a snake game with C#? The only guides i see about GUIs in C# developments are all about menus and buttons.

What GUI toolkit?
You can do anything in C#. There are even a couple of videos about making a snake game in C#.

monogame

>list comprehensions in Python
>married and employed, so I know a lot of women
>also, pajeet

Learning C#'s TcpListener/TcpClient

It's going alright, but I am probably doing things the hard way since I have tons of Java experience and am just writing it like I would there.

Try writing your own native implementation after you are done.

>What are you working on?
Slowly making progress on my tower defense.

Attached: spooktitles.png (812x768, 67K)

>pointers in c
>does it count if I know them but they don't know me?

Attached: twice twice.jpg (3840x2400, 708K)

lambda expressions
mom, sister, nana, 3 i guess
not much traffic in my basement

About to read "On Lisp"
I kind of want to learn Common Lisp well, and I downloaded Portacle for Mac OS X.
Unfortunately, I get the this error when I boot it up:

Debugger invoked on a SB-INT:SIMPLE-FILE-ERROR in thread
#:
Can't create directory /Volumes/Portacle/portacle/mac/asdf/cache/

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL...

What do?

Attached: Screen Shot 2018-04-23 at 4.33.20 PM.png (2490x1832, 451K)

Fast pace eh?

anybody have ideas for programs that have no practical purpose but entertaining in some way. Love making these things but im bad at coming up with ideas

You could try making a Go, D, or Haskell compiler.

install emacs -> install slime -> +x+"slime"
where meta is one of the command key or alt, or I dunno how a mac keyboard even looks

don't run it from the downloaded image
copy it first to your hard drive

Attached: -1.jpg (200x286, 12K)

kek

Might have more luck here than on /fglt/
Trying out GNU/Linux development
Why are the lib names so stupid?
I mean libc.so.6? Seriously?
Are the names different in different distros?
Is there a compiled list of these system libs like x11, wayland, libc.. etc?

digital russion roulette?
something that deletes the content of your main hard drive with a chance of 1/6

you could then fiddle with the chance for fun sake

If you have time, read E. F. Codd's The Relational Model for Database Management or his papers on functional dependencies. The relational model is pure awesomeness and it's not specific to databases.

>Why are the lib names so stupid?
They're named to follow a particular format that was set in place long ago and allows you to know what the file is what it is involved with by reading the name
lib mean library, c means c programming language, so means shared object, 6 means major version 6 (though the naming of libc specifically is special because it was copied and shared and changed between different authors and systems.

>Is there a compiled list of these system libs
You'll have to look at the packages in your package manager to see what libraries are installed. You'll be able to find them easily. They all start with lib you see. Wonder what the library is used for? It's the word after lib.

Thanks, m8

Attached: magnificent.png (217x251, 88K)

Dumb weebs cannot program for shit.

Prove me wrong virgins.

Attached: 1492352468935.jpg (258x360, 55K)

@65665735
There was an attempt.

Attached: good boy noodle.png (600x570, 124K)

Creating a GC for Rust because I miss them a lot for cyclic datastructures
Makes me reeeeally want higher kinded types (or at least associated type constructors) soon, I'm missing Idris already
Monads are clumsy in Rust and proper functors I'm yet to come across, which is fucking great when I've just come off a category theory course and everything looks like a functor.
I wrote a fucking database module in C using natural transformations for my core design, so I'm an FP masochist, but please rust, why can only lifetimes be higher-rank?
If necessary, steal the uniqueness+hkt interactions from idris again, they did a paper recently on smoothing out some cracks in higher-kinded uniqueness shizzle

To further my point about HKT, I currently store metadata about references into the GC heap using a maually-erased generic type, and have to reconstruct the type again elsewhere based on 'tag passing' and impl specialisation, rather than do the pretty thing and say 'type GcPtrTy = MyNonErasedRefTy;'

Made a program that deletes a random file in a given directory with a 1/6 chance, mediafire address for any takers
no3hoxrbqbb9de7

do it!
post results

I'm not sure which language I should try to specialize and get really good at. I'm tossing up between C, C++, Rust, Haskell.

what industry do you want to get into?
what languages are common in that industry?
[spoiler]it's not rust or haskell[/spoiler]

if you're just a hobbyist, not knowing C is kind of silly imo

>what industry do you want to get into?
Just for fun. I guess if I wanted to get into industry I would use C++.
>what languages are common in that industry?
Again C++ is probably the most common.
>if you're just a hobbyist, not knowing C is kind of silly imo
I do know C. I just thinking about getting really good at it.

I guess getting really good at C++ would have double benefits in the professional life. But apparently Rust is getting popular, I've seen companies like Chucklefish and Dropbox shilling it.

I think taking a good survey of the industries out there might be helpful for you user

Please help me, I am trapped in the output of this assembly code.

.section .data

my_str:
.ascii "Hello world!\n\0"

.section .text

.globl _start
_start:
movl $4, %eax
movl $1, %ebx
movl $my_str, %ecx
movl $4, %edx
int $0x80
addl $12, %ecx
int $0x80
movl $1, %eax
movl $0, %ebx
int $0x80

ATCs are coming whenever they integrate Chalk.

How is C ergonomic for large applications?

is anyone familiar with using linux performance tools (perf) and benchmarking suites?

Trying to get very good at python and study machine learning, but actually in two month I am gonna look for whatever position as python / backend dev... just keep me outside of the frontend js framework bullshittery

it's not

Then how the fuck does the linux kernel function? Especially when it probably has tonnes of different functions. How do I do anything in it without accidentally creating an already made function name?

>Then how the fuck does the linux kernel function?
through the sheer willpower from linus's autism.
you fork it and QA your own patch before the PR.

Why do people hate C++ so much though? yeah it is a bit of a cluster fuck, but it is way more ergonomic and allows you to express yourself a bit better in a more high level way, especially with templates, with minimal performance cost in comparison.

because Java faggots are afraid of losing their jobs

The highest tedium in C is nothing to an average sepples template. And i would never call C++ ergonomic. And it's a lot easier to keep a standard in a C code base than a sepples code base. Theres plenty of good reasons why C++ was never used.

The problem with C++ is that everybody writes their own dialect of it.

C++ is lovely to write but horrible to read and debug (due to templates, overloading, 20 kinds of pointers and 5 different ways to write the same statement). Since programming is mostly reading and debugging, this is a big issue.

If you don't have much contact with other people's code then it's not too bad though.

One final update before I have to go for a bit.

Attached: scrot.png (908x861, 479K)

RTFM

this is a standard hello world

Attached: standard.png (253x334, 15K)

looking good!

>yeah it is a bit of a cluster fuck,
This is the reason why people hate it so much. Any program worth its salt is written by more than one person. Different people have different coding styles. C++ accommodates different coding styles via its many redundant features that differ mainly in style themselves. Most of the time, any two features that do the same thing in different styles do NOT work well together, which, by extension, prevents the programmers USING them from working well together.

C++ tries to address this problem with POO -- classes provide abstraction and hide implementation details, so that programmers that come from different styles don't have to worry about the incompatibilities between those styles -- but first of all, POO is a stylistic decision itself, and not a very elegant one; and, secondly, and more importantly, the whole issue could've just been avoided if they'd just make all their different supported paradigms compatible in the first place.

wtf is this cancer shit

>implying that's meaningfully different

I wasn't literally asking for help, I was making a joke.
The fact that it doesn't even properly output "hello world" is deliberate. Instead it outputs only part of it: "hell."
That's where I'm trapped.
Get it?
Get the joke?
Do you get it?

I'm literally baby tier here, but I'm learning and it's fun. Dumb javascript questions:

>What's the benefit of using const over let?
>If I'm setting a variable with a method that generates a unique number each run, is it still safe to set it with const?

Attached: Screenshot from 2018-04-23 21-15-41.png (2560x1440, 379K)

Why the sys_write of (&ascii + 12) in your second int op?

Because that jumps it to the \n after writing the first 4 letters.
Hence achieving the desired effect.
"Hell\n"

ahh, I was confused because you left the length the same to also write two bytes after the "\n\0"

oops yea lol you're right?? ?

First of all I'm don't mean to presume or impose and I don't mean this in any sort of condescending way (although others probably will), but Javascript questions are generally best posted in the Web Dev General.

As for your question the difference between const and let is that const is immutable and let is mutable (i.e. let can be changed, const can't). If you know that the variable is not going to change throughout the run, by all means make it const (in fact the move towards making as many variables immutable as possible is one of the more substantial "developments" in popular programming this decade because knowing that a variable will never change is a form of type-safety and is very powerful when multi-threading code).

>stock ubuntu desktop environment, no ricing
>two /v/ tabs
>trying to make your javascript, of all things, look pure ("let", "const")
>using a switch block over a random number to randomly select a string literal, instead of just storing the literals in an array and using the random number as an index
>"Jonathon"
>"Jonathon"
>"thon"
>"t h o n"
this has to be bait

>Javascript questions are generally best posted in the Web Dev General.
This. But not because Javascript isn't programming or anything.
People will tell you Javascript isn't programming. Actually it is.
HTML isn't though.
CSS even less so.

I'm trying to write concurrent code in C++ on Windows. I put 4 threads in a vector, then try to join them all in a for loop. This sometimes causes a runtime crash, sometimes it doesn't. It never crashes on Visual Studio though. Am I fucking up?

I haven't learned arrays yet. This is literally lesson 2 and I just learned about if/else statements :(

I know the functional difference between the two, I just wasn't sure if there was some overhead difference in allowing a variable to be mutable, or if it was just good overall form

An extremely smart compiler can do cute and clever things with an immutable variable. But I don't think even V8 is that cute yet. So basically, no, there will probably be no performance difference, it's just a design difference.

My reverse shell, any one want to be a test dummy?

mega.nz/#F!lZgAwZyZ!sxIZg6rZHVME2bcsAs6v2Q

In Javascript there's no overhead difference. There can be a difference in some languages but Javascript is too high level to benefit from anything like that. It's mainly just considered good form to declare variables as const if yo don't plan on changing them. This is so that if you do accidentally change them, the browser will complain sooner than later. That way, it will be easier to debug.

what do you mean youre trying to join them?

Thanks a ton, I appreciate the insight

Sounds like either a problem with your multithreading library or your actual business logic. Not that that sounds like the most ideal way to do multithreading, but it's not "wrong."

>C++
>This sometimes causes a runtime crash,
valgrind

>doesn't know arrays
>thinks he knows the difference between const and let

"var is scoped to the nearest function block and let is scoped to the nearest enclosing block, which can be smaller than a function block. Both are global if outside any block.

Also, variables declared with let are not accessible before they are declared in their enclosing block. As seen in the demo, this will throw a ReferenceError exception."

bad bait m8

Not him but that's the difference between var and let, not the difference between const and let.

This. Also, JS doesn't have arrrays

Why is haskell so bad? It literally does not even have moan ads

Attached: e5e.jpg (527x705, 56K)

What does it do?

something like
for(int i ; i < n_threads ; i++)
thread_array[i].join();


good call

>for(int i ; i < n_threads ; i++)
If this is your actual code then your problem is probably that you didn't initialize i to 0.

nah it's ok on the actual code, thats just an example in which i fucked up

Hey Jow Forums, so trying to figure out which page my variable is at, using lookup_address to find the page, and its returning 0 even after I make sure to pass it a value with data written to it.

Or more precisely I have a systemcall that just does lookup_address on a provided virtual address, and I'm passing it a pointer to a malloc. I'm then writing to a random area in that malloc'd space and giving the system call the address the pointer is pointed at. and it returns 0.

Very neat user

Attached: IMG_9384.png (727x582, 187K)

dumb frogposter

dumb frogposter

dumb frogposter

Shared libraries where a mistake.

>Shared libraries where a mistake.

Attached: 1517429337730.png (645x729, 105K)

dumb frogposter

Nice argument.
Shared libraries are more trouble than they're worth.
>Adding extra overhead with PIC
>Adding extra overhead on program start
>Can't be used with LTO
>Need a dynamic linker object file
>Complicates kernel design
>Version issues
All just to save a bit of space.
Static libraries are superior.

Didn't expect any intelligence from a wojak poster though. That's to be expected I guess.

>Shared libraries are more trouble than they're worth.

Attached: e0stFTO.png (800x800, 84K)

In C I sometimes see structs declared as struct my_struct x and sometimes declared as MY_STRUCT x. What's the difference?

>struct my_struct x
In this case, x's type is a struct my_struct.
>MY_STRUCT x
In this case, x's type is a MY_STRUCT, which is defined as a struct my_struct, according to the following piece of code which is usually somewhere else:
typedef struct my_struct MY_STRUCT;
So there's no semantic difference.

I have a 1080 GPU in my Windows desktop and a couple 975s in my closet. I want to do some GPU accelerated training with tensorflow. Which of these would be the best option?
>set up a ubuntu partition on desktop and train on that while i'm out at the office or whatever
or
>set up a real shitty $200 box with a crapass CPU and train with the 2 975s on that

I'm having FUN! Solving babby algorithms in Javascript! Anyone wanna join in? Just solved this one: freecodecamp.org/challenges/title-case-a-sentence

function titleCase(str) {
var stringArray = str.split(" ");
var finalString = "";

for (var i = 0; i < stringArray.length; i += 1){
finalString += (stringArray[i].substring(0, 1).toUpperCase() +
stringArray[i].substring(1).toLowerCase());

if (i < stringArray.length - 1){
finalString += " ";
}
}

return finalString;
}

titleCase("I'm a little tea pot");

typedef

>my Windows desktop

Attached: I+love+the+brainlet+memehere+have+some+more+_a47acbb1f1e89f1faa66e791c0c28ba0.jpg (588x823, 62K)

Looks good, now make it actually title case instead of just capitalizing every word

I want to create a robutt with wifi, a camera and some wheels, prowling around and sending the camera data back
Anyone do anything like this and have some recommended reading?