/dpt/ - Daily Programming Thread

What are you working on?
Previous

Attached: 1529381023816.png (615x597, 301K)

Other urls found in this thread:

voices.canonical.com/jussi.pakkanen/2011/09/13/autotools/
bazel.build/
internals.rust-lang.org/t/rust-2018-an-early-preview/7776
rust-lang-nursery.github.io/edition-guide/2018/status.html#rust-2018-feature-status
github.com/ksimka/go-is-not-good
en.wikipedia.org/wiki/Most_vexing_parse
github.com/qemu/qemu/blob/7ed14cbf3cf083f125c079bd02b3215941853830/slirp/ip_icmp.c#L152-L207
stackoverflow.com/questions/3792663/atol-v-s-strtol
github.com/redox-os/termion/blob/master/examples/commie.rs
amir.rachum.com/blog/2016/09/15/knowledge-debt/
twitter.com/NSFWRedditVideo

Hey. kid! If your library uses CMake I'm gonna fucking close the tab and move on! Life's too short to deal with that shit!

why do people hate c/c++ so much?

Attached: 34897328821213.png (959x265, 30K)

Terrible ecosystem

>c/c++
Don't group completely different languages together.
C is an excellent language that fits its niche incredibly well, which is why nobody has been able to displace it despite trying for 30 years.
C++ is a fucking bloated abomination that goes against all good sense in programming.

Reading Programming in Lua to write better code in Love2D. Pretty comfy language, very similar to JavaScript but smaller, with less idiosyncrasies, better scoping and some cool additional features like multiple assignment and multiple returns. Can be faster than V8 with LuaJIT too.

FUCKING THIS

This. Good luck finding a sane package manager for C/C++.

>c/c++
don't do that

HolyC is one true programming language

The reason C will never die is the same as why PHP and Javascript will never die.

nobody needs over 10 year old webpages.
Embedded systems will never go away.

There are heaps.
dnf, APT, pacman, portage, etc.

He meant packages like .jar, writing portable code is assumed

He didn't say that.
>writing portable code is assumed
C is extremely portable. Just the binaries are not, which is true for every natively compiled language.

portage shares just code and compiles it on users pc.

>Embedded systems will never go away.
Exactly. It has nothing to do with quality of the language itself.

What you guys using then, autotools seems even worse

Asking because I'm writing the build system for some software at work and right now I'm using CMake

I use Meson for my projects. It's honestly nice, and doesn't make me want to kill myself when I have to modify it.

the only "portable" C standard doesn't even have "portable" integers

>dnf, APT, pacman, portage, etc.
All of those use autotools under the hood. And autotools is UNIX-exclusive and a mess.

int is at least 16 bit wide and it's size is sizeof(char) * something.
There's also fixed sized integer types if you need them like int32_t and such.

shut up and KKKode

Attached: roastie.jpg (2480x2480, 477K)

Yes it does, you idiot.
Just because something is implementation-defined, it doesn't mean that it's not portable.
The code just has to not make any assumptions based on a single implementation.

>All of those use autotools under the hood
What? No they don't. They usually use some sort of shell script which just calls into the build system that a library/program uses.

"portable makefiles". i have a GNU makefile lying around somewhere with all the boilerplate necessary to detect the host platform and compile for mingw, linux, netbsd, openbsd, freebsd, and for some reason IRIX. and to cross-compile you just override the target and architecture variables when you invoke make, provided you have the required cross-compiler installed.

having to reach for boilerplate every time i start a cross-platform project is regrettable but the upside is that i don't run into CMake Rot,, and i don't have to deal with autotools.

premake and bakefile are interesting but i don't really have a reason to test them out now.

>C is extremely portable.
Standard doesn't cover many important topics, and when it tries to it fails horribly, see the reasons why there are no C11 threads in glibc. That's not even including the fact that many compilers are not entirely standard-compliant despite claiming to be.

Pixiv changed the way image data is sent from the server so I have to rewrite the data parser. They changed to JSON so that actually helps.

WHAT

>What? No they don't. They usually use some sort of shell script which just calls into the build system that a library/program uses.
Which in 99% cases is autotools. The alternatives are shit too. Sane package managers have integrated build systems. See cargo or go.

>voices.canonical.com/jussi.pakkanen/2011/09/13/autotools/

>You can use Autotools on Windows, but first you need to install either Cygwin or MSYS and even then you can only use variants of GCC. There is roughly zero support for Visual studio, which unfortunately is the most popular compiler on that platform.

>The end result is that if you want or need to support Windows as a first class platform then Autotools can’t be used. Many projects provide both Autotools and Visual Studio projects, but that means that you have two independent build systems that will go out of sync on a regular basis.

Bazel
bazel.build/

>Which in 99% cases is autotools
There is plenty of shit that doesn't use autotools, but that honestly isn't particularly important.
>Sane package managers have integrated build systems
Literally nobody wants to duplicate the work for potentially thousands of packages for basically no reason.
>See cargo or go
Great. Completely tied to a single language and don't play nicely at all with anything else.
Not to mention they basically have no security built in.

Rust 2018 preview is out: internals.rust-lang.org/t/rust-2018-an-early-preview/7776 , rust-lang-nursery.github.io/edition-guide/2018/status.html#rust-2018-feature-status , looks pretty good so far

Attached: rust_2018.png (730x1270, 112K)

Rust language design is fucking shit. Should just use golang instead.

Do you have brain damage?

woohoo more useless shit inspired by sepples and ml

>A toy language with GC is somehow an alternative to Rust
Besides, github.com/ksimka/go-is-not-good .
> shit inspired by sepples and ml
You have no idea what you're talking about, don't you?

Attached: Da9Cp2l.png (680x680, 118K)

Another breakthrough lol

nice to see you're forming your own opinions!

>Great. Completely tied to a single language and don't play nicely at all with anything else.
You miss the point. The build system and the package manager both need to understand the source files they ship, and conversely, the compiler needs to understand packages. See the user whose CMake couldn't find libraries for LuaJIT from the previous thread. Libraries and #includes are VERY low level abstractions and can't be used in place of actual packages, yet that's what all of the popular C build systems do. CMake or autotools have no knowledge about .deb or .rpm packages, so they can't use those to decide where the library is installed. And neither of them know about headers and libraries the underlying C code needs to #include and link against to build properly. It's fundamentally broken. What we need is a single package manager and a single build system that works on all distributions, all integrated. There's nothing stopping it from supporting multiple languages, but it needs to understand all of the languages that it supports. #include needs to be deprecated and replaced with a different preprocessor directive that works on packages and not source files.
>Not to mention they basically have no security built in.
Show me what additional security dpkg or portage provides you with.

>I have never heard of pkg-config: The post

Attached: 1485262515835.jpg (1065x859, 76K)

Go and Rust are intended for different tasks, and have almost nothing in common. You may as well tell people to use HTML.

Rust is growing stronger.

>pkg-config
It's just a shitty overlay on top of current broken mess and it fails often because of that. It has no real packages or knowledge about build systems or source code as well. What I'm proposing is a complete overhaul. I know it will probably never be implemented because of sheer amount of inertia the current systems have accumulated, but that doesn't mean they're better.

>no real packages
Why would it needs to know about irrelevant shit like .debs?
>knowledge about build systems or source code as well
Why would it needs to know about this either? It's just telling you where the header files and library files are, any maybe a couple of other things.

struct N { std::size_t a; unsigned char b; };
// ...
std::cout

I meant sizeof(N), of course.

use a bash script

in its early days, rust was a lot closer to go because they both drew heavy inspiration from alef and limbo, but quite late they decided to take CSP concurrency out of the syntax for some unfathomable reason.

that early similarity is why they're still viewed as competitors to each other, though frankly go has left rust in the dust. it's in that known-but-never-quite-taking-off bog that D is eternally stuck in.

Because it interprets it as a function type N() (function that takes no arguments and returns an object of type N) and not the result of calling N(), which is a default initialized instance of N. Shit like this happens because of C++ syntax ambiguities, see: en.wikipedia.org/wiki/Most_vexing_parse for details.

It's worth noting that taking the size of a function type is a gcc extension and not standard C or C++.

Building the network stack for my pet OS.
Right now I've done datalink, network and UDP transport layers (also physical layer, if you count the nic driver), but, from the user perspective, only basic UDP sockets are working.

Attached: screen.png (1846x1080, 156K)

>No ICMP yet
Cmon

I have ICMP, but for now it only support echo/reply messages

Oh alright, fair enough.
Good work user.

Based on what I know, TCP sure sounds like it'll be fun to implement :^)

Thanks senpai

Do you run on real hardware (ignoring the network drivers)?

Is there any good resource on creating multithreaded Java applications? I tried few, but they are complete clusterfuck.

char *a[10]

Does this give me pointer to strings with length 10? Or 10 pointers with undefined string length?

10 pointers. Declarations follow the same operator precedence rules as normal code.

An array of 10 char pointers. Nothing at all is implied about what they point to.

The QEMU Slirp NAT engine does not support emulating any other ICMP messages anyway.
github.com/qemu/qemu/blob/7ed14cbf3cf083f125c079bd02b3215941853830/slirp/ip_icmp.c#L152-L207

To be honest, I dread that one too, but at least there's the book to guide me around
I do all of the development work using qemu, but I always test it on metal too.
I have a nice old-ish pentium 4 machine with all the right hardware (including the RTL8139 card, which I use for networking).
It's kind of a pain though because I have to load everything from floppy.
Once I complete the network stack, I'll finally install it for good.
Yeah, networking under qemu is limited and/or complicate to set up right, another reason why I also test on hardware.

Attached: screen.png (862x408, 135K)

>but quite late they decided to take CSP concurrency out of the syntax for some unfathomable reason.
What do you mean?

Can someone explain what is the difference between atol and strtol other than strtol allow non base 10 string?

atoi has basically no error checking. If you're trying to write something more robust, you should use strtol.

[[Vote to close as duplicate intensifies]]

stackoverflow.com/questions/3792663/atol-v-s-strtol

strtol handles errors properly. It sets errno on overflow or if the string doesn't have a valid numeric prefix. You can also check if the entire string has been parsed using endptr attribute.

you know how go has stuff built into the language like

>you know how go has stuff built into the language like

no i don't have any specific source, i've been following the language since 2011, this isn't information i've just recently gleaned

>message-channels
just like go, alef and limbo, rust used to have an operator for sending on a channel

So this is the power of Rust: github.com/redox-os/termion/blob/master/examples/commie.rs
const COMMUNISM: &'static str = r#"
!######### #
!########! ##!
!########! ###
!########## ####
######### ##### ######
!###! !####! ######
! ##### ######!
!####! #######
##### #######
!####! #######!
####!########
## ##########
,######! !#############
,#### ########################!####!
,####' ##################!' #####
,####' ####### !####!
####' #####
~## ##~
"#;
println!("{}{} GAY SPACE COMMUNISM ",
cursor::Goto(1, 1),
color::Bg(color::AnsiValue(state)));
println!("{}{} WILL PREVAIL, COMRADES! ",
cursor::Goto(1, 20),
color::Bg(color::AnsiValue(state)));

i too, love sticking the insignia of genocidal ideologies in my source code

sieg heil

rewriting GCC/CLANG compatible C to work on TCC.
C really needs better macro system and some reflection would be nice.

Looks good

Attached: gsc.png (442x404, 10K)

>&'
what

>I want to do x!
>Find tutorial on how to do x
>To do X, you need to learn how to do y1
>To do y1, you need to learn how to do y2
>To do y2, you need to learn how to do y3
>...
>To do yn, you need to learn how to do yn-1
>Quit project

Every fucking time, with 5+ new tabs open with stuff i need to learn. Sure, it's fairly easy to just copy code and get something running, but there's just far too much to understand for me to be bothered learning about. Does this ever stop?

Why do people expect code to be entirely comprehensible even if they don't know the language?

amir.rachum.com/blog/2016/09/15/knowledge-debt/

Look for tutorials that don't do this. Don't have an encyclopedic approach, better learn only as much as you need to start. You can systematize your knowledge AFTER you get some practical experience and get some intuition. Good luck and have fun.

-t TA of CS courses in one of central european uni.

I have a tiny light industry business, I perform work on objects that range in size from small rings and jewellery to large car parts, so it's rare that any 2 job is ever the same. For someone small scale like me with no real programming experience is learning to code with the idea of trying to automate this process within my reach, or is it still too early for me to be thinking about something like that.

I would need to be able to scan an object in 3D, mark what areas need to be worked on, and what areas need to be avoided. What sort of language would be best to work to achieve this goal?

That's a hardware question, not a software one.

As far as languages go, Python would probably fit your needs, since it has a friendly interface and libraries for pretty much every domain of application.
Regarding your domain in particular, keep in mind that 3D image manipulation and computer vision are pretty advanced topics, better suited for advanced programmers (possibly with an university-level education)

Isn't there a header file, chromium.h or something? You can try indexing that. It has all the function prototypes.

char* wompWomp() {
return {
"How dare you?",
"How dare you!",
"How absolutely dare you, sir.",
"How dare you, sir, how dare you."
}[randomInt(4)];
}

I posted in the stupid questions thread because I felt like this was a stupid question but I didn't get any responses and I have been up for the last 22 hours on d-amph.

In java how can I convert an input like 3.92 into a decimal?
I got distracted while doing a problem for class and made a program to calculate the number of payments needed to pay off a loan. I have it working properly however you need to enter the APR in monthly decimal format which is silly. I tried converting the double I was using from the input into a new double that would be used for the calculation but that throws the result off. I tried to convert it by doing
double monAPR = (APR / 12) * .001
I know doubles aren't precise, I just don't know how to get from number with decimals to just decimals.

Attached: sad-beagle-looking-out-window.jpg.653x0_q80_crop-smart.jpg (653x436, 32K)

char* a[10];

ALWAYS put the pointer on the type, to avoid misunderstandings like this.
Mnemonic: the leftists like using stars as symbols

Attached: 582px-State_Emblem_of_the_Soviet_Union.svg-2.png (582x600, 339K)

What's the most difficult language to learn?

Doesn't that need to be casted to char first?


Number modulus 1?

You're retarded.

should i bother learning ruby on rails?

I'm not a communist, it's just a good mnemonic.
You have a char pointer, a, ten times over, not a (char, whose dereference yields a), ten times over.

thats not a mnemonic

Star goes on the left because the star is a leftist symbol.

that sounds too advanced for you to code it on your own. look into CAD software and whatever scripting languages they use

>Macchina virtuale
Let me guess: polimi or polito?

>using translated OS or development tools
absolutely disgusting
do you watch your anime dubbed, too?

Attached: 1529760420124.png (350x379, 122K)

you already made a thread.
fuck off

Any Java equivalent of Python's Celery or multiprocessing packages?