/dpt/ - Daily Programming Thread

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

Attached: hidamari_dpt_waifu2x_traps.png (1618x1308, 1.95M)

Other urls found in this thread:

c9x.me/x86/html/file_module_x86_id_29.html
r-a-d.io/
listen.moe/
dlang.org/spec/version.html#debug_specification)
libsodium.org/
download.libsodium.org/doc/secret-key_cryptography/secretstream.html
unix.stackexchange.com/questions/73627/how-to-find-heap-memory-of-a-running-process
twitter.com/NSFWRedditImage

First for Ruby

Oh, I'm just trying to survive at my work in javaland.
What a horrible place.

testing

Do post moar code!

Attached: govnocode.webm (640x360, 2.35M)

>It's an Algorithms & Data Structures episode
>overpriced textbook is full of significant typos and incomprehensible pseudocode on way too many layers of abstraction to actually implement in your projects but gets used anyway because it was written by someone formerly on the faculty
>It keeps happening
I know I should have transferred...

what meme is this referencing?

I know some basic ASM...
use c9x.me/x86/html/file_module_x86_id_29.html ?
also, use a disassembler to see if the opcodes are really being translated or not

Reposting because i want to know what i'm doing wrong.
jmp _bubble

;allocate memory
CON1 EQU 100
arr DD ? DUP(CON1)
flag DB ?
tmp DD ?

_bubble:

mov di, 0
;mov cx, CON1
data:
mov dx, ([di]%3 * [di]) ;load pseudorandom data into array registers
mov arr[di], dx
inc di
cmp di, CON1
jne data

sort: mov di, 0
mov flag, 1 ;flag default true

inner:
mov dx, arr[di]
cmp dx, arr[di+1]
jl cont ;check if need swap, if not continue
mov flag, 0 ;set flag false
;swap
mov dx, arr[di]
mov tmp, dx
mov dx, arr[di+1]
xor tmp, dx
xor dx, tmp
xor tmp, dx
mov arr[di+1], dx
mov dx, tmp
mov arr[di], dx
cont:
inc di
cmp di, CON1-1
jne inner
cmp flag, 1
jne sort
print:
;print shit here

Everything runs fine but i don't know how to print it as numbers or characters so i am not sure if there is data loss or not. I suspect i'm handling the data wrong in some way since dx stays 0 constantly once i'm done loading data into it (and for some reason when i load data in it just flip-flops between 09EB and EB09 but whatever). Help me Jow Forums, am i doing something wrong? how into interrupt routine print and is there any subroutine that prints values as decimal, hexadecimal, or binary digits on console?
please and thank you.

df is not an available register on 8086 asm.

>dx, di, cx
That's not x86_64. That's not x86... Are you really writing assembly for a 386 or something? The fuck user. Post pictures of your box.

Still what happened to your good friends ax and bx? That tmp variable for xorswapping...

Nevertheless I don't see why you're xorswapping.
mov dx, arr[di]
mov tmp, dx
mov dx, arr[di+1]
mov arr[di], dx
mov dx, tmp
mov arr[di+1], dx

But think about how much simpler that would be if you use ax or bx. Just push their contents to the stack if you need too.

Anyway your method of loading "pseudorandom" data in looks really flawed.

its an emulation of assembler for 8086, not x86, or i386, but a predicessor of both, a common ancesstor.

Xor swapping is easy to do for swapping two values and does so in exactly 3 instructions.

Attached: shit.jpg (403x403, 110K)

Attached: imagesqtbnANd9GcQFRoJdl1AZoToEUsInMHbdNdwOOfDnAC8YbZwprlck_2WR1CME.jpg (237x213, 17K)

Haskell isn't even a programming language.

but you don't have to xor swap. if you use bx, you don't even need tmp.
mov dx, arr[di]
mov bx, arr[di+1]
mov arr[di], bx
mov arr[di+1], dx

You're being too "clever" and not seeing the forest with your xorswap. You aren't swapping in 3 instructions, you're swapping in 9.

With branch prediction, it would still be better to do
for() {
if()
foo()
if()
bar()
}

rather than
if()
for()
foo()
if()
for()
bar()

right ? Or is it the opposite ?

tfw not cute

I want to learn how to program but I don't have any ideas of what to make. what do?

do challenges or exercises until you have an idea.

what can I use to make a connection encrypted?
I understand the RSA method
but to make it I need to multiply and sum numbers bigger than 2^64
How can I do those operations in C++

first. less in the branch cache. branch prediction is per particular branch.

wait fuck second of course by far.

>Jow Forumsovnocode
Like govno/гoвнo, or "shit" in some Slavic languages?

Hello friends! I wan't to start working on networking apps between android phones, but I don't really have the means to buy a bunch of android phones to develop with. Do any of you have recommendations for some virtual networking software that can help me out? preferably something lightweight but it doesn't have to be.

Attached: 1519091361645.png (699x781, 116K)

It doesn't have to be with another android if you run your server.
I would just run an ASP website locally

GHC is confusing me, can anyone explain the following behaviour?

I compile a program as ghc -Wall test.hs and I get a few reasonable warnings. However, if I immediately call ghc -Wall test.hs again, there are no warnings shown. If I delete the intermediate test.hi and test.o files, and compile, the warnings are shown again.

Is this intended behaviour? Can I make it so warnings are always shown and I don't have to delete intermediate files?

I don't get it..
Does GCC mean "GNU Compiler Collection" or "GNU C Compiler".
Perhaps it also means "GCC is not ..."?

Uppercase = compiler collection
Lowercase = C compiler

Working on an ARP spoofer using (layer 2) sockets. The ARP spoofer is done, but I'm just tweaking the program right now.

what the fuck should i program

its gonna be serverless networking but ill have a look into it

P2P? even easier.

so asp.net?

What's a feelfag?

Second is more efficient but it's uglier because you repeat the code for the for loop. Maybe for 2 branches ok but I'm not gonna do it for more than 5

Make your own int data structure out of 512 bools that should be enough

Nah forget it. Might be more trouble than it is worth.
Just open a port and send from the device and listen on computer or same device on the same network
If it is not just text I'd recommend json w/ extra info to debug

So I just need to switch to ghc -fforce-recomp -Wall test.hs and the warnings are always shown

yh, it's what I thought.
I'll see if "sorting" (what I can), is worth or not. Maybe do a benchmark.

Wont an Android emulator work

Is Atom any good?

no

Even vs code is better

Friendly reminder to listen to r-a-d.io/ or to listen.moe/ to enhance your coding flow by several tenfold.

Attached: 6487.jpg (1178x833, 857K)

somafm.com

Why not just operate directly on an array? Much simpler and extensible.

drone zone and thistle radio up in here

Killim plz

In C++, is it legal to do this:
class MyClass
{
MyClass() {}
void *value;
};

/* ... */

#inclue

MyClass mc;
mc.value = (void*)15; // some random value
new (&mc) MyClass();
printf("%p\n", mc.value);


I've got a problem with MSVC where, at one point in the code, this approach works, where as in another part of the program, with a different class, after calling the constructor the pointer (MyClass::value in this case) becomes null. Is the standard OK with doing this?

If no constructor is declared or defined, then new (&mc) MyClass(); has a different meaning to new (&mc) MyClass;
The former will set the pointer to null, the latter will not.

Hmm, that's strange because I have created a default constructor for the base class that does other stuff, but doesn't touch the pointer, which becomes null.

Can you post that constructor?

no

Can someone give me a simple example of where dynamic branch prediction will be better than static prediction?

Attached: 1506932291819.jpg (1280x960, 259K)

System::System()
: m_component_pool_hashtable(16)
{
m_component_pools.Init(16);
m_props4.Init(128);
m_props8.Init(128);
m_props16.Init(128);
m_props32.Init(128);
m_props_var.Init(128);
}

>GitHub comment from user with Anime avatar

Attached: le-anime-trashman.jpg (680x680, 99K)

>tfw workmate has an anime avatar in the official repo

If you don't explicitly add a member to the constructor initializer list, it will behave as if m_whatever() is implicitly added to the list. For a pointer, that means zeroing it out.
The only way to avoid this is to avoid using an initializer list.

c compiler historically, compiler collection presently

dynamic is more accurate.

Attached: Vyi3a.png (709x278, 38K)

I failed to give more information in my question: considering consider a 2-bit dynamic predictor.
I know that in simple cases like like (i % 2 == 0) in a loop both predictors will have the same degree of accuracy. I need a case where the 2-bit dynamic predictor will do better.

...

What you won't get with C++:
- Standard build/package/dependency management tool
- Standard (unit/) testing mechanism
- Standard documentation idioms
- Debug blocks (dlang.org/spec/version.html#debug_specification)

C++ bears the baggage of being compatible with C, hence being compatible with C is probably the biggest reason to use it imho. Otherwise you can use D with betterC, which can address the lackings stated above.

>Non-sequitor greentext from chantard complaining about someone's avatar
Opinion discarded

But why xorswap when xchg exists and allows you to do the job in 2 instructions?

irrelevant on modern processors.

...

>but to make it I need to multiply and sum numbers bigger than 2^64
99% of the time it's a bad idea to roll your own crypto.
libsodium.org/

Thanks. I changed the constructor so that what was initialized via an initializer list was now initialized via a placement new call, and did the same to the deriving class, but for some reason the pointer is still getting set to 0.

Too bad the API needs to work with constructors, but I really need those pointers to be valid. I'm starting to think of doing something like allocating the class and then right after it, a block with just the pointers. Then the getter functions could get said pointers this + pointer_offset. Or I don't know, maybe I've still got a mistake somewhere and that's the reason they're getting set to 0.

Get back to me when the D compiler has reached optimisation levels comparable to gcc

>C++ is bad because it has a diverse set of tools
>D is better because the only toolchain that exists for it is by default the standard

Trusting someone elses implementation defies the purpose of crypto.

D has a gcc compiler backend too.
Standard tools are always better. Your "diverse" set of tools (CMake and Doxygen) are relics from the 80's. Hence you depend on Google test for testing framework (wtf).

I'm guessing the warnings are only shown when compiling the file. If ghc decides not to compile it since the .hi and .o files already exist, nothing is compiled so no warnings are shown.

Check download.libsodium.org/doc/secret-key_cryptography/secretstream.html

>Standard tools are always better.

Attached: 1t3KoWBneb3LXwQ_ouQ-980x620.jpg (980x620, 90K)

i once saw a facebook dev who had Lenin as his avatar picture.

Do paid IDE (say visual studio for example) get a dick in the bum if it corrupts an enterprise project or do they just offer support and a bug fix?
Are all paid programs required to provide support and whatnot?

So yeah, I did have a mistake there. Where you said "former" in your earlier post, I read (or assumed), "latter". Thanks a lot. One of the few times /dpt/ has been helpful.

Yeah that doesn't work well when you don't have a standard or even know what the fuck are you supposed to be lol.

>Are all paid programs required to provide support and whatnot?
No

Any legal issues? Does it depend on the program's license?
Someone sued redbull because it didn't give him wings.

anyone else have severe depression

>Someone sued redbull because it didn't give him wings.
That statement is pointless without specifying the outcome of the lawsuit

nope. it's just you.

Go on camping

They paid 13M$ I think and I am not willing to get into a lawsuit for a small paid program.

I'm debugging a kernel module and a certain address is causing problems. Is there some way I can see what variable this address belongs to? Or what it's pointing at?

What's the fastest way to check if a string is a number (int _or_ double) in C#.
I don't need to cast it, just check it.

I would do it with a regex, but apparently they're rather slow. And I don't need the result, so there might be something better than a tryParse.

Google it

unix.stackexchange.com/questions/73627/how-to-find-heap-memory-of-a-running-process

Try parse

A loop on the string to check if every char is within the ascii range for 0-9

Why?

Are there any good code editors that are not emacs or vim?

intellij

no.

That said, it still heavily depends on the support of your language. Which heavily depends on extensions/plugins, and the vim/emacs community is just that big, being full of neck beards also really helps for the support of niche languages noone ever heard of.

guess i'll have to learn vim then. *sigh*

Just use VS Code, it's lean, modern, backed up by a billion dollar company and has a huge ecosystem of plugins because there's an influx of webdevs and these are written in JS.

It's not that hard.
You don't have to learn everything in one gulp either. Just learn enough to get a "decent" productivity. And you can learn the rest on the fly.
It's also quite gratifying once you start to get the hang of it.

There's also evil-mode on emacs, which is just the best imo. But learning vim-keybindings + emacs at the same time might be tedious.

The biggest problem I have is the abundance of key bindings makes it easy to do something unintended, for someone with fumble fingers, like myself.

And yes it's not supported by a multi billion dollar company famous for abandoning support of any tech that is not profitable anymore. Instead those editors have been around for multiple decades now, despite sometimes their multiple flaws (that the OSS community tries to fix, e.g. neovim).