/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous thread:

Other urls found in this thread:

izzys.casa/posts/millennials-are-killing-the-modules-ts.html
git.suckless.org/sbase/tree/utf.h
git.suckless.org/sbase/tree/libutf
youtu.be/QM1iUe6IofM?t=1540
docs.microsoft.com/en-us/visualstudio/debugger/debugger-feature-tour
twitter.com/SFWRedditGifs

Rust is shit. Cargo is god tier enough to make me want to use it anyway.

...

Rust is good. Cargo is also good

powerapps and flow

I'll just leave this here.

izzys.casa/posts/millennials-are-killing-the-modules-ts.html
JUST

>Cargo is god tier enough to make me want to use it anyway.
Hope you're ready for the NPM dick.

>What are you working on, Sup Forums?
something similar

A WebAssembly runtime environment in C++17. It's coming along well.

Re-writing like 60k lines of code. Working on the graphics engine right now.

That bio

hi, i want to use utf8 in my c program.

anyone ever used this library for parsing utf8 text?

git.suckless.org/sbase/tree/utf.h
git.suckless.org/sbase/tree/libutf

seems simple but i can't find documentation, i want to be able to get a rune array from a utf8 char* or something

this is my program that crashes. i might be brainlet.

#include "utf.h"
#include
#include
#include

static void
process(const char* str)
{
printf("=============\n");
printf("str = %s\n", str);
int slen = utflen(str);
printf("slen = %i\n", slen);
Rune r;
int rc = utftorunestr(str, &r);

if (rc)
{
printf("runelen = %d\n", runelen(r));
}
}

int
main()
{
/* process("This is text"); when uncommented segfaults*/
process("笑");
process("A");
process("语言");
process("再见");
/* process("cyкa блять"); when uncommented segfaults*/
return(0);
}


tld;dr utf-8 in c, experiences, libraries, tricks, etc

valgrind that shit.

>falling for the suckless meme
Protip: suckless is meant to be satire.

Does
Rune r


need to be allocated?

Rune r;
int rc = utftorunestr(str, &r);


I think utftorunestr expects an array, so try this:
Rune r[256];
int rc = utftorunestr(str, &r);

Use python. It's the best version of C out there

youtu.be/QM1iUe6IofM?t=1540

Thoughts?

> int
main()
{

criticism against oop is laughable coming from procedural fags

>thumbnail
I'm not even wasting my time.

Also,
if (rc)
{
printf("runelen = %d\n", runelen(r));
}


You possibly want:
if (rc)
{
printf("runelen = %d\n", runenlen(r, rc));
}

Because it's questioning Java or because you already know what it is?

it works now!

Who started that shitty trend in sepples?
I see in everywhere now.

Because it's a discussion video about a shitty topic that is clearly not a conference recording and because they don't even know how to make a proper slide, so it's probably written made and directed by some unemployed kid or negatively-employed neck beard whose opinion nobody asked for and nobody wants.

how about
auto main (void) -> int
{

this code was just a test for the library, i forgot it and the compiler didn't complain about it

Any modern language has a good dependency handling system. Not saying Cargo is mediocre or anything.

Somebody's cranky today.

>When we pollute our code with generic entities like managers, factories, and services, we're not really making anything easier to understand. We're just putting a happy face on the underlying abstract business, and for every excess layer of abstraction, we're getting more abstract-ness
>In attempting to neatly modularize and label every little fiddly-bit that our program does, we're actually just making our program harder to understand
This guy has never worked on a serious programming project in his life and has no idea what he's talking about

I just meant the function type on a line above the name.
>auto main (void) -> int
That's fucking horrid though.

...

Why do C++ users act as if C++17 is a different language? Does it break in compatibility every major release like that?

>Why do C++ users act as if C++17 is a different language
they dont

Why do you need auto and int if I'm reading that correctly? No arguments should just be (), implicitly. Arbitrarily ones are bad.

On linux it's quickly becoming the path of least effort for a quick desktop app desu, since gtk.rs works out of the box together with Glade. Alternatively, libraries that provide more declarative interfaces are quickly maturing.

Then again, my thinkpad doesn't have a lot of memory so a big part of it is me having a very low tolerance for memory bloat, which generally rules out anything based on the Jvm or Mono (and dynamic languages even more).

auto main(void) -> std::decay_t {

I wanna create a program to rule the world. What do I do

do you know what trailing return types are?
and idk what you mean about ()
(void) is much better

lmao

It's not a different language but the C++98 to C++11 changes were very major so now the C++ community has a habit of specifying what language version is used for their projects. It's a lot more dynamic than it used to be.

>and idk what you mean about ()
>(void) is much better
They aren't the same thing so one isn't better than the other, webdev.

>do you know what trailing return types are?
A shitty sepples device.

In C++ they are the same thing. In C they are different.

c++ was a mistake

writing program to find the twos complement of 4 digit hexadecimal numbers for my assembly class.

what are you talking about lol
() behaviour is litteraly retarded and only exists for ansi compatibility

ok

What do I need to study if I want to make money?

I know JS, C#, Java, Lua, XML (+ JSON?) and have made a few projects. I want to learn more and do more and I eventually want money. What more is there?

Definitely learn SQL. It's not that hard, but you don't want to be caught flat-footed in an interview because you've never touched a database before, because 95% of jobs out there will be touching databases. A lot.

...

C++ got a lot of things right for all the shit it gets. RAII works. Really. Anyone who says you have to do your own memory management in C++ is either a bad C++ programmer or has a VERY restricted environment.

Too many schools still teach C with classes and it's fucking annoying.

What, the

return_type
function_name(args)
{


It's actually a rather sane style if you think about it. The bracket on its own line is just Linux Kernel Style/K&R Style/Stroustrup Style (e.g. how everyone does things normally). The return type on its own line comes because it's often accompanied by other keywords, like static, inline, [[noreturn]], constexpr, etc... further, the parameters may take up more space due to const qualifiers and such. We don't want the line to take up more than 80 characters just on principle, so we allow the return type and attributes to go on their own line. Although I would argue it's not going to hurt too much to be inconsistent when each of the lines would be super short, otherwise, it's perfectly fine. You should be declaring many of your functions static anyways, in which case, it'll look nice.

void as a concept is retarded you mean.

Are rhs/lhs not agnostic for keywords?
So you couldn't do:
keyword keyword keyword
type func(args)
{

}


which i think would be better. even though i still prefer:
type func(args) keyword keyword keyword
{

}

unless the args or func name are too long.

template
void heapsort(T arr, Compare cmp){

std::make_heap(arr.begin(), arr.end(), cmp);
std::sort_heap(arr.begin(), arr.end(), cmp);
}

>reinventing the wheel

Definitely not agnostic.

const int& get_integer();

Returns a reference to const int.

int& get_integer() const;


Declares a member function which returns a reference to non-const int which can only be called on a const object. Or it's ill-formed if it's a free function.

Unless you're talking about something else.

You absolutely can do that, but I think
keyword keyword type
func(args)
{
}

looks nicer.

This. SQL is relatively easy to get the hang of. Also, liberally use EXPLAIN while you learn

Why is void as a concept retarded? There are plenty of valid reasons for a function to accept no arguments, or to return no values.

Probably a functional programming weenie.

>Why is void as a concept retarded?
Because languages need to adopt Nothing/Maybe as they make much more sense.

void is paradoxical.

durrr

Jesus the organization is crazy here.

> void is bad
> Nothing is better
This is vocabulary masturbation.

ugly font and colour

void can not do the same things Nothing can, so no, it's not.

I am running through a beginner project for my C++ class in college. I'm having a difficult time trying to figure out an error that keeps occurring on this week's project.

What, is this just a null reference? I'd rather have static type checking tell me when I try to use the result of a function that returns nothing. void does that. Something akin Python's 'None' silently succeeds.

Nice blog post.

Stop dereferencing null pointers

Have you tried using Rust instead?

>, is this just a null reference?
no, and that's my point.
> I'd rather have static type checking tell me when I try to use the result of a function that returns nothing.
Which is where the Maybe type is perfect.

Right? I was just testing the water as a new software developer in training. I know that if a noob throws himself into a pool of experienced computer scientists and software devs then he possibly could get some assistance. Contradicting that though, this is Sup Forums. No one would honestly give a shit for another on this site

The instructor is strict on C++, and I'm not sure how coding with rust would differentiate. Honestly I've dabbled in python slightly, but all of my experience is with c++

Are you trolling? Idk what context you're thinking of but if I have a function that returns nothing, you're suggesting that I do this:
std::optional func_that_returns_nothing_useful()
{
// ...
return std::optional();
}

How is this better than void? I've now made it possible to mistakenly use the result of a function that semantically has no useful information to return.

If that function is void, then I would get scolded by the compiler at compile time.

Perhaps you should actually define what your "Nothing" actually is. We aren't mind readers and you aren't explaining it at all.

I've encountered "Nothing" two times in languages and neither seem to be applicable:
-in Visual Basic "Nothing" is a market that represents the default value for whatever type is being acted upon
-in Kotlin, "Nothing" is a value that will never be created because the control flow prevents the code point from being reached (generally used to mark the fact that it will always throws an exception)

What is your Nothing?

His nothing is a whole bunch of wank about monads and shit. The upshot is you have to handle the nothing case or else in haskell.

shut up idiot

did calling monads wank trigger you user?

Need to make a GUI for a program that runs on both Mac and Linux. I've tried Qt but it is so hard to get something really nice and polished. Thoughts Sup Forums?
>inb4electron

Qt is the nicest thing I know of outside of electron. Sorry user if you want better you'll have to sacrifice 2 gigs to the meme.

Why not Tk?

Bumping for interest this user's question

I hate GUI programming but if you're using C++, wxWidgets is a thing.

Got it. I'm running through a scholarship course for android Java/XML development, when I'm done I'll check out SQL.

Thanks anons.

which text editor and which ide (if any) are you using? for what language?

Vim.
Everything.

visual studio.
everything that matters

I exclusively use Vim.

vim for almost everything and my own personal editor for lisp.

>did calling monads wank trigger you user?

This, no other editor has the features it has. It probably reduces development time by two thirds.

If you rely on your editor to keep track of two thirds of the complexity of your codebase, your complexity is out of hand.

Abstract better, pajeet.

how do you debug?

visual studio or visual studio code?

- valgrind
- address sanitizer
- gdb
other tools depending on what the problem appears to be.

docs.microsoft.com/en-us/visualstudio/debugger/debugger-feature-tour

It's not about keeping track of complexity retard. Some of these are available in other editors, but I don't know of one which has all of these:
>Code snippits allows fast insertion of boilerplate
>Auto refactoring allows you to quickly change variable/class/method names, extract or inline methods, replace code with shorter code with identical functionality without introducing accidental bugs
>Debugger has great features
>Code analytics finds any shit code and tells you about it, you can define your own rules for it as well
>Git integration always you to quickly check old code, commit or delete changes while coding
>Organising which libraries are used by each program is retarded easy when compared to some other editors I've used
>Good pre and post compile build commands.
>Sharing code between projects works a lot smoother than other editors.

Vim user here.

He's trolling you. Just let him be.