/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: 1445171480400.jpg (400x579, 72K)

Other urls found in this thread:

open-std.org/jtc1/sc22/wg21/docs/papers/2018/n4791.pdf
bartoszmilewski.com/2014/10/28/category-theory-for-programmers-the-preface/
es6-features.org/
twitter.com/SFWRedditVideos

daily reminder that programming is for trannies

deep anime convolutional stuxnet backed by block chain technology crud

redpill me on JPA

I'm working on my logic simulator. It's one of those white whale projects for me that I've started probably a dozen times but I never quite got working in a way I'm happy with. This time is different, it works. Exactly the way it's supposed to. It handles feedback, correctly (think S/R latch) and is really fucking fast, despite being single threaded.

Attached: cute tacgnol.jpg (647x1008, 44K)

What does a logic simulator do that a repl doesn’t?

I want to know more about language design process.

N.B.: most languages were never actually designed, e.g. Lisp originated from idea of using S-expressions for everything and then got more and more features; Haskell at some point adopted the idea of "let's put all IO in a monad" and was adding more features for fun and academic interest. Something like C, JS, PHP and many other languages were also thrown together.

So, what languages did undergo a solid design/engineering process? Where can I read about it?

Attached: 2009040803.jpg (440x326, 40K)

I do a lot of digital logic work in my spare time and I like to have a graphical tool for building logic circuits. Logisim is nice, but it's a bitch to extend, it's also written in a poo language (implying the C++ I wrote mine in isn't). My simulator is explicitly designed to be make extending in trivial. The backend is at a point where I could probably start writing a frontend.

Nothing you couldn't really do in a repl, but it's a nicer way of designing something that you're going to build, physically.

open-std.org/jtc1/sc22/wg21/docs/papers/2018/n4791.pdf

all languages that are actually used by anyone are designed for practicality first
you don't engineer languages or you end up with stupid shit like esperanto, or haskell
their purpose is communication which is a human thing not a mathematical thing

JavaScript rocks!

Attached: js-rocks.png (1000x494, 286K)

Eh?
Cpp, aka "let's throw some classes at C", is a hodgepodge of semi-random features. And this particular document does not even provide any hints on how exactly those features were added.

I guess my request was not clear enough. I'll try to rephrase it.
Doing "pure", "math-y" language has nothing to do with how the language was designed.
I'm not interested not in the languages themselves. I want to see a disciplined process of deciding on what a language should be.
You know, like in a real world you can put an engine on a horsecart and call it a car; or you can first think about the desired performance, air drag, fuel efficiency, transmission losses and then design a car to satisfy set requirements — that would be an engineering process, which will yield a much more practical and comfortable car than you might achieve by adding more horsepowers to the gas-powered horsecart.

This approach can be definitely used to make a more ergonomic PL, and I'm sure that someone did apply such a process in a language-making venture.
Engineering does not oppose practicality at all.

Attached: image_big_94157.jpg (600x428, 182K)

No, designing a language isn't engineering
The implementation of some of its abstractions may be considered engineering but the language itself isn't

C++ was designed for programmers.
Everyone else uses other languages.

D. so good it's dead. can't argue about a perfect language after all.

Redpill me on Javascript

>C++ was designed for programmers.
it's quite literally designed by non-programmers at this point.

Actually it's more like everyone just agrees that it's shit and serves no purpose.

Block Chain implementation in JS. Does anybody know what it takes to deploy a smart contract system. I have an implementation of block chain but I don't understand how people can start to use it

C++ was designed for people who think they're better pregrammers than anyone else because they know how to half-wrangle a dumpster fire of a language

Javascript is what happens when a dimestore crackwhore is gangbanged raw by a bunch of different CEOs and is thrown, unconscious, in a dumpster. The resulting baby of which, is Javascript.

Ada is both the love of my life and my favorite programming language. I bet you can't say that about your languages.

I'm really liking the eloquence of /dpt/ today

can't spell dumpster without dpt

> C++ was designed for programmers.
> Everyone else uses other languages.
These two statements being obviously true, it’s does not follow that those who use other languages are not programmers, or whatever else you retard wanted to write.

Ok why is C++ so useful if it's not useful?

c++ is the definition of sunk-cost.

its useful but its ugly

le swiss army knife maymay

I'm trying to recreate Club Penguin

I've been trying to get my girlfriend's dad hired at my company but he's struggling with the communication skills obviously knows the material but refuses to speak in detail about it to my boss.He just stays silent or says "yes" when asked to explain things in detail. How do I get him to speak more in meetings? My boss likes him but he won't let him move forward because he's afraid he'll freeze/not say anything to the customer.

Attached: sadpepe.png (1092x1037, 27K)

C++ is the most useful programming language. It's also the only programming language.
All others are just languages.

It does a lot of things. Someone who knows nothing about programming will look at lists of features, see that C++ has the longest list, and assume it's the best. In reality, C++'s features step on each others toes. Most are horribly integrated with each other, so others were added as glue. Meanwhile, its foundation is nonexistent- it strips itself of many of C's strengths (portability and robust ABI), while keeping many of C's weaknesses (finicky build system, inadequate type system). The end result is an extremely complex language for no meaningful gain, but hey it has the most keywords so it must be good!

...

He's applying for a Java position.

see

dumb frogposter

If you don't already, go to lunch with your coworkers and bring him with you. He might warm up to everyone if he gets to interact with them in a more casual environment.
What does he like? Is there something about programming that he's particularly passionate about?

He's Korean so he doesn't really have that many friends outside his current work (some Korean company).

>some Korean company
삼성?

No not samsung. Some POS company (they handle card transactions). Korean businesses are brutal and will lay you off when you get old. He's 50 and has been demoted to part time after pissing the CEO off (guy probably had a power trip).

Any cflags or cppflags I should be using aside from O3? Trying to speed up some critical code on android JNI

>will lay you off when you get old
Huh, always thought respecting your elders was a really big thing in Korea

-finline-functions (very, VERY, important for C++)
-O2 not -O3 (unless you've actually confirmed O3 performs better. Benchmark this)
-fomit-frame-pointer
-frename-registers
-flto

>-O2 not -O3 (unless you've actually confirmed O3 performs better. Benchmark this)
why the fuck would O2 perform better than O3
doesn't that defeat the point?

O3 a lot of the time performs worse, as it enables some questionable optimizations.
Benchmark.
If you can't be bothered to do so, it's best to stick with O2 and finline-functions.

Sometimes I've even had O1 perform better on some code.

What is more useful to learn in terms of getting hired as a Junior Developer, Java or C++. And no biased answers please and thank you gentlement, women and scholars :)

That flag optimizes for the average computer. Sometimes O3 optimizations will be fast over all computers, but maybe not for the computer you are targeting.

-O3 basically gives the compiler permission to do whatever it wants to transform your code. some of those optimizations are only helpful in certain scenarios, and the compiler will not pick up on those scenarios very accurately. Some -O3 optimizations done by GCC and Clang come with the disclaimer that they might just completely break your program.

First step is to let the compiler help you write good code, before it tries to compile your code.
CFLAGS=\
-Wall \
-Wextra \
-Wredundant-decls \
-Warray-bounds=2 \
-Werror=return-type \
-Werror=logical-op \
-Werror=array-bounds \
-Werror=reorder \
-Werror=type-limits \
-Werror=cast-qual \
-Werror=cast-align \
-Werror=logical-not-parentheses \
-Werror=override-init \
-Werror=shadow \
-Wfatal-errors \
-Winline \
-std=c11

A couple of these might not work in C++ (I'm pretty sure override-init won't work for sepples)

-O2
-emit-llvm
and use souper

>-std=c++17
fixed

Not for the work place apparently.

>all of this shit
no idea how sepples friends do it.

Bump, does anyone know what it takes to launch a decentralized block chain?

You're replying to a C programmer.

yeah saw it after, same thing still applies though.

we thrive on complexity

C preprocessor is used by shitty programmers to make shitty programs that crash just for clicking on the wrong pixel.

Thanks. Didn't see much performance gain unfortunately.

The code I'm trying to optimize is already written and optimized, but when I've pulled it out into it's own thing from the main project, I'm seeing something around 10x worse performance on a critical function.

I'm looking at our build system and trying to see what flags I might have missed.

What's souper

A good language used to make websites and do vidya scripting.

>I'm seeing something around 10x worse performance on a critical function
do you know what cpu caches are?
do you think C is a """low-level""" language?

Monads were explained to /dpt/ last weekend. Did /dpt/ understand them?

>and do vidya scripting.
name literally one non web-game based company that uses fucking JS for scripting

wtf are you sperging at you autist

HOW DO I START LEARNING HOW TO PROGRAM

Attached: 21963ab8cfb9318bf189b696580f600752aef5a1eb3165ffb822d6c39329b0f2.png (1080x1145, 852K)

Yeah I hate that everyone here thinks C is low-level. It indicates to me that most people on here learned with retarded Python...

I Wanna Be The Webdev

C is a relatively low-level high-level language.

what the actual fuck?

RMS spotting

>sperging

ok sweaty you said:

>but when I've pulled it out into it's own thing from the main project, I'm seeing something around 10x worse performance on a critical function

which sounds like the function was part of a "hot path" were the data it was using was in the L1 cache, making it fast since the data is nearby

when you pulled it out, perhaps it was pulling data from RAM, aka slow memory, and affecting its performance

Google it slut

bartoszmilewski.com/2014/10/28/category-theory-for-programmers-the-preface/
then dive into Idris or Agda

Messing around if JavaScript ES6, classes and meme arrows are pretty cool.

>arrows
javascript got arrows? sweet. does it have profunctors too?

Hey guys, just started learning to program the other day, the book I'm using from told me to run this:

#include
#include
int main(void)
{
char buffer[256];

printf("Enter your name and press :\n");
fgets( buffer );

printf("\nYour name has %d characters and spaces!", strlen( buffer ));

return 0;
}


and gcc is giving me the error "too few arguments for fgets" and "format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘size_t"

Is this a gcc thing, or is the book retarded and trying to teach me wrong?

Nope, I'm running the exact same code just in it's in own project instead of compiling all the other stuff I don't need.

I'm testing the performance of both in a near identical benchmark.

fgets(buffer,256,stdin)
just google fgets if you tell there is a problem with it.

clearly it's not the same

Not to my knowledge but I'm really high right now, check it out for yourself: es6-features.org/

Something something category theory, and then my eyes glaze over

cheers m8

How do you program while super high? I was trying to do some coding challenges and I always end up staring at a few lines of code and spacing out.

I'm a Haskell newbie, gimme some good programming challenges/ideas to begin developing

>It is simple, really: Monads are just monoids in the category of endofunctors.

Attached: z.jpg (768x1024, 171K)

Don't? Being high isn't very good for short term memory. It's better when you're done coding for the day and want to generate ideas for the next session.

You don't, I get super high so I stop for a bit.

It's sql with Java. It's also something I have to implement in an uni project.

I'm on page 782 of Haskell From First Principles. Still no fucking clue what a monad is.

Attached: haskell programming.jpg (225x291, 9K)

what the fuck is there actually no syntactical difference between calling a function with an argument passed by value or by reference in C++
do you actually have to memorize or look up every single function to see if the values you pass in as arguments will be modified
why is this so much more retarded than C's simple effective shit

>over-complicating something a simple as function composition
and they criticize sepples

You'll never know anyway, but if you happen to learn it, then you will immediately be uncapable of explaining it succintly in way that anyone could understand.

Because C++ is cancer.

>C++
just stop using it. There's much worse in store for you.

how is this unique to c++ sweaty?
you have to know what a function does in every language. it's called a contract

>do you actually have to memorize
No, good APIs will only accept by value small, trivially copyable values, everything else by const ref which prohibits modifications due to constness anyway. If the API doesn't follow these very simple rules then it's a garbage API.

>prohibits modifications
then how do you modify data lol xd

Learning how to draw to a canvas and take key input in Julia while learning Julia. Might try to make a simple game.

Attached: Screenshot from 2019-01-15 11-22-33c.png (1702x916, 240K)

You're right.
Good thing C++ discourages the use of the C preprocessor.

The easiest way to understand shit is through acual concrete examples and hands-on experience, only going to the theory afterwards