/dpt/ - Daily Programming Thread

...

Other urls found in this thread:

site.com
peter.sh/experiments/chromium-command-line-switches/
pythonchallenge.com/
youtube.com/watch?v=vKUAMHSfMOk
wiki.osdev.org/Porting_GCC_to_your_OS
twitter.com/SFWRedditVideos

dumb op
what are you working on, lads?

please use a programming related anime image and not a disgusting image

(USER WAS BANNED FOR THIS POST)

Attached: 1494541901812.jpg (473x496, 105K)

anime retards btfo

(USER WAS BANNED FOR THIS POST)

Attached: matsuri haskell.jpg (1920x1080, 153K)

Very nice, I'm gonna try it out.

Seriously though, what is a monad?

I read that book and woke up realising I did something really awful

Attached: 1526692959547.png (1107x1077, 733K)

so /dpt/ have you started writing your own database software yet?

The monad is nothing but a simple substance which enters into compounds; simple, that is to say, without parts. God alone is the primary Unity, or original simple substance, from which all monads, created and derived, are produced.

No, I use existing solutions (either SQLite or PGSQL depending on the needs).

please do the needful

Attached: notAYoutubeVideoStill.jpg (1280x720, 129K)

what did they mean by this?

MODS ARE GODS

>what did they mean by this?
All discussion should pertain to technology and related topics.

Based

Attached: 1501920222131.jpg (253x299, 13K)

Why?

LISP is the typical Jew language. It's used by academics to demonstrate their abstract bullshite theories and never to accomplish anything in the real word.

C is the Aryan man's language. It was born out of necessity for the purpose of developing the Unix operating system. It's a very pragmatic language.

>C is an Indo-Iranian man's language
sounds about right

VSCode is using Python 2 instead of 3. What do I do to change it?
I'm using Ubuntu.

I think the build stuff is in .vscode/tasks.json and .vscode/launch.json

How much did you all make at your first Jow Forums related job? Tell us about it.

Hella based mods.

Attached: 1526855800228.png (704x1171, 904K)

Kys weeb

The command "python.execInTerminal" uses Python 2. Is there a similar command for Python 3?
I'm a total noob.

This is because Ubuntu uses Python 2 as the default Python version, switch the interpreter from the command palette.

Thanks, man.

This place really is redshit 2.0 this is fucking pathetic

if you use chrome, --app=site.com opens chrome without tabs or location bar, nice for netflix with a tiling wm for instance
make fun of me for using chrome if you want, I'd use uzbl but it doesn't seem to be in development anymore

Should I learn Emacs as a beginner?

How is it red shit exactly? I thought it would be green.
>peter.sh/experiments/chromium-command-line-switches/

And that's programming related how exactly?

Anime is programming related fight me irl

No, it takes a lot time, focus on actually learning programming

No, vim.

holy moly

Vim binds are better and most IDEs have a plugin for them
I'd recommend spacemacs though desu

Ditto
Also useless unless you are a devop (aka useless)

I recall using some of these flags when I used to play with selenium. Pretty neat

A restricted behaviour on a wrapper type (usually). By restricting the behaviour in certain ways, we can be sure that it will always behave as expected, which allows for some neat stuff that just works(TM) for any such wrapper with the same behaviours, as the behaviours are shared amongst the different wrappers.

It effectively has two important operations, `wrap` (in Haskell this is `pure`/`return`) and `apply_fn` (also known as `bind` in FP). The `wrap` wraps the data up, simple as hell, and `apply_fn` takes a function for some type and applies it to a wrapped version of that type, so that you don't need to unwrap the type yourself whenever you need the underlying value. From these, you can build up a load of neat tools to emulate almost anything.

Monads are useful for FP because they represent the monoidal behaviour of code (a:code + b:code = c:code) while retaining directed execution order dependencies (by binding b to a, for example, we force a to be evaluated before b). Hence, their usefulness in emulating imperative constructs (which rely on set order of evaluation to get the right order of modification) in functional languages (which don't have modification to have orderedness in the first place).

Any grep wizards about?
How the fuck do I use egrep -P properly? Every single time I try to hand it PCREs it just bitches at me that INVALID SPECIFIER GIVEN and I can't get it to use the FUCKING regex that works everywhere else
I'd just literally use Perl but my boss insists I build these scripts in pure bash

w-what is happening

I'm trying to learn javascript. why is it that the people who know how to code don't remotely know how to teach?

because teaching is its own skill

same goes for management. people just treat teaching & managing like a natural step after specialized expertise.
If you have any resources that stand out to you, please share.

I don't think webshits use pure javascript anymore. Learn cawfee script or typescript and find your way to pure js when you feel you grasped the basics.
Also,

Ugh.. Wanted to reply to Try /fglt/ and I would suggest double checking your regex

what are some exercises for python so i can test my skills? im currently learning python as my first language and im trying to test my progress

what is the regex you're trying?

pythonchallenge.com/
Go for it big guy

>reversible computing

Attached: 066[1].jpg (680x598, 43K)

class Monad m where
(>>=) :: m a -> (a -> m b) -> m b
return :: a -> m a

Plus laws:

return a >>= k = k a
m >>= return = m
m >>= (\x -> k x >>= h) = (m >>= k) >>= h

Simple | commands, which get routed as pipes
I want to do something like
(?: non-matching expression \s+)(Followed|By|Matching|Expressions|Here)
egrep SUPPOSEDLY does perl matching

if I have a bool array, something like [0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0], is there a simple functional way to transform it into something like [2, 3, 1] - the length of each section of true? It's fairly easy to do iteratively, but I feel like there's some weird one liner for it

Any one-liner is going to be an iterative search anyways. It also wildly depends on your language.

Jow Forums is dying

this proves it

map sum . wordsBy (==0)
Or something like that. Check Data.List.Split.

What is this meme language?

Probably haskell
>proves it!!!!
Jow Forums has been dying since 2003

Attached: 1488601249358.png (292x389, 124K)

>haskell
Natch.

(define (wtf age) (cond ((string=? (cond ((> age 12) "too old!")("ok.")) (cond ((> 7 age) "too young!")("ok."))) "ok.")("Nope!"))))

By me

Java is most comfy language
And with graalVM it will be the only language you ever need

Isn't the point of Graal to use whatever language you want?

Entertaining a thought of making my own Victoria-era game with economic warfare and political intrigue.

no generics lol

>no generics
?????

What you failed to comprehend retard? Java doesn't have generics. Enjoy your type erasure.

public class Person {
public int id;
public String firstName;
public String lastName;
public int age;
public String lifeStory;
public String[] sex;
}

public class PersonRec {
public int id;
public String firstName;
public String lastName;
}

public class AgeRec {
public int id;
public int age;
}

public class SexRec {
public int id;
public String sex;
}

public class LifeStoryRec {
public int id;
public String lifeStory;
}


You have a 1000 people represented via a number of Lists. Given an unsorted List of PersonRecs, unsorted List of AgeRecs, unsorted List of SexRecs, and unsorted List of LifeStoryRecs, how would you create a List of People objects?

I can loop through each List and fill in a Person object in phases (keeping them in a Map), but it doesn't feel right.

Attached: askingforthis.jpg (505x497, 28K)

>Java doesn't have generics
what did he mean by this?

>public String[] sex;
So not only are you allowing for the list of sexes to be extensible, but each person can have multiple???

What is this design?

i think its a gag

>GraalVM
>focused on bad design by bundling a number of interpreters for use inside java
>java is the only language you ever need

Each Person is built from one PersonRec, one AgeRec, one LifeStoryRec, and zero or more SexRecs.

I am trying to figure out a way to process the Lists into a List of Person objects that does not involve a Map.

How the fuck are people getting past step 3 of this? I have an image but can't do anything with it.

Attached: 1526265687070.jpg (645x729, 81K)

honestly I cant understand what the stetup is or what you're trying to do. imo if you have something working let it be and come back to it later if you want to improve it.

I have the following fully functional list shuffle in scheme (I'm aware that the time complexity is bad)

(define (without xs n)
(cdr (foldr (lambda (x acc)
(if (= (car acc) n)
(cons (- (car acc) 1) (cdr acc))
(cons (- (car acc) 1) (cons x (cdr acc)))))
(list (- (length xs) 1))
xs)))

(define (shuffle xs)
(let ((n (random (length xs))))
(if (null? xs)
'()
(cons (list-ref xs n) (shuffle (without xs n))))))

and I implemented it in javascript like

function shuffle2(xs) {
const n = rand(0, xs.length);
if (isNull(xs))
return nil;
else
return cons(ref(xs, n), shuffle2(without(xs, n)));
}

It works, but when I try to express it in lambda form as

const shuffle1 = (xs) => {const n = rand(0, xs.length); isNull(xs) ? nil : cons(ref(xs, n), shuffle1(without(xs, n)));}

I get

> shuffle1(list(1,2,3,4))
TypeError: Cannot read property 'length' of undefined
at cons (repl:9:38)
at shuffle1 (repl:16:76)
at shuffle1 (repl:16:93)
at shuffle1 (repl:16:93)
at shuffle1 (repl:16:93)

I can't figure out why one form works and another doesn't, despite them being the same code.

Also javascript is probably the ugliest language I've ever encountered.

test

did it work user?

Shtap producing apps with shitty UX, you godless cunts!

you probably meant to write it as something like this:
(define (wtf age)
(cond
((> age 12) "too old!")
((> 7 age) "too young!")
(#t "ok!")))
cond can take multiple conditions that it evaluates sequentially, it's more like a full-blown if-else chain than if. #t is always true, so it's typically used at the end in place of the final "else". though something tells me that you wanted to write that in the most roundabout way possible, so everything i say here is probably meaningless. and ffs, format your code.

meant as a reply for

Sexual preferences of an average Lisper.

C++ types should be able to specialize a trait or overload a function that tells std::shared_ptr which field to use as a reference counter so it can avoid overhead of managing a separate or combined block itself.
Not all objects are allocated normally so not all objects can be allocated with std::make_shared to take advantage of the optimization it does.

That sounds like an actual feature.
Dream on.
The committee only ever gives you fragments of features in the language. If you want something done right you write it yourself. There's no need to constrain yourself to the std smart ptrs.

how does one get into the upper ranks of porn dev
youtube.com/watch?v=vKUAMHSfMOk

Porn has always driven technology. pornhub is still more reliable than any streaming service other than netflix maybe.

Talk to me about this. I'm willing to learn.

Did you change the definition of "without" in the meantime? xs becomes undefined in the 4th stack frame and "without" is the only place where that value can come from.

>you write it yourself
Good thing I am.
I'm writing an OS in C++, and I'm also writing my own standard library for it because fuck libc and libstdc++ or whatever it's called.

Happy to see this.
But people will expect semantic compatibility.

>people
The only people who will be using my OS is me.

Why don't you write your own compiler with your own custom language? I'd imagine you'd eventually want to make your OS freestanding, and porting GCC or Clang would be a huge pain. And C++'s standard (especially the "modern" C++, i.e. starting with C++11) is so huge that writing your own compiler for it is infeasible.

>freestanding
*meant self-hosting.

First of all. I have no intention of supporting the C++ standard library (as defined by ISO), if you didn't already deduce that.
Making a non shit compiler is difficult. Making an actual compiler that optimizes as well as GCC is FUCKING DIFFICULT. Making a compiler AND language that competes with GCC and C++ would be a bigger challenge than the OS I'm writing.
I want to write an operating system, not a fucking GCC & C++ competitor. I won't accept any other compiler that doesn't optimize as well as GCC or Clang, and since I obviously can't compete with those two then my only choice is to just use one of those.
Terry Davis wrote his own compiler, but his compiler doesn't optimize anywhere near as well as GCC does. While Terry seems to be okay with that, I'm not.

Besides, I suck at compiler dev. I've attempted multiple times to write a basic compiler and I never really get past the parsing phase.

Studying
>Discrete mathematics
>Calculus
>C
>Grinding Leetcode
>Webdev stuff (MERN)

Not enough time in the day for this shit. Also I have nothing built really. I still have to tackle Git and how to properly test my code.

Attached: fuccmepapi.jpg (645x968, 47K)

>"modern" C++, i.e. starting with C++11
Is C++98 pre-modern C++ and before that archaic C++?

Attached: e3b.jpg (645x773, 31K)

I don't like that term as well, but I often hear it used, hence the quotes.

absolutely, unironically, 100% based

Attached: 1527133072857.png (686x800, 353K)

Okay, so I have a file opened as a bidirectional stream in Common Lisp, and I what I'm wanting to do is read data, and then write some new data.
I've opened the file with :if-exists overwrite
but after I write, if the new data is smaller than the old data, some of the old data's "left overs" are left and basically I have bad data because I then can't use the program.
How do I solve this problem?

why pythen cant into fp?

Attached: brainlets.png (1846x867, 417K)

Also, the file is is a symbolic link.

You don't need GCC-level optimizations if your OS is just a single-man project. Compiler optimizations follow Pareto principle, i.e. you need approximately only 20% of optimizations GCC does to be 80% as efficient (this is a generalization, but bear with me). Besides, you'll need libc and libsdc++ to port GCC, see: wiki.osdev.org/Porting_GCC_to_your_OS
>Have a sufficient C Library. GCC is fairly portable and needs the C standard library, and some extensions from POSIX. It needs fork and exec, for instance, to run the assembler and linker. You will need a C++ standard library (such as libstdc++) as GCC is now written in C++.
As I said, writing your own compiler would be easier than porting GCC, and it would be the easiest to design a custom language similar to C with C++ features that you deem necessary. You won't have to implement the ones that make C++ compilers so complicated or implement them differently so that it's easier. You could fix some mistakes those languages made along the way, while copying the good parts.