/dpt/ - Daily Programming Thread

Old thread: What are you working on, Jow Forums?

Attached: 1566749433361.png (1000x1000, 588K)

Other urls found in this thread:

github.com/dekuNukem/daytripper
twitch.tv/videos/468789946
dlang.org/articles/mixin.html
docs.gitlab.com/ee/gitlab-basics/
mabez.dev/blog/posts/esp32-rust/
twitter.com/SFWRedditGifs

Yuno is not programming related

Do C and other langs do dead code elimination with the language run-time?
I've always thought it'd be neat for a language to not have any implicit/default imports, and force the programmer to import only exactly what they needed.
But I'm absolutely mt. stupid with compilers so i really have no idea how that area works.

How come in my book when they define a function they put the scope before it like MyClass::foo() but my instructor's example don't do that? Which is the correct way thx.

libc is usually dynamically linked, so no. But I believe it would with statically linked code.

Anime is always programming related on this anime website.

Attached: 1557605964542.jpg (1000x1181, 130K)

Yuno is not anime related

no. tree-shaking to this degree is very rare.
and no, C compilers don't do it even with statically linked code.
maybe some specific Forths or Lisps do it.
That aside, there are certainly some languages with very minimal 'defaults'. Zig might be more what you're looking for.

>dead code elimination
is fairly pointless

I used to love learning new languages but after browsing /dpt/ I've started using pretty much only Python. Ironic, considering that seems to be the opposite of what most shills here want.

>Zig
might give it another look then.
Wouldn't having an explicitly sized run-time be good though? Or is the C one just so small, it's a non-issue?

I don't know what "explicitly sized" means but program size is very small in relation to the amount of memory you have, there's not much point in bothering

for an entire system, if you have 100 different processes running, and each one has used tree-shaking to kick out parts of the runtime that it doesn't use, then you end up using more memory, not less, because these processes are all now special snowflakes that can't share memory.

>if you have 100 different processes running, and each one has used tree-shaking to kick out parts of the runtime that it doesn't use, then you end up using more memory, not less, because these processes are all now special snowflakes that can't share memory.
ah, that is a good point.

empowering the wagies
github.com/dekuNukem/daytripper

>blood pressure a little high
>look at some random Lua code
>problem solved

.head.remove()
oof

>girl I know wants to learn to #kode
>some java class
>Help!!! My code won't work!!!
>public class SomeClass {
void SomeFunc() {
if (something==true); // rofl
String[]arr=newString[9]; // yes, no fucking whitespace
for(int i=1; itell her that she's missing a closing curly brace and that the for loop is doing absolutely nothing there, hoping she would realize the array initialization mistake herself
>AAA it still isn't working!!!
>public class SomeClass {
void SomeFunc() {
if (something==true);
String[]arr=newString[9]; // yes, still no fucking whitespace
(int i=1; i

java will optimise out the for loop
less whitespace = faster parsing
she's a natural 10000 IQ way out of your league DURGA certified java programmer

unironically why whitespace langs are superior

kek, getting this mad that you couldn't help her because you are just as retarded

I can't help her when I still don't understand what she wants or needs

This is why you will never score

Attached: A2A1BC9B-74F0-4CEF-BC82-EA91A17D02A4.jpg (809x440, 89K)

disgusting, I don't even want to
told her to revise the fucking loops again, I ain't doing her homework

looks like a "im learning a bunch of concepts and want to randomly apply them" thing.
the for loop is questionable though.
Is she just testing syntax, or does she think the arr[2] assignment is being ran inside it?
but most likely she half-assed it and was trying to get you to do it for her.

JAI JAI JAI!

Attached: 25B68057-9868-4FCE-9FBE-E66683F3CA8E.png (413x352, 164K)

>I still don't understand what she wants or needs
A real man, not a whiny fucking incel

haven't watched a vod in a while.
We any closer to a public release?

>most likely she half-assed it
probably
I wouldn't bet she's just "trying syntax", I doubt she even understands the errors
the quality of the course is questionable but I wouldn't blame it though since I already fixed her snippets before and it doesn't seem like she even bother to check what's different from her '''''solution''''
>the for loop is questionable though
ye no shit, pic related was the last message
then she should go to her fiance

Attached: IMG-20190909-WA0004.jpg (903x1600, 105K)

I'm convinced anyone hyped about Jai is a cargo-cult amateur programmer
It's not meaningfully different to C++

People have wanted a games-focused language for ages.
And it's basically anti-C++ with a lot of lisp-inspired macro stuff.
Granted I don't think Jon will ever quite get the synatx to something decent. He seems pretty lost/uninterested in it.

Is she our new queen?

Attached: 1568105319062.jpg (903x1600, 105K)

How is it "game focused"? It's about as game focused as C++. Whats so different about the macros?

>be me
>create diy device designed to let me steal company time without getting caught
>put it in my portfolio
>wonder why nobody ever calls me back

Attached: 1560573587395.jpg (1024x1010, 63K)

okay user, people know how to use archives, no need to repost it

>How is it "game focused"?
The developer and company are specifically making it for games?
Jump around twitch.tv/videos/468789946
for examples though.
But there's nothing really special about them, they're just Lisp-style macros you'd expect.
The language itself is actually closer to C in features, and most other features will be library-offloaded according to Jon.

she looks like a qt

I'm not familiar with Lisp which is why I asked, it's hard to watch an hour long video looking at that awful syntax
For it to be a games language it'd need to have features specifically for building games, and I haven't actually seen any so far that set it anywhere above Jon Blows personal preferences

I want to have consensual sex with her assuming she is of legal age.

>I'm not familiar with Lisp which is why I asked,
ah, well basically jai lets you denote functions with #expand, which turns them into macros. And then you can #insert code directly into wherever you want alongside regular code.
Sort of like the idea of string mixins, could be another way to think of them.
dlang.org/articles/mixin.html

POST UR CODE RIGHT NOW

newtype Nat p a b = Nat { runNat :: forall x . p (a x) (b x) }
type family Mapping k :: k -> k -> Type
type instance Mapping Type = (->)
type instance Mapping (i -> j) = Nat (Mapping j)

type (i :: k) ~> j = Mapping k i j

class Functor f where
fmap :: (a ~> b) -> (f a ~> f b)

What does ~> mean?

#include
#include
#include
using std::cout; using std::cin; using std::string;
using std::runtime_error;

int main()
{
int in1, in2;
bool repeat = false;
do {
cout > in1 >> in2;
if (in2 == 0)
throw runtime_error("Cannot divide by zero.");

cout

I defined it as Mapping k, where k is the kind of the argument
For regular types it's just ->, but for higher kinded types it's a natural transformation. This lets you write a functor instance for every parameter of a type
instance Functor ((,) a)
instance Functor (,)

And also cover hoisting (forall a. f a -> g a) -> (h f -> h g)

>gaming console
>gaming PC
>gaming Laptop
>gaming monitor
>gaming mouse
>gaming mousepad
>gaming keyboard

>gaming soda


>gaming programming language

C++'s most popular application is games.

>isn't going to half half the features promised
Just like a real game!

no it's just applications, games are a subset of that

More games are made than wagie enterprise shit with it.

I created a library that is composed out of multiple files.
I generated both shared and static libraries and copied them to /usr/lib/. Which of the files I need to copy to the header dir (/usr/include/muhlib/) so I can use the library? Is it all of them? But in that case I'm leaving code that is internal to the library available to the user? What do?

make a dir in home/dev or something and just link to everything there.
I wouldn't litter sys dirs with user libs.

was he right?

Attached: 2.png (596x165, 9K)

Are refinement/dependent types more for safety or convenience?

Attached: qq.jpg (400x323, 51K)

citation needed

I am rewriting my robot from scratch, because fuck the ROS2 overhead.
Should I use Rust or C++?
I know c++, I barely know rust. Just did a few tutorials with it.

Attached: asdasd.jpg (480x360, 17K)

do you include the developer in this assessment?

In that case I hope that you have a set of headers that only expose the public functionality of your library, which e.g. includes incomplete declarations of types (for example think of FILE in the C standard library, which in glibc is a typedef for the opaque type "struct _IO_FILE") that the user is only supposed to use through a pointer.
Typically you split all internal details into separate headers that only your code includes.

try ada

Both, just like any kind of types.
If you can prove things about your values then you can write functions using them without having to check predicates (convenience) or lose totality (safety)

why would people who haven't suffered using existing languages care about Jai?

No Jon Blow is a good programmer, his language just seems like his own personal language

Same reason amateur gamedevs try to use Vulkan? Because it's new and shiny?

>JAI
Isn't that just a vaporware github readme file?

Where do I learn git from?

docs.gitlab.com/ee/gitlab-basics/
start here

unironically "how do i X in git".
Most people only need ~3-4 commands.

yes.

The ecosystem is especially guilty of not fixing its shit. C/C++ people defend shit toolchain/library management all the time.

i have sinned
def mk_fizz(n,s)
return lambda { |x| s if x%n == 0 }
end

fizzbuzz = [mk_fizz(3,'fizz'), mk_fizz(5,'buzz')]
(1..100).each { |n| printf("%3d %s\n", n, fizzbuzz.map { |f| f[n] }.join) }

what about this

Attached: 4.png (685x529, 37K)

>muh monoids
very haskelly

Guy seems based, but C++ isn't all that bad.

>be me
>work completely unrelated to tech
>know python
>only one in this small company
>automate shit
>done works in an hour instead of a dau
>mostly I just come to office and watch youtube
so this is the power of programming.

don't let them catch on or they'll assign you more tasks
obviously, because you're so efficient

Care to give an example? Also what if I have inline functions defined in header files? Do I copy those header files too?

>automating your own job
good work retard

You don't tell other people how to run the automation, idiot.

If you think nobody will realise you're an idiot. You aren't the only one who knows python.

Do you know if it's possible to make the F* auto-completion in emacs give relevant suggestions, like things that are actually in a module? When I press Ctrl+Enter, the suggestions are very generic things like true, false, unit, etc.

Context: I'm pressing it after Map.

they're for refining and depending

astute observation

If you make a shared library, you usually want it to have a stable ABI. That means it contains declarations and no definitions. It's good to have for static libraries too.
So this is cool:
struct bar;
typedef struct bar *Bar;
void foo(Bar);
But this not so much
struct Bar { int baz; };
static inline void foo(Bar bar)
{
bar->baz++;
}
Sometimes this is unavoidable, for example with macros. In those cases if you still want to maintain a stable ABI you have to pick a definition and never change it. That's horribly inconvenient so you should do that as little as possible.

You can set 'repeat' using the conditional statement, rather than using the if condition:
repeat = !cin || c == 'n'

it's the truth user, anything more than that is circumstantial

His opinion of Go is far too high.

mabez.dev/blog/posts/esp32-rust/

rust then it is, but not on the esp. On a raspberry

For example, you might have a public header file for libmystery which looks like this:
#ifndef MYSTERY_H
#define MYSTERY_H
typedef struct _mys MYSTERY;

int mys_do_magic(MYSTERY *);
#endif

And an internal header which delivers the full definition of the struct:
#ifndef MYSTERY_INTERNAL_H
#ifndef MYSTERY_INTERNAL
#error "internal use only"
#endif

struct _mys {
int mystery_value;
};
#endif

Which now means that you can ship mystery.h with your library while using it together with mystery-internal.h in your code to deliver the implementation:
#define MYSTERY_INTERNAL /* this is sometimes hidden in another helper header */
#include "mystery.h"
#include "mystery-internal.h"
int mys_do_magic(MYSTERY *m) {
m->mystery_value = 42;
return 1; /* signal success */
}

That all depends how much of your internal data structures you want to hide from the library users.

>Also what if I have inline functions defined in header files?
Move them to your private headers and preferably make them static.

it's not that I like the edginess of a dark theme. it's that I can't understand shit with the blinding light of the light ones

Attached: 1562369462717.png (40x40, 3K)

Got a tough challenge I can't solve.

Recently I moved some classes around in Java so that their fully qualified package names have changed.
This means it's gone from:
com.foo.bar.Class
to:
com.foo.bar.ted.Class
or something similar.

Essentially, my function will take a fully-qual package name or simple class name and check to see if it's the old package name or not.
How can I check that the given string uses the old prefix? I can't seem to solve this robustly.

light theme during the day
dark theme during the night

unless it's black on white, I have problems with light themes, even under daylight

Attached: solarized.png (603x364, 41K)

I prefer off-white like ;)

luv rust
match std::os::unix::net::UnixListener::bind(&socket) {
Err (e) => {
log::error!("Socket binding failed: {}.",e);
panic!();
}
}

::rust::

>std::os::unix::net::UnixListener::
yikes

Lisp is the most powerful programming language.

Maybe you could create a text file with all class paths:
$ find . | tr / . > a.txt;
$ grep -r import | sed -e 's/import //' > b.txt;
$ diff -s a.txt b.txt


Or something like that.

The book. Your instructor is likely some Asian or Pajeet brainlet.

in C++ classes and structs are the same thing