/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: c++.jpg (900x1145, 472K)

Other urls found in this thread:

ats-lang.org/
github.com/lizhuohua/linux-kernel-module-rust
geeksforgeeks.org/vector-in-cpp-stl/
pastebin.com/CrRVAqzp
en.wikipedia.org/wiki/Monomorphism
en.wikipedia.org/wiki/Obfuscation_(software)
twitter.com/NSFWRedditGif

Bjarne is so full of himself, i can't stand watching his talks

Who ATS here?
ats-lang.org/
>ML syntax
>theorem proving
>can inline C code

fun
fibats{n:nat}
(n: int (n))
: [r:int] (FIB (n, r) | int r) = let
//
fun
loop
{i:nat | i 0)
then
loop{i+1}
(
pf1, FIB2(pf0, pf1) | n_i-1, r1, r0+r1
) (* then *)
else (pf0 | r0)
// end of [if]
) (* end of [loop] *)
in
loop{0}(FIB0(*void*), FIB1(*void*) | n, 0, 1)
end // end of [fibats]

He's like a real gnome, I can't stand watching him walk

haskell fags blown the fuck out

require 'prime'

Prime.each do |prime|
puts prime
end


import Control.Monad
import Data.Numbers.Primes

main = forM_ primes print


$ echo "$(timeout 1m ./primes)" | wc -l
10274461
$ echo "$(timeout 1m ruby primes.rb)" | wc -l
24036035

Ruby is disgusting tbqh

bjarne is smug moe

first for rust

What does the term differential time mean in programming? I can't find any answer to this.

This is in context to vectors in c++, i understand what constant time and linear time would mean.

I have awaken
time to continue learning c++

Attached: 1537460454137.jpg (1280x720, 68K)

I don't understand
Are you writing a program that has a main() function in it? Or are you writing a C runtime?

This looks worse than Perl.

Can you show me the sentence in which it is used?

For some reason I get this error:
error: invalid conversion from ‘char**’ to ‘const char**’ [-fpermissive]

What is causing this?

It says right there, it's an invalid conversion. And it's correct for it to be invalid because it would open a hole in the type system otherwise.

>want to make a SPA with gridsome
>cucked COC
is there any non SJW static webpage generator that doesn't use a gay ass long forgotten completely useless templatintg language?

Differential time means O(dt)

Post code

>COC
Dumbest reason to avoid a technology, you don't even have to participate in the community if you don't want

Are shitty unit tests better than no tests at all?

Attached: 1561163614311.jpg (680x813, 56K)

github.com/lizhuohua/linux-kernel-module-rust

>Post code
Basically I'm trying to pass something of type "char **" to a function that takes "const char **". C++ btw.

Attached: sigh.jpg (306x306, 68K)

There is literally no point in unit tests

no, they are not

trying to find good, idiomatic Julia code

If you know it should work, use a cast. But if it doesn't then you only have yourself to blame.

lmao if your language doesnt allow you to go from read-write to read only it should be thrown awah

converting from char* to char const* not the same thing as converting from char** to char const** retard

Very good reason actually.
Cause they try to conform their code to social justice bs like Rust does.

Plus what if a company X uses language or free software Y.

And suddenly Xirplets are rustled and try to force you not to use software Y thats already a big infrastructure in said company.

Potential damages are just too great.
With SJW infested software or code.

This happened to ICE btw.

Well companies ask it but i find it inane.
If you have good programmers.

how do i learn angular?

Google it nigga.

But i would rather learn Vue or React.

you don't because it's trash

>they try to conform their code to social justice bs like Rust does
really makes you think

Attached: A10A136A-5531-4842-879A-D827B1665A38.jpg (385x385, 27K)

why

>try to force you not to use software Y thats already a big infrastructure in said company
don't use non-free code

I already told you, it opens a hole in the type system
int const x = 0;
int *p;
int const **q = &p; // !!
*q = &x;
*p = 1;

Whenever I develop I of course try my functions when they're done. For some reason I always remove the sample input when I'm done. Doesn't seem to require much/any extra effort to just save them as tests. In general I feel like tests might be overrated, but if it's almost-zero effort to add it I don't see why not.

Attached: just be yourself.jpg (805x556, 116K)

geeksforgeeks.org/vector-in-cpp-stl/
> In vectors, data is inserted at the end. Inserting at the end takes differential time, as sometimes there may be a need of extending the array. Removing the last element takes only constant time because no resizing happens.

>This happened to ICE btw
Story?

Not much I can do about that...

C is the least verbose language I know, I don't know what you mean. I say it's the least verbose because you don't have to go down five levels of encapsulation for a print.

ICE used linux for administrations and servers.
SJW thought they could bully ICE out but they failed since everyone can use it there are no restrictions.

No they are going full force to try get total power on the license.
Wich is retarded and will not work since nobody really "OWNS" Linux.

Working on a Madcow 5x5 Training Program Calculator.
As suggested by an user last week, I generalized and simplified the code: pastebin.com/CrRVAqzp

Is there any reason to prefer this:
type Day = [(Exercise, [Weight])]

over this:
type Day = Map Exercise [Weight]

go back you dumb frogposting nigger

watch out the next meme word he is gonna say, is that it is "unsafe" cause niggers don't understand how to avoid a overflow in a array.

>meme
it's true

rust is full of unsafe code

You don't need "safety" to avoid mistakes of this kind, what you need are sane constructs like iterators. If you index an array out of bounds in Rust you still get a panic, the point is that using arrays this way should be the exception to the rule.

kek

Hey folks, a possible retard question, but does the following not work with the backslash?

I was under the impression that a double backslash in Java represents a backslash:

String t = "abc\r\n";
char[] a = t.toCharArray();
for(char s : a) {
if(s=='\\') {
System.out.println("Found backslash");
}
else {
System.out.println("Just another letter: "+s);
}
}

Is the fact that the backslash a part of the newline a problem?

what is the behavior

both \r and \n are single characters and not '\\' + ( 'n' | 'r')

Attached: Rustfags.jpg (662x602, 212K)

A newline isn't two characters consisting of an '\' and a 'n'. It's one character that is represented _in_a_format_string as "\n".
In other words, if you inspected the String "t" it would be the five chars 'a', 'b', 'c', '\r' '\n', The "\" in format strings indicates just indicates that what follows should be interpreted as a control character.

I thought its the same like in C/C++.
\r \n \0

And like user above said they are single characters.
If you are unsure i would lookup what hexadecimal value it prints.

all your programming languages suck.

Attached: 1294552759056.jpg (399x371, 16K)

Lisp is the most powerful programming language.

Mine is still better than yours checkmate.

Attached: 1558388442681.jpg (640x632, 20K)

Think you are confusing double backlashes with that it is used when pointing at a directory in your drive.

I dont have one cause I dont program. pawn takes bishop

>C is the least verbose language I know
Is this nigger serious or has it gone complete cnile?

Attached: 1537771566378.png (1200x1400, 502K)

Come on, argue, I don't know what makes you think it's more verbose so I don't know what to respond.

Does C99 have monomorphism? Or do you have to use the pre-processor? Or do you have to use the inefficient void*?

monomorphic "generics" are a mistake tbqh

I'm looking at image data.
a pixel with RGB 8-bit color depth has three values in the range [0:255].
shouldn't a pixel with RGB 16-bit color depth have three values in the range [0:65536]?
I don't see values like that in the images I look at.

I didn't ask for your opinion.

Sounds like code obfuscation to me. In terms of making a game engine, you don't need any of that shit, and it doesn't get more verbose because all you need is to know how to organize your several layers of abstraction.

nobody asked for yours tripfag

>generics are obfuscation
the absolute STATE of cniles

>Instead of getting the compiler to duplicate code for me I'll just waste my time duplicating it myself and also having to maintain each duplicate individually.
Great fucking strategy there.
>b-but I can optimize it individually
You can do that with type_traits too for the cases that can be optimized, and that's if the compiler doesn't do the optimizations for you anyway after monomorphisation.

based Rust

Why do I have to cast it? I wouldn't have to cast it if this were C.

Nah I'm not interested in defending a language that completely lacks generics, I'm merely saying that code duplication macros are the worst way to do it.

>Sounds like code obfuscation to me
Monomorphism has nothing to do with code obfuscation. Don't use phrases that you do not understand.
en.wikipedia.org/wiki/Monomorphism
en.wikipedia.org/wiki/Obfuscation_(software)
> In terms of making a game engine, you don't need any of that shit
Why are you bringing up "making a game engine"? And who are you to determine what I need for a game engine if I'm making any?

It should raise a warning and it would be right to do so.

So you rather use untyped pointers? Enjoy your inefficient shitcode I guess.
It also only works with trivially copyable types.

I should learn programming but I did drugs instead

im so bad at math ffs. i need to keep relearning how to make simple arithmetics with fractions every time i stumble upon them

Attached: IMG_20190404_081925.jpg (414x414, 26K)

I don't speak math, what the fuck is a "monomorphism" ?

learn lisp

If you want macros then use macros, don't use macros masquerading as generics.
>inb4 by macros you must mean shitty C text substitution

Something like compile time generics

I have been programming for 20 years and I still have to do divisions in calculator before I type them in because I can never remember what order the operands go

Templates are a programming language. They're more than macros.

>In terms of making a game engine, you don't need any of that shit
You don't _need_ anything other than raw assembly to make anything.
The whole point of programming languages is to make it easier to achieve what you want from your program.
Of course, you could just copy and paste blocks of code rather than using generics just as you could also copy and paste blocks of assembly rather than letting C generate the corresponding scaffolding code. It's not that you need to use it, it's that it's retarded not to use it.

C is only good for comparing the line count of generated ASM.
For any real world use cases, you use C++, for example, writing C compilers themselves.

That's part of what's wrong with them, a sane macro system just manipulates the syntax tree the same way it would manipulate any other data in the target language.

There's no real reason to use C over C++ for a game engine, or most software for that matter

>a sane macro system
Templates aren't macros.

I've never heard that phrase used. Must be because they don't wanna say std::vector is O(n) since it sounds bad. They're trying to say the time complexity of insertion can change depending on the current state of the vector. Basically insertion is usually in O(1) (constant time) but if the vector needs resizing and it can't be done in place, i.e. the base address of the internal buffer changes then all the elements need to be moved to the new buffer in order to maintain the invariant that all the elements are sequential which would take O(n).

They are. They duplicate the syntax tree of the templated entity and inject symbols into it in a parametric way. They're macros, they're simply incredibly obtuse about it - because they're pretending to be generics instead.
The result is that they're good at neither role.

how do make graffical Ui on c+

Attached: 1490404062053.gif (480x270, 2.47M)

As a programmer all you need to know is that monomorphism is what the compiler does when it takes your polymorphic code (code using generics) and generates a monomorphic version for each use instance.

It's best explained with an example. If you have some generic "sum" function that adds up a list, that's your polymorphic code. If you then use that function to add up a list of integers in one place and a list of floats in another then monomorphism is what the compiler does when it generates a version of sum that'll work for summing integers and a version of sum for summing floats.
It's not just as simple as a macro text expansion since the compiler can optimise the sum function in different ways depending on the types being used.

>std::vector is O(n)
meant to say "insertion into std::vector is O(n)"

you could just say "templates" and avoid sounding like a blowhard but whatever

Thoughts on this?

Attached: Big TECH.png (412x385, 82K)

Just because I know the definition of monomorphism and could answer the question doesn't mean I use the word.
I agree with you, words such as monoid are just mathematical wankery when used by programmers.

If you're a wagecuck just leave the thread

No idea about reallocation complexity but think it is worse than O(n)

Thats cause you never touched embedded stuff.

I need it for serial communication and Atmel chips.

well yeah, most software isn't embedded

this

Attached: 1554770612197.png (600x688, 402K)