/dpt/ - Daily Programming Thread

Previous Thread: What are you working on, Sup Forums?

Other urls found in this thread:

haskellbook.com
discuss.leetcode.com/topic/41128/12ms-golang-solution-with-dfs
blog.xamarin.com/android-in-c-sharp/
learnyouahaskell.com/chapters
github.com/xamarin/XobotOS
robmiles.com/c-yellow-book/
reddit.com/r/Nerf/comments/52mjcl/rapidstrike_burst_fire_circuit_diagram/
pastebin.com/eTtqn7WP
twitter.com/SFWRedditImages

We're talking about IDs and ages here, which are both integers you moron.

>which are both integers
Oh yeah, negative IDs are the most common kind of ID!

Unsigned integers. Both unsigned integers.

Either way, the representation is the same. That's what structurally similar means.

But regardless, the point is arithmetic is even more general than just "they're structurally similar so i should be able to add them"

Which is of course silly. If you had an enum class { Apples, Oranges } the fact it's enumerated doesn't mean you should be able to add them

What is your example where I should be able to take an Age, and an ID, and anything structurally similar (including the enumerated apples/oranges earlier) but not anything more general than that (i.e. not something numeric or integral etc)

How the fuck is the finite set {Apples, Oranges} structurally similar to an unsigned integer?

>How the fuck is the finite set {Apples, Oranges} structurally similar to an unsigned integer?
Oh of course! You're right!

I meant Boolean!
{Apples, Oranges} is structurally EXACTLY THE SAME as boolean!

Yes, it is. While some operations might not make sense to people (how is an apple a "not orange"?), there's no real reason to disallow them. You never know when an operation that was designed for booleans only would actually become useful for {Apple, Orange}.

oh, and unsigned and signed integers are structurally the same

>there's no real reason to disallow them
I cannot believe someone is saying this

>oh, and unsigned and signed integers are structurally the same
No, they're not.

>I cannot believe someone is saying this
picrel

Question.

I just read on stackoverflow:

>As I heard, C# came later and made better decisions by looking at Java's mistakes.

Why doesn't some company like google make something like C# so that it wouldn't be tied to Microsoft and their corporate empire ?

Is that what Dart is ?

Or another language I don't know of ?

of course you'll have to draw the line somewhere, structural equivelence needs to be defined by some sane middle ground to still be practical while being easier than nominal typing (e.g. in a composite types the name and types of fields need to match up, not just the types).

What's the best multi-platform GUI toolkit? I don't really mind what language or anything, I'd like to make a simple note taking application as a learning project, but have it cross platform for Windows and Linux (to run on say, Debian).

>considering structural typing for a hypothetical scripting language that's about as easy to write as a dynamically typed one, but still runs a bunch of type checks to prevent dumb type errors at runtime
Well, if you think the language will be easier to use because it will be simpler without the nominal typing stuff then you might have a point. But otherwise I don't see what harm having nominal typing adds, or how it makes anything harder besides needing to learn it.

Working on a VST plugin to make plugins of another plugin format available to DAWs that don't support the other plugin format.
The API is partially really fucking strange and the documentation is nearly non-existant. Thanks based Steinberg.

They did. They made Go. It's kinda shit though.

>No, they're not.
.. yes they are

Reminder not to have impure thoughts

Unsigned integers (natural numbers) are well-founded. Integers are not.

But Go is not like Java or C#
It's more comparable to C

Yes they are. The sign bit is just an extra power of 2 in unsigned ints.

Anyone is welcome to fork Roslyn (C# compilers and code analyzers), Mono (cross-platform .NET), and .NET Core (lightweight .NET).

They're all FOSS.

>Hobby programmer for 4-5 years
>Get a summer job doing back end web development
>soul draining
>Go back to uni
>Can't enjoy programming anymore

What do, programming was the only thing that filled the void for me.

I'm not really sure what's happening here

> It's kinda shit though.
how so ?

I downloaded a copy of SICP and I'm reading from the beginning but all the information is floating in through one end of my head and out the other.

>spent 7 hours, 2 of which were me crying and hating myself for being dumb
>finally got my simple java program that takes an array of integers, uses a method to remove duplicate integers, and returns a new array with no duplicates to work

Structural similarity usually implies identical memory representation, but it certainly doesn't go the other way around.

See .

They have interchangable binary representation, id est, structure, you fucking retard.

Google's Dart is more like C# or Java:
>A class-based, single inheritance, object-oriented language with C-style syntax.

Go is much simpler, comparable to C.

I guess the answer is that they could just use Java. Making something like C# with a strong ecosystem of libraries and tools is expensive.

0 0
1 -1
2 1
3 -2
4 2
...

QED

having to explicitly convert between two structurally equivalent types A and B for instance (assuming you mean a lang that has only nominal typing and no structural typing)
as i said before, having both nominal and structural typing shouldn't really be an issue, i just think that the caller should somehow be the one to decide which one to use, and not the author of the function

See .

Is that relation useful?

>assuming you mean a lang that has only nominal typing and no structural typing
I mean having both. Everything is structurally typed, unless you specify the type.

>i just think that the caller should somehow be the one to decide which one to use
Not a problem as far as i can see

>Is that relation useful?
It's a one to one bijective mapping between the natural numbers and the integers.

It is a proof that they are isomorphic.

Bar, an interface, is a type that defines a set of methods.
Foo has a method foo.
Foo does not explicitly implement Bar (which would be the case in nominally typed languages).
Foo "satisfies" the structure required by Bar.
there's no type inference involved anywhere.

It does not matter if it's useful.

So? Only a madman would represent the integers like that in order to make them structurally similar to the natural numbers.

I suppose it is correct to call that representation of the integers structurally similar to the natural numbers, but that's a massive strawman.

yeha but Oracle is suing Google for using java with android

I think that's why they're trying to create a new OS (Fuchsia ) that will be based on DART their n ew programming lang

Which one is Sup Forums approved?

i see now

They didn;t think they would be sued at the time. Sucks to be them. Should have gone with C#.

always go for sedgewick

Is DART not dead yet?

And to add to this
>Is that relation useful?

A damn sight more so than {True,False} = {Apples,Oranges}

>So? Only a madman would represent the integers like that in order to make them structurally similar to the natural numbers.

And only a madman would use two's complement to make integers similar to natural numbers!

They ARE structurally similar. That is a proof that they are structurally IDENTICAL.
The difference is the functions using them - which need to distinguish between them!
(Modulo arithmetic is another example of a useful, different kind of algebra with the same carrier set)

>Not a problem as far as i can see
deciding structual vs nominal typing should be a choice of the caller because it's a trade off of safety (and arguably readability) for ease of use.
the author of a function shouldn't be required to make that decision (in fact, he can't make that decision, because deciding whether the trade off is worth requires the context of the caller, which the author doesn't have, and as a result of that, the author has to make an arbitrary decision for the caller).

didn't oracle lose that lawsuit recently?

>Should have gone with C#.
While this might happen in [current year], when Android dev started, all the C# components weren't FOSS, nor did it have great cross-platform support.

It would be pretty damn interesting to see a mobile OS written in C#.

Anyone got a ripped version of this somewhere?

haskellbook.com

>$60 for a fucking ebook

They are absolutely identical, because they are implemented via two's complement. "Negative" numbers are simply numbers bigger than 2^31.

Just try LYAH

discuss.leetcode.com/topic/41128/12ms-golang-solution-with-dfs
this is what I needed... and I failed

>deciding structual vs nominal typing should be a choice of the caller
I'm not arguing with that. I'm saying that sound completely reasonable.

>all the C# components weren't FOSS
But the C# spec was fully open, which is why Mono existed. Which Google could have used.

>It would be pretty damn interesting to see a mobile OS written in C#.
Already done
blog.xamarin.com/android-in-c-sharp/

i remember when that nigga was shilling his book here

learnyouahaskell.com/chapters

>Structural similarity usually implies identical memory representation, but it certainly doesn't go the other way around.
You can represent them identically.
That's the whole point.
TRUE structural typing literally just compares the sizes of the sets. (and |N| = |Z|)

I read this whole book and can't remember anything

After a while it's just "damn, Haskell looks like *THAT*??"

do IT or security?
security is awesome if you love learning stuff and making money by yourself, although vuln discovery and exploiting is getting harder as time passes...

forgot pic

Well, shit.

github.com/xamarin/XobotOS

That's pretty neat.

Not him, but here are a few things I dislike about it

>nulls
>very tedious, manual error handling (just barely better than exceptions)
>casting everything to interface{} is standard practice because no generics
>copy pasting the exact same function over and over with different types is standard practice because no generics

They created a new language and then made the exact same mistakes previous languages made. From my perspective, Go can be summarized as "doesn't do anything better than what currently exists, and in many cases, does things worse".

The meta-aspects of the language are apparently nice though (tooling, code formatting, compile time, etc.)

Do execizes and projects at the side.
No book will be able to teach you any language if you never apply what you learned.

>casting everything to interface{} is standard practice because no generics
>copy pasting the exact same function over and over with different types is standard practice because no generics
It's only one of these two, as both attempt to deal with the lack of generics.

I was thinking of buying SICP too but I know middle level of C++ already and I think it's pretty basic... Does it worth it?

Go ahead and prove that
data bool := true | false
and
data fruit := apple | orange
are equal in CoC or MLTT.

Maybe one per developer, but different code bases will choose different solutions

>be stupid
>wanted to be a programmer as a kid
>feel too stupid to start.

>They created a new language and then made the exact same mistakes previous languages made.
This. The problem with go is it fixed some random problems with C and nothing else. You have to think about it completely different to most langugaes, so it's not easy to get into or port code to. If you're going to start fresh with a totally new language that has a tiny ecosystem of a low number of people who know it, there's far better options for just about any given problem you could want to solve with it.

Rate my JavaScript event binder. I considered using a 3rd party library, but the implementation of this is less than 80 lines so I didn't bother.

// Simple example representing a save action.
Action.register({
shortcut: { ctrl: true, key: "s" },
trigger: [ saveButton, "click" ],
enabled: () => isEditing,
action: () => model.save()
});

iso1 fruit apple = true
iso1 fruit orange = false

iso2 bool true = apple
iso2 bool false = orange

go back to /r9k/...

Been doing Python for a while now and I've been using it to throw together smaller programs to automate some tedious stuff for me.
Been looking at embarking on a bigger Python project and use OOP to structure my program.
Any good material on how to structure and design OOP code, especially in Python?

Start crossdressing. It will help you gain self-confidence and improve your abilities.
And read SICP.

looks nice

() => model.save()

can't that just be
model.save

?

That's isomorphism not equality.

If pajeet can do it, so can you x

structual equality should be defined in terms of how types can be used.
e.g. a language that allows you to pattern match this kind of type against its literal value should define
data bool := true | false

and
data fruit := true | false

to be structurally equivalent, but not
data bool := true | false

and
data fruit := apple | orange

for a language that only allows you to pattern match this kind of type against its index (e.g. foo = bool[0] or bar = fruit[1]), defining structural equivalence in terms of the second example might make more sense.

robmiles.com/c-yellow-book/

Link to free PDF on page.

Beginning of the book explains programming before any code is shown.

Get cracking.

>iso1 fruit apple = true
>iso1 fruit orange = false
The fuck is this?

There are actually two structural equivalence (isomorphism) proofs. One that relates (trueapple) and (falseorange) and, the second, vice versa.

equality is isomorphic to isomorphism

"trigger" should be "triggers" i guess.

>structual equality should be defined in terms of how types can be used.
... so nominative subtyping?

Or do you mean type classes a la haskell?


in some fp languages like haskell idris coq agda you can write functions like this

boolToInt True = 1
boolToInt False = 0

or like this

True && x = x
False && _ = False

Given univalence.

>so it's not easy to get into or port code to
iIm not sure about this, most people I know found learning Go very easy (and understood enough to write a bunch of useful code with just the go tour).
For webdev backend (which it is intended for) the ecosystem is also anything but tiny.

"easy" is relative. There's a lot you need to learn about how the whole language works before you can start writing good code.

>the ecosystem is also anything but tiny.
Again, "tiny" is relative. It's tiny compared to other available options.

But im literally this guy

Isomorphism is not equality.

That doesn't even make sense. I suppose you wanted to paraphrase the univalence axiom, but that doesn't apply in CoC or MLTT, so no.

Well, if you're not considering isomorphism, then whatever point you're trying to make has nothing to do with structural typing.

Finally got time to start migrating the directory admin panel to AngularJS and rewrite the backend as a REST API.

I wanted to have language bindings, mostly for Python, so I could automate the DNS backend.
E.g. when creating a new VM using Ansible, automatically reserving an IP address and a DNS record.
It can also be used for automating BGP prefix lists for our company VPN.

I really don't like doing UI stuff. I just want to build the backend, but no one else is going to do it.

Then you fell for the SICP meme.

SICP and K&R are running jokes that /dpt/ plays on "newfags" to basically scare or bore them into never wanting to program ever again.

There are easier languages and easier books made for beginners that are much more accessible and less shitty to use.

Of course, that's why neither CoC nor MLTT are purely structural.

And?

Bumping for ! Any suggestions for a cross platform GUI toolkit would be really appreciated. I've been looking at Qt, has anyone here used it? Am I better off trying something like QtPython or will I learn more if I go for C++?

reddit.com/r/Nerf/comments/52mjcl/rapidstrike_burst_fire_circuit_diagram/

lol

Finally got my copy of "Programming Principles and Practices Using C++" by Bjarne Stroustrup in the mail yesterday. I just completed the chapter 1 review, terminology, and exercises. I can't help but feel like I got memed. Just by the first chapter that is, I probably should have skipped this shit.

pastebin.com/eTtqn7WP

for C++? probably QT

I don't think there's any point in you replying unless you're the fag from the other thread, in which case you should admit your mistake.

Qt looks the nicest and is widely supported. The docs are great.
Java also does some UI stuff.
If you also want to support all sorts of devices and operating systems, just build a web app.

Qt if you're doing C++.

You could do C# with GTK# or WinForms (both of these will work on Linux/OSX/Windows).

There's a few decent Python GUIs, too.

You just asked an open question and I answered it.

Clearly there was more than one person with the same idea since you got three different responses.

>I can't help but feel like I got memed. Just by the first chapter that is
Do you even know what a "meme" is?

The first chapter of that book is not a meme. No one fucking talks about the first chapter of that book. No image macros have been made. No one tweets about it, or smugly mentions it on Sup Forums.