/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Previous thread

Attached: lm0mocjys7p11.png (735x627, 114K)

Other urls found in this thread:

infinitroid.com/blog/posts/did_i_just_waste_3_years
unix.stackexchange.com/a/99351
kunststube.net/encoding/
destroyallsoftware.com/talks/wat
devdocs.io/javascript/
dlang.org/blog/2017/08/23/d-as-a-better-c/
nim-lang.org/
dlang.org/
twitter.com/SFWRedditVideos

First for C++ is the worst programming language to ever exist.

>not realizing most of us have 4CX so your dumb gimmick forced us to have to manually copy and paste the new thread because it was seen as one link
baka

also install Shen.

Attached: Screenshot_2018-09-26 g - dpt - Daily Programming Thread - Technology - 4chan.png (3328x740, 147K)

Attached: javascript.jpg (659x317, 36K)

Does anyone use elixir?
I wanna have a realistic view going into it about the good and bad things but everything I google makes it sound like god's gift to programming, just like every other niche language.

using cmake was his first mistake
c++ his second

nah, just make your destructors virtual

it's niche for a reason

The good:
+ Very good resources and community
+ pretty good libraries
+ least awful dynamic functional lang
+ most syntax is pretty straight forward
+backed by erlang

The bad:
- Compiler can be VERY dumb sometimes, and spit out errors that aren't actually valid, but caused by an underlying chain of other errors due to MAGIC
- some syntax is VERY ugly like maps
- VERY pedantic sometimes, such as an error if you forget to space your keyword argument after a colon
- lots of libraries tend to have a lot of MAGIC and bloat which can feel VERY overwhelming and unnecessary.

And that's just in my ~few months with it

Tenth for Nim is the best

>Muh game developer
>My mind was circling around some staggering recent game industry stats, and some foreboding writings from prominent indie developers. And around the fact that, for the 3 years I’ve invested on this project, only 4 copies have sold so far.

>Those four sales were from generous folks who already had free access to the game, but wanted to support its development (thank you guys). New sales, from new visitors to the site (1,016 since I put the game on sale in November) are currently at zero.

>Zero. Yikes.

infinitroid.com/blog/posts/did_i_just_waste_3_years

Is functional programming worth learning?
If so, which language? Haskell?

>Is functional programming worth learning?
Yes
>If so, which language? Haskell?
Any works desu. But Haskell is a good choice.

It's great for its niche, but my experience with it was the ecosystem is still immature and it doesn't save you from ultimately having to learn/use Erlang alongside it.

> found their innnovative latest game Scanner Sombre to be a total flop
>Inspired by Gone Home and Dear Esther, Scanner Sombre is a cave exploration experience.
ah yes
>Infinitroid - Roguelike Metroidvania & Sci-fi Platformer
ah yes
It's always the absolute shittiest games made by the most oblivious people.

Is this still Python? x

Attached: 1538353431229.jpg (900x1200, 138K)

>keep whining about programming languages
>meanwhile people are writing great things in them
Jow Forums

Well technically he didn't have to risk a relapse because he could add this comment without opening the file.

unix.stackexchange.com/a/99351

Attached: 1538231406732.png (501x455, 201K)

I made an NES CHR viewer in C tonight! A CHR viewer is not my end goal obviously but it's what I have right now.

Attached: pbs_twimg_com_media_DoaqSJgU0AAs.jpg (665x536, 153K)

kunststube.net/encoding/

Attached: 1536063434958.jpg (500x500, 53K)

Does C support changing datatype to a const?
Case example: Need to parse arg or reading a config file to determine program's configuration and store it to an object which is a struct of enum in the global namespace. After the configuration is completed, the program should not modify the configuration object at all.
I know, that the object could be left as mutable, but set it to const prevents accidental modification of the config object since the compiler will warn it.
the only method that I could think of is my using dynamic object such as:
struct Config const * conf;
void init(void)
{
struct Config * temp = maloc(sizeof(struct Config));
//...
conf = temp;
}
which seems really hackish

const is almost pointless

The conf pointer isn't immutable, only the pointee. Your example is fine.

Attached: brainlet1.jpg (1462x2046, 98K)

Sure, compiler warning about const violation is useless

What the fuck is a BaseX script and how do you hardwire PHP code into a Manjaro VM?

oh look the sepples wojack retard is triggered for the Nth time, i must correct if i trigger the right people

const allows the compiler to treat it as an invariant and optimize code better. For example, pointer aliasing can be ignored. This also means that modifiying a const is undefined behavior.

No, you must correct yourself for being wrong and blatantly ignorant about it.

Even the Linux kernel cares about const-correctness now, and both clang and gcc defaults to warn about ignoring const qualifiers (contrary to the past, where you'd need to enable -Wextra or -pedantic for this).

This. Based standard poster.

>const allows the compiler to treat it as an invariant and optimize code better. For example, pointer aliasing can be ignored
Not really, considering that a const pointer can alias a non-const object.

SDL?

>considering that a const pointer can alias a non-const object.
This is not related to pointer aliasing.

I think I am ready to sell my soul. I don't mind how disgusting the job is or how much shit I have to put up with if the pay is great. What technologies should I study and what jobs look for? Java EE? CRM stuff? Working maintaining old software for banks?

Yes

Hi friends, how do I make my Python code modular? It's kinda messy atm and it's not really doing much.

I'm the fella from last night who was doing the Python dungeon-crawler.

Attached: 1538306717998.jpg (750x543, 85K)

get rid of all your globals.
only have pure functions.
And then install Nim, as the python syntax will mostly translate just fine but you'll be using a good language.

JavaScript rocks!

based

>javascript

destroyallsoftware.com/talks/wat

>javascript

Attached: js.webm (1280x720, 1.66M)

>obscure edge cases that never happen IRL

based kid
cringe zombie cunt

devdocs.io/javascript/

Done. Next

there is no "next" user
that's all JS detractors have

>wah I want compiler daddy to babysit me

kek

i'd better have compiler told me about errors instead of customer

you know there's a point where shitposting goes too far.
it's fun to pretend to defend JS and get (you)s, but it's time to stop

or maybe get a brain instead

seethe, freetard

>smallest & simplest building blocks of your language are completely broken
>h-heh, this is fine

kill yourself s0yb0y numale

>me or my team never made any error
you must be genius, show us your paycheck

>compiled langs never ever fail after compilation
You need to be 18 or older to post here

I can't wait for dynamically typed languages to become illegal and see arrogant code monkeys like yourself behind bars.

yes, you literally can't wait lol

>what are compile time assertions

def Player_Fight(PlayerHealth, PlayerName):
DamageDealt = random.randint(0,20)
print(PlayerName + " took " + str(DamageDealt) + " damage.")
PlayerHealth = PlayerHealth - DamageDealt
print(PlayerName + " has " + str(PlayerHealth) + " HP left.")
return PlayerHealth

I'm new to functions. Can someone help me out here? How do returns work? I've got a global variable of PlayerHealth at 100, but every time my loop runs through, my health resets back to the base value. It's removing health from the characters with the attack, but when the second attack hits, the health value is back to base. Any help?

exactly, why everyone from intel engineers to google devs don't have a brain lol, all those bugs and vulnerabilities
just get a brain and don't make mistakes lmao

>>completely broken
>feature has very well defined rules that anyone who spends 5 minutes to read docs can learn

Attached: 1507484846491.jpg (645x729, 26K)

>(((intel)))
>(((google)))

>sEeThE, FrEeTaRd

Attached: 1515765226844.png (1170x1647, 183K)

how's that linux fork going along hahahaha

>it's written in the docs, it has to be right!
Yes, if addition performed division instead and they wrote it in the docs, would you also defend it?

I use OpenBSD, rajeev

>you will make errors anyway so decreasing number of potential errors is irrelevant

I'm convinced, for a very long time also, that C++ is shit and that C is not better. however I want a language with good tooling and not dependent on some sort of runtime to replace it in my future projects. I've considered rust, but it's community make me puke, and their delusion of thinking rust is the best thing to ever happen to humanity. maybe I can use it without interacting with anyone, but if there is another alternative I'd rather take it instead. so, is there any other choice?

t. fizzbuzzer

There needs to be a compiler argument or something that tells you when const is actually useful so you don't have const on every line of code.

OH NO NO NO NO

How's your womyn in tech diversity hire going, microcuck LOL

Attached: 1536153632772.jpg (1920x1080, 561K)

>so, is there any other choice?
dlang.org/blog/2017/08/23/d-as-a-better-c/

Nim
nim-lang.org/

>SJW ads right into your lock screen

Attached: 640.png (288x415, 135K)

>Although C++ classes and COM classes will still work, D polymorphic classes will not, as they rely on the garbage collector.
>Exceptions, typeid, static construction/destruction, RAII, and unittests are removed.
into the trash

based MS reminding roasties of their place

Where can I find good resources/tutorials to learn how emulators, like a Gameboy emulator for Android, work?

kek
Imagine waking up your screen to THAT

weird. the function seems fine, except for the returning the health part. it all depends on how you use that function, and how PlayerHealth is defined. can you show more?

>I need exception, typeid, static ctor/dtor
dlang.org/

oh yeah, D. I heard it was actually getting some traction lately. have forgotten about it for some reason. gotta try it out later today
have heard about it. gotta check it out too. any good points about it?

Is this for real?

I'll walk you through my thought process so maybe you can tell me if I'm thinking about it wrong.
PlayerHealth = 100
EnemyHealth = 100
Defined both of these at the top, so they're global variables. I wanted them to be base values.

while FightActive == "Active":
This pretty much just keeps the while loop going until the player dies.

def Player_Fight(PlayerHealth):
DamageDealt = random.randint(0,20)
print(PlayerName + " took " + str(DamageDealt) + " damage.")
PlayerHealth = PlayerHealth - DamageDealt
print(PlayerName + " has " + str(PlayerHealth) + " HP left.")
return PlayerHealth
## If the players health is more than 0, he'll take damage.
if PlayerHealth > 0:
Player_Fight(PlayerHealth)

## If the players health is equal to, or less than 0, the player loses the game and the while
if PlayerHealth

I hate to be argumentative itt but it's clear that anyone who thinks python is "bad", whatever that means, doesn't know what they are talking about.

>any good points about it
sane syntax
static typing
can compile to many platforms including C and Javascript
compile-time procedures and ma
can have pure functions
dependency-free single binary outputs
deterministic gc

python isn't bad, its just slow and dynamically typed
which is OK for simple scripting or some web backend logic, but games usually are performance demanding, and thus Nim better option

Retard.

>>node.js
>technical committee exerts pushback against CoC fanatics (ayo.js)
>>Python
>technical committee allow linguistic inquisition in the technical language

he's right
const int a = 133;
*(int*)&a = 128;

Definite right about that, I never understood why people choose Python for games other than familiarity.

That's literally undefined behaviour. Enjoy your nasal demons.

>you're wrong
>no you're actually wrong
>d-doesn't count anyway!
every time

undefined behaviour or not the type system still valids and compiles this code.

>C adopted the const qualifier from C++, but unlike in C++, expressions of const-qualified type in C are not constant expressions; they may not be used as case labels or to initialize static and thread storage duration objects, enumerators, or bit field sizes. When they are used as array sizes, the resulting arrays are VLAs.
Const exists in C, it's just useless.

Are you too retarded to understand that you avoid UB at all costs?

It's useful in one specific case: You pass an argument as const to a function, indicating that it should not be modified to anyone who maintains your code in the future.

Aside from that you are better off with #define and enums, if you want it to actually be a constant.

#defines are disgusting and enums only work for ints

Really though, it means you're better off with C++. C is best thought of as a maintenance language at this point like COBOL.

What exactly is your problem with #define? It works fine for its intended purpose.

You forgot the GIL