/dpt/ - Daily Programming Thread

just be nice, ok?

Previous thread:

Attached: dpt_3.jpg (2560x1600, 708K)

Other urls found in this thread:

github.com/mananapr/cfiles
pybind11.readthedocs.io/en/stable/advanced/exceptions.html
docs.python.org/3/extending/extending.html#intermezzo-errors-and-exceptions
twitter.com/SFWRedditVideos

First for Ruby.

You can't spell trust without Rust.

I'm partway through a degree that's heavily cosc and stats orientated
This means I'm left to choose one path out of software engineering or embedded systems
What would Jow Forums recommend?

Third for LSD.

Attached: Screenshot_2019-01-17 I've been programming on LSD for 6 months.png (1013x300, 26K)

that redditor is cringe and bluepilled

Indeed

Attached: Screenshot_2019-01-17 I've been programming on LSD for 6 months(1).png (937x312, 18K)

whatever, a microjunkie is still a junkie
hope he gets locked up

fuck you I love acid

>2019
>C++ still doesn't have template enum classes

hope you get locked up

first for
I O T
O
T

Attached: iot.webm (1280x720, 2.45M)

>fat neckbeard with fedora on

>2019
>C++ still doesn't have template goto

>2019
>talking about c++

good numbers. Get them quints, m9!

>2019
>C++ still doesn't have modules
This is not a joke, it's actually very sad.

...

C++20 will, though.

>2019
>C++ still doesn't have
This is not a joke, it's actually very sad.

Imagine unironically defending interface{}

Attached: Screenshot_2019-01-17 Rob Pike on Twitter.png (628x537, 48K)

>Rob Pike
>thinking

The original quote is pretty good tho, imagine getting more stupid as you age.

82 = 114
Got it.

Pob Rike is a faggot.

anons pls respond

nobody is arguing with that

Do you like c and embedded systems?
If you do, go for that. If you don't, the other.

>trying to code C
>not working

Attached: 1514429091821.png (681x611, 407K)

c gamedev here, can someone pill me (any color) on golang?

why would you lock someone up for self-harm

its trash

I really like both

that's what I was afraid of. When I first heard of it, I was hoping it could be a more comfy than c but still decent performance. Guess I'll be a c boomer forever

Attached: seoungseok-charlie-kim-girlcry.jpg (1500x1418, 197K)

I'm not sure how you evaluate a language on "comfyness" but it's an unncessary language full of wierd design choices made for "Googlers"
and it enforces formatting rules

systemd rewrite in Rust when?

Attached: Screenshot_2019-01-17 Lennart Poettering on Twitter.png (615x535, 62K)

You mean C++, of course.

No, he meant D.

as an acidhead trying to wrap my uead around at least some code I find this inspirational

Attached: punchcard.png (800x360, 526K)

No, I meant Rust.

Attached: x6yekft5c2p11.png (500x700, 153K)

Tell me about the shills, why do they like Rust?

Attached: Screenshot_2019-01-17 Rust programming language.png (1185x389, 44K)

D is not a systems programming language.

T-they are stealing my smd capacitors, stop them.

>Rust is fast
Not with the number of defensive copies or arbitrary synchronizations you need to make to satisfy the BC.
>Rust can easily integrate with other languages
lol no stable ABI
>Rich type system
lol no HKTs
lol no pi types
>guarantee memory-safety
still trivial to leak memory with a reference cycle
>productivity
enjoy fighting the BC more than doing actual work

I am working on a terminal file manager. code is at github.com/mananapr/cfiles

>lol no stable ABI
You can use the FFI with C to create an ABI, but apparently that is a bitch to use. Otherwise, I agree with everything else you said.

The same can be said of C++ - does that excuse it? Hell at least C++ has Itanium.

Reminder that turing machines are declarative.

>does that excuse it?
Yes, because it fulfills any and all need for a stable ABI when you need it, which you don't most of the time.
It's hilarious how Ctards always bring up the ABI thing as if it's somehow a big issue.
Protip: It isn't. As long as you've got an FFI, it's basically a non issue.

>productivity
Does a language without productivity issues even exist?
You're either paying upfront at compilation or later during debugging/tests/etc.

JavaScript rocks!

Attached: javascript rocks.png (1000x494, 134K)

Use TypeScript. Don't worry about it being a Microsoft, they

dumb wojak poster

If you don't go back to the original image I'm going to consider this image and post a violation of global rule 6

It's alright, but really bad in some cases.
Never ever use fixed size buffers for strings that can change size.
malloc, calloc and free are your friends, don't reuse variables that could have side effects.
Global variables are usually bad, you can use them, but put functionally related variables into a structure and pass that.

Really, don't do this ever.
// Stores the path for trash
char trash_path[250];
...
...
// Set the path for trash
sprintf(trash_path,"%s/.local/share/Trash/files",info->pw_dir);

One specific thing, is don't use sprintf, use snprintf. Pass "buffer" NULL and "bufsz" 0 and it'll return the number of bytes you need to store the string.
Then, you can allocate it, and use another call to snprintf to actually print into the allocated buffer.
Minor thing, for something this simple to compile, consider a plain Makefile instead of CMake.

You already used that image

Attached: jiuzjh.png (1061x1006, 404K)

How do you expect to build a functioning FFI without a stable ABI?

C++ needs symbol manipulation.

>Jow Forums doesn't memoize its recursion

Why do you think you need one? They're completely unrelated.

thanks for the feedback.
I was actually planning to use a makefile but then I got a pull request that added cmake so I just went with it

You can't call functions if the mechanism for calling them is unstable.

>tfw too lazy to start working on my assignment
some things never change h-haha
time to wank

Fair enough.
A few more things, use Valgrind and get comfortable with gdb or lldb. There's more to it than what I posted, but it'll get you started.
Good luck with the project!

But the language is so fucking ugly. Did they even spend a minute to think about syntax? An abomination, really. Also, code of conduct.

$ grep -wrf swear_words.txt ~/Repositories/* | wc -l
26

wew lad

FFI implies using the C ABI.

>You
Nope. I haven't been to /dpt/ in months prior to last thread. Also notice that filenames and OP texts are different.
Last time _I_ used this image was in September,

Kill yourself C++ faggot. Your "FFI" consists of limiting yourself to C. Stable ABI? My sides.

>what is itanium
unless you're a winfag you've had stable calling conventions and name mangling for a decade

Kek. Nobody cares kid. Not windows people, not Linux people. Nothing but C++ code will ever touch C++ code. Most of the time not even C++ code.

Nice non argument. I can tell you're 12 years old.

Show me Python code that handles a C++ exception, then. Must be easy with all those standards and shit. Lmao

>Show me Python code that handles a C++ exception
You shouldn't even have C++ code that handles C++ exceptions, much less Python code.

Show me C code that handles a python exception

What the fuck are you talking about? You can't throw C++ exceptions from a C linkage function, retard.

I have a box full of components like resistors, capacitors, motors and power supplies. How hard would it be to make a little robot using a microcontroller board?

Attached: 1547259189094.jpg (1280x720, 127K)

>imagine being so ignorant yet so loud
pybind11.readthedocs.io/en/stable/advanced/exceptions.html

depends on the kind of components and what you want the robot to do

Doesn't mean every idiot C++ code monkey is smart enough to avoid exceptions. But fine. Show me code on ANY language calling a method on a C++ object through the utter garbage C++ ABI.

docs.python.org/3/extending/extending.html#intermezzo-errors-and-exceptions

Nobody's claiming Python has a stable ABI. In fact, most implementations are fully virtualized.

>C linkage

You lose.

I'm willing to bet money this doesn't use any C++ ABI and just catches them in C++ to convert them to Python. And dont post boost shit either because that one definitely does not use any C++ ABIs.

>I'm willing to bet money this doesn't use any C++ ABI and just catches them in C++ to convert them to Python.

>When a Python function invoked from C++ throws an exception, it is converted into a C++ exception of type :class:`error_already_set` whose string payload contains a textual summary.

lol

The components are from old printers, scanners, radios, TVs, etc.

And I was thinking about a small robot arm or crane.

Attached: 1547485422510.png (400x400, 160K)

>Le brainlet python programmer thinks he can shit on c++ while programming in his chastity cage language.

I feel a faint sense of accomplishment whenever I make g++ emit an internal compiler error.

Is there an equivalent of __based from Microsoft C compilers in the GCC world?

Should I just keep a pointer (uintptr_t?) and offsets to it to get the same functionality?

Whatever kiddo. Call a method on a C++ object from C, Lisp whatever you want. And don't brong me extern C horseshit. I'm waiting.

Did you know Scheme faggots can use .NET assemblies? No such luck for C++ dumbshits.

If you want high level programming languages, better stick to Python. It opens more doors nowadays.
However in the world of embedded programming and operating systems C is and will always be the king.

>docs.python.org/3/extending/extending.html#intermezzo-errors-and-exceptions
Python is just using the C ABI here.

The only time I've ever got it to do that was when trying to use the buggy as fuck concepts implementation.

What are you trying to prove? That the C ABI is incompatible with the C++ ABI? No shit nigger.
We're talking about FFIs here. You know what an FFI is? It's where you interface with FOREIGN functions.
C++ has an FFI to C but C does not have an FFI to C++. You're going completely off track here.

>And I was thinking about a small robot arm or crane.
It depends on the nature of the motors you have in your posession. You need servomotors for your project, as you can program their position directly using a microcontroller.
If they're not servomotors, you will need to do many things by yourself or buy some components in Digikey, like H-bridges, MOSFET drivers and transistors and 5V regulators as these motors will surely work with a bigger voltage, such as 9, 12, 15 or 24 volts.

Just fuck around with templates for long enough and you're certain to find some.

Nothing has an FFI to C++. Every example of such amounts to an FFI to C.

what is D

This.

Attached: 1547334655034.png (1926x906, 188K)

None of the motors seem to be servo motors, the closest thing I have to that is a few printer motors with optical rotary encoders. It probably makes more sense then to make a car or something like that.

Attached: 1546269554559.jpg (849x1200, 171K)

I saw the Shewstone at the British Nuseum

>Throwing exceptions and letting the user catch them
Absolutely disgusting.

>excuses

Top kek