[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 340
Thread images: 23

File: STRENGTH THROUGH PURITY.png (36KB, 2000x1412px) Image search: [Google]
STRENGTH THROUGH PURITY.png
36KB, 2000x1412px
Previous Thread: >>56580427

What are you working on, /g/?
>>
>>56586908
We're talking about IDs and ages here, which are both integers you moron.
>>
>>56586926
>which are both integers
Oh yeah, negative IDs are the most common kind of ID!
>>
>>56586945
Unsigned integers. Both unsigned integers.

Either way, the representation is the same. That's what structurally similar means.
>>
>>56586926
>>56586945
>>56586954

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)
>>
>>56586972
How the fuck is the finite set {Apples, Oranges} structurally similar to an unsigned integer?
>>
>>56587001
>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!
>>
>>56587049
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}.
>>
>>56586954
oh, and unsigned and signed integers are structurally the same

>>56587096
>there's no real reason to disallow them
I cannot believe someone is saying this
>>
File: flat,800x800,075,f.jpg (116KB, 761x800px) Image search: [Google]
flat,800x800,075,f.jpg
116KB, 761x800px
>>56587108
>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 ?
>>
>>56587049
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).
>>
>>56587054
>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.
>>
>>56586885
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.
>>
>>56587124
They did. They made Go. It's kinda shit though.
>>
>>56587122
>No, they're not.
.. yes they are
>>
File: 1473634396214.png (741KB, 1920x1600px) Image search: [Google]
1473634396214.png
741KB, 1920x1600px
Reminder not to have impure thoughts
>>
>>56587178
Unsigned integers (natural numbers) are well-founded. Integers are not.
>>
>>56587173
But Go is not like Java or C#
It's more comparable to C
>>
>>56587122
Yes they are. The sign bit is just an extra power of 2 in unsigned ints.
>>
>>56587124
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.
>>
>>56587103
I'm not really sure what's happening here
>>
>>56587173
> It's kinda shit though.
how so ?
>>
File: 1452245969877.gif (953KB, 330x300px) Image search: [Google]
1452245969877.gif
953KB, 330x300px
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.
>>
File: 1111111.jpg (13KB, 405x94px) Image search: [Google]
1111111.jpg
13KB, 405x94px
>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
>>
>>56587205
Structural similarity usually implies identical memory representation, but it certainly doesn't go the other way around.

See >>56587192.
>>
>>56587192
They have interchangable binary representation, id est, structure, you fucking retard.
>>
>>56587173
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.
>>
>>56587198
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.
>>
>>56587192
0 <-> 0
1 <-> -1
2 <-> 1
3 <-> -2
4 <-> 2
...

QED
>>
>>56587152
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
>>
>>56587231
See >>56587228.

>>56587251
Is that relation useful?
>>
>>56587252
>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
>>
>>56587275
>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.
>>
>>56587215
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.
>>
>>56587275
It does not matter if it's useful.
>>
>>56587292
So? Only a madman would represent the integers like that in order to make them structurally similar to the natural numbers.

>>56587306
I suppose it is correct to call that representation of the integers structurally similar to the natural numbers, but that's a massive strawman.
>>
>>56587246
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
>>
File: algorithms.jpg (4MB, 7742x4618px) Image search: [Google]
algorithms.jpg
4MB, 7742x4618px
Which one is /g/ approved?
>>
>>56587304
i see now

>>56587312
They didn;t think they would be sued at the time. Sucks to be them. Should have gone with C#.
>>
>>56587324
always go for sedgewick
>>
>>56587312
Is DART not dead yet?
>>
>>56587275
And to add to this
>Is that relation useful?

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

>>56587311
>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)
>>
>>56587281
>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).

>>56587312
didn't oracle lose that lawsuit recently?
>>
>>56587331
>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?

http://haskellbook.com

>$60 for a fucking ebook
>>
>>56587122
They are absolutely identical, because they are implemented via two's complement. "Negative" numbers are simply numbers bigger than 2^31.
>>
>>56587417
Just try LYAH
>>
https://discuss.leetcode.com/topic/41128/12ms-golang-solution-with-dfs
this is what I needed... and I failed
>>
>>56587390
>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.

>>56587402
>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
https://blog.xamarin.com/android-in-c-sharp/
>>
>>56587417
i remember when that nigga was shilling his book here
>>
>>56587432
>>56587417
http://learnyouahaskell.com/chapters

>>56587228
>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*??"
>>
>>56587211
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...
>>
File: lyah.png (107KB, 492x650px) Image search: [Google]
lyah.png
107KB, 492x650px
>>56587479
forgot pic
>>
File: 71de890b.png (21KB, 553x363px) Image search: [Google]
71de890b.png
21KB, 553x363px
>>56587441
Well, shit.

https://github.com/xamarin/XobotOS

That's pretty neat.
>>
>>56587218
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.)
>>
>>56587479
>>56587491
Do execizes and projects at the side.
No book will be able to teach you any language if you never apply what you learned.
>>
>>56587495
>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.
>>
>>56587344
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.
>>
>>56587533
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.
>>
>>56587495
>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()
});
>>
>>56587549
iso1 fruit apple = true
iso1 fruit orange = false

iso2 bool true = apple
iso2 bool false = orange
>>
>>56587564
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?
>>
>>56587564
Start crossdressing. It will help you gain self-confidence and improve your abilities.
And read SICP.
>>
>>56587588
looks nice

() => model.save()

can't that just be
model.save

?
>>
>>56587603
That's isomorphism not equality.
>>
>>56587564
If pajeet can do it, so can you x
>>
>>56587549
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.
>>
>>56587564
http://www.robmiles.com/c-yellow-book/

Link to free PDF on page.

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

Get cracking.
>>
>>56587603
>iso1 fruit apple = true
>iso1 fruit orange = false
The fuck is this?
>>
>>56587549
There are actually two structural equivalence (isomorphism) proofs. One that relates (true<->apple) and (false<->orange) and, the second, vice versa.
>>
>>56587621
equality is isomorphic to isomorphism
>>
>>56587588
"trigger" should be "triggers" i guess.
>>
>>56587627
>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?


>>56587633
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
>>
>>56587639
Given univalence.
>>
>>56587577
>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.
>>
>>56587676
"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.
>>
>>56587614
But im literally this guy
>>56587223
>>
>>56587638
Isomorphism is not equality.

>>56587639
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.
>>
>>56587723
Well, if you're not considering isomorphism, then whatever point you're trying to make has nothing to do with structural typing.
>>
File: Untitled5790.png (88KB, 1920x991px) Image search: [Google]
Untitled5790.png
88KB, 1920x991px
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.
>>
>>56587719
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.
>>
>>56587739
Of course, that's why neither CoC nor MLTT are purely structural.
>>
>>56587774
And?
>>
Bumping for >>56587145! 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++?
>>
https://www.reddit.com/r/Nerf/comments/52mjcl/rapidstrike_burst_fire_circuit_diagram/

lol
>>
>>56586885
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.

http://pastebin.com/eTtqn7WP
>>
>>56587781
for C++? probably QT
>>
>>56587779
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.
>>
>>56587781
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.
>>
>>56587781
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.
>>
>>56587823
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.
>>
File: fuck.png (4KB, 619x73px) Image search: [Google]
fuck.png
4KB, 619x73px
>>56587816
>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 4chan.
>>
>>56587324
link to pdf?
>>
>>56587816
When you reach the graphics chapter and download framework from his page (is an appendix is the book that tells you how to do that) you will notice that the code if full of errors... You must to fix a lot of shit to make it work... but don't quit... it works...
>>
>>56587928
>there's this car with two very bent wheels, no radiator, and one of the 7 (?!) pistons is from the wrong engine and must be replaced
>don't worry, it works
>>
>>56587818
It's mainly a small learning project so I don't mind the language but yeah C++ would be one of my first picks. Thanks!

>>56587838
Ah good docs are a massive plus! Didn't even consider doing it as a web app but that would work quite well too, thanks for the suggestion!

>>56587839
Thanks a lot for the input, I forgot C# Winforms worked with Mono as I've been using XAML for a long time now.
>>
>>56587928
Is it incompetent programming? Or is the purpose of the exercise fixing the code and getting an awesome easter egg when the program works?
>>
Hey /dpt/,

Python noob here. I have a question:
How do I print out whatever string was typed in the raw_input?
Like, let's say I have:
height = raw_input("First off, how tall are you?")

If it doesn't match a certain height, I wanna print out something like this "You're not XY" (XY being the height that was typed in)

It should look like this, right?
print "You're not " + somethingsomething

What goes in somethingsomething?
>>
>>56586954
>Being able to multiply IDs makes sense.
>>
>>56587759
You are a fucking retard.
>>
>>56587954
If you have a fully functional brain, a little of common sense an a good IDE you would be able to fix the shit... I don't understand how the book apparently wrote by the fucking creator of C++ makes download buggy code from his own web page... but I think that's how this fucking world works...
>>
>>56587985
How do I average two IDs in C?
>>
File: 1473620059103.png (209KB, 453x435px) Image search: [Google]
1473620059103.png
209KB, 453x435px
>>56587096
>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}.
You're retarded.
>>
>>56587994
This, I'm so glad I read SICP.

The recruiter for my current $300,000/year job specifically asked for applicants that had read SICP, so thanks to /dpt/, I got the job!
>>
>>56587965
First, don't use the 'old' style print command.

Do something like
print('You are not %.2f' % height)


The %.2f is a formatting code, such that whatever height is, it will be displayed up to 2 decimals.
>>
File: sicp1.jpg (3MB, 2448x3264px) Image search: [Google]
sicp1.jpg
3MB, 2448x3264px
>>56587223
Do the exercises. You do have Scheme installed, right?
>>
>>56587965
I mean, you have a variable for a reason, common programming sense would tell you:
print "You're not " + height


or a better way to do it, although idk if python2 has it
print "You're not {0}".format(height)
>>
>>56586885
>What are you working on, /g/?
not-programming.

Trying to help my Indian class/teammate understand a "learn to use Git" assignment. One day after a 2.5 hour lecture on "This is Git. This is how to use it." In a "Masters-level" course.

I wish I was joking.
>>
>>56587546
Just read it online. You even get the lectures for free.
https://mitpress.mit.edu/sicp/full-text/book/book.html
http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-001-structure-and-interpretation-of-computer-programs-spring-2005/video-lectures/
>>
>>56587962
No, the chapter is about learning derived classes, inheritance, abstract classes, etc applied to a graphics interface... the book doesn't help since it gives you the basic instructions for setting up the framework...
>>
Reading up on cubical type theory, where univalence is provable.
>>
>>56588101
>cubical theory
I think you've been doing a bit too much currying
>>
>>56587494

If they can port Android to C#, why hasn't anyone just ported the entire thing to C yet for performance benefits?
>>
>>56587608
Do this and build on it.
http://www.roguebasin.com/index.php?title=Complete_Roguelike_Tutorial,_using_python%2Blibtcod,_part_1
>>
>>56588115
Paths are lines. Paths between lines are squares. Paths between squares are cubes. And so on.
>>
>>56588118
Because that would cost money. And would probably just take too long. Better things they could spend the time on like just optimising the JVM.
>>
File: hypercube.gif (819KB, 256x256px) Image search: [Google]
hypercube.gif
819KB, 256x256px
>>56588140
>>
File: sicp3.jpg (438KB, 900x2134px) Image search: [Google]
sicp3.jpg
438KB, 900x2134px
>>56587759
>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.
Your new is showing.
>>
>>56588147
Yes. Paths between cubes are 4-cubes.
>>
>>56588160
Do paths represent functions?
>>
>>56588156
This, SICP and K&R are great books that made me want to continue programming.
>>
>>56588140
>Paths between lines are squares.
the shit...
>>
>>56588166
Paths represent equality.
>>
>>56588182
>>56588147
>>
Any tips on how I can improve my programming?
Any ideas on what I should add or change?
I might add a lexicon, but I don't know.

https://github.com/enigma424242/Into-the-Shadows
>>
>>56588191
I saw the gif anon. How the fuck is a path between two lines a "square"?
>>
>>56588186
Oh, are you the one reading HoTT? Do you mean that thing where they're all continuous transformations or something?
I didn't get far into the book before getting distracted
>>
>>56588006
You don't. Nobody averages ID numbers. If you represented ID numbers as integers in a C program, you could add them together and divide them by two, but that would be stupid.
>>
>>56588202
Think of the surface.
A path between two lines is a surface.
A path between two squares is a volume.


>>56588210
>adding and dividing by 2
But that would overflow anon.
It's not possible to average 2 IDs in C.
>>
>>56588146

They already went through several iterations of that.

You would think just giving people a wider base and expanding the NDK would do it, but it's still just way too limited.
>>
>>56587417
Yeah, I bought it.
https://dropfile.to/EsWB1jB
>>
>>56588205
Yes. A path is just how you represent equality if you are in homotopy type theory, where types are spaces and values are points.
>>
>>56588218
>But that would overflow anon.
Divide each number two and add them.
>>
>>56588271
That loses accuracy.
>>
>>56587218
>casting everything to interface{} is standard practice because no generics
what's wrong with this ?
func question(anything interface{}) {
switch v := anything.(type) {
case string:
fmt.Println(v)
case int32, int64:
fmt.Println(v)
case SomeCustomType:
fmt.Println(v)
default:
fmt.Println("unknown")
}
}


(I started a project in Go but haven't coded in years, I forgot everything about Java)
>>
>>56588096
speaking of which, why does he use
#include "std_lib_facilities.h"
instead of
#include <stdio.h>
The code wont even compile with g++.
>>
>>56588205
>>56588252
A path is technically just a continuous function from the interval [0,1] to some value, where the endpoints should be considered judgmentally equal. That's actually exactly how they are implemented in cubical type theory, with some axioms for path composition and other things.
>>
File: 1448564120701.jpg (139KB, 779x635px) Image search: [Google]
1448564120701.jpg
139KB, 779x635px
Learning higher-level / object-oriented languages is boring as fuck.

Every language higher than C is just memorizing which library you have to import or which method you have to call to do a specific thing.

All I do is spend hours and hours combing through documentation looking for the specific method I need to call, what its arguments are, or what class its in.
>>
>>56587324
Both are OK. Sedgewick is more readable. CLRS is more like a reference book: a really great doorstop, but not worth reading cover to cover IMO.
>>
>>56587495
this was supposed to be for you : >>56588289
>>
any tips on how to make my programming life horrible?
>>
>>56588307
Then just do javascript / Node.js / webdev

I'm not kidding.
>>
>>56588306
>from the interval [0,1]
What if you have a type larger than R?
>>
Typing this from class as my old ass professor teaches us Visual Basic. Why VB you ask? No fuckin clue

Dim fuckThis As Double

How easy or hard will it be to learn C# after VB.net.
>>
>>56588307

So you use BASIC, then?
>>
>>56588289
1) it's done at runtime
2) interfaces wrapping/unwrapping is quite slow
>>
Singletons. Thoughts? Opinions?
>>
>>56588320
Change keyboard layouts and switch to International English.
>>
>>56588320
fall for every single meme language and framework that comes out. Convince yourself they are all always the "next big thing" and never learn to critically evaluate them.
>>
>>56588346
Easy. But much easier to learn C# first and then VB
>>
>>56588332
Huh? The domain is the interval, while the codomain is whatever type (space) the path is contained in (i.e. its endpoints are equal values of that type).
>>
>>56588331
>webdev
>literally what he described but you have to learn new libraries every year or so to do the same stuff as you did before
>>
>>56587495
>>nulls
Agreed.
>>very tedious, manual error handling (just barely better than exceptions)
I thought the same at first, but explicit error handling on the spot is cleaner and more selective. You can see right there what happens, if this function returns an error, not track it up the stack to see what will catch it.
>>casting everything to interface{} is standard practice because no generics
If you're casting things to interface{}, you're doing it wrong. Define interfaces with actual methods and have your passed values implement them.
>>copy pasting the exact same function over and over with different types is standard practice because no generics
In general, applying patterns from other languages to a fundamentally different language can never lead to anything decent.
See above.

>>56587577
I disagree. Being easy to learn was one of the design goals and I think they fulfilled it. On the matter of being different: how can you expect better things to ever come about, if everything has to be familiar?
>>
>>56588346
Do your future self a favour and learn C# (or whatever proper language you fancy) in your free time. I've never met anyone in my life so far who hasn't learned programming through endless hours of self-study and practice. No lecture will do that for you.

Especially not one on VB.
>>
>>56588359
They are pretty good at describing the weight of the average american.
>>
>>56588382
Isn't that a bit limiting?
>>
Is hackerrank good for learning algorithms and shit? Or would I just be wasting my time?
>>
>>56588388
interfaces do not solve the same problem space as generics, though.
>>
>>56588422
No, it's incredibly powerful. In particular, it implies function extensionality.

Just to be clear, there are normal dependent functions. Propositional equality is just implemented using paths instead of, well, something less powerful.
>>
>>56588388
>Being easy to learn was one of the design goals and I think they fulfilled it.
Okay. That seems stupid to me.

>On the matter of being different: how can you expect better things to ever come about, if everything has to be familiar?
Not very easily. My point was Go is very different, and still has tons of problems that other langugaes solved decades ago. Using very different novel langugaes comes at a cost, but if you're going to use one it might as well be actually good like OCaml for example, and lot some shortsighted solution looking for a problem that is Go. If it wasn't for the fact that Go was made by Google, no one would even be talking about it. It would just be on the huge pile of abandoned C """"killers"""".
>>
>>56588400
>singleton
>single ton
>>
>>56588284
take the mod of each number, add them, and divide by 2, and add that as well.
>>
File: ed.png (61KB, 147x167px) Image search: [Google]
ed.png
61KB, 147x167px
>>56588400
Don't bully. I have a disorder.
>>
>feel like shit
>can't program
>don't know what to do
>play videogames
>don't even like playing videogames
>shitpost on /dpt/
Can you guys help me help you get rid of me?
>>
>>56588476
What if I want to keep the decimal place?
>>
>>56588490
>can't program
Can't even post correctly.
Can't program because I feel like shit.
>>
>>56588490
git gud
>>
>>56588496
We're averaging IDs, nigga, the result is gonna be an ID.

IDs don't have decimal places.
>>
>>56588459
it's not that go is made by google, it's that go is made by rob / ken / rsc
if we're comparing go to ocaml:
ocaml solves a bunch of issues that go doesn't solve, but go solves certain other issues that ocaml doesn't solve.
examples being the fragile base class problem or having battle proven parallelism with csp (which, the last time i checked, was still being worked on for ocaml and definetly not mainstream yet).
>>
>>56588490

This sounds pretty typical.
>>
>>56588200

Start by not using python
>>
>>56588524
How would you know? Have you averaged IDs before? What makes you think averaging IDs should give you back an ID? This is new territory here
>>
>>56588490

>Feel like shit
>Can program
>Have incurable condition leaving me unable to function and concentrate on any task

End me
>>
>>56588200
>Any tips on how I can improve my programming?
Try writing something without OOP. Completely. Then see how you feel about that.
>>
>>56588531
>examples being the fragile base class problem
Go doesn't solve this at all. it just makes you use composition instead. Any language can do that, it's up to the discretion of the programmer what will work best for the current project. Go just forces you to always do things a certain way.

> having battle proven parallelism with csp
Pretty sure it's in. It was in the main source tree since january. In any case, there's always F#.
>>
>>56588490
Do some dumbbell clean and jerks. Get your blood flowing and the heart rate up for a few minutes.
>>
>>56588490
pick a language and read a book on it
it's hard to get motivated knowing that you're struggling to make things that are trivial to others, but it's important to keep pushing
>>
>>56588490
Haskell is the answer
>>
>>56588289
You should generally avoid using empty interfaces. They are both slow and provide no static type checking. If you have a lot of interface{} in your code, you probably need to refactor.

>>56588432
They kind of do in Go, because interfaces are implemented implicitly.

>>56588459
Problems like what? Apart from generics.

I think being developed by Rob Pike and Ken Thomson is enough to generate plenty of attention, even if it wasn't endorsed by Google.
>>
>>56588393
Oh I plan on it, I self taught myself Python and a bit of Ruby and JavaScript before I got into any programming classes. Now that I've done all the core classes, I'm taking a 300 level class on learning Visual Basic, a 300 level class on JS, HTML5, jQuery, etc. Next semester learn Java and C#, along with ASP.net

I didn't realize i could substitute this 300 level with CS 135 and just learn C instead of VB. Wish I'd done that.
>>
>>56588573
>Any language can do that
Show me a clean example of composition in those any languages with child property and method promoting.
>>
>>56588573
i consider not having inheritance a solution to the problem since i don't trust people with inheritance because of the way it's taught (the fragile base class problem is astonishingly unpopular amongst most programmers too).
go has type embedding, which is basically inheritance without overriding (which is the key factor that causes the fragile base class problem).

regarding parallelism, that's neat, i'll have a look.
go's concurrency primitives have been pretty nice to use, though, and i found them to be more understandable than any other concurrency model i've used before.
of course, go isn't the only language with csp, but iirc the runtime is crazily optimized for go's concurrency model (even the new transactional gc is).
>>
>>56588533
What's wrong with Python? It's amazing. Are you one of those people who use a low level language like C even though you don't need a low level language?
>>56588571
I don't think I understand. You mean like functional programming? That's what I used to do before I started OOP.
>>
>>56588623
>They kind of do in Go, because interfaces are implemented implicitly.
no, they don't, and the go designers have publicly outlined that fact (too lazy to find the source now, maybe something posted in the thread for the hypothetical generics spec?).
>>
File: jerry386-293449.png (132KB, 386x272px) Image search: [Google]
jerry386-293449.png
132KB, 386x272px
>programming paradigms
>>
File: er.png (11KB, 563x190px) Image search: [Google]
er.png
11KB, 563x190px
erlang a cute
>>
>>56587564
No programmer is more stupid than a computer.
>>
>>56587124
>made better decisions
>didn't release with generic support, leading to huge code bloat
>literally created another studio to support cross platform, which took years to support even mac
>barely makes anything safer than java, just pretty much forces you to use microsoft-supported languages and libraries because of the ease-of-use
>100% compiler-specific syntactic sugar to make it a unique language, yet boasts how it is a c/++-like-syntax-mimic, which essentially gets cancelled out because of the special syntax they implement.

Yeah, not many decisions were made wiser. In fact, some were made worse. C# is 100% on par with java. It's literally a design choice. It is more c++ like and a little less oop, which is the only thing giving it any significance (along with the fact microsith made it)

And before anyone says "well you don't have to use their syntax shortcuts derr" go ahead and try. See where that gets you, you linux shell scripting pseudo hacker wannabe.
>>
>>56588156
K&R is great but King's book is better for nabs IMO
>>
>>56588752
provide a sample program in erlang pls
>>
>>56588708
>You mean like functional programming?
Well I mean procedural programming.
Just don't use OOP.
>>
>>56588773
>>didn't release with generic support, leading to huge code bloat
Java got generics barely ahead of C#.

>C# is 100% on par with java.
Only a Java baby could say this.
>>
Hey, for those that use python, do you need to type 'python3' in the terminal every time you want to use python 3 instead of python 2? Because right now, if I type 'python', it uses python 2. Is there any wayt to change this?
>>
>>56588815
Yeah, OOP is terrible. My dad told me "If you use OOP, you'll begin smelling like curry and even though you buy toilet paper, you'll never be able to find it."
>>
>>56588847
It's pretty easy in many distributions. Google it.
>>
File: minhavida.jpg (38KB, 500x373px) Image search: [Google]
minhavida.jpg
38KB, 500x373px
What's the best Java book, i learn better through books.
>>
>>56587996
It's literally just FLTK, just get a package.
>>
>>56588815
I see. I mean, I know most of my data structures are immutable, but I figured this might require polymorphism.
>>
File: c-programming.jpg (49KB, 430x310px) Image search: [Google]
c-programming.jpg
49KB, 430x310px
Why is C programming so difficult?

1. Write a C program to output the names of your favorite bands and/or musical artists. Remember to include your program's output as part of your submission.

2. Write a C program that computes and outputs the current age of the United States in days (you can use 1776 as the US founding year). You don't have to worry about fractional years or leap years for this assignment. Remember to include your program's output as part of your submission.
>>
>>56589011
>Why is C programming so difficult?
It is not.

>1. Write a C program to output the names of your favorite bands and/or musical artists. Remember to include your program's output as part of your submission.
>2. Write a C program that computes and outputs the current age of the United States in days (you can use 1776 as the US founding year). You don't have to worry about fractional years or leap years for this assignment. Remember to include your program's output as part of your submission.
We are not going to do your homework. Not to mention that these are both easy as hell.
>>
>>56589011
>that
>hard
>>
File: 1473442521136.png (21KB, 900x900px) Image search: [Google]
1473442521136.png
21KB, 900x900px
>>56589011
>>
>>56589011
Those programs are completely trivial.
That's "First day of programming" sort of shit.
>>
>>56589011
1. is literally hello world
2. is just multiplying
>>
>>56588249
thanks m8

but does anyone have this course:

http://lambdaschool.com/video1
>>
>>56588490
>Go back to /r9k/ where you belong...
>Post the same shit
>They encourage you to commit suicide
>>
>>56587564
this
>>56587626

I'm a bit of a sexist so when ever I think I can't do something, or that I'm not smart enough for something, I just imagine a woman doing that same thing and because logically women are inferior, I must also be able to do whatever she's doing and then some.
>>
>>56589011
https://www.youtube.com/watch?v=Vy3DvF8nibA
This is for you... you will thanks me later...
>>
>>56589011
>Why is C programming so difficult?
It's not difficult.
>1. Write a C program to output the names of your favorite bands and/or musical artists. Remember to include your program's output as part of your submission.
This assignment lets you literally do a bunch of printf statements
int main(){
printf("ArtistA\nArtistB\n"); //input as many artists as you want
return 0;
}

But it's possible there's other requirements. Like maybe storing them in an array or something.
>2. Write a C program that computes and outputs the current age of the United States in days (you can use 1776 as the US founding year). You don't have to worry about fractional years or leap years for this assignment. Remember to include your program's output as part of your submission.
http://www.tutorialspoint.com/c_standard_library/c_function_time.htm

But anon. Maybe try exploring a little bit first before you hand in your plagiarized assignment.
>>
>>56589049
If only I had time to sit down and read my textbook.... family things.
>>
>>56589090
Don't spoonfeed him.
>>
>>56586885
>What are you working on, /g/?
Just added a killstreak counter into my game. I'll do the high score screen and achievements tomorrow I think, then test, then put the update live :)
>>
>>56589094
You mommy is a whore and your daddy takes it in the ass. :(
Naturally you were also abused as a kid.
>>
>>56588893
Effective Go
>>
>>56589025
Stupid frogposter
>>
>>56588821
ms says "wiser, therefore better" yet chose a non-traditional ("new"), bullshit design choice to keep users on their platform. I've been using c# more than I use java. I am not a java-born cocksucker, I'm just saying what needs to be said. Ppl gotta stop putting c# on a shiny fuckin stool like its the best thing since ARM.
>>
>>56589096
>Don't spoonfeed him.
Why not?
Why waste their time?
Is this really teaching him anything?
No it's stupid school assignments, they get you nowhere and if you started with this kind of stuff and found it useful to find these answers yourself you're probably terrible at programming.
What he should do is ask about what's going on.

But if he can't do that here they will fail either way. So why not spoonfeed?
>>
>>56589094
Do you want personal help, like answering questions directly in a chat or over skype/whatever?
I can't post contact info in anyway because I got banned for a week last time I posted my contact, but I'm willing to help if you want it.
>>
>>56588847
python is usually a symlink in /usr/bin, change it to point to whatever python3 points to.
Or create a new one in your ~/bin.
Or create a shell alias.
>>
>>56589121
>But if he can't do that here they will fail either way
Good, he doesn't deserve to pass if he can't do something as simple.

>What he should do is ask about what's going on.
There is a big difference between having a question on an assignment and wanting to be spoon-fed.
>>
>>56589120
C# isn't locked to Microsoft platforms, though.
>>
Take responsibility.
Get rid of that inner dialogue that says
"I'm too stupid." or "Why is this so hard?"
Take steps needed to improve your current situation.
"What can I do to learn programming?"
"Well, I can learn a little at a time instead of overwhelming myself with a ton of doc pages."
"I can set some time aside each day to practice and apply what I have learned in order to better my skills."
Instead of thinking "I keep getting errors because I'm a dummy." You should be thinking "Okay, well I can't do this. Let me try it a different way."
>>
>>56589138
>skype
Kill yourself non-free scumbag.
>>
>>56589148
That can break packages relying on Python 2 though.
>>
>>56589120

C# really is the best thing since ARM. It's so good.
>>
>>56589011
#include <stdio.h>
const char* k[4] = {"MCA\n","Jogeir Liljedahl\n","Timelord\n","Karsten Koch\n"};
int main(void)
{
for(unsigned int i = 0; i < 4;i++)
printf(k[i]);
return 0;
}


#include <stdio.h>
#define CURRENT_YEAR 2016

int main(void)
{
unsigned int days = (CURRENT_YEAR - 1776)*365;
printf("%d\n",days);
return 0;
}



Are you happy now, faggot?
>>
>>56589182
>current age of the United States in days
Sorry to say it doesn't really check which day it is.
So it's an incorrect solution
>>
>>56589182
Yeah just turn in this desu it will make you look much better than >>56589090
>>
>>56589115
But i need it to be java, it's for college :/
>>
>>56589201
>ignore fractional years
>>
>>56589182
0/10
>>
>>56589011
> Write a C program that computes and outputs the current age of the United States in days
Just nuke the US and problem is gone!
t. Kim Jong-Un
>>
>>56589210
Go to the lectures your parents are paying for, you little shit.
>>
>>56589215
>fractional years
I interpreted that as being an option to leap years. Since a year isn't really 365 days.
But sure you can make that interpretation too I suppose.

Shouldn't you take 2015 then?
>>
>>56589094

Yet you have time to shitpost on 4chan about how you don't have time to read your textbook.
>>
>2016
>people still don't use FP
>>
>>56589225
Thanks
>>
>>56589263
It's slow.
>>
>>56589280
How so?
>>
>>56589182

You did his homework. Why have you done this? He just started his C module at school.
>>
>>56589236
I don't know, and I'm not sure I should waste the time on someone's homework.
>>
>>56589302
top fucking kek
>>
>>56589245

I shitpost on 4chan to avoid doing my work. It enables my procrastination.
>>
>>56589308
Well you're wasting time here anyway. It's not like it's hard.
>>
>>56589280
Camels are pretty fast you know
>>
>>56589293
Well it simply doesn't compile to fast code.
it should reach decent speeds in theory. But it usually doesn't.
>>
>>56589138
My grandfather passed last week. I attended his funeral today. My mother has serious medical issues... My father had a serious brain aneurysm that nearly took his life. He was in a coma for about a month. My brother passed about 2 and a half years ago. I'm at this point in my life where everything is hitting at once... I'm 29 btw. I'm realizing it's this kind of stuff that makes life difficult and a struggle. Working retail and construction for years wasn't anything. I'm not sure there is seriously anything you can help me with but I appreciate the offer.

>>56589090
>>56589182
I'm not going to C&P there. I'm going to try and read through the chapter and bust it out. Problem is this stuff id due my midnight. Appreciated if yall were actually trying to help and posting legit work.
>>
>>56589394
If you are 29 and can't do something as simple as calling printf then you should seriously considering giving it up. You will fail miserably if you continue.
>>
OK, so from the previous conversation, is it reasonable to say C++ raw pointers are good for specific instances where memory management is highly important, but smart pointers are better for general use?
>>
>>56589011
win or linux?
>>
>>56589394
This is not your blog.

>>56589293
Having only pure functions can lead to a lot of unnecessary copying. Instead of mutating that value of some data, you have to make a copy of the data with the changes already applied.
>>
>>56589414
Shut the fuck up anon. Can you do perspective painting? Maybe you can. But that's because you practiced it. If you hadn't you'd have to learn it like anyone else. It's very simple stuff but you not knowing it doesn't mean you're incapable. you just haven't spent time.
>>
>>56589360
http://web.archive.org/web/20121218042116/http://shootout.alioth.debian.org/u64/ats.php
ATS is an experimental language, too. No serious backend optimization.

>>56589435
>purity means no mutation
>>
>>56589436
>Can you do perspective painting?
It's not in the modules for my uni.

>If you hadn't you'd have to learn it like anyone else
And I would, not ask others to do them for me.

>It's very simple stuff but you not knowing it doesn't mean you're incapable. you just haven't spent time.
Maybe, however a better comparison would be drawing a line. If you can't even draw a straight line then I doubt that you can finish the art school.
>>
>>56589445
>purity means no mutation
Yes, I know it doesn't, but if means you can't mutate any state outside of the function.
So if you want to change the value of some record type or whatever inside of a function, you have no choice but to copy it.
>>
>>56589468
What about purity means you can't use pointers?
>>
>>56589486
Modifying the things which those pointers point to means that your function is not pure.
>>
GitHub vs Bitbucket vs GitLab

Which one are you using and why?
>>
>>56589497
Would register-only assembly count as pure?
>>
>>56589497
>A pure function is a function where the return value is only determined by its input values, without observable side effects.
Using e.g. linear types or monads, you can make pointer reads/writes pure.
>>
>>56589528
https://gitgud.io
>>
>>56589530
How is modifying the pointed-to value not a side-effect?
>>
>>56589466
I mean, printf() is only abit more confusing that cout

so yes this anon is right
>>
>>56589528
Github, because I'm lazy as fuck(and I hope to get their student pack thing).
>>
>>56589445
I'm not sure you understand the problem.
Comparing implementations of things is rather pointless. What you should look at is what real code boils down to.

Writing C or C++ just ends up being easier dealing with than trying to do FP.
>>
>>56589538
It's modeled so as to not be a side effect. It could be seen as part of building up an AST that is interpreted inside a function that, while using side-effecting operations internally, itself has no side effects.

>>56589552
>Comparing implementations of things is rather pointless.
>What you should look at is what real code boils down to.
These two statements are contradictory.
>>
>>56589639
>using side-effecting operations internally, itself has no side effects
Yes, I know, but that is not what I'm talking about.
If a function modifies state outside of itself or relies on state not passed in through the arguments, it's not pure. I'm not talking about what other functions happen to use it and their purity.
>>
>>56589537
Oh my god it's real that's hilarious
>>
>>56589682
If the types make it impossible to observe the side effects, do they really happen? It's easier to understand by thinking in terms of free monads, but the same principle applies to linear types.
>>
>>56589639
>These two statements are contradictory.
Sorry I wasn't clear. Point is to compare actual software projects and see what they compile to rather than simple algorithms.
Because that's where you see the real performance issues.

All that comparison proves is that the language managed to beat someones C++ implementation of an algorithm. If there's more of a system going on it's not so certain the FP code can compile down to something like that. The demand on the programmer to express what's supposed to happen in more detail of C or C++ can give performance gains. It also allows you to improve the implementation easier.

At least me personally I don't even know where to begin if I notice the produced machine code from a FP implementation has cache misses. That's my own failing obviously but it's almost always going to have a less visible solution than C or C++ would have.

Perhaps that explains better
>>
>>56589718
You seem to be thinking in terms of existing FP languages instead of what FP really means (in the sense of making everything pure) and the possibilities.

Granted, I'm seriously interested in PLT and language design so I don't really think of this stuff in terms of what's out there already.
>>
Is the C Programming Language book still good? I'm working through it now and I'm enjoying it a lot but someone said Ritchie didn't even know what he was talking about
>>
>>56589766
It's still an excellent book, but a little outdated because there have been new versions of the C standard since then.
It still teaches you most of what you need to know though.
>someone said Ritchie didn't even know what he was talking about
Don't listen to that hack Zed Shaw.
>>
>>56589718
>You seem to be thinking in terms of existing FP languages instead of what FP really means
No. see: >>56589360 >>56589263
You're the one that's saying people should move to FP when it's obviously not ready.

But even so, I have trouble seeing FP getting in a ready state because the entire idea is based on inferring things from high level code. I haven't seen that working.
>>56589766
There's better resources.
Ritchie was writing software in a different era, probably why someone claimed he doesn't know shit.
>>
>>56589784
ocaml is fast
>>
>>56589784
>You're the one that's saying people should move to FP
Where did I say that? I'm simply saying that it's not intrinsically slow. I'm not >>56589263, my first post was >>56589293.
>>
>>56586885
Write last (I think?) C library for my portfolio, make a few slight last modifications to a library I already completed, and then hopefully either do a test deployment to google cloud platform or start my java portion of my portfolio.
>>
>>56589802
Ok. Well maybe you should understand that I'm talking about a context that's relevant to my previous posts.

Current FP doesn't perform great. In theory it should. But it doesn't.

Also I'm worried when I hear people saying stuff like "memory is cheap" when discussing FP. You hear that a lot. It doesn't exactly gain me much confidence in FP-programmers or the future for FP.

We don't really have good high-level programming languages right now. It's a spot to fill. I think the most promising areas right now is programming languages that try to make low level code more easy to work with. Which is kinda sad.
>>
>>56589639
Fancy words won't make a side effect go away. Your function is an impure slut. Accept the truth like a man.
>>
>>56587224
7 hours is unfortunately what it takes to learn most new things in programming whatever level you're at

Right now I'm working on automating ebook production and debugging takes several hours every time something breaks even if it really should take 5 minutes

You just learn from your time wasted and the next time you'll blaze through similar problems
>>
list your dumbest/cringeworthy/funniest variables you've ever created. I'll start.

>bogi
>gigi
>bobo
>>
>56589978
Kill_Yourself
>>
@56589978
Nah
>>
>>56589978
>doubleAnal
>>
>>56589869
Do you agree that a pure function is something that, given the same input, will always produce the same output? That's all that matters, right?

Well, if the output is a computation wrapped in a monad, it's very clearly going to be the same every time. With linear types, part of the input would be a linear capability, basically a proof that it's okay for the function to write to the pointer (it would also be part of the output, or else the pointer would be "locked" forever). Since the capability is linear, it's impossible to call the function more than once with the same input, and you're also not violating purity if everything is set up so as not to make any other function impure because of an observable side effect.
>>
>>56590040
Modifying external state is also output. Your function is impure and no amount of type jerking will make it stateless again.
>>
>>56590118
Pure doesn't imply stateless nor the other way around.

>is autistic about purity
>talks about types as masturbation
wew lad
>>
>>56587049
it's not. they're similar in terms of a certain pattern, but they're not structurally identical
>>
I'm fairly new to C/C++, but would the C string equivelant of
const std::string &str;

be
const char *&str;

?
>>
>>56590187
>they're not structurally identical
Yes they are. Anon wanted structural subtyping.
>>
>>56590200
I don't think C has references.
>>
>>56590200
>C/C++
Why are you grouping two completely different languages together?
>>
>>56590200
Not quite. You have a reference to a const char *, but you're looking for a const reference to a const char *. It's easier to reason about complicated const constructs by putting const on the right:
char const *const &str;

That said, there's no reason to pass a pointer by const reference. It'll probably be optimized to passing the pointer by value, but you should just pass by pointer to begin with.
>>
>>56590140
Yes, it does. A stateful function produces effects other than it's returned values and thus is impure.
>>
>>56590266
>putting const on the right
Disgusting.
<storage> <qualifier> <type> is the objectively best way to do it. Although you're a sepplesfag, so it's safe to assume that you have shit taste.
>>
>>56590240
Because I'm new to both.
>>56590266
Thanks.
>>
>>56590272
If the side effect isn't observable (due to the types involved), it remains pure.

If side effects that aren't observable made functions impure, everything would be impure because of the CPU heating up, for instance.

>>56590299
You can't put all consts on the left in general.
>>
Very new to programming here, learning java

How do I make this loop work so that it prints out that there is a target in position i for every occurance of target within my array?

Don't want spoonfed, just point out problems, I feel like I'm missing something important

int count = 0;

while (count > -1) {
for (int i = 0; i < array.length; i++){
if (array[i] == target){
System.out.println ("\tThere is a " + target + " in position " + i);
count++;
}
else {
System.out.println ("\tThere are no " + target + "'s in this array");
count = -1;
}
}
}
>>
why doesn't python implicitly convert when working with variables?

It automates a whole lot of other things, you'd think for verbosity's sake it would allow that

I mean obviously there can be confusion but there could be a preset order like double>int>string
>>
>>56590309
>Because I'm new to both.
Don't fall for the stupid meme that C++ is a superset of C.
It's not, and the two are completely different languages.
You're learning C++, not C/C++.

>>56590321
Yes you can.
>>
>>56590272
f (x, s) = (x + s, s - 1)

Is this function pure?
>>
>>56590331
How do you put all consts on the left while saying "const reference to a const char *"?
>>
>>56590342
nah its lewd as fuck
>>
>>56590331
As I said, I'm new, learning both you silly.
>>
>>56590342
does it have side effects?
>>
>>56590350
const char **const ptr;
>>
>>56590374
>putting const on the right
Disgusting.
>>
>>56590383
It's not on the right though.
The const is to the left of what it applies to.
>>
>>56590321
So if your type system is too shit to realize mutating external state isn't pure by any margin, the function is pure? Nice denial :^)
>>
>>56590363
What do you think?
It takes a pair of values and returns a pair of values
>>
>>56590040
What if I want my function to generate a random output?
>>
need some advice bros. 4th week into my programming class and last 2 grades have been F
should I just withdraw now before I fuck up my gpa
>>
>>56590461
>Failing shit
You must either be stupid or not trying at all.
>>
>>56590393
Wait, never mind, that's not even the same fucking thing as >>56590266. I wrote "const reference to const char *" but that is "pointer to const char *, stored in a const variable".

>>56590398
You're an idiot.

>>56590448
Well, fundamentally, it needs to take the state of an RNG as an input and output a value as well as the new state of the RNG.
>>
>>56590448
https://hackage.haskell.org/package/MonadRandom-0.1.3/docs/Control-Monad-Random.html
>>
>>56590461
>>>/adv/
>>
>>56590461
>in modern schools gpa is more important than not being a fucking retard.

This is why game studios don't give a fuck about school and focus solely on results like functional projects and demos.
>>
>>56590482
Says the haslel retard.
>>
>>56590482
>pointer to const char *, stored in a const variable
You're phrasing that weird.
It's a "const pointer to a pointer to a const char".
>reference
I'm not falling for you stupid sepples memes.
>>
File: 1438611168527.jpg (225KB, 742x720px) Image search: [Google]
1438611168527.jpg
225KB, 742x720px
>>56590398
You're retarded. Pretending to troll doesn't change that.
>>
>>56590420
of course, then it doesn't have side effects, meaning its pure
>>
>>56590523
Where are you inferring anything about Haskell from?

>>56590524
True. If we take that into consideration, and change "reference" to "pointer", I wrote (and the OP wants): pointer to constant pointer to constant char; you wrote: constant pointer to pointer to constant char.
>>
im learning about storage classes
and I don't understand thread storage
what is a thread, and what does it have to do with concurrent programming

explain using baby words please, since I'm kind of retarded
>>
>>56590554
the state monad allows for the pure evaluation of stateful processes, by means of wrapping functions as taking extra parameters, and returning an extra value
>>
ok we obviously need an daily advanced programming thread this is ridiculous
>>
NEW THREAD!

>>56590613
>>
>>56590554
>>56590598

for instance a stateful computation is a function
\s -> (s', x)
where s is the initial state, x is the result and s' is the new state
there's nothing impure about this, it's just a function taking an initial state and returning two values (new state + result)

you can run it simply by passing in an initial state (giving you the final state and the result)

you can chain these stateful computations so that the end-state of one is fed into the initial state (the extra function parameter) of the other
>>
>>56590598
right.
i hate this meme that state == side effects
using a pair (2 element tuple), one can easily have state
>>
>>56590629
how does the state monad come into play
does it lift functions to be uncurried
>>
>>56590656
it works like this
your stateful computations are of the form
\s -> (s', x)
s' the new state, x the result

so to simply put in a new state value

\_ -> (s', ())
-- _ because we don't care about the previous state
-- () is the result because it's like a void function, we're just setting

to get the state value out, we need to put it into the result value
\s -> (s, s
>>
>>56590327
you don't actually need the else, and you should check if count is still 0 after the loop ends. if it is, then print "there are no targets blah blah"
>>
>>56590765
Hmm, I just tried this, but the loop doesn't end, how do I make it so that once the loop goes through the whole array, count is set to -1?
Thread posts: 340
Thread images: 23


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.