[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: 306
Thread images: 27

File: bjarne.png (91KB, 136x275px) Image search: [Google]
bjarne.png
91KB, 136x275px
Danish Gnome Edition

What are you working on, /g/?


Previous Thread: >>56812538
>>
First for C++ iostreams are a complete joke, as well as the rest of the language.
>>
>>56815638
learning C so I'm not a cuck in my robotics class.
>>
>>56815651
>first for old news
>>
>>56815657
What do you mean, "sort of manual but sort of not"? It's all manual, using either linear types or monads to keep it safe.
>>
>>56815665
I mean I would just do the computations in the IO monad, or a restricted version of it
>>
>>56815675
So then you have no safety.
>>
>>56815675
>>56815685
And thus, no purity. Well, I suppose it's technically pure, if you consider the IO monad as describing effects like "segfaults" or "corrupts the kernel" or "does irreversible damage to your hardware".
>>
>>56815665
>>56815675
Like just using peek, poke, malloc, alloca, etc

>>56815685
No memory safety, yeah.
If I want to mess around with memory I'll do it myself.
You could implement reference counting or custom GC and abstract it away.
>>
>>56815700
>you can make it safe by making it slow!
Your best point against linear types is that you don't care about what they fix. Might as well have gone for that in the first place instead of wasting my time.
>>
File: IMG-20160924-WA0001.jpg (181KB, 1036x869px) Image search: [Google]
IMG-20160924-WA0001.jpg
181KB, 1036x869px
Look at my beautyfull Vba code /g
>>
>>56815651

>>56815667
>>
>>56815638
Working on an extension to make code executable in code tags. Still choosing which language it should execute. I was thinking Scheme, calling it FourScheme, or ForeScheme
>>
>>56815718
uh.. n-no habla espanol
>>
>>56815698
>And thus, no purity
That doesn't follow at all.

>>56815712
RC isn't that slow, and as I said, I'd rather do it manually
If I wanted "True safety (TM) (TM)" I'd be using a dependent language, not some trashy "C with linear types" language. Oh, and your definition of true safety apparently excludes a great deal of programs, including the rm program.
>>
I'm programming a Video/TV Show app, and I want your input /g/ on something!

If the user chooses an episode of a tv show, what would the back button do?

A. Go back to TV Show's episode list
B. Go back to the Video Library

So? Which is the most correct?
>>
>>56815723
And that is better than proper format strings how?
>>
>>56815718
>goto's
>comments longer than code
>espanol
-2/10 tbqhwuf
>>
>>56815736
>That doesn't follow at all.
Read the rest of the post.

>>56815736
>If I wanted "True safety (TM) (TM)" I'd be using a dependent language, not some trashy "C with linear types" language.
Where are you getting this from? Where did I say no dependent types?

>Oh, and your definition of true safety apparently excludes a great deal of programs, including the rm program.
rm isn't safe.
>>
>>56815739
Didn't say it was better. Just not as horrible as international anon wanted to make out to be. All his other complaints still stand.
>>
>>56815754
It doesn't matter what effects IO does, standard Haskell or safe ghc haskell never peeks inside.

>>56815754
>where did i say no dependent types
You didn't, but then that's not an argument for linear types.
(Which of course can be encoded into monadic effects with dependent types)

>rm isn't safe
It is a program people would like to write
>>
>>56815773
>Just not as horrible as international anon wanted to make out to be
No, your solution is just as horrible and isn't scalable at all.
Are you seriously going to do that every time you want to print something?
>>
File: what?.jpg (32KB, 310x280px) Image search: [Google]
what?.jpg
32KB, 310x280px
How do I become a 3 star programmer?
>>
>>56815799
>It doesn't matter what effects IO does, standard Haskell or safe ghc haskell never peeks inside.
What?

>(Which of course can be encoded into monadic effects with dependent types)
And it would be horribly verbose.

>It is a program people would like to write
Well, ideally, simply removing a file would be safe. It's the fault of other programs that it's not. It's kind of a grey area. But this is getting into a whole philosophical discussion of what safety means, when it's really irrelevant to the topic at hand.
>>
>>56815846
You shouldn't need to go beyond 2 stars.
If you're using 3+ stars, you probably need to re-evaluate the design of your program.
>>
>>56815846
What's a 3 star programmer?
>>
>>56815862
>What
It's still pure, whatever effects IO does. Because main is just an IO value.

>and it would be horribly verbose
It would be library code, not on the user end.
Just create a function that takes a non-linear ref computation and possibly returns a linear one if it can guarantee they aren't referenced twice. Otherwise, again you're just embedding it.

It's generally considered a lot nicer to have these things as library features than language ones, especially something like linear types that effects the rest of the type system.
>>
>>56815830
It's about as scalable as the c examples, and it's easy to wrap it into a printf like wrapper if you really want to.
>>
>>56815871
It's how many levels of indirection (pointers) a C programmer uses.
>>
>>56815890
I mean Haskell is still pure.
Main is just an IO computation, to be performed.
Obviously what main does isn't pure, that's the point.
>>
>>56815898
Oh right, that makes sense. I think the most I've used was 2.
>>
>>56815890
>Just create a function that takes a non-linear ref computation and possibly returns a linear one if it can guarantee they aren't referenced twice.
Right, and how do you propose being able to write the code to be checked in such a way that it isn't horribly verbose?
>>
>>56815898
Sounds like you've done something wrong if you end up with a triple pointer.
>>
>>56815893
>and it's easy to wrap it into a printf like wrapper if you really want to
All you've done is create a stupid format pointer implementation. That doesn't counter my argument at all.
>It's about as scalable as the c examples
There is way more variables and extra text involved, duplicated of information and other nonsense.
With C and printf, you can use gettext and your calls just become
printf(_("My name is %s.\n"), my_name);
and all of the translation is done outside of your program.
>>
>>56815930
How else am I supposed to allocate a 3D array?
>>
>hey anon, you know that project due in 6 months that you haven't started yet?
>well the customer wants it in a month now
>here's the 1000 page standard you have to read, drop everything you're doing and have fun

I hate my life
>>
>>56815923
As I said, it's library end. It's not at all trivial if the programs are complicated. You could provide pre-proven, more complicated building blocks.

It's nicer than making it a requirement of the language.
And really, you're just pushing the work off to the compiler writer.
>>
>>56815941
No, that's when you ask for a pay raise and a new title or else you're G O N E.
>>
>>56815737
To the episode list press one more library .imo
>>
>>56815944
All that said, you're still using linear types. What's your point?
>>
>>56815836
I guess you could do single thread IO interleaving, but you can't use ReadKey for that. Does C# have something like PeakKey?
>>
>>56815961
You said linear types
Then you said "I didn't say no dependent types"
If you've got dep. types then you might as well not have linear types built in
>>
>>56815937
Flatten it to 1D.
>>
>>56815975
You're not not using linear types, though.
>>
>>56815743
B-but they are so useful
>>
>>56815985
So what?

Have you changed your mind? Are linear types now only relevant if you've also got dependent types?
>>
>>56815937
Why on earth do you need a 3d array?
Also, as >>56815984 says, 1D is a much better idea.
>>
>>56815997
What? Linear types are relevant anyways, you're just saying that you'd have them as a library feature and not a language feature of a dependently-typed language. I.e. using that language as a logical framework for encoding a language with linear types.

Where are you not using linear types here?
>>
>>56815992
99% of the time, I always end up rewriting my gotos because there's a cleaner way to exit a nested loop structure.
>>
>>56816010
You were saying that you use them for safety, and I said if I wanted safety I'd use dependent types. Linear types by themselves would restrict a bunch of safe but not obviously safe programs.
>>
>>56815932
>All you've done is create a stupid format pointer implementation.
Which is what printf is.

All i'm saying is i don't think iostreams fuck localisation. It's just all about building strings.

Iostreams are still heavyweight, complicated and verbose.
>>
>>56816025
>Linear types by themselves would restrict a bunch of safe but not obviously safe programs.
No more so than using monads instead.
>>
>>56816031
What do monads restrict?
>>
>>56816041
What do linear types restrict?
>>
>>56816049
Using the same value twice
>>
>>56816061
>>56816049

Anyway this discussion has gone on far too long and we're far past what I originally said
Can you please STOP bringing up linear types when I mention monads as a good feature?
>>
>>56816061
All that effectively does is force things to happen in sequence. Which is what monads do.
>>
>>56816011
Yeah I was joking , I'm in a programming class and some guy posted this and said he was the best programmer .
>>
I can't believe these fags are still arguing about this monad thing.
>>
File: ULTRA-rage-feels.jpg (106KB, 601x601px) Image search: [Google]
ULTRA-rage-feels.jpg
106KB, 601x601px
my professor's pet language isn't compiling my stuff properly
>>
>>56816077
We're not arguing about monads, we're arguing about linear fucking types which had nothing fucking to do with what I fucking said
What I fucking said was a ONE OFF FUCKING COMMENT that it would be nice to have a pure lisp with monads (and types, obviously).

This is the THIRD TIME he's felt the need to bring up fucking linear types for no fucking reason
>>
>>56816084

Go on.
>>
>I am angry.
>ANGRY ABOUT LINEAR TYPES
>>
>>56816084
You fucked up
>>
I DEFINITELY should've stopped here
>>56813921

I fucked up again by responding to that stupid faggot
>>
God, I might actually start filtering posts.
>>
File: memes.jpg (46KB, 695x431px) Image search: [Google]
memes.jpg
46KB, 695x431px
>>56816145
filter anything with "python" in it

trust me
>>
>>56816097
Did you fix your boids?
>>
>>56816180

No. My boids are still broken.
>>
>>56816187
put them out of their misery
>>
>>56815734
>>56815743
its alberto barbossa's language you americucks
>>
>>56816162
I don't even know why cause python is not taught at most uni at least not in the regular course
>>
>>56816198
People for some reason decide to learn Python
I have no idea how or why, it's kind of like being chosen by the devil, it just happens
>>
>>56815734
>>56815743
murrican "education" and dpt's "elites", everyone
>>
>>56816162
Beautiful, thanks.
>>
>>56816207
it's quite popular with the data science crowd
>>
>>56816244
for
no
good
reason
>>
>>56816198
I know my Uni had Python for their Intro to Programming course. I had experience and AP credit, so I never learnt it. We used a safer version of C.
>>
>>56816097
here you try it
http://www.cs.ecu.edu/karl/cinnameg/8-2/lin/Misc/get.html

i don't know if i'm just going insane. i finally got it compiling things and it gives errors that shouldn't be errors. when i create a type, it says i'm trying to extend a type that already exists but i'm not

http://www.cs.ecu.edu/karl/3675/fall16/Assn/Assn4/deriv.cmg

here's the demo file he provided


please just try and let me know if it's just me or if it really is broken. i'm the only one trying to actually install it on my machine, everyone else uses a windows-only virtual machine to connect to a machine that has it installed
>>
>>56816282
Mine was c# but my uni has a partnership with Microsoft so that's is probably why
>>
>>56816320

It's giving me eye cancer, but I can test this binch out for you.
>>
>>56816334
Yeah, that's probably why. Do a lot of your school's grads feed into Microsoft?
>>
>>56816255
Simplicity. Although that is largely going away with Python3 so I have a feeling R is going to take over given its much better suited for the same sorts of tasks.
>>
>>56816358
Not that anon, but you're a real human bean.
>>
>>56816255
>lots of libraries for scientific stuff, with great support
>>no good reason
>>
>>56816417
no

good

reason
>>
>>56816396
But R is for statistical analysis only.
>>
>>56816389
They either work for Microsoft or dell but most of them work from less than a year there
>>
The only reason Lisp isn't popular is because people are lazy and dumb
>>
File: cinnameg.png (1KB, 366x29px) Image search: [Google]
cinnameg.png
1KB, 366x29px
Well, this is definitely not going to work on Winders. I'd need to set up a Linux VM (don't currently have one).
>>
Racket scheme literally has all of the features of Python and the capability for much more. The standard library is bountiful and theres a great C FFI.
People just don't use it because apparently infix notation is too bizzare to handle, or they think it isnt good because KODE WITH KARLY is taught in Python
>>
>>56816474
is karly hot
>>
File: 1453648836231.png (681KB, 840x720px) Image search: [Google]
1453648836231.png
681KB, 840x720px
>>56816320
>Cinnameg is a programming language that allows you to mix declarative (functional and logic) and imperative (including object-oriented) programming seamlessly.

>mix _ and object oriented
>seamless
>>
>>56816499
http://kodewithklossy.com/
>>
>>56816535
You can do it seamlessly with Swift. You can avoid using objects if you want and can even do functional programming
>>
>>56816539
the answer is yes
i'll be damned
>>
>>56816535
See OCaml. Structural typing can be used to represent OOP-style objects really well in any language with Hindly-Milner types.
Of course, "message passing" is usually a stateful action so that implies lack of functional purity.
>>
>>56816556
I looked her up. She's a fashion model.
>>
>haven't done any programming today
Give me a fizzbuzz or something I can solve before I go to bed.
>>
>>56816561
>OOP style objects
>>
>>56816561
I'm sure you could have a language like Erlang, that's pretty functional as far as each process goes on its own, but the way processes interact, you can have state.
>>
>>56816575
https://en.wikipedia.org/wiki/Mathematical_object
Pretty much everything is an "object" in some sense or another. Do you prefer to call ints and structs, "datum"?
>>
>>56816599
>ints and structs
>datum
Don't you mean data
>>
>>56816535
modern C++ does a pretty good job of mixing oo/imperative/functional, with less and less template syntax required as time goes on (check out generalized constexpr, constexpr/generic lambdas, variable templates, and the Boost.Hana library, which makes extensive use of those)
>>
>>56816599
Are you seriously now saying that the C term object and the OOP term object are comparable? Or that a simple tuple is now an object?

>>56816625
It honestly doesn't.
>>
>>56816641
At least they didn't call it Entity Oriented Programming.
>>
>>56816641
>C term object
wat
>>
>>56816674
Yes, "object" is also a C term, referring to basically anything that takes up memory
Were you not aware?
>>
I guess I'm filtering the word object now too.
>>
>>56816699
I guess I'm filtering the word filter now
>>
>>56816641
>It honestly doesn't
nice argument. do you actually know what those features are?
>>
>>56816704
Good idea.
>>
>>56816641
I'm saying that you could consider C, or Haskell, or Lisp functions to be manipulating "objects", even if it's not in the sense of OOP objects.
Are you going to go yell at those mathematicians who wrote the wikipedia page?
>>
>>56816335
Its not type safe, though, most of the time gcc can detect errors (but not all the time).

You're right, I should just do it once. it is rare that I need printf style printing and I used to just use some hack to get the desired functionality, rather than spending the time to implement output properly.


I think I might try to implement my own output for C++ and try to optimize it reasonably well, now, and see how much of the computation I can do at compile time. I assume I can get most of it done at compile time with some template trickery, may as well try now.
>>
>>56816710
I'm not familiar with generalised constexpr, I assume it just lets you do more in a constexpr function.
>>
>>56816724
It's wildly different from the OOP sense, because when they say "object" they mean object in the "thing" sense.
So imagine someone invented a technical term, "Thing", and developed "Thing Oriented Programming", and then someone said "XYZ language must be TOP! It involves things, even if they aren't the Things from TOP"
>>
File: shimakaze (male).jpg (47KB, 600x455px) Image search: [Google]
shimakaze (male).jpg
47KB, 600x455px
Is it bad if I have a nested loop that's 4 levels deep?
I ended up using i, j, k, and l for iterator variables.
>>
Everybody needs to shut the fuck up.
>>
>>56816798
It's probably time to split your functionality into different procedures.
>>56816803
Filtered.
>>
Cinnameg guy, if you're still here, I'm still working on it. VM is installing Lubuntu as we speak.
>>
>>56816776
Exactly.
Things in C are called objects but I never meant to claim that C is OOP
>>
>>56816798
>i and l
Don't do this. Yeah yeah on a proper font blah blah. There's no advantage to it so just don't.
>>
File: (can't wake up).gif (112KB, 255x231px) Image search: [Google]
(can't wake up).gif
112KB, 255x231px
>the fucking state of swift's documentation
>>
>>56816842
what, should I use m instead?
>>
how many of these goddamn bootcamps are there
does the world need so many emitters of mediocre javascript
>>
>>56816358
>>56816455
thanks for the attempt
>>
>>56816884
there's a whole alphabet of letters out there, just waiting to be found
>>
>>56816890
We're just on the cusp of a second tech bubble burst.
99% of new startups make no profit and are only being held together on shit JS backend code and venture capital funding with no plans to ever become profitable.
>>
>>56816927

See: >>56816820

I'm still working on it, lad.
>>
>>56816953
error: stray ‘\343’ in program
unsigned i, j, k, あ;
^
>>
>>56816730
>I think I might try to implement my own output for C++ and try to optimize it reasonably well, now, and see how much of the computation I can do at compile time.
I'm interested in seeing the results.

Lately i've been feeling i should learn how to do efficient string handling and parsing, rather than the naive solutions you get from all the basic textbooks.

Anyone have any good reading resources on that matter?
>>
>>56816973
you could use that character in swift (^:
>>
>>56816962
oh i see. thank you very much. if you try to install it while in /usr and run into problems, you may try to create a directory in home for it, and then untar it and run the commands there. if it says something about yacc t_parser.c you have to go into src and parsers i believe, and then touch t_parser.c to update the modified date to right now. that's my wisdom imparted to you. i'm going try to see the professor at his office hours this morning to ask him for tech help regardless
>>
>>56816973
ah, that's a problem
>>
>>56816973
Shit-ter language

$ ghci
λ: let あ = 2
λ: あ
2
>>
>>56816973
use clang
>>
>>56817006
>can't do this on windows
>can't run ghci on bash on ubuntu on windows because no timer_create
life is suffering
>>
>>56817006
me@me:~$ ghci
GHCi, version 7.6.3: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> let あ = 2
Prelude> あ
2
Prelude>


neat
>>
>>56816762
it lets you do anything in a constexpr function as long it's actually a constant expression, including branching/switching/loops. so, assuming you're writing/using code that is properly constexpr-qualified, you can do anything except what can't be constexpr by nature (disk IO, keyboard/mouse input, etc). combine that with template variables/functions and constexpr/generic lambdas and you can have higher-order functions and such, all still constexpr. i really recommend checking out Boost.Hana if you haven't
>>
>>56816990
I have post traumatic stress from that one thing i did in swift. Now everytime someone mentions swift i get the overwhelming urge to declare that swift is a troll language.
Seriously, coding in swift and that apple ide i don't remember the name of felt like i was using 4chan as my ide and compiler.
>>
>>56817038
https://www.youtube.com/watch?v=zBkNBP00wJE
>>
>>56817051
it'll be good once they purge the last vestiges of obj*ct*v*-c 2bh
>>
File: yacc err.png (4KB, 465x36px) Image search: [Google]
yacc err.png
4KB, 465x36px
>>56816998

Interestingly, I was just about to post that.
>>
>>56816762
>>56817038
oh and i forgot to mention generalized return type deduction and decltype/declval. those obviously play a big part too
>>
Just started learning the game maker language, literally have no idea why this character isnt moving left when i press the designated key...
any help please?
Heres the code.
Character also wont jump, but moves to the right when i press the designated key

///Get the player's input
key_right = keyboard_check(ord("D"));
key_left = keyboard_check(ord("A"));
key_jump = keyboard_check_pressed(vk_space);
//React to inputs
move = key_left + key_right;
hsp = move * movespeed;
if (vsp < 10) vsp += grav;

if (place_meeting(x,y+1,obj_wall))
{
vsp = key_jump * -jumpspeed
}
//Horizontal Collision
if (place_meeting(x+hsp,y,obj_wall))
{
while(!place_meeting(x+sign(hsp),y,obj_wall))
{
x += sign(hsp);
}
hsp = 0;
}
x += hsp;
//Verticle Collision
{
if (place_meeting(x,y+vsp,obj_wall))
while(!place_meeting(x,y+sign(vsp),obj_wall))
{
y += sign(vsp);
}
vsp = 0;
}

y += vsp;
>>
>>56816973
He said alphabet. あ is part of a syllabary, not an alphabet. Besides non-shit languages would let you use that as a name.
>>
>>56817051
What happened?

Anyways, I've been trying to solve cryptopals with it, but I'm trying to also make my code portable with Ubuntu and OSX, so I'm not using and IDE.
>>
>>56817072
you, me, and the professor himself may genuinely be the only 3 people in the world to do this.

i'm rather tech illiterate so i tend to blindly copy and paste things but i looked at this command
./configure --prefix=/usr/local/lib/Cinnameg/8-2-1 --exec-prefix=/usr/local
and im wondering if maybe changing the prefix to something in home will fix the problems i'm having. you can try it out for yourself as well if your normal install doesn't work. i don't know why that'd make it work i just know that putting the files in home worked for something previously
>>
File: tumblr_inline_ndei96aXh71qgx55j.png (130KB, 500x709px) Image search: [Google]
tumblr_inline_ndei96aXh71qgx55j.png
130KB, 500x709px
>>56816973

Unicode should not be part of source code.

This is how you end up with shit code like pic related.
>>
>>56817090
>>>/vg/agdg
>>
>>56817133
No, the problem there is that emojis fucking exist and are in that character set
>>
How/Can I use std cin to nothing?
>>
>>56817133
Why is this so jarring?
I know they're being used as letters, but I can't make myself see stupid pictures as forming words.
>>
>>56817133
> -> Void
for what purpose?
>>
>>56817164
To prove that it can't be run, probably.
>>
>>56817164
I was about to defend it, but then I remembered that it's unnecessary.
>>
trying to get syntax highlighting to work in Padre with Perl 6.

anyone had any experience with this?

>Hardmode: its a work computer so I have to use Windows 10, and not something Unix based like a sane person
>>
>>56817124

No matter what I do, the make gives me an error at line 89

target '/usr/local/lib/Cinnameg/8-2-1/lib/native' is not a directory
>>
>>56817141

I don't think the problem would be alleviated if you had Chinese characters or Cryllic letters instead.

>>56817156

Because emojis are supposed to be images, not writing glyphs.

>>56817164

It means the function doesn't return anything in Swift. It's not super bad, but I rather the C version of annotating what the function will return.
>>
>>56817168
>Functions are not required to define a return type. Here’s a version of the greet(person:) function, which prints its own String value rather than returning it:
func greet(person: String) {
print("Hello, \(person)!")
}
greet(person: "Dave")
// Prints "Hello, Dave!"

>Because it does not need to return a value, the function’s definition does not include the return arrow (->) or a return type.

>>56817208
I know what it means m8 I'm just saying it's a waste of time
>>
File: 1463612034039.jpg (188KB, 1680x910px) Image search: [Google]
1463612034039.jpg
188KB, 1680x910px
>>56817222
>it does not need to return a value
not
a
function
>>
>>56817111
It just seemed incredibly inconsistent. I never really got a grip on the design logic. It was like the ide was actively listening in me and my pair programming partner trying to understand the language, and kept changing the rules just to troll us.
>>
>>56817241
*tips*
>>
>>56817143
wat?
>>
>>56817251
What?
>>
>>56817222

I didn't know it was optional but that's almost as bad as C++ defining these two functions to mean the same thing and C mistakenly having the same semantics as well.

int main()
int main(void)
>>
>>56817198
yep it gave me that when i tried to put it in usr. try making a directory in home called cinnameg with a subdirectory 8-2-1, and put everything in there. and change this command
./configure --prefix=/usr/local/lib/Cinnameg/8-2-1 --exec-prefix=/usr/local
to suit that. i'd change exec-prefix to home too and got it semi working. now all im doing is waiting to see if this works
>>
>>56817156
Because you're brain is unable to attach syllables to the symbols, making it incredibly hard to pars.
>>
>>56817270

*mistakenly assumed to have the same semantics as well

I should sleep soon
>>
File: le tip.gif (3MB, 312x250px) Image search: [Google]
le tip.gif
3MB, 312x250px
>>56817261
>excuse me, but I think you'll find that TECHNICALLY a function is not a function if it does not return a value. contrary to popular belief, this is in fact known as a "procedure". please avoid making this mistake in future, you uneducated plebeian
>>
File: cmgr.png (48KB, 398x599px) Image search: [Google]
cmgr.png
48KB, 398x599px
>>56817124

If you run the config script with $PWD, it's built in the local folder, and then you can cd to bin and run the interpreter
>>
>>56817298
I didn't mean to trigger you
>>
>>56817308
>using trigger unironically
>>>tumblr

>using trigger ironically
>>>/pol/
>>
>>56817301
so you mean to untar it, and then instead of
./configure --prefix=/usr/local/lib/Cinnameg/8-2-1 --exec-prefix=/usr/local
do ./configure $PWD ? like i said i normally just copy and paste things. by interpreter, do you mean i can compile and run files or something different?
>>
>>56817251
>>56817298
>>56817316
>>>/news/
>>
>>56817330
more like >>>/(You)s/ lmao sucker
>>
>>56817208
>I don't think the problem would be alleviated if you had Chinese characters or Cryllic letters instead.
Chinese characters are actually comfy as fuck for variable names. You get basically 1/2-letter long names that hold as much meaning as words.

string 名 = "John Wang";
string 国籍 = "American";
int 歳 = 30;
string 出身 = "China";

Sadly the whole world doesn't speak Chinese (or Japanese in the case of my examples), otherwise they would be superior to english words as far as variable names go.
>>
File: goodnight.png (4KB, 431x44px) Image search: [Google]
goodnight.png
4KB, 431x44px
>>56817324

You set prefix to $PWD and exec-prefix to $PWD. That said, it seems to shit itself on that "demo" file you gave me.
>>
>>56817350
>making all your variable names indistinguishable from each other
>a good idea
>>
>>56817367
not if you can read it dickhead
those all look totally different to me
>>
>>56817367
>I don't understand it therefore its universallt incomprehensible
>>>/retardation/
>>
>>56817367
>>making all your variable names indistinguishable from each other
Yeah indistinguishable... in the same way that when a chinese person reads the newspaper all he sees is "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" right? Because the characters arr rook same?
>>
>>56817380
>>56817381
>>56817385
spotted the weebs
>>
>>56817357
i did
./configure --prefix=$PWD --exec-prefix=$PWD
and now tried
justin@debian:~/Documents/academic/3675/assn4$ cmgc deriv
Wrote listing to file deriv.lst
justin@debian:~/Documents/academic/3675/assn4$ cmgc testderiv
Wrote listing to file testderiv.lst
justin@debian:~/Documents/academic/3675/assn4$ cmgr testderiv
Cannot find compiler /usr/local/lib/Cinnameg/8-2-1/bin/cmgc
Cannot open file /usr/local/lib/Cinnameg/8-2-1/lib/standard.cmo
justin@debian:~/Documents/academic/3675/assn4$


previously today, i got bogus errors trying to cmgc deriv. now i don't, but i get this error. it looks like a more sane error. got any ideas on what i should do different?
>>
>>56817398
>chinese
>weeb
you got me though, good troll
>>
File: chink.png (21KB, 614x481px) Image search: [Google]
chink.png
21KB, 614x481px
>>56817431
>>
>>56817426

You know what's weird? I run the include test suite and it all seems to work, but I can't even get my own hello world to compile.
>>
>>56817197
>Perl 6
I don't think anybody has experience with Perl 6
>>
>>56817499
i'm going to have to see him tomorrow morning. thanks for the help. nite nite
>>
File: lift off.png (4KB, 364x47px) Image search: [Google]
lift off.png
4KB, 364x47px
>>56817560

WE HAVE LIFTOFF. I REPEAT, WE HAVE LIFTOFF!
>>
>>56817571
did you do anything special?
>>
>>56817586

Just found a file that actually worked. The very first sample program on his page.

I am probably the first person outside of your university to ever successfully compile a Cinnameg program.

I'm going to put this shit on my resume.
>>
Tbh, this language is not that bad. I mean, I don't like some of the design choices, but it seems to have every feature under the sun, including Monads™
>>
>>56817617
I looked at the demo code and it reminded me of Haskell
>>
>>56817617
>No linear types
>>
>>56817603
there's no doubt you are. grats i guess i'm still trying to figure it out myself

oh wtf i copy and pasted the cmgr file into the file and now it works

this is the most ghetto rig i've ever used but it may be what i use all semester
>>
>>56817634

More accurately, it's a clusterfuck of everything. One of the testfiles even includes the canonical Haslel """"quicksort"""".
>>
>>56817639
*i meant i copy and pasted the cmgr file into the directory with my test code, and then did ./cmgr test
sleepy time here i go
>>
>>56817649
I don't know if it's lazy, but if it isn't then that's a really inefficient quicksort
>>
>>56817006
$ gore
gore version 0.2.6 :help for help
gore> あ := 2
2
gore> あ
2
gore>

had no idea Go supports unicode in the source code
>>
>>56817639
>this is the most ghetto rig i've ever used but it may be what i use all semester

Tell your prof I helped so I can get some extra credit.

When he adds me to the class roll, I want to be "Spede Pasanen"
>>
>>56817656

Yes, it is. Cinnameg is the future, everybody.
>>
>>56817663
i got overly excited. hello world works but it still doesn't work for the deriv and testderiv files. i'm still going to have to wake up early and see him. i'll tell him you say hi though
>>
>>56817684
ADTs and case expressions is nice though
>>
Do you guys still play video games if you have a full time job?
>>
>>56817693
only if you have literally zero life to speak of
>>
>>56817687

Are you sure the test file isn't written in Cinnameg 9.0? This is 8.2 we're using here.

>>56817690

It needs more memes, though. Where's muh HKTs?
>>
>>56817693
I did when I first got out of school and was working while living at home with the parents and super bored all the time but I eventually moved out and got hobbies.

you have to do things to be interesting to make conversation to meet women.
>>
File: bf1beta.png (3MB, 1752x938px) Image search: [Google]
bf1beta.png
3MB, 1752x938px
>>56817693

Video games are ""fun""
>>
>>56817752
Does it even have arrow kinds?
Are there type constructors?

Does it have polymorphic recursion?
Then he could've used a generalised catamorphism for his deriv:
deriv = cata deriv'

deriv' constant(?) = 0
deriv' xx = 1
deriv' (a + b) = a + b
>>
>>56817782

NO! CINNAMEG A SHIT! REEEEEE
>>
>>56817785
data Expr r = XX | Constant Double | r + r


Then you use the type-level fixpoint operator
data Fix f = Fix (f (Fix f))

So
Fix Expr

becomes
Expr (Fix Expr)

Expr (Expr (Fix Expr))

Expr (Expr (...))
>>
>>56817820
This is as an alternative to

data Expr = XX | Constant Double | Expr + Expr


The benefit you get is generalised catamorphisms

unfix (Fix f) = f
cata f = f . fmap (cata f) . unfix
>>
>>56817820
>>56817829

To be honest, chief, you lost me a while ago. All I know is that Cinnameg does not have these super fancy type theory sounding things.
>>
>>56817841
osgtp im on my phone in bed but can you do something for me and check to see how involved that online interpreter is? i remember seeing one. i just realized i may be wasting my time trying to get it running on my own computer. does it allow uploading .cmg files and stuff?
>>
>>56817888

His online interpreter is shit and has a million restrictions.
>>
>>56817931
ok. in going to sleep now. dont let me wake up
>>
File: 214124124.png (230KB, 517x316px) Image search: [Google]
214124124.png
230KB, 517x316px
>>56817888
>getting a trip to do your homework for you from your bed
>those digits
>>
>>56817954

I didn't do his HW, though, I just helped him figure out how to get this shitheap of a compiler to successfully compile.
>>
>>56817841
cata f
Imagine f is an "eval" function for an expression, but unlike a regular eval function, it assumes sub-expressions are already evaluated.

I.e. for a binary tree
data Tree = Leaf Int | Split Tree Tree

this "weird" eval function acts like it's actually defined as
data Tree = Leaf Int | Split Result Result

(where Result is the type that eval would give back)

The cata bit transforms f so that it evaluates all the nested expressions first (using f)
>>
>>56818004
So for instance

count' (Leaf _) = 1
count' (Split a b) = a + b
count = cata count'

vs

count (Leaf _) = 1
count (Split a b) = count a + count b


Notice how in the second, the recursion is explicit, but in the first, it was like the input (Split a b) already contained the count of the subtrees
>>
How am I supposed to make sure that a DirectX application will run on every machine? By every I mean that at least on Win 7-8-10?

Right now I'm testing it on another machine, and I get missing DLL errors. When I read about those, the official MS site tells me that I need to install the SDK to solve the issue (that's why I didn't get the error on the dev machine). I could pack those with the executable, of course, but isn't the whole point of DX that it should find everything already on the machine? Or am I following an outdated tutorial? http://www.rastertek.com/tutdx11.html
>>
>>56818042
You bundle the DLLS. You don't need the whole SDK, just the runtime.
>>
Why can't I use a negative number as an array index?
>>
>>56818042
Have you noticed that pretty much every game also installs a Visual C++ Redistributable when installing the game?
>>
>>56818132
Because you're not using Python anymore, Toto.
>>
>>56818142
>>56818131
Ah, so there's no escape then.

>every game also installs a Visual C++ Redistributable when installing the game
Now it makes sense.
>>
>>56818152
I'd like to peek at the char at the address right before s, but I don't know how to do that without explicitly writing it like this.

while (*(s - 1) == '\n') s--;
>>
c
#include <stdio.h>

void
rput (void)
{
char c = getchar();
if (c != '\n') {
rput();
putchar(c);
}
}

int
main ()
{
printf("string?: ");
rput();
putchar('\n');
}


haskell
rput = do
c <- getChar
if c /= '\n'
then rput >> putChar c
else return ()

main = do
putStr "string: "
rput
putChar '\n'
>>
>>56818201
It's also possible to compile your program using static linking, obviating the need for dll's. That may or may not bloat your executable, depending on the size and structure of your code base.
>>
I'm following http://www.mysqltutorial.org/mysql-subquery/
And I'm confused on correlated subqueries
SELECT
productname,
buyprice
FROM
products AS p1
WHERE
buyprice > (
SELECT
AVG(buyprice)
FROM
products
WHERE
productline = p1.productline
)
So in the subquery it's getting the average for each product line? How is the outer query knowing which productline to compare to though
>>
>>56818210
prev = s[0];
for (i= 1; i< s.length; i++) {
curr = s[i];

// do whatever you want with current and previous value here

prev = curr;
}
>>
>>56818210
instead of
s[-i]

do
*(s-i)
>>
>>56818273
What's wrong with s[-1]?

>K&R Section 5.3: If one is sure that the elements exist, it is also possible to index backwards in an array; p[-1], p[-2], and so on are syntactically legal, and refer to the elements that immediately precede p[0]. Of course, it is illegal to refer to objects that are not within the array bounds.
>>
>>56818224

>non-tail recursive function with indefinite input length
You're asking for a stack overflow, Anon.
>>
>>56818224
>haskek
>terse
camelCase
>readability of perl scripts

>c
>beautiful
>self commenting code
>>
>>56818298
Nothing. My brain is just mush and needs sleep.
>>
>>56818321
non-tail?

>>56818323
i think the self commenting of c code just comes down to familiarity,
>>
>>56818321
Can a function be TCO if the input is indefinite?
>>
>>56818344

You have actions after the recursive call. So what you're doing is basically building the string on the call stack and then printing it in reverse order. If you're going to be building a stack to reverse print an input, you should use the heap with malloc and realloc. I could write up a proper example of doing this if you give me a couple of minutes.
>>
>>56815661
good job

where you learning from
>>
>>56815949
>Alright, your new title is senior codemonkey and you get one extra banana per day. Now get back to work, faggot.

>Ye.. Yes sir...
>>
>>56818386
do it
>>
>>56818358

Yes. You can write a simple infinite loop using recursion, and an optimizing compiler can usually turn it into a normal infinite loop. TCO doesn't occur when you have actions that occur after the recursive call. Although some simple actions like multiplication and addition can be optimized anyways. The classic recursive factorial function (n * fact(n - 1)) isn't tail recursive, but can nonetheless be optimized to one.
>>
>>56818224
>if cond then act else return ()
use when from Control.Monad

rput = do
c <- getChar
when (c /= '\n') $ do
rput
putChar c
>>
>>56815941
It would take me 3 months, at least, just to read 1000 pages.
>>
>>56818429
when (c /= '\n') (rput >> putChar c)
?
>>
>>56818454
I wouldn't put it all on one line
>>
so, is void a hack that was thrown in in c just so that one can work on a general type of containers?
>>
>>56818486
void as a generic pointer type is definitely an ill-conceived hack
it wasn't even part of the language until C89.
>>
File: Rob Pike looks like an elf.png (368KB, 444x697px) Image search: [Google]
Rob Pike looks like an elf.png
368KB, 444x697px
Rob Pike is a nice and funny man but I won't deny he looks like an elf in his older age. Maybe it's a good thing.
>>
>>56818560
No wonder he hates C++
Elves hate gnomes
>>
File: 1463654008054.png (190KB, 1920x1432px) Image search: [Google]
1463654008054.png
190KB, 1920x1432px
Friendly reminder to const qualify your data where appropriate.
Contrary to popular belief, const DOES help the compiler to optimize.
>>
File: handles_overflow.png (52KB, 1344x726px) Image search: [Google]
handles_overflow.png
52KB, 1344x726px
>>56818426

#include <stdio.h>
#include <stdlib.h>

void rput(void)
{
size_t cap = 1024;
size_t len = 0;

char c;
char *tmp;
char *buf = malloc(cap);

if (!buf) goto OutOfMemory;

/* Read string into heap allocated buffer, resizing as necessary */
do {
c = getchar();
if (len == cap) {
cap *= 2;
tmp = realloc(buf, cap);
if (tmp) { buf = tmp; }
else { goto OutOfMemory; }
}
buf[len++] = c;
} while (c != '\n');

/* Print characters in reverse order */
len--;
while (len) putchar(buf[--len]);

goto Cleanup;

OutOfMemory:
fprintf(stderr, "error: insufficient heap memory\n");
Cleanup:
free(buf);
}

int main(void)
{
printf("string?: ");
rput();
putchar('\n');
}
>>
>>56818620
If I have a const array of strings, do I have to const the string pointers themselves with
static const char *const arr[] = { ...
>>
>>56818654
I'm not sure, you'd have to ask someone who is familiar with const pointers.
>>
>>56818654
My guess is that yes you probably do.
>>
>>56818620

Is that even C++ standard conformant? I am guessing since there is no restrict in C++ and the semantics for const is slightly different than C, it is legal for this to happen.
>>
File: builder apu.png (32KB, 729x792px) Image search: [Google]
builder apu.png
32KB, 729x792px
>>56818620
how to get assembler output from gcc???
>>
>>56818768
very stupid frogposter
>>
>>56818768
gcc -S
>>
>>56818768
How about you stop posting frogs and learn to google you underage fucking faggot.
>>
>>56818783
I think reading the man page might be a faster option.
>>
File: sepples.png (52KB, 1344x726px) Image search: [Google]
sepples.png
52KB, 1344x726px
It's even simpler to do this program in C++

#include <string>
#include <iostream>

void rput()
{
std::string str; // std::string is an auto-resizing container
std::cin >> str; // iostreams handle this seamlessly behind the scenes

// Reverse iterators take care of needing to keep track of indices
for (auto rit = str.rbegin(); rit != str.rend(); ++rit) {
std::cout << *rit;
}

/* As str goes out of scope, it's destructor is called, freeing memory
* Thus, we do not need to call free(). If we ran out of memory, an
* exception would be thrown, calling the string's destructor, and
* printing an error when not caught by main(), our calling function.
* We therefore do not need any extra code here.
*/
}

int main()
{
std::cout << "string?: ";
rput();
std::cout << std::endl;
}
>>
File: zika pepe gas.png (207KB, 748x651px) Image search: [Google]
zika pepe gas.png
207KB, 748x651px
>>56818783
>>56818771
ill google my micropenis into your mum's dungeon fagets
>>
>>56818789
A frogposter can never become a man
>>
>>56818790
Take that, iostream haters.
>>
>>56818790
main = interact reverse

rate my haskell code
>>
>>56818824
It's shit.
>>
>>56818824
illegible/10
>>
>>56818790
>it's destructor is called
>it's
>>
>>56818824
way too hard to read
>>
>>56818849
*it's destructor its called
>>
>>56818854
your and idiot
>>
>>56818824
impractical/10
>>
>>56818824
0/10
>>
>>56818813

It has its advantages and its disadvantages.

>>56818824

gets.reverse.display


>>56818849

Yeah, I derped.
>>
>>56818872
interact is a really nice function for this sort of thing

takes a string->string function, applies it to stdin, then returns that as stdout
>>
C++ is so strange and arcane it may as well be it's own programming paradigm.
>>
>>56815963
Non-blocking console io is probably the best your gonna get.
I'll post code when I'm done being a (((mobile poster)))
>>
>>56818893
C++ is proof that 1000 typewriters sitting on a committee CANNOT reproduce shakespeare
>>
>>56818824
haskell/10
>>
>>56818901
At least you'd think their committee is made of typewriters, given how many books they write that exist solely to explain the stupid decisions they've made
>>
Clang or GCC?
>>
>>56818926
Depends, are you an S or an M?
>>
>>56818884

Sounds pretty useful if you're doing a lot of shit with stdin.

def interact
puts yield gets
end
interact &:reverse
>>
Can you improve on this code?
try {

} catch (彼女) {
throw new 彼女(KanojoAttribute.性病);
}
>>
>>56818977
//done
>>
>>56818971
"useful" is how i'd describe most of the functions in Haskell's standard library

higher order functions are one of many reasons why FP is goat
>>
>>56818977
пoпpoбyй {

} cлoви (彼女) {
кинь нoвый 彼女(KanojoAttribute.性病);
}
*
"GRUNNUR"
;
>>
File: 1474262817357.gif (822KB, 600x366px) Image search: [Google]
1474262817357.gif
822KB, 600x366px
I want to write a bunch of functions to help me prepare WebGL attributes and buffers, but I don't have any good and brief documentation on the pipeline.
>>
>>56818651
>>56818651
I approve of this, but I heard goto is harmful.
>>
>>56819082
It gives you brain cancer
>>
>>56819082
Avoid at all costs. I heard that if Goto bites you, you also become a Goto.
>>
>>56819082
why?
it's really useful, allows you to jump to wherever you want
>>
What do people who get a degree in cs do other than be code monkeys?
>>
>>56819126
>don't get degree in cs
>realise you are shit
>>heh stupid csfags
>>
>>56819082
It's pretty good, you don't even need functions so performance is maximum!
>>
>>56819133
so gotos are functions?
>>
>>56819142
he's in his own little world where function means C compliant function call
>>
File: mother_and_son.jpg (104KB, 600x898px) Image search: [Google]
mother_and_son.jpg
104KB, 600x898px
NEW THREAD
>>56819162
NEW THREAD
>>56819162
NEW THREAD
>>56819162
NEW THREAD
http://boards.4chan.org/g/thread/56819162NEW THREAD
>>56819162
>>
>>56819126
QA monkey
>>
>>56819126

Research.
>>
>>56815734
>>56815743
that's huehue not tacospeak, daily reminder that the u.s. stereotype is being ignorant and elitist
>>
anyone here do any programming on their android device? I am constantly commuting and wonder if I can code on the go
>>
>>56818436

Do you work for a company? If so, the management is shit. Just say you're going to try your best but you're going to fail, then fail, while collecting your biweeklies.

Don't ever try to make ends meet with unrealistic deadlines. Work at your own pace, write quality code, and fuck every1 else. If they keep on doing it just go find another job and let them use a pajeet programmer
Thread posts: 306
Thread images: 27


[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.