/dpt/ - Daily Programming Thread

This is /dpt/, the best subreddit of Jow Forums

In this thread:
r/programming
r/compsci
r/ReverseEngineering
r/softwaredevelopment

/!\ ** Read this before asking questions ** /!\

catb.org/~esr/faqs/smart-questions.html


What are you working on?

Attached: timetocode.webm (1152x648, 2M)

Other urls found in this thread:

cone.jondgoodwin.com/
cone.jondgoodwin.com/play/index.html
news.ycombinator.com/item?id=19565824
en.wikipedia.org/wiki/TIS-100
twitter.com/SFWRedditImages

Invalid thread.

Horrible, horrible thread.

Cone is a fast, fit, friendly, and safe systems programming language

cone.jondgoodwin.com/
cone.jondgoodwin.com/play/index.html
news.ycombinator.com/item?id=19565824

fn fact(nbr u32)
if nbr

How is it that there are so many wannabe systems programming languages are coming out and are shit?

Wrong thread m8. /dpt/ is this way:

looks gay

it's easier now to develop your own programming language so why not? llvm almost provides everything you need out of the box.

see

>use go because i'm retarded
>everyone assumes i use it because it's common
the perfect crime

Attached: SgF2zW6.png (251x169, 70K)

aren't generic types planned for go 2.0?

See

that thread is already at page 10, why i would waste time posting there?

non-reddit thread

>that thread is already at page 10, why i would waste time posting there?
Because it's the only /dpt/ thread up right now?
Oh wait nevermind a new one was just posted Everyone go into that thread.

what?

I said,
>that thread is already at page 10, why i would waste time posting there?
Because it's the only /dpt/ thread up right now?
Oh wait nevermind a new one was just posted Everyone go into that thread.

autism

At least I understand English.

autism

Is there any way to call the elements of a tuple separetely?
like i have a tuple (22,KS9OP).
Is there any way to call only the 22 or only the KS9OP?

what do you mean call? and a tuple is pretty useless if you can't get the nth element out

what programming language?

what language, also context?

where's the Rin image, user
in python it's just tuple[0] or tuple[1]

Python, and by call i mean print.
like i will do something like that.
Print("Seat Code"

And i wanted to print the 22 below the seat and the string below the code.

fug forgot
btw i am using tuples in arrays, if i tuple[0] it will call the whole tuple that is in [0] wont it?

Attached: Screenshot_12.png (1142x764, 1.14M)

I thought you decided to use dictionaries for your assignment.
if you have an array of tuples, say
arr = [(10, "H3KJ"), (20, "F56G")
then arr[0] will give you the tuple
(10, "H3KJ")
and arr[0][0] will give you "10".
I mean, you can just save the tuple into a variable if you want
var1 = arr[0]
seatCode = var1[0]
print(seatCode)

Yeah i am going to probably use them, but since i am already doing this assignment i tought i could use this chance and learn dictionaries, tuples and arrays.
I mean i could need them in a later assignment.

btw thanks, now its working.
I think i will make this assigment using tuples and then using dictionaries.

Attached: kute_kotonoe.png (1341x756, 1.3M)

t = (10, "H3KJ")

#left aligned with a minimal width of 15
print('{0[0]:

oh, this way is actually so much fucking easier.
And here i was expending 5 minutes to do this using blank spaces every time i had to print a column.

Attached: seriously_kurochan.png (1349x761, 954K)

no, that's why the formatting exists
are you even taught or shown anything in that class

My professor is pretty bad.
I mean almost one month of classes and the last thing she told us about was for loops.

>Significant indentation
Dropped.

Attached: fioc.png (800x400, 101K)

you might want to start reading some Python book on the side then

that code example manages to be pretty fucking unreadable despite how small it is and how much of it is just text, quite an achievement really

anyone here has experience with accumulator architectures?

I've used map_reduce before, does that count

No.
I am playing this en.wikipedia.org/wiki/TIS-100
help me

Attached: pxA3H4N.png (1368x770, 189K)

wrong thread

i want to ask general questions about accumulator architectures, not specific questions about tis-100. retard.

you want to ask general questions about accumulator architectures for the specific intent of getting help with tis-100 problems
and in 3 posts you've asked 0 actual questions about accumulator architectures

>and in 3 posts you've asked 0 actual questions about accumulator architectures
because i got an answer on discord since then.

AppImage creates AppImages. Snappy/snapcraft creates snaps. FlatPak creates ??? ?

I'm on page 600 when does this stop being boring?

Attached: 51KEqIsBa4L._SX370_BO1,204,203,200_.jpg (372x499, 44K)

Learn c

when c++ 30 comes out

When should I use extern consts instead of just defining static consts in my headers

It's a quasi-reference book comprehensively covering language features. It is only ever "not boring" if you genuinely enjoy this kind of thing, and then it will be interesting from pretty much the start.

Even K&R is rather boring, except it's such a short book that you usually don't really notice it. C++ being a large language simply means you have to slog through the boredom for that much longer, and so feelings of resentment rise accordingly.

when those constants are an implementation detail

the book sucked, the movie was better

THIS IS WHY I TOLD YOU TO GET OUTTA HERE YOU STUPID SQUREL

Most technical books are boring. It's more fun to implement something.

if they're constant expressions, use constexpr rather than static const

>not reading C++ Primer
You fucked up

>systems programming language
>first design goal is 3D web support

Attached: 1514427534262.png (921x1077, 1.47M)

Why are sepples templates so dysfunctional compared to Java ones?

Sepples temples and Java generics are completely distinct concepts that happen to share similar syntax and overlapping usage cases.
One is a cast macro and the other is a tool for generating arbitrary code.

how do generics work in Java if it's not code generation?

Why does os.system('cls') doesnt work on my program?

Java generics have the same representation, i.e. F has the same representation as F, so you don't need to generate code for each instantiation

Type erasure. A List of T has the same representation as a List of Objects, and the Java compiler simply inserts casts into the bytecode where necessary.
That's why you can't overload methods with different type parameters, like this.
void foo(Bar barbaz);
void foo(Bar barquz);

but how does that work beneath the hood? how can you run the same code on two different types which have variables/fields in different locations?

oh I see
so it's type safe it just doesn't give you any performance benefits

They don't have variables in different locations. Every object in Java is a reference (which is why only members of the object hierarchy can be used in generics, not primitives.
An object like this
class Foo
{
T data;
}
will always have the memory representation of
class Foo
{
CommonSubclass data;
}
and "data" is always a reference to an object, not the object itself. Similar to void*.

The JIT will probably be able to more easily figure out that the casts are safe and avoid having to check them, but yes.

well consider pointers for example
if you assume every type variable that gets used ends up behind a pointer, then it works

you can also look at something like Haskell which has the same sort of generics, but taken to extremes with stuff like higher ranked types (generic functions have one representation, so you can treat them as almost a regular type, take them as arguments, etc), higher kinded polymorphism (generics on generics, like template in C++), polymorphic recursion and so forth

...

Not directly related to programming, but is there a way to "scale" the number of strongly connected components a graph has to its number of arguments? I basically want something like an "SCC density" or something, where ideally a graph composed entirely of trivial SCCs (one vertex per) would score 0 and a graph consisting entirely of one big SCC would score 1. Is this dumb? I keep jotting down ideas for a formula but they keeps giving retarded results.

what are the advantages of writing code on paper with a pen?

You save electricity

none

Pokemon rip-off, I'm almost done with all the graphics. It's kinda fun (to me anyway).

Attached: Screenshot_20190404-101603.png (1080x1920, 168K)

Now make it competitively balanced

It is, that was the first thing I did lol.

Java actually has Rank-N types, because you can treat parametric functions as first class values with unwieldy constructions like this.
// forall a. a -> a
interface Ex1
{
T apply(T t);
}

// forall b. (forall a. a -> a) -> b -> ()
interface Ex2
{
void apply(Ex1 ex1, T t);
}
This isn't possible in C++ AFAIK. There may be some glorious template metaprogram for it.

Hey why is VS Code suddenly showing that every line of code, even blank spacing likes, as an error?

>There may be some glorious template metaprogram for it.
I would honestly be surprised, as a likely unintended feature.

Basically I built a tool that runs a huge amount of battles with every other monster, each one has a win/loss ratio of 50% (beats half of the other monsters, not any given monster half the time). I tuned the stats to be set up like that way before I started making graphics or music.

wtf? i love Java now
if Java has rank n types i might unironically use it

god i fucking HATE pycharm who was the fucking nigger that made this shit

vector f(){
return {0, 1};
}
Does this always compile?
I distinctly remember it not compiling on my college pc, doublechecking it at home, but now it runs perfectly

May not work on older C++ standards.

Here Zaume beats 40/83 monsters with this moveset. But depending on the moveset it could be a little higher or lower.

Attached: Screenshot_20190404-103325.png (1080x1920, 196K)

Nice. How do the battles work? Is it an automatic process (like damage = attack - opponent defense, apply to opponent health, then opponent attacks, repeat per-turn until one dies; or something more complex but along these lines) or is there user input (like in actual pokemon games)?

I feel like in the former case it's a glorified RPS but in the latter case I wonder how you managed to automate testing.

Okay, printing \n+1000 works, but this is ugly as hell since the line goes to the bottom.
Isnt there no way to erase all in the screen instead of just printing a thousand empty lines?

Bump before I uninstall and reinstall?

Stupid question:
I have a huge memory problem using Pandas and Python. I need to query and hold thousands of rows with 20~100kB of data each and using del() on the DataFrame after finishing using it doesn't do anything, as the next call will still ask more memory to the OS until all available RAM in my computer gets allocated.
Is there a good way to clean a Pandas DataFrame's memory?

Attached: 1551125975981.jpg (396x396, 18K)

Well, I know what I'm working on.

There is user input every time it is the players turn. The enemy acts automatically on an AI.

For automation I did two separate types of test; firstly just having them attack over and over without using their other moves, and second having the AI fight itself using the moves to it's best ability. The second one can hang for a while so I cut the battles to 11 per monster, and a Max of 100 turns before a draw is called (in the event they both stall). But the first one can run ~83000 battles in a few seconds.

The damage calculations are a little more complicated than attack - defense too, the basic attack is ([player.attack/enemy.defense]×random (50 to 70)) I can post the GitHub if you want to see the whole thing. But it's a clusterfuck because I'm self taught.

Nice I'm curious how "the best of their ability" works, though. Maybe I'm overthinking things, but I'm just thinking back to pokemon and how a good AI is really non-trivial to create. Although, granted, most of that complexity probably comes from switching; in a 1v1, even pokemon seems trivial. I'm assuming your game is 1v1?

Flat dicks

>good AI is really non-trivial to create
not for Pokemon

No seriously you cunt, what terminology is used

Flapjacks

I have never seen an attempt at a pokemon AI turn out decent. Keep in mind that prediction of your opponent is a large part of the game, so while it's not nearly as psychological as e.g. poker and is thankfully tractable by game theory, you need to take quite a lot of stuff into account.

It's absolutely doable but it's not something you could slap together in an afternoon with some if-elses.

It's one monster vs one monster at a time. For the most part the AI is not a problem, I just manually played against every moveset (small number of moves in the game, 10 heals, 10 specials and 14 boosting moves) and added more nuance until it could consistently beat me. But you can switch monsters mid fight, the AI doesn't care, it can see your moves and stats. It calculates damage ranges etc to try to prevent it's own death and cause your monster to die. I'm not gonna say the AI is perfect, but it's strong enough to represent players like me.