/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

github.com/rust-lang/rust/issues/38869
strawpoll.me/12023125
toptal.com/developers/sorting-algorithms/
youtube.com/watch?v=fHNmRkzxHWs
en.wikipedia.org/wiki/Bead_sort
github.com/Microsoft/vscode
twitter.com/SFWRedditVideos

M
O
N
A
D
S

thank you for using an anime image

Thank you for using a non-anime image

learning make and company c++11 coding guidelines for new work.

what's the most simple programming mistake that you spent most time with?

>C++11
come on bro
it's 2017

Using C++.

Im reading 11 now, later I'll move to 14 part.
but they don't use later stardards.

One algorithm for Disjoint Sets I missed an i for a j in my implementation and it took a couple hours of debugging to find.

And you blame the language for your typo? I don't get the message.

Sorry meant to reply to

ok mate, sorry too.
cpp defense mode off.

In Python how can I use a dictionary in a function I wrote before that dictionary

Make the dictionary an argument.

Have the function accept the dictionary as an argument.

Failing that... global variables.

I'm interested in low-level programming. Should I learn C or rust?

the non-meme language obviously

C. Is it objectively a much more popular language, and learning C will help you appreciated the strengths and weaknesses of Rust.

this doesnt work


def scrabble_score(word,**score):
word = word.lower()
scoresum = 0
for i in word:
if i in score:
scoresum = scoresum + score[i]
print (scoresum)


input = "Hello"
scrabble_score(input)

score = {"a": 1, "c": 3, "b": 3, "e": 1, "d": 2, "g": 2,
"f": 4, "i": 1, "h": 4, "k": 5, "j": 8, "m": 3,
"l": 1, "o": 1, "n": 1, "q": 10, "p": 3, "s": 1,
"r": 1, "u": 1, "t": 1, "w": 4, "v": 4, "y": 4,
"x": 8, "z": 10}

Depends how you take your pronouns.

C, than Rust.

>low level
>C
>fucking Rust
this meme needs to die

both will give you job.
But c is here for the last 40 years, and will be for the next 40.

You need to unpack the dictionary ie scrabble_score(**input)

Programming is just hobby for me.

is it even possible to have a replacement for C? what should it be for it to do so?

So try both, start with c because it's the lingua franca of this world.
My hobby is wargames. I have plenty of ones that are horrible and I no longer play and i regret nothing.

are you saying c is not low level?

Then there is no reason to use C.

As someone whose favorite language is Rust, C first and then Rust, for the reasons in .

No, it's not. Maybe compared to some other languages, but it is not a "low-level language" itself.

yeah, k

ok granpa, go back to you punching cards.

Fess up /dpt/, which one of you was this?

github.com/rust-lang/rust/issues/38869

Dunno, but that Meh guy from Opalgate posts here. He's the guy making the terminal emulator in Rust.

Text editor poll continues
strawpoll.me/12023125

What is the most practical way to parse asm code with c?

Implement a Haskell compiler in C, then use Parsec.

>mfw C++20 will have modules, concepts, coroutines and ranges

One can only hope, brother.

>mfw C++20 still won't be any good

That relates to me.
Is sublime a meme? Is it worth 70$?
VSCode gives me bad memories of MS telemetry services, and many people complain about atom effectiveness.
I don't want to start learning 2 state editors neither... opinions?

>C++20 will have modules, concepts, coroutines and ranges
And the standard library designed for C++98.

great, more bloated syntactic sugar

Please go back to your containment general.

I'm already there, muthafuckaaa

None of these are "syntactic sugar" though.

I studied C for a few weeks as my first programming language and now I'm learning Python.

I have so many "I can't believe I can express it like this and it actually works" moments. I'm blown away.

def censor(text, word):
new = ""
textaslist = text.split()
for i,n in enumerate(textaslist):
if n == word:
textaslist[i] = len(n)* '*'
new = ' '.join(textaslist)
print (new)


censor("hello how are you","are")

>60 elements
>almost sorted
>elements are just uint32_t
which sorting algorithm would be the fastest in this case?

some cppcon guy (chandler carruth i think) said bubble sort was best for fewer than 64 elements and when they're just numbers.

the consensus on wikipedia and stackoverflow seems to be that insertion sort is better than bubble sort, but wikipedia said that the threshold of number of elements for when you should choose quicksort over insertion sort was only around 10.

would the cocktail shaker sort be a good choice?

>>almost snorted
xD

toptal.com/developers/sorting-algorithms/

def censor(text, word):
print (text.replace(word,"*"*len(word)))

Why are you unpacking the dict into keyword arguments? Just do it normally.

because i wanted some internet points

yea lol

def censor(text, word):
print (' '.join([len(x) * '*' if x == word else x for x in text.split()]))

censor("hello how are you", "are")

>some cppcon guy (chandler carruth i think) said bubble sort was best for fewer than 64 elements and when they're just numbers.
I wouldn't mind a citation, because that seems very surprising. I think bubble sort is just worse than insertion sort.

If you care about performance you should implement a few different sorts and just time them. Intuitively insertion sort should be the fastest, as the small array + almost sorted are both good for insertion sort.

How lazy are you?

wait a second

your code is not good because it wouldnt work with

censor("hello how are you", "el")

for example

youtube.com/watch?v=fHNmRkzxHWs

52:30

Here's a fun sorting algorithm you've never heard of:
en.wikipedia.org/wiki/Bead_sort

I'm planning on implementing a language with similar behavior to c++ with better metaprogramming

>60 elements
>caring about speed

They might be sorting a million 60-element arrays.

Clearly very

Haze got cucked by mandingos.

it'll run on mobile devices, most of the time it'll be in a worker thread where it's basically free but in some cases it may need to run repeatedly in the rendering loop, and it has to run fast on the weakest devices, hopefully without skipping frames, and there's a lot of other things too so even if just the sort is "fast enough" it should not be slower than necessary

Why not just do cuckoo hashing but with having a fixed array queue of entries for each hash and when the fixed sized queue is full pop off an element and then push it to a new location?

sublime has free version with full functionality, only sometimes (about 1:100 or even 1000 saves?) when you save file it asks you to purchase full version

its really effective, nice and quite easy to use, has a neat package control system with lots of useful (and unuseful too) packages and doesn't choke on files larger than 1MB (like Atom)
I think its worth that 70 bucks

although you should learn at least basics of vim too, cause it enables you to be productive without x system, like through ssh or on other architectures

>VSCode gives me bad memories of MS telemetry services
It's literally open source, and I'm assuming by "many people" you mean the NEET memelords in /dpt/.

It's a fantastic editor.

That being said, Sublime is also great. You can easily get a license key for Sublime, too.

What is the best place to start out learning how to program neural networks? I would prefer something that goes over everything conceptually instead of in code.

Did you mean to greentext the atom part?

I think I cannot use free version commercially and that's what I'm intending to do.

>Is [x] a meme?
>telemetry
Pic related.

VSCode and Sublime are both good; I like both equally. Have/had an intern at work who absolutely LOVED Sublime and had a tiny fit if someone was using something not Sublime, but it's still good software. Don't purchase Sublime unless you really want to.

He can also get rid of the prompt to purchase the license by binding the ^S key to save command.

Also Sublime has Vintage mode which enables Vim-like navigation so he could have the best of two worlds.

Yes, but I don't see how that changes the meaning of what I said.

VS Code is open source: github.com/Microsoft/vscode

Atom is fine, but VS Code actually improves on Atom's performance and feels more streamlined overall, with a fuckton more features.

>c++ with better metaprogramming

Literally D

andrew ng coursera

how's it going with removing the garbage collection from the standard library?

I never used VSCode neither Sublime thus my corelation to peoples opinions. I just heard a lot good stuff about the second. On the other hand I heard a lot of bad about atom (which I'm testing atm desu).

thanks for the feedback

linked lists c implementation for uni

How many of you actually completed Advent of Code on Christmas?

VS Code is built on top of the same framework as Atom, but that's like comparing Arch and Ubuntu.

I started working on a bunch of other programming projects around the same time and abandoned it after a few days

I got behind during finals week but managed to barly finish

guys seriously Python gives me a huge boner

def count(sequence,item):
count = 0
for i in sequence:
if item == i in sequence:
count += 1
return count

sequence = [2, 3, 4, 2, 3, 9, 7, 7]
item = 7

print (count(sequence,item))


it's light years apart from C

print $ length $ filter (== item) sequence

Scraping images off booru to get datasets to train a cute anime girl classifier. Goal is to have a watched folder where I save cute anime girl images and then my program classifies it as a certain girl and moves the image to the appropriate folder if it is sufficiently confident, and into a manual sort folder if it is unable to classify.

I worry that there are too many labels so I will need a lot of training data. So for now I'm also thinking of how to reduce this. Perhaps only choose the most common or popular girls/series.

print(sum(c == item for c in sequence))

But that's basically the same as the C version, at least show off higher-level features.

And
if item == i in sequence:
pretty sure "in sequence" is irrelevant, in fact why does this even work? Shouldn't it become True in sequence or False in sequence which would always be false?

Probably a typo.

Actually, he's just misread it.

>no goroutines
fuckin dropped!

numbers = [1, 1, 1, 2, 2, 3, 3, 3, 3, 5, 5, ]


def remove_duplicates(numbers):
new = []

for i in numbers:
if i not in new:
new.append(i)
return new


so what's the high-level feature solution for this?

numbers = [1, 1, 1, 2, 2, 3, 3, 3, 3, 5, 5]

def remove_duplicates(numbers):
return list(set(numbers))

numbers.Distinct();

>had a good job interview
>recruiter told me they want to hire me
>said they'd get back to me this week
>no response yet
>sent an email
>no response

if you want to kill a man who's out of options, this is how you do it

Neither. Learn a bit of assembly, implement your own forth, use it.

You will learn a lot more about computer and will at least understand what you are doing.

Assembly isn't hard at all, it gives you a lot of freedom (and thus power and thus responsibility), and because of this a bit more work, but it changes your way of thinking, kinda like learning lisp for first time. Implementing forth isn't hard at all and is a very good experience and it's ultimate low-level language. It's very low level, but it has very good means of abstraction.

For assembly maybe try Programming from ground up book and for forth try to find literate forth assembly tutorial.

I have found an algorithm to iterate over an entire, perfectly normal/regular, array in O(log n)

Ask the next richest man on Earth anything

Literally common lisp, just ignore half of its features.

It has all this low level stuff, from go to-s to embedding assembly. And it's the god of metaprogramming

>Ask the next deadest man on Earth anything