/dpt/ - Daily Programming Thread

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

Other urls found in this thread:

en.wikipedia.org/wiki/LLVM
benchmarksgame.alioth.debian.org/
doc.rust-lang.org/book/ffi.html
wiki.c2.com/?StaticTyping
courses.cs.washington.edu/courses/cse341/04wi/lectures/13-dynamic-vs-static-types.html
adventofcode.com/2016/day/16
twitter.com/NSFWRedditGif

Rewriting C in Idris.

Can /dpt/ solve this in one (ONE) function?
I was wondering how would you go about subtracting generic types. For example, the function (let's call it "without") should be able to pass the following tests:

assert([12, 23, 23, 11, 5, 23].without(23) == [12, 11, 5]);
assert("ccxi".without('x') == "cci");
assert("abcderfiibcne".without("bc") == "aderfiine");
assert(["siwwo", "lkaiwmn", "diw"].without("iw") == ["swo", "lkamn" "d"]);
assert(['c', 'd', 'd'].without('d') == ['c']);
assert([234, 301, 322].without(12) == []);

re-writing rust in go

Threadly reminder that dlang-chan is not dead; she's going to have her GC tumor removed (eventually); and she's super duper cute and easy to prototype in! Say something nice about her, /dpt/!

Please, don't post shit girls.

Can a rust enthusiast give me a few reasons to learn rust? I'm looking to learn a new language and something to replace C could be interesting.

>Please, don't post shit girls.
>Posts shit girl anyways

>subtracting types
Sorry?

Wew. Thanks.

Rust is not a revolutionary language with new cutting-edge features, but it
incorporates a lot of proven techniques from older languages while massively
improving upon the design of C++ in matters of safe programming.
The Rust developers designed Rust to be a general-purpose and multi-paradigm
language. Like C++, it is an imperative, structured, and object-oriented language.
Besides this, it inherits a lot from functional languages and also incorporates
advanced techniques for concurrent programming.
In Rust, the typing of variables is static (because Rust is compiled) and strong.
However, unlike Java or C++, the developer is not forced to indicate the types
for everything as the Rust compiler is able to infer the types in many cases.
C and C++ are known to be haunted by a series of problems that often lead to
program crashes or memory leaks which are notoriously difficult to debug and solve.
Think about dangling pointers, buffer overflows, null pointers, segmentation faults,
data races, and so on. The Rust compiler (called rustc ) is very intelligent and can
detect all these problems while compiling your code, thereby guaranteeing memory
safety during execution. This is done by the compiler by retaining complete control
over memory layout, without needing the runtime burden of garbage collection
Rust compiles native code like Go and Julia. However, in contrast to these two, Rust
doesn't need runtime with garbage collection. In this respect, it also differs from Java
JVM and the languages that run on the JVM, such as Scala and Clojure. Most other
popular modern languages such as .NET with C# and F#, JavaScript, Python, Ruby,
Dart, and so on, all need a virtual machine and gc.
As one of its mechanisms for concurrency, Rust adopts the well-known actor model
from Erlang. Lightweight processes called threads perform work in parallel. They
do not share heap memory but communicate data through channels, data races
are eliminated by the type system

ctd
These
primitives make it easy for programmers to leverage the power of many CPU cores
that are available on current and future computing platforms.
The rustc compiler is completely self hosted, which means that it is written in
Rust and can compile itself by using a previous version. It uses the LLVM compiler
framework as its backend (for more information on LLVM compiler framework, go
to en.wikipedia.org/wiki/LLVM ) and produces natively executable code
that runs blazingly fast because it compiles to the same low-level code as C++ (To
see an example of its speed, go to benchmarksgame.alioth.debian.org/
u64q/rust.php .).
Rust is designed to be as portable as C++ and run on widely used hardware and
software platforms; at present, it runs on Linux, Mac OS X, Windows, FreeBSD,
Android, and iOS. It can call C's code as simply and efficiently as C can call its own
code, and conversely, C can also call Rust code

Please, don't post about your shit taste.

>the typing of variables is static
So like every language?
>Rust is compiled
So like every language?

>Rust is compiled
>So like every language?
hmmmmmmm made me think

Rust is worth picking over C++, not C. C is not replaceable.

Also Rust is not worth it if you use GC'd language, since it solves almost nothing (emphasis on almost) over a GC'd language

>What are you working on, Sup Forums?
got muh oled display working on plain C with an atmega8, no arduino shit anymore

>for any generic S of type T and the deletion generic s define F as the set of endomorphisms f: S → S and G as the set of epimorphisms g: S → s
>let H = F\G then return the image of morphisms in H

JavaScript is a programming language, but it is neither compiled (at least not ahead of time), nor is it statically typed.

Teach me senpai

Looks like buch of PL autists made a Frankenstein 2bh

>assert([234, 301, 322].without(12) == []);
are you sure this test case is correct?

>mfw even quora can solve this

So, how does the speed of rust compare with C++? Also, could I use a library compiled with C linkage with a rust program?

>it is neither compiled
Impossible.
>nor is it statically typed
Also impossible. You simply can't create a programming language which is not statically typed.

doc.rust-lang.org/book/ffi.html

Nevermind, I didn't see the last part of

top snek

You could return a null (preferably) or the whole array intact

should it be
assert([234, 301, 322].without(12) == [234, 301, 322]);?

Yeah, I wouldn't prefer that but I guess I can consider that

I made some 90s style box art for my currency converter script

I want to protect that snek!

Sasuga Sup Forums

Muh unityping.

Well check this out...

rubyist@Overmind:~/cs/scratch$ cat hello.js
var x = 5;
console.log(x); // Prints 5
x = "hello";
console.log(x); // Prints hello
rubyist@Overmind:~/cs/scratch$ nodejs hello.js
5
hello

I assigned a number to x first, and then assigned a string to it. Didn't get an error. If it was statically typed, that shouldn't be allowed.

I also ran it in one command without first generating a binary. It just ran as is. That's not something that occurs in ahead of time compiled languages...

This is one of the more popular programming languages out there, and yet it is neither compiled nor statically typed. Imagine that!

Can you make an application in C or C++ and then import them to a rust project and potentially find segmentation faults?
Or would it just magically fix it?

assert([[234,12], [301,121,12], [322]].without(12) == ?);

Exclude C++, Only D can interface with C++ correctly.

Now if the C program itself segfaults you cannot do anything about it. If you use a gtk wrapper, Rust won't solve any of gtk's issues

C++ doesn't need GC either what is your point?

return [[234,12], [301,121,12], [322]]

It sounds like you've never heard the "every dynamically typed language is actually just a statically typed language with one type" argument.

Yeah, C++ hot other issues in itself. The convenience GC provides nullifies most of Rusts safety restrictions/features.

>won't solve any of gtk's issues
Nothing can.

wtf man you're program spec makes no sense then
should it not be
assert(["siwwo", "lkaiwmn", "diw"].without("iw") ==(["siwwo", "lkaiwmn", "diw"]);

I have, and it's a shitty argument. Besides, there would not be a need to have the term "static typing" if it were a property of all languages. The existence of the term implies an opposite.

No

@60384156
>If it was statically typed, that shouldn't be allowed.
Static typing doesn't say anything about how the program is type-checked. I know you're pretty retarded, but that's a new low even for you.
Static typing (there is no other kind) simply refers to the typing rules of the language. Which are in the head of the programmer and preferably also in some form of static type-checking, though there are retarded languages like r*by and *s which don't do static type-checking. That doesn't somehow mean that the typing rules are now "dynamic".

"dynamic typing" only makes sense if you mean that your language constantly switches between type systems. The number of types it has doesn't play a role here.

@60384280
>there would not be a need to have the term
There is no need to have it. Retards such as yourself just can't use words correctly.

How much would I have to pay to dick Ruby? She's pretty cute.

Okay.
It would be cool to have the application automatically print the backtrace without having to crash the application in a debugger.

please provide a description of the problem, your test cases are not enough

I was under the impression that Julia was interpreted.

@60384291
>being this much of a static typing fanboy

I think you need to go back to r e d d i t.

Seriously, they have a huge hard-on for static typing.

>Play hardbass
>Productivity skyrockets
So this is the power...of the russian hackers? Whoa!

How can you be a "fanboy" of something every possible language already has?
I am a static type-checking fanboy though, and your kind (pl*bbitors) usually don't like it.

The program should
1. Strip a string out of string[]
2. Strip a char out of char[]
3. Strip an int out of int[]

It's not even the entirety of the problem I have for Sup Forums

Who are you quoting?

...

The "person" I am replying to.

/dpt/-chan, daisuki~

Ask your favorite programming literate anything (IAMA).

>Static typing (there is no other kind) simply refers to the typing rules of the language.
No, that's the type system. Static typing is just the type system applied in the static environment.

Untrue.

Thank you for using an anime image.

>type system applied in the static environment
Also known as "type-checking". Not to be confused with "type system".

...

trying to implement simd sorting of 32-bit integers

merge sort seems to be the fastest way i guess

>tfw your faggot professor marks this book as a requirement for your summer semester
>tfw this new """edition""" was only released because the 7th edition is all over the internet

I fucking hate kikes, and there's no way I'm paying $250 for a book that I will NEVER use (seriously, I spent $500 on books last semester and only used one!)

Anyone got a download link or wanna share a digital copy? I've looked on libgenesis and a few private trackers to no avail

Oh also,
0. Strip a string from string

Who is that?

just stick with the 7th edition until some 8-th edition shit comes up senpai

I don't know. But you can probably find her by checking the post numbers I prefixed with '@'.

So if there was no point in the eighth edition and the seventh is everywhere... use the seventh.

>Static typing doesn't say anything about how the program is type-checked

wiki.c2.com/?StaticTyping

>Static typing is very often misunderstood to mean that values are associated with types at CompileTime, when instead it means that that a ReferenceValue is manifestly (which is not the same as at CompileTime) constrained with respect to the type of the value it can denote, and that the language implementation, whether it is a compiler or an interpreter, both enforces and uses these constraints as much as possible.

Relevant portion:

>ReferenceValue is manifestly constrained with respect to the type of the value it can denote

So no, you can't do this in a statically typed language:
x = "hello";
x = 5;

I'd do that, but class is tomorrow and the homework is based on problems found only in the 8th edition

dynamic x;
x = "hello";
x = 5;


Valid C#.

>Untrue.

Not if you use retarded definitions!

Eh, effort.

If people actually wrote more programming languages instead of porn downloaders, they'd use the term 'manifestly typed' and be aware of the fact that the crux is associating types with variables, rather than just values.

Just download the seventh and get the exercises off someone who has the eighth.

Create a SIGSEGV handler which uses execinfo.h backtrace() and friends to produce a backtrace.

You can also enable core dumps and inspect those with the debugger afterwards.

There is a phrase used to refer to many .NET languages, and that is "gradually typed". The reason for that is that while the languages use static type checkers for the most part, the .NET ecosystem has a lot of runtime type information available, and therefore, it is possible to circumvent the type checker by using the object type for everything.

Too bad. The term agreed upon by both the industry and academia for a language that provides a static type checker is "statically typed". Your opinion of this is irrelevant -- that is the definition of the word.

@60384394
>wiki.c2.com/?StaticTyping
Irrelevant trash.
>So no, you can't do this in a statically typed language:
I can create a language with any type system I want, and since a type system is by definition static, you can.
You wouldn't be able to do this in a statically type-checked language though, but I hope you aren't mentally ill enough to claim that "type-checking" and "type system" are even remotely similar words.

@60384435
>Your opinion of this is irrelevant
Your abuse of terminology and twisting of words is irrelevant.

>Buying textbooks
>Ever
I'm not an burgercuck, so maybe the "culture" of this shit is different where I live, but I've only ever bought a single textbook, and it literally only cost $20.
Basically all of my courses didn't even mandate a textbook. There might be a "recommended reading", but it only went as far as that. Even in the rare case there was a "required" textbook, you could pretty easily get by without it.

>excessively confrontational towards someone agreeing with you
Whoops, forgot I was on Sup Forums again.

>Your abuse of terminology and twisting of words is irrelevant.
I am merely using the terminology that everyone else uses. The definition of words is based on how people are using them (otherwise, the word "inflammable" might rightfully mean "non-flammable"). So you can make whatever arguments you want about what the term "static typing" SHOULD mean, your words are irrelevant. The only thing that matters is "what are people in the real world referring to when they use this term?"

Let's look at what the University of Washington, one of the top computer science universities in the country, has to say about this...

courses.cs.washington.edu/courses/cse341/04wi/lectures/13-dynamic-vs-static-types.html

>[A static type system is a] tractable syntactic method for proving the absence of certain program behaviors by classifying phrases according to the kinds of values they compute.

>A dynamically typed language is one in which type-incorrect operations are caught during program execution, rather than during a type checking phase that precedes execution.

Do you claim to be more authoritative on this subject than professors at the University of Washington?

@60384498
>I am merely using the terminology that everyone else uses.
Which doesn't make it less retarded.
>Let's look at what the University of Washington
Irrelevant trash.
>Do you claim to be more authoritative on this subject than professors at the University of Washington?
I do.

Good PHP challenges / tasks for the beginner?

>I do.
Do you have a PhD in computer science? From what university? On what subject is your dissertation?

linking these posts for readability

>the tripfag thinks degrees mean anything but a waste of money
cute.

@60384526
>Do you have a PhD in computer science?
Nope. I am more authoritative on this particular subject though, simply because I'm correct.

So, having no credentials whatsoever, you make the claim that everyone in academia and the industry are wrong about the definition of a word?

That's cute.

>easily confusing people and sucking up to authority
cute.

>""credentials""

My professor wants me to write one, but I don't think it is worth it.
Is there any upsides to having a PhD if you don't want to teach?
It seems like you are less likely to get hired in consulting or rnd positions and I don't want to start my own thing and I don't want to teach people.

Im writing again scheme interpreter. Yesterday i was trying to make my custom lang with flex/bison but only thing i did get out of it is fact im missing some knowledge... I would understand my problems if i didnt have required courses at uni as undergrad, but i forgot everything...

Good thing you have notes from that time.

hey Sup Forums, I'm doing the Advent of Code just for fun, looking for some help. Problem for day 16 is basically perform a checksum on some digits. I got the first part right, but now for the second one I have to do a checksum for a binary number that is 35651584 digits long. It was designed to be so big to make you run out of memory, which is what happens to me. So what are some ways of dealing with huge data without running into such problems? How could I get around this?

Btw, my solution to the first part is just some for-loops on Python.

Here's link to the problem:

adventofcode.com/2016/day/16

I dont, well i can find them... Thanks god there are books all over internet. I always had great short term memory so i always manage to score well but week after i dont rememeber a thing. I think its a curse.

>Is there any upsides to having a PhD if you don't want to teach?
Yeah, plenty of industry research institutions (i.e. Microsoft Research) only hire PhDs. A PhD is a research degree. If you want to do research, you get one. Otherwise, you can get away with just a BS or an MS and a few years of experience in programming.

Scheme is dead simple. Implementation language?

Yeah it is, its super easy thats why im starting from it. Scheme isnt a problem, problem is i cant apply my knowledge to non scheme languages... Tried to make bastardized version of python yesterday. It failed as anything but more advanced calculator.

it does open up some doors, but you have to wonder whether 5 years minimum (some people take 6 or 7 to finish their PhD's) of eating shit and making no money, possibly getting into more debt, is actually worth it. Most people going into PhD's end up hating their field, but they've invested so much they don't wanna quit. Me, I got out after the 1st year, realized it was just bullshit all the way through. Not a computer PhD, but still related.

There's not too much to it. Just gotta parse Lex it, yacc that into some interpretable form, then interpret it. You don't even need to use those tools, you could implement your own recursive descent parser.

Admittedly though the harder part is probably the runtime.

What is your implementation language?