/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Previous thread

Attached: 1538143303183.png (1578x1668, 187K)

Other urls found in this thread:

gitlab.com/9898287/termsearch/tree/master
youtube.com/watch?v=xnqTKD8uD64
isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines
github.com/DanilaFe/chalk/
github.com/Microsoft/vscode
en.wikipedia.org/wiki/Floating-point_arithmetic
twitter.com/SFWRedditGifs

working on my peer to peer bluetooth network `blech`

>rust almost as slow as PHP
lol

Wrote a compiler for CHIP-8 assembly using Python, since it's only a 35-opcode architecture

Pic related

Attached: 1537905577015.jpg (1201x1201, 294K)

post a screenshot of your code

Attached: scrot.png (3360x2100, 2.26M)

>Wrote a compiler
>Pic related
?

CHIP-8 assembly abstraction on the left

CHIP-8 emulator code showing opcode parsing on the right

Attached: chip8.png (1309x764, 224K)

>69 ms and 110 ms are almost the same

Attached: 1538065062326.jpg (1000x564, 228K)

that could be alot terser if you stored that in a data structure instead of hardcoding it

Rust reigns once again

>loses to PHP in IPs
rust is joke

where's Nim?

little late, but install shen

Oops lel

Pic related. It's shite code, but this was in my first month or 2 of learning python

Attached: Screenshot from 2018-10-01 18-25-34.png (1600x900, 378K)

>case statement
the simplest, ugliest way to implement an interpreter.

Attached: xOuA2dr.gif (500x1155, 541K)

total matters you cuck

It's only 35 opcodes tbf fampai and I started this project like 3 years ago when I was somewhat more of an idiot. Only just got back to it and can't be bothered changing it

>losing to PHP
>ever

it's also the fastest way seeing it can be optimized down to only one/two instructions by the compiler

>Nim
who?

>JS beating all of these languages even before optimizations on subsequent calls
Holy shit

is _start hardcoded to be the program entrypoint with gnu ld or can I change it with a linker script?

A or B? Forget about the first curly. I'm only interested in the second.

if (){
// A
}

if (){
// B
}

if(cond) {
}

you tool

A. Never seen anyone do something retarded like B

first obviously.

no matter who wins or loses.
multi-lang benchmarks are mostly ass because some langs will always be written better and take advantage of language specific tools. And others will be written like a first-month user just learning it.

get a loads of this mad rustfag

{ if (foo)
{ if (bar)
{ if (baz) qux(); }}}
welcome to lisp town

Rate
gitlab.com/9898287/termsearch/tree/master

Attached: 1536636142018.jpg (500x500, 33K)

All right then. A it is.

you're mistaken, i'm a deadlang/ nim user.

>gtilab's UI front-end is broken again

Holy shit Rust is fast. FAST.

Looks fine to me. Never seen gitlab before though

No, it's a silly way with a bunch of useless testing.
You know where the next instruction is, so just jump to its handler directly instead of going through a switch again.
Unfortunely hardly any language exposes that kind of construct to you.

nice license.
other than that, learn haskell

Attached: image0.jpg (486x332, 28K)

>license
based and redpilled

Is there a language that does that? Cause I can't imagine not going through a switch to know what the next handler is in C though I use it rarely and only as a hobby for things like CHIP-8, so maybe I'm just being an idiot

>C# cucks right now

Attached: 1536636142019.jpg (322x640, 21K)

>Unfortunely hardly any language exposes that kind of construct to you.
thats my point, switch case with int constants is the next best thing you can do if you can't directly control the instruction pointer

C with GNU extensions has address of label so you can make a table of addresses and every handler "returns" with goto *op[ip++]

So is C, losing to JS lmao

"- YOU ARE USING THE SOFTWARE FOR A GOVERNMENT OR AN ORGANIZATION THAT BENIFITS
ISRAEL"
Should that be read "for [any] government or an organization that benifits [sic] Israel", or "for a government that benefits Israel or an organization that benefits Israel"?

>tfw remembering a talk years ago about how JS can be almost as fast as C when optimized
>tfw this speed pre-optimizations
damn

Whats a good reference on modern C++?
I know a bit of this and that, but I feel kinda lost and need to relearn what i should/shouldn't use

Thats because no one uses the standard regex and its just kept for backwards comparability, everyone uses other libraries which are much faster. ms said they have other stuf to care about and wont be improving it since alternatives exist.

No worries. I wouldn't even touch C# if even semi decent performance is of any concern.

youtube.com/watch?v=xnqTKD8uD64
This covers 90% of what you need to know.

This. Also the c++ core guidelines: isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines

>ms said they have other stuf to care about
Why do they choose to appeal to normies this hard?

Now is the time boys

Attached: emasc.png (684x1007, 147K)

>he fell for the meme

How about I, uuhh, C-d... your mum

JavaScript rocks!

github.com/DanilaFe/chalk/

I replied in the dying thread, but here's my attempt at what you did. No case statements, those are a good idea.

So now both vim and emacs are memes? what the fuck Am I supposed to use? Atom??

Based, redpilled and checked

vscode

Nim has PCRE built into the standard, so it should be similar to C/Rust.

>ms profitsource editor
no thanks

>open source is great unless ((they)) do it

import random

def name(a, b, c, d, e):
fname = a + b + c + d + e
return fname

clist = ['b', 'c', 'd', 'f', 'g',
'h', 'j', 'k', 'l', 'm',
'n', 'p', 'q', 'r', 's',
't', 'v', 'w', 'x', 'z'
]

vlist = ['a', 'e', 'i', 'o', 'u']

dlist = ['mighty', 'wicked', 'destroyer',
'tactician', 'undying', 'sunholder',
'damned', 'patient',
'retard'
]

name1 = name(random.choice(clist), random.choice(vlist),
random.choice(clist), random.choice(vlist),
random.choice(clist)
)
print(name1, 'the', random.choice(dlist))

Attached: 1417104688232.png (717x533, 252K)

Absolute legend. I've always thought about doing something like that, but wondered if it was worth it due to the 4kb constraint. Have you kept that in mind too? I'm thinking of dropping it since there's no safety checks on Instruction pointer in the spec, and I think other people do as well to get their massive games in

>(((open))) source
>but only open to the select few

open source botnet is still botnet

Your code and examples are written really nicely. Will take a longer look later. Crystal seems pretty alright

Fuck you.

Attached: 2018-10-01_20-07-16.png (908x759, 50K)

Lol that's not true. Switches, as well as table of functions always require a return to the head of the dispatcher. A good dispatcher can dispatch from it's current location. It's an unnecessary jump and somewhat nullifies the benefit of branch prediction on couple opcodes.

>only open to the select few
its literally for anyone who can browse github
github.com/Microsoft/vscode

>you probably don't have the normal Friend() constructor, so it can't create an array

No, I have Friend::Friend()

>A good dispatcher can dispatch from it's current location.
you cant do that in most languages though

My trivial programs have made it into the space constraint, but I haven't done big stuff. It's hard to come up with anything big. I also don't check when I run out of registers. Basically, it's currently not 100% finished, but maybe I'll come back and update sometime today or tomorrow. The project really didn't take long, and it's a great intro to basic compiler design. Good luck!

Thanks!

name = join

yes, look, but not touch. they claim to use an open licince but blocks anyone who tries to do anything with it unless it makes them money.

vscode is a trap. It hides under the guise of open source. Unless you build vscode yourself, vscode is proprietary. Unless you build them yourself, addons are proprietary. I put their addon under the original license on their store and 2 Microsoft engineers emailed me and asked me to take it down (which I did because I decided to stop using vscode at that point).

Ah fuck, meant to reply to instead of myself.

Considering natural numbers of the form, a^b, where a, b < 100, what is the maximum sum of the digits of a^b?

Yeah I'll take a look, I've been interested since looking into the cpython code to get until and ++ -- operators in, some saw stuff about lexers, parsers, etc, but you have a folder quite small for it since it's chip-8 so would be great to learn from it

And pretty impressive portfolio anyway with the language variety

For some reason I've been getting a lot of 'cuck' variants too. I don't think I've ever gotten an actual name like 'peter' yet.

Didn't even know that was a method, time to rework it.

Sepples might be interpreting your code as creating a new single object of class friend and then calling the array operator on it, but I doubt it. Try removing the space before the [].

name1 is actually just
join([random.choice(clist) for _ in range(6)])

Attached: tegaki.png (400x400, 4K)

I didn't mean my compiler specifically is a good intro to compiler design. More like working on your own small compiler is worth it because it teaches you the concepts without throwing you into CPython or LLVM. Thanks for your feedback!

ugh my bad, it should be
" ".join ...

Oh I see, what resources did you use to start on it?

Also what bigger decisions did you make beforehand that shaped it (maybe just 1 or 2 so I can make some myself)

rate
from random import choice
from string import ascii_lowercase as _a

name = lambda a,b,c,d,e:a+b+c+d+e

lst = [
list(_a.translate(str.maketrans(dict.fromkeys('aeiou')))),
list(_a[0:5]),
['mighty', 'wicked', 'destroyer',
'tactician', 'undying', 'sunholder',
'damned', 'patient', 'retard']
]
name1 = name(
choice(lst[0]), choice(lst[1]),
choice(lst[0]), choice(lst[1]),
choice(lst[0])
)
print(name1, 'the', choice(lst[2]))

Remind me how this is acceptable again?

Attached: file.png (226x34, 3K)

am i a real programmer yet

Attached: fuck.png (413x227, 8K)

>what is a floating point number

>not a one line ternary
awful

how about just
name1 = "".join( [choice(lst[i]%2) for i in range(5)] )

>c#
you are pajeet

why not modulo?

there's nothing wrong with C#

>C#
Not even close buddy

>java
Why not something actually useful?

For a language based on abstraction, I honestly expect it to cancel sqrt and squaring out.

en.wikipedia.org/wiki/Floating-point_arithmetic

anyone writing something like that is using java

its java