/dpt/ - Daily Programming Thread

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

Other urls found in this thread:

godbolt.org/g/j6Z8xL
yager.io/programming/go.html
gravity-lang.org
chaiscript.com/
getcaption.co/
nomad.so/2015/03/why-gos-design-is-a-disservice-to-intelligent-programmers/
github.com/ksimka/go-is-not-good
swtch.com/~rsc/regexp/regexp1.html
twitter.com/SFWRedditVideos

The image you've used, let me express my gratitude to you for using it.

Language translation tool.

Any cute girls in this thread? What is your favorite programming language and why?

>Come up with a pretty decent set of ideas of addressing concurrent programming
>Syntax is nice enough
>Minimal core
>Performs quite good, considering a GC'd languege


>LITERALLY NAME IT CHAPEL

Well it's still better name than C or D.

I'm a cute boy(male) and I can't decide what I like more, Rust or Idris.

I am a "cute girl".

My favorite language is C#, because it's easy to get things done, and LINQ makes me moist.

>I'm a cute boy(male)
what did xemean by this?

> "cute girl"
There's no need to be ashamed, you're a cute girl for us.

}~/prog/c{cat tmp.c
int add2 (int x, int y) {
return x + y;
}
}~/prog/c{gcc -c -O3 tmp.c
}~/prog/c{objdump -M intel -d tmp.o
tmp.o: file format elf64-x86-64


Disassembly of section .text:

0000000000000000 :
0: 48 81 ec 38 10 00 00 sub rsp,0x1038
7: 48 83 0c 24 00 or QWORD PTR [rsp],0x0
c: 48 81 c4 20 10 00 00 add rsp,0x1020
13: 64 48 8b 04 25 28 00 mov rax,QWORD PTR fs:0x28
1a: 00 00
1c: 48 89 44 24 08 mov QWORD PTR [rsp+0x8],rax
21: 31 c0 xor eax,eax
23: 8d 04 37 lea eax,[rdi+rsi*1]
26: 48 8b 54 24 08 mov rdx,QWORD PTR [rsp+0x8]
2b: 64 48 33 14 25 28 00 xor rdx,QWORD PTR fs:0x28
32: 00 00
34: 75 05 jne 3b
36: 48 83 c4 18 add rsp,0x18
3a: c3 ret
3b: e8 00 00 00 00 call 40
>There are people pretending that C has no overehead
>There are people pretending that compilers are smarter than humans

>There are people pretending that C has no overehead
There are?

I think it's generally accepted that C has very little overhead in most cases compared to other higher-level languages.

/dpt/-chan, daisuki~~

Ask your much beloved programming literate anything (IAMA)

>tfw no question

godbolt.org/g/j6Z8xL

Thank you for using an anime image.

>There are?
>I think it's generally accepted that C has very little overhead

C has zero overhead

You're doing something wrong, m8.

$ cat test.c
int add2 (int x, int y) {
return x + y;
}

$ gcc -c -O3 test.c
$ objdump.exe -M intel -d test.o
test.o: file format pe-x86-64


Disassembly of section .text:

0000000000000000 :
0: 8d 04 11 lea eax,[rcx+rdx*1]
3: c3 ret
4: 90 nop
5: 90 nop
6: 90 nop
7: 90 nop
8: 90 nop
9: 90 nop
a: 90 nop
b: 90 nop
c: 90 nop
d: 90 nop
e: 90 nop
f: 90 nop

-Ofast

stop being a nigger

It's the same, the only way to fuck it up is by using -O0:
0000000000000000 :
0: 55 push rbp
1: 48 89 e5 mov rbp,rsp
4: 89 4d 10 mov DWORD PTR [rbp+0x10],ecx
7: 89 55 18 mov DWORD PTR [rbp+0x18],edx
a: 8b 55 10 mov edx,DWORD PTR [rbp+0x10]
d: 8b 45 18 mov eax,DWORD PTR [rbp+0x18]
10: 01 d0 add eax,edx
12: 5d pop rbp

compiled with gcc -O3 -c btw

Can someone tell me if this guy's being an idiot or if I am being one?
yager.io/programming/go.html

On the part about interface{} he complains about not being able to tell what's really going to be the underlying type. Isn't this a problem with literally every generic data structure? Isn't that why you never use the top type of a language to define a data structure's fields? I thought I understood generic data structures but now I'm having a personal crisis over realizing that they're basically never useful.

Please do what this dude is doing in your webm

>Not using a hardened gcc

What are the best alternatives to Lua (for allowing user-scripting of native binary applications) right now?

Is it a good / bad / terrible idea to try to embed Python in a C++ program?

"very little" is not the same as "none"

just use Lua it's the perfect language for this kind of things

>go

Can anyone give me a decent article on Rust for Java programmers? I'm still thinking in terms of classes and objects and one class per file, I need to know the rusty way of doing things.

LuaJIT, Squirrel, ECMAScript, AngelScript, GameMonkey Script

I have to write an essay evaluating how good or bad of a language it is. I realize how shit it is but I still have to word that properly you see.

b-but

Global by default, and undefined variables evaluating to nil.

These things are so fucking bad.

I could always use Moonscript and translate it to Lua I suppose.

>Squirrel ... AngelScript
These pique my interest. Are either Squirrel or AngelScript fast?

>Why Go Is Not Good
He's being right.
>Isn't this a problem with literally every generic data structure?
No, in a langue with generics you always know that an element of List is an int, you don't need run-time casting and compiler won't let you insert a string in it. In Go you 1) have to cast elements back and forth in run-time 2) don't have compile-time type checks. It's really shit and you should drop it, I'm not even meming right now.

gravity-lang.org

Absolutely BTFO

If you already know the language, just read the source code of the standard library, it's easy and documented enough to be a good introduction material.

>Comparing Go to Rust
Why
You wouldn't compare parrots to ravens

People should be publicly flogged for creating yet another programming language.

>c++
chaiscript.com/

>Go-tards are that desperate
There's no task out there for which Go would be a better choice than Rust.

This
Interested to know, if Rust is a Raven what are C and C++?

What makes it good is the way basic features of the language lets you do basic reflection stuff (iterating the members of a table and printing its keys+values for instance). It's perfect for the small tools users might need.

And depending on the application (games for instance) Lua has a sandboxed environment that has a good reputation. Python simply isn't meant for that.

I've no project idea
Give me something user, I want to write something useful in C that I can put on my public github
so not a Sup Forums thread analyzer or shit like that
shoot your ideas

Eagle and Falcons

Vultures

Everytime I hear complaints about Go it's either smug FP faggot or weakly typed code artisan. Maybe I should try Go

Thank you, after writing about Go for six hours I forgot that real languages just assign a type (that isn't just the top type) to the data structure after its creation. However couldn't you just create a real interface that makes sure your types are nicely bounded within what you can work with?

My brain is honestly fried at this point

also read

Make something you would find useful yourself

a CLI version of this getcaption.co/

It started well, but C still does everything better.

Making a "secure" backup system, Id happily take suggestions on how to improve.

import os
import binascii
import time
import zipfile
import subprocess

static = time.strftime('%d-%m-%Y--%H-00-00')
file = ' '
importer = ('backup', static, '.txt')
gen = (binascii.hexlify(os.urandom(256))).decode('utf8')
encrypt = 'gpg --batch --passphrase ' + gen + ' --output ' + static + \
'.backup --symmetric --cipher-algo AES256 --digest-algo SHA256 ' + static + '.zip'

with open(file.join(importer), 'w') as f:
f.write(gen)
f.close

zf = zipfile.ZipFile(static + '.zip', 'w')
for dirname, subdirs, files in os.walk('C:\\test\\'):
zf.write(dirname)
for filename in files:
zf.write(os.path.join(dirname, filename))
zf.close()

print 'Starting encryption AES256 hash SHA256'

subprocess.Popen(encrypt, stdout=subprocess.PIPE, shell=True).communicate()

print 'encryption complete'

os.remove(static + '.zip')

# Decrypt gpg --batch --passphrase INSERT --output backup.zip --decrypt
# FILENAME.BACKUP

maybe you should first learn what weak typing is truly about.

>t. FP code ninja

Fact: there is no formal distinction between weak typing or strong typing.

>implement regex in c
>use it to write html parser

I thought that Go is "C for webshit"

Gentoo installer

aren't regex really hard to write tho? for it to be efficient at least

You just don't understand the Lua way. Lua's features make it a nuisance for designing large programs, but very good for writing small ones. You probably don't understand the Luaisms and why it does particular things. For instance, undefined variables as default as useful because you can do things like
word_count = {}
for word in pairs(list) do
word_count[word] = (word_count[word] or 0) + 1
end

Hopefully when you learn more about Lua you can understand why it does certain things

yes there is

>couldn't you just create a real interface that makes sure your types are nicely bounded within what you can work with?
And how would such an interface look like for List? You have no bounds on it, except being a type.

Also here's some additional info for you nomad.so/2015/03/why-gos-design-is-a-disservice-to-intelligent-programmers/ .

write image editor in C for webassembly

In Rust is it bad to have only one struct in a module?

False, Go has a better concurrency model than POSIX threads.

Did the gatekepper get lobotomized?

t. doesn't understand what formal means

Please don't summon him

Why did you write this post so stupidly?

>You don't understand what "formal" means.
is much more effective and direct.

No, why should it be?

>Rust is [...] bad

As for your question, no it's not.

A simple regex system (which just does matching) that can do the basics (concatenation, *, +, ?, (), etc.) isn't actually that hard, you just need to know the theory behind it.
Once you start adding all of the extra shit that people expect from regex systems, that's when things start getting a shitload more complicated.

I've met his type before, it's some form of recreational activity I guess, basically
>consume a lot of drugs
>post furiously on various internet forums
>sleep for 24h+
so he's probably sleeping or hungover

What I mean is you'd write the interface according to the methods you want to use on that list later.

And don't worry, there's no shortage of resources on why Go sucks. What I really need is more time to read them all
see github.com/ksimka/go-is-not-good

Ok I might do something like that then. Any link on how to get started with this?

It was a joke altogether and I'm kind of disappointed no one caught it: you can't actually write an HTML parser with regex. It's impossible

Finite automata

But since Go has no generics you'd have to implement a different List for each such an interface you have in mind. The only way to implement universal list is via interface{}.

t. upset

swtch.com/~rsc/regexp/regexp1.html
It starts off as a gripe about how most regex implementations suck, but then goes onto talking about the theory behind regex and actually provides an implementation.
There are multiple articles in this series.

>Regards, upset
wtf

le who are thou quoting argument

regarts, dolan

Do all C functions have to finish with a RET instruction? Are there times where the compiler might choose to optimize them away?

I think you're right, and now Go is even worse than I thought. Thanks for the help.

Hi All, Good morning.
I have one windows 10 key. Said it is single lincense. Can I have multiple hard drives on my pc and install multiple windows 10 ?

That's an architectural thing but yeah overall when you do a function call it has to know when the function is done and it must jump back to the instruction after the one that called.

What are some use cases for generic traits?

Generic classes make sense

Generic functions make sense

What the fuck would generic traits be for?

If an execution path in a function ends with a call to another function compiler will generate an unconditional jump instead of a call.

learning generics in C#
i luv this language

(You)
> instead of a call
And a ret, ofc.

Thanks.

HRRESULT for you

->60562330

Why are humans such bad computers? Secondary memory is in the head yet system dumps come out the ass??

Humans are built to last decades and withstand decades of abuse. I bet your shitty thinkpad couldn't even last half a century without replacing all of its organs.

>thinkpad
and that is another thing, somehow the human brand of computer cannot think without pads????
so much for machine learning

How do I write a program in lisp to compute the outcomes of fights to the death?

I wish to know who would won in the fight:
>12 video tapes containing footage of Justin Bieber repeatedly saying "baby"
VERSUS!!!!!!!!
>a squirrel

Dunno, it just seems weird having to type
>Foo::Foo

Just pub use it in the parent.

>you can't actually write an HTML parser with regex. It's impossible
I'm pretty sure it is very much possible.

mod Foo;
use Foo::Foo;

Think of it like using namespace Foo in C++