[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 31
File: yuki.jpg (104 KB, 984x927) Image search: [Google]
yuki.jpg
104 KB, 984x927
Old: >>51449718
What are you working on, /g/?
>>
Generics without partial specialisation and lookup are shit
Languages without macros are shit
C# is shit
>>
reposting from last thread

whats the best way to learn lisp?
reading SICP?
or
following the MIT SICP lectures?
>>
>>51457781
the best way to learn lisp is not at all
>>
>>51457506
Fair enough. I am new and have not fully accrued the vocabulary. What I meant to say is that that would be simpler if I used filter and fold. I didn't know filter or fold at the time then, thus the unreadability.
>>
>>51457831
bro... i hope one day you will have the lightbulb moment and see the brilliance of lisp
>>
>>51457781
Why not both?
>>
>>51457781
lisp is not a programming language. You do not learn lisp. You learn *a* lisp, you learn *a* lisp *dialect*.

Fuck off you uneducated slob
>>
does
n * 2.0
ever have better accuracy than n + n

does
a * (b + c * 2.0) / 3.0
ever have better accuracy than
a * (b + c * 2.0) * 0.3333333333333333
>>
>>51458067
i know retard. but i'm not learning dialect specific stuff. i'm learning stuff that's common to all the dialects. so you could say i'm learning lisp
>>
Daily reminder that all lisps are speech impediments.

If you have a lisp, you are autistic.
>>
>>51458084
no
yes, according to the data format. Although the second might be quicker on some platforms that don't have single cycle floating point division.
>>
>>51457781
You don't read SICP to learn lisp. This is just a side effect.
And you should do both.
>>
File: wouldyouliketoknowmore.jpg (16 KB, 355x151) Image search: [Google]
wouldyouliketoknowmore.jpg
16 KB, 355x151
>be me
>do C# winforms / wpf / asp.net stuff
>lots of small, simple, one-man projects
>bored as fuck

Does programming in the real world ever get interesting?
>>
>>51458142
no
>>
Java or C# for hobbyist?
>>
>>51458142
Learn something that isn't a winkek, codemonkey language.
>>
>>51458171
Like what? Can I get a job doing it?
>>
>>51458142
>>51457736
>>
>>51458193
Not everything you do has to be about getting a job.
Do you even enjoy programming?
>>
How does one who is familiar with C/C++/Java/Haskell and some other languages learn python?
>>
>>51458224
I used to when the simple stuff was more difficult, but now it just feels straight forward. There's no challenge in it. And while I do enjoy programming, I enjoy money more (plus I made shit money until I moved into programming, so kinda behind).
>>
>>51458308
Just read the official Python guide and use the Python docs to look up specific functions.
>>
>>51458308
https://www.codecademy.com/learn/python
https://automatetheboringstuff.com/
>>
>>51458166
why not learn both and then choose the one you like more? (hint: it's C#)
>>
File: madeinchina.png (43 KB, 1037x981) Image search: [Google]
madeinchina.png
43 KB, 1037x981
>Academic code
>>
>>51458166
C# is better in almost every way.
>>
>>51458567
>almost
[which?]
>>
I'm triying to make some bash that allow me create users in my LDAP domain introducing only the firstname, lastname and username
I've got something like this

 #!/bin/bash###############################################
#VAR1=$(tail -n 1 /root/ldap/availableuid | cut -f1)######
#VAR2=$(tail -n 1 /root/ldap/availablegid | cut -f1)######
#echo "before uid: $VAR1"#################################
#echo "before gid: $VAR2"#################################
#let "VAR3=$VAR1+1"#######################################
#let "VAR4=$VAR2+1"#######################################
#echo $VAR3 >> /root/ldap/availableuid####################
#echo $VAR4 >> /root/ldap/availablegid####################
>>
>>51458166
java

>>51458567
java is cleaner and more similar to C++
>>
>>51458851
>java is more similar to C++ than C#
hello australia
>>
>>51457707
>>>/out/
>>
>>51458851
>java is cleaner and more similar to C++
How is it more similar to C++? It has some things in common with it that C# doesn't, sure, but the opposite also holds true. In fact, other than a few syntactic differences, C# is probably more similar since it has:
>pointers
>structs
>unions (kind of)
>operator overloading
>actual destructors
>multiple inheritance
>default/optional arguments
>had lambdas for a lot longer than Java
>>
>>51457781
Common Lisp has a free textbook.
http://www.gigamonkeys.com/book/
I know Clojure is DUDE VIRTUAL MACHINES LMAO but it has the most momentum of all the Lisp dialects right now.
>>
Whats a good way to learn how to make Android apps if I already have a lot of experience with Java?
>>
For those who want to program, but don't know what to work on:
https://better-dpt-roll.github.io/
>>
>>51459124
Use the official tutorial. They walk you through how to make a full app from start to finish, brushing upon every subject you'll need to make something yourself.
https://developer.android.com/training/index.html
>>
>>51458851
C# is far more similar to C++ than Java is. In fact, I don't think there's a single thing Java has over C# concerning similarities to C++.
>>
>>51459153
>https://developer.android.com/training/index.html


Looks good thanks.
>>
File: dpt roll.png (127 KB, 546x486) Image search: [Google]
dpt roll.png
127 KB, 546x486
>>51459134
everyone knows this is the best /dpt/ roll
>>
>>51459200
>official
>>
>>51458897
>the name is all that matters

>>51458986
>a few syntactic differences
>a few
kek
>>
File: wall.jpg (517 KB, 1536x1536) Image search: [Google]
wall.jpg
517 KB, 1536x1536
>What are you working on, /g/?
Image mosaic generator.
Since choosing C means writing a lot from scratch, I just got most of the basic stuff like normalization and bilinear filtering working.

>pic related, normalized image wall from random /a/ thread
>>
I need project ideas.
A local company is hiring programmers, but it's all C++.
I know basic C++, I took a class on it in college, but I haven't used it (at all) since then so I'm a little rusty.
>>
>>51459361
http://www.cplusplus.com/doc/tutorial/
>>
>>51459364
I know C++, I just need projects to work on so I get comfortable with the syntax.
I've been programming the last 5 years in Java for work.
>>
>>51459404
How do you program in Java for 5 years without attempting suicide? Or did it not let you allocate a noose?
>>
>>51459430
This
>>
>>51458603
my nigga have you tried AWK
>>
>>51459349
>my dick hurts, stop that
What?
WHAT?

>that girl with the weird black marks on her
>>
>>51459430
Don't believe the /g/ memes. Java isn't a bad language, and the JVM is a marvel of technology.
>>
>>51459534
>Java isn't a bad language
Java dindu nuffin wrong
>>
>>51458565
looks intersting.

what is this ?
>>
Java screams "corporate meddling". It has no redeeming features besides inertia.
>>
So, what's a good place to get started with AI development?
>>
>>51459653
ok NEET
K...KEEP ME POSTED
>>
>>51459665
Google, Microsoft or Facebook, they're working on turning their botnets into skynets
>>
>>51459666
If you actually had a job writing Java and weren't from India you'd agree with me.
>>
>>51459690
But I want to make my own skynet first.

But seriously, is there a good introductory textbook or something that can get you acquainted with the basics? There's not a whole lot showing up on Amazon.
>>
shutup u cunts
>>
>>51459738
k keep me posted

positively euphoric
>>
>>51459534
Sure the JVM is pretty impressive, but Java is a verbose piece of shit. In order to pass functions, I have to encapsulate them in interfaces? Fucking disgusting.
>>
can someone give me a concrete example of 'dependent types'?
>>
>>51459534
>JVM is a marvel of technology
Good shit is still shit
>>
File: muhskynet.png (198 KB, 597x680) Image search: [Google]
muhskynet.png
198 KB, 597x680
>>51459735
Don't let the Erlang part fool you, the concepts are universal. Erlang is pretty well suited for growing neural networks, though, if that's your thing.
>>
>>51459735
Coursera has several courses on Machine Learning. That's a good place as any to start.
>>
>>51459735
Artificial-Intelligence-A-Modern-Approach-3rd-Edition.pdf
>>
File: lol.jpg (196 KB, 731x900) Image search: [Google]
lol.jpg
196 KB, 731x900
>>51457707
I just made a Java RSA keygen and encrypter/decrypter but I only programmed it to accept small numbers <10,000.

How do I go about making it able to handle large messages and text files? From what Ive read online its something like file-> bytestream ->biginteger -> encrypt/decrpty individual chunks

also, how can someone encrypt/decrypt a message with out the product of the two secret primes, n? if anyone actually cares about this see my SO question

https://stackoverflow.com/questions/33849823/sending-and-receiving-large-rsa-encrypted-cyphers

thnx <3
>>
>>51459230

NIce trolling, m90
>>
>>51458084
> does
> a * (b + c * 2.0) / 3.0
> ever have better accuracy than
> a * (b + c * 2.0) * 0.3333333333333333
Yes.

If b+c*2.0 is a multiple of 3, then
> (b + c * 2.0) / 3.0
will be an integer, while
> a * (b + c * 2.0) * 0.3333333333333333
may or may not be depending upon which side the rounding falls.

More generally, 1/n cannot be represented exactly unless n is a power of two. So dividing by n and multiplying by 1/n should give different results. Sometimes they'll give the same result simply because the rounding error happens to be in the correct direction to compensate for the inaccuracy in the value of 1/n.
>>
I made this hack to save everything that someone streams to a file.
anyone know how to improve it?

I'm thinking it needs to mark streams with the starting time rather than the ending one, and to contain the stream title.

#!/bin/bash
# watch a given channel that livestreamer suports, and catinates everything aired on it to a file.
if [ -z "${1}" ]; then
echo "usage: <command> <URL> [<extra filename content>]"
return
fi

FILENAME=stream"${2}".mp4
#ATTEMPT=1
#while sleep 0.5 ; do livestreamer -p "tee -a stream\"${2}\".mp4" "${1}" best && date; echo Attempt number $((ATTEMPT++)). ; done
while sleep 0.5 ; do nice livestreamer -p "tee -a \"${FILENAME}\" " "${1}" best > /dev/null 2>&1 && ( date ; mv -- ./"${FILENAME}" ./"${FILENAME}"-"$(date)" ) ; done
>>
>>51459772
Think about C++'s std::array<T, N> type, which encapsulates an array T[N] and provides compile-time bounds checking. Now imagine allowing N to be determined at runtime from something like user input, such as with std::vector<T>. Now you have to choose between having bounds checking with runtime overhead, or having none at all. Dependent types allow you to ensure at compile time that there will be no out-of-bounds errors without adding any unnecessary checking at runtime (i.e. a runtime check can be done once and then knowledge that the index is less than N can be "shared"). You could even take it a step further and allow T to be specified at runtime.
>>
>>51459718
>what is android
there is literally nothing wrong with java
>>
>>51459985
and how would this be implemented? does it require dynamic typing?
>>
File: ezjvcv.png (7 KB, 399x201) Image search: [Google]
ezjvcv.png
7 KB, 399x201
>>51459925
>http://manpages.ubuntu.com/manpages/utopic/man1/livestreamer.1.html
>File output options
> -o FILENAME, --output FILENAME
> Write stream data to FILENAME instead of playing it.
>
> You will be prompted if the file already exists.
read the fucking man page
>>
>>51459985
You could constrain functions to ensure you only get valid input, with current C++
>>
>>51459863
> I just made a Java RSA keygen and encrypter/decrypter but I only programmed it to accept small numbers <10,000.
Did you actually write RSA encryption/decryption or just a function which computes (x^e)%m?

Because there's a lot more to RSA than modular exponentiation. In particular, you need a padding scheme such as PKCS#1-v1.5 or OAEP, which is far from trivial.

Also, key generation can't just pick any two suitably-sized primes and multiply them. You have to check for weak keys (e.g. those where p-1 and q-1 have common factors other than 2, or those where p-1 or q-1 only have relatively small factors).
>>
Best way to learn Java quickly?
>>
>>51460038
You need language support for dependent types. So Agda, Idris, Coq, etc. The issue with dependent types right now is that there aren't any languages suitable for general purpose programming where both performance and safety are concerns, which is where dependent types can really shine, especially when you add linear types.

>>51460057
Not if the notion of validity isn't constant at compile time, like if the upper bound is determined from user input. C++ has type-level programming, same as Haskell with extensions like DataKinds, GADTs and TypeFamilies.
>>
>>51460099
Do you have prior programming experience and just need a crash-course in Java syntax and language features?
Yes: Java in a Nutshell.
No: Head First Java
>>
>>51460056
That doesn't give me the option to append to the file though.

Thanks for reminding me though.
>>
>>51460136
so concatenate them together with ffmpeg
>>
>>51459892
do you have an example?
>>
>>51460124
If validity isn't available at compile time, there will be overhead.
>>
>>51460124
that's my question, how would the language (compiler/runtime) implement such a feature?
>>
>>51460186
nvm i tested it and a lot of numbers differ on the lowest decimal
>>
>>51460169
This thing is meant to be set and forget.
The only reason I made the script stick everything together was to make handling files easier.

Can you think of a way to get the name of the stream without interrupting the recording?
Like, is there some way to fork off a process to get the title and set it in a shell variable so I can use it for naming the file after it's done? Getting the filename after it's done may not be possible.
>>
>>51460013
Java is the most verbose language in popular use. Other problem include:
>no structs
>no points
>no lambdas's (until very recently)
>native interop is a huge pain
>no unsigned integers

It's generally just been incredibly slow to pick up modern language features in recent years. Worst of all C# pretty much does almost everything Java does, has similar syntax, but has none of the problems listed above. It also has a mature ecosystem and labour pool. There is no reason to use Java over C# in new projects unless you absolutely need to use a specific Java based technology.

Android uses Java because it was fastest, easiest to develop in language that was available to freely implement at the time. Google was certainly never going to use C# in Android. Though Xamarin did port most of android to C# as a proof of concept and found it ran faster using mono.
>>
>>51460303
>it ran faster using mono
no and the apk sizes are ridonk
>>
>>51458565
You need to learn to have comments or descriptive variable names, because that is unreadable as fuck.
>>
>>51460403

It's very likely he didn't write it. That's the kind of code you get when you let non-programmers have their hand at writing a program.

Especially mathematicians.
>>
>>51460365
Benchmarks right here:
https://blog.xamarin.com/android-in-c-sharp/

I'm referring to the entire OS being ported to C#, not just the apps.

But there's also benchmarks out there show that mono is faster than native Java apps for at least some things.

Xamarin will make you're APK about 4.5mb bigger. Obviously only worth using when the benefits of using C#/F# to make apps outweighs the drawbacks of the extra space needed.
>>
>>51460196
It's not really overhead if it's strictly necessary. The overhead I was referring to is like using std::vector::at() instead of std::vector::operator[]. If you use the same index multiple times, the bounds check inside of at() will be wasted work. So you use operator[], but then you have to always remember to check at least once to ensure that the value isn't out of bounds. Dependent types allow you to verify at compile time that if a check is needed, it's been done.

As a really concrete example, you'd have a proposition type that the index is within the bounds, and require a proof in order to get the element at that index.
-- definitions are irrelevant here
_<_ : U32 -> U32 -> Set
less : (m : U32) -> (n : U32) -> Maybe (m < n)

Array : Set -> U32 -> Set
get : (ind : U32) -> Array a len -> (ind < len) -> a


>>51460207
Usually the language will base itself off of a dependent type theory, typically Martin Loef's (MLTT). Implementation isn't as tough as it sounds; a minimal dependent type theory AST and checker only takes a few hundred lines in Haskell.

Dependent typing also only really works if you can guarantee referential transparency (purity) and totality. However, this doesn't preclude manual memory management, which may not seem intuitive at first.
>>
>>51460424
>But there's also benchmarks out there show that mono is faster than native Java apps for at least some things.
for absolute garbage biased benchmarks maybe

>Xamarin will make you're APK about 4.5mb bigger.
nah it's a lot more than that. a hello world in xamarin will be like 11 MB and then it will get even bigger when you use more of the standard library or whatever
>>
>>51457781
HtDP2e will be the best for this, but an SICP is fine too.
>>
>>51460440
Why can't you just have a contract with a function that says the result is constrained to lie within bounds?
e.g. array.last (where the size cant be 0)
>>
>>51460424
>you're APK
>you're
kill you'reself
>>
>>51460080
yeah I just did the (x^e)%m thing
one guy on SO told me to just use RSA for encrypting other keys and use AES for the actual message... if I did this I assume I'd still need the padding scheme for AES? thanks for the help m8
>>
>>51460303
>>no structs
It's an OOP language. Use a class.
>>no points
Do you mean pointers? If so, there isn't much use for pointers in Java. The desired behavior (passing by reference) is already done by default for objects.
>>no lambdas's (until very recently)
There are lambdas. Invalid criticism.
>>native interop is a huge pain
native T someFunction(some parameter);
Then you just write your accompanying function in C/C++.
>>no unsigned integers
unsigned Integer (not int!) utilities were added in Java 8.

>There is no reason to use Java over C# in new projects
Our server runs Debian, our developers run Mac, and our clients run Windows.
Java lets us have one codebase to maintain that we can deploy on any platform, with functional and native-looking GUIs.
Plus, since it's JVM-based, we can use any JVM-based language for any of our projects and integrates into our existing codebase with no problems. We've been using Scala a lot lately; it's pretty nifty.
>>
>>51460502
That's exactly what's happening, but instead of being some weird addition to a less expressive type system, dependent types allow you to encode it first-class as part of the standard library, which makes it easier to understand and modify.
>>
>>51460548
>oop can't have structs
>the purpose of pointers is passing by reference
>unsigned integers weren't added till verison 8
jesus christ
>>
>>51460468
>for absolute garbage biased benchmarks maybe
Why do you say that? Why would mono be any slower than native Java?
By virtue of the fact that C# has support for structs, pointers and SIMD would make it intrinsically faster for many things.

>a hello world in xamarin will be like 11 MB and then it will get even bigger when you use more of the standard library or whatever
Google is your freind
https://developer.xamarin.com/guides/android/advanced_topics/application_package_sizes/
It's about 11mb in debug builds, not distribution builds, which will use a linker.
>>
>>51460583
How does it know that you've written a function that can't exceed the bounds?
>>
>>51460080
Why would p-1 and q-1 sharing large factors reduce security? Can you link me a paper on it? The whole idea of RSA is that the public doesn't know p-1 and q-1.
>>51460303
Anonymous functions aren't that big of a deal if functions aren't first class.
>but but muh interfaces
Absolutely disgusting.
>>
New to programming, been learning c++ for about 3 months now.

Working on recreating Minesweeper, and I've almost got it done.
The only things left are to make the input less clunky (using stringstream, maybe?) and fix how the program acts when you select a square on a pocket of zeros. You can see it didn't uncover D8 even though it was supposed to.
>>
>>51460548
so much retardation in one post.

>It's an OOP language. Use a class.
So is C#. Structs are extremely useful as you can assign them on the stack. Extremely useful for performance.

>If so, there isn't much use for pointers in Java
In C# pointers are used to easily import native methods with one line of code and interact with it. Otherwise they are great for getting very high performance. Image manipulation is a good example. Non bound checked arrays are useful here too, which Java does not have.

>Then you just write your accompanying function in C/C++.
You don't need to write any C/C++ to use native with C#. Just one line to reference the native assembly and the name of the function you want to import.

>unsigned Integer (not int!) utilities were added in Java 8.
Fair enough. About time. Are they primitives?

>Our server runs Debian, our developers run Mac, and our clients run Windows.
what is mono.

>with functional and native-looking GUIs.
What are you using to make these "native-looking" GUIs?

>We've been using Scala a lot lately; it's pretty nifty.
Kill yourselves. Twitter was using that years ago and stopped because they realised it's a huge clusterfuck of terrible design decision:
https://www.youtube.com/watch?v=uiJycy6dFSQ

.NET has F#, which is actually good.
>>
>>51460829
It's ok anon, nobody on /g/ can uncover a d8
>>
File: 1444888760231.jpg (57 KB, 500x417) Image search: [Google]
1444888760231.jpg
57 KB, 500x417
>Programming in Java
>>
>>51460705
I'm glad you brought that up, and the short answer is that it doesn't. It obviously can't enforce anything dealing directly with FFI, including manual memory management.

In practice, this is okay. Since most functions that directly do FFI will just be thin wrappers, it's pretty hard to get them wrong, so you don't care if the compiler can help you there or not. What the compiler can prove is the correctness of a function, assuming it's built on top of correct functions. This means that library users can actually say with confidence that a bug occurred upstream, and library developers have an easier time tracking down said bug.
>>
>>51460904
Ah, I get it.

If you want an analogy, const in C-like languages.
>>
>>51460936
Sort of, yeah. If a const variable is changing somehow, and you never did anything silly like take a pointer to it and coerce it to mutable, then you know that it's not your fault.
>>
>>51460988
Does that mean they're monadic?
>>
>>51461031
Monads don't really have anything to do with this.
>>
>>51460126
Thanks! I've downloaded Head First Java but it looks like I'd benefit more from having the physical copy so I went ahead and ordered it. Any other suggestions?
>>
>>51461043
I bet you money it's related.

It constrains chained operations.
>>
I'm about to finish my "programming for mathematicians" module where we have been taught Java. The furthest we have gotten in the module is learning about objects and inheritance. Is there a lot more to be learned by sticking with Java or should I move onto C/++. My interest is solely in mathematics and scientific computing.
>>
>>51461071
Move on to C++.
>>
>>51461071
I don't know much about this, but it seems that a LOT of scientific and math-related computation and visualization is moving over to python.

You might want to check out Anaconda (a Python distribution pre-packaged with popular data science tools): https://www.continuum.io/
>>
>>51461071
If you like mathematics you'll love Scheme. I don't know of a mathematician familiar with Scheme who doesn't like Scheme.
>>
>>51460904
On a side not, it's worth mentioning that some dependently typed languages can translate type-level assertions to normal assertions so that the program can perform run-time checks for code that isn't functionally pure. I'm not sure about Idris/Agda/Coq but F* can do this and I'm fairly certain ATS is able to do it as well.
>>
>>51460526
> one guy on SO told me to just use RSA for encrypting other keys and use AES for the actual message.
Indeed. For performance reasons, you don't use RSA for encrypting "bulk" data, only keys, hashes, tokens, etc.

> if I did this I assume I'd still need the padding scheme for AES?
Padding is part of RSA. It turns a sequence of bits (which must be smaller than the modulus, preferably much smaller) into the integer x in "(x^e)%m". Together, the padding and the modular exponentiation form a cipher. And the padding is the hard part (some languages have modular exponentiation as a built-in function, e.g. Python's pow() function has an optional third argument for a modulus).

Once you have that, you'd generate a random AES key, encrypt the message with that key, then encrypt the key with RSA and include it with the message.
>>
hey /dpt/ this is in c++ and i have to find the longest increasing sublist of an array of mountains. i'm trying to find it dynamically by having an array of best increasing sublists, where a sublist is the "best" if it has the lowest value possible. so then by the end, the last and therefore longest best increasing sublist will be the longest increasing sublist for the entire array. but it doesn't work at all and i'm having an issue pinpointing why
// Function longestIncreasingSublist inserts BestIncreasingSublists into sublistArray.
// It returns the location of the longest increasing sublist within this array.
int longestIncreasingSublist(BestIncreasingSublist *sublistArray, Mountain *mountainArray, int numberOfMountains, int sublistLength)
{
for(int i = sublistLength; i > -1; i--)
{
if(mountainArray[i].elevation < mountainArray[sublistLength].elevation)
{
BestIncreasingSublist* newSublist = new BestIncreasingSublist;
newSublist->mountainArraySpot = sublistLength;
newSublist->next = sublistArray[i+1].next;
sublistArray[i+1] = *newSublist;
}
else if(i == 0)
{
BestIncreasingSublist* newSublist = new BestIncreasingSublist;
newSublist->mountainArraySpot = sublistLength;
sublistArray[0] = *newSublist;
}
}
if(sublistLength < (numberOfMountains-1))
{
longestIncreasingSublist(sublistArray, mountainArray, numberOfMountains, sublistLength+1);
}
else
{
return sublistLength;
}
}


i have a trace
printf("sublistArray[%i] = newSublist\n", (i+1));
printf("newsublist.mountainArraySpot = %i\n", sublistArray[i+1].mountainArraySpot);
if(sublistArray[i+1].next != NULL){
printf("the one after in in the chain is %i\n", sublistArray[i+1].next->mountainArraySpot);}
at the end of the first if statement, the one within the for loop, and the "the one after in in the chain is..." is never getting printed out. all my other traces are. pls halp
>>
>>51461185
here are my structures
const int maxNumMountains = 100;
const int maxNameLength = 100;

struct Mountain
{
char name[maxNameLength];
int elevation;
Mountain()
{
elevation = 0;
}
};

struct BestIncreasingSublist
{
BestIncreasingSublist* next;
int mountainArraySpot;
BestIncreasingSublist()
{
next = NULL;
mountainArraySpot = -1;
}
};
>>
>>51461185
>unnecessary repeated code
>single statements in { } blocks
disgusting
>>
>>51461216
>>single statements in { } blocks

This is a good thing.
>>
>>51461216
i wouldn't have duplicated the sublistArray[i+1] = *newSublist; vs sublistArray[0] = *newSublist; parts, but they can't be merged. one of them sets it equal to i and the other to i+1
>>
>>51461255
Holy shit, why live?
        BestIncreasingSublist* newSublist = new BestIncreasingSublist;
newSublist->mountainArraySpot = sublistLength;
if(mountainArray[i].elevation < mountainArray[sublistLength].elevation)
{
newSublist->next = sublistArray[i+1].next;
sublistArray[i+1] = *newSublist;
}
else if(!i)
sublistArray[0] = *newSublist;
>>
>>51461068
Monads, in that sense, are more of an approximation or encoding of linear types in languages that don't have any notion of linearity.

The language I'm developing has both dependent and linear types built into it, so you don't need monads to express operations that need to be sequenced, you can just do something like this:
main : IO ()
main = let
x, io = read I32 io
in write (2 * x) io

Of course, it's possible (and quite desirable) to write a monad that can do this automatically, it's just not necessary.

>>51461152
Can you elaborate? I'm not very familiar with F* or ATS.
>>
I'm trying to use Python to rename every file in a directory to a random number.
but i just don't know to proceed from this point, i think i need a var that includes all .jpgs in the folder

here is my code so far
import os
import random

newname = random.randint(10000000, 20000000)
directory = ('D:\\b')

for i in directory:
os.rename(i, newname)
>>
I'm thinking I should make a github so I can have a portfolio to point to.
Should I start one now, even if the only thing I have right now are codeeval solutions?
>>
>>51461185
>>51461215
http://pastebin.com/UwEKMi1X
here's a link to the complete tracing of it
>>
>>51461316
To clarify: in that code example, the "io" values are linear. You obviously can't duplicate or throw out the world.
>>
>>51461185
i'm 60% sure the problem is somewhere in the

BestIncreasingSublist* newSublist = new BestIncreasingSublist;
newSublist->mountainArraySpot = sublistLength;
newSublist->next = sublistArray[i+1].next;
sublistArray[i+1] = *newSublist;

portions but i don't know what it is
>>
>>51461419
When you recurse, is it supposed to return that?
>>
>>51461316
ATS and F* both have a bit more of an emphasis on side-effecting code (since they're both more closely related to the ML family as opposed to Haskell and are very focused on general purpose programming) so the compilers try to help you out with that. In F*, pure, total functions are marked as `Tot` in their type signature, while side effecting functions are `ML` (since they behave like ML functions). Functions that are marked as `ML` don't get the same treatment as pure functions -- any attempt at doing so would result in 0 difference during runtime and no actual guarantees during compile time. Instead, it tries to translate the types into normal code. So if you have a function that reads in a string and converts it to an integer, then you pass that to a (pure) functions that finds the nth element in an array, the compiler is able to insert a check (like a call to an assert function) that will basically crash the program if the number entered is less than 0 and greater than or equal to the length of the array.
>>
>>51461352
Yes, it allows you to prove that you know programming.
>>
>>51461350
    directory = ('D:\\b')

for i in directory:

That will just iterate over the characters "D", ":", "\\" and "b".

You need
    for i in os.listdir(directory):
>>
I'll preface with I'm a Linux, Python, Ansible user.

My main two things this week are:
1. Migrating our entire company's infra over to AWS and making it completely immutable. When I'm done every action from commit to deployment to rolling restarts of the autoscaling groups with new gold images will be 100% autonomous and automated.

2. I started a CS:GO trading, betting and jackpot service with a friend. Have to learn C# for the bots though :/
>>
>>51461495
Also, do certain kinds of usernames make you look unprofessional?
I'm trying to think of one because every combination of my first+last name is taken and the usual username I use brings up too many anime and 4chan-related things on google.
>>
>>51461504
Just did it with another method, works great!
Ignore variables names, i'm not very smart

import glob
import os
import random
while True:
for f in glob.glob('*.jpg'):
new_filename = random.randint(100000000, 200000000)
new_new = str(new_filename)
new_new_new = new_new + '.jpg'
os.rename(f,new_new_new)
>>
>>51461547
Yes. Be careful with your username.

Try adding a delimiter like _ or your middle name (or both)
>>
>>51461547
It's weird, but a lot professionals I see on GitHub use anime profile pics and all. I don't think most (or at least many) employers care.
>>
File: csci instructs.png (42 KB, 1521x480) Image search: [Google]
csci instructs.png
42 KB, 1521x480
>>51461459
it's really more of a void function. it fills up a formerly empty array of bestincreasingsublists and then returns the spot where the last one is, which is the longest increasing sublist which is what i'm really trying to find. the array spots in the bestincreasingsublist array stand for how many parts of the mountain array it's looked at. so bestincreasingsublist[0] has only looked at the first mountain, and then [1] has looked at the first one and the second one, etc. my prof says this is the way it should be done. pic related is the instructions for the algorithm
>>
>>51461557
What's a glob? Is it like a frob?
WE NEED TO KNOW
>>
>>51461488
Oh, I see. The types I wrote in >>51460440 show how I deal with validating runtime values -- you have to pattern match on the result of the comparison to either get the proof or handle failure. I'm not a big fan of just crashing, especially on something that should be benign like incorrect user input.
>>
>>51461595
I have no idea what that module is or do, will take a look tomorrow
It's vanilla though, didn't have to install anything
>>
>>51460829
That's not C++, that's just C.
Just change your file extensions from .cpp to .c and use gcc instead of g++ if your not going to actually use any C++ features.
>>
>>51461639
A lot of people are a big fan of crashing.
Crashing means it's a lot less likely you've permanently corrupted data (or performed an unintended action).
>>
>>51461582
They're popular and successful enough to be different.
That's why employers dont care.
>>
Somebody say Frob?
>>
OMG I TOTALLY GET THE TOWERS OF HANOI PROBLEM NOW
Not quite worth staying home on a Saturday, but still...
>>
>>51461704
No, just /*fro\
\
b*/
>>
>>51461639
Yeah, it's very much an experimental approach to dependent typing. It haven't used F* or ATS enough to really know how well it works in practice, but I think the idea comes from the sort of approach to errors that governments, militaries, stock market companies, etc. use, which is basically crash if anything goes wrong to reduce potential damage to the system.
>>
>>51461698
>>51461746
I guess that's a good point. In that case, I may make it possible to write pseudo-partial functions that can crash and produce an error message + trace, although I think I'd make availability depend on a compiler switch.

Personally, I'm thinking of things from the use case of programming interactive, performance sensitive applications like games or simulations, not hard real time systems. But it would be crazy to write a super-safe language and tell the systems programmers to take a hike.
>>
>>51461575
github doesn't accept underscores in names.
just hyphens and you can't start or end names with them.
>>
how do i make a char in c++ act like an integer
char a = 102;
std::cout << a << '\n';

i want this to print 12, not f
>>
>>51461803
monad  
m
d o
a n
n a
o d
m
danom


error ceases execution chain, possibly starts alternative chain
>>
>>51461803
Since these functions that might crash are already impure, it might be possible to implement an exception type (or something like that) to help out with stack traces and also allow you to recover from a potential crash further down the call stack.
>>
>>51461856
std::cout << static_cast<int>(a) << '\n';
>>
>>51461856
>i want this to print 12
meant to say 102 desu
>>
>>51461856
std::cout << int(a) << '\n';
>>
>>51461887
>>51461879
i know you can cast it but is there truly no simpler way? i want a to be 102, i don't want to coerce it into being 102.
>>
>>51461873
->
>>51461863

maybe monad but instead of value present it's error present
>>
>>51461905
printf
%d
>>
>>51461905
just do it the C way, (int) a.
>>
>>51461873
That's what I'd already be doing, though. I originally planned to completely disallow crashing, you'd have to handle errors all the way down (which encourages you to PREVENT errors using types in the first place).

>>51461863
Monads just reduce the boilerplate from the "pattern match on result to get either value or error" idiom.
>>
File: shit.jpg (36 KB, 583x310) Image search: [Google]
shit.jpg
36 KB, 583x310
>>
>>51461940
>i know you can cast but can you do it without a cast?
>just use a c style cast
cfags everyone
>>
can someone pls help me?
ListCell* newListCell = new ListCell;
newListCell->value = x;
newListCell->next = listArray[i+1].next;
listArray[i+1] = *newSublist;


it's C++ and an array of lists. the first value at each spot is created fine, but it always points to null instead of the rest of the list it's becoming the head of and i can't see why
>>
File: 5e4aa8e0f67fd6ea.png (169 KB, 305x365) Image search: [Google]
5e4aa8e0f67fd6ea.png
169 KB, 305x365
Which FOSS project needs the most help? I want to help them out. I am thinking HURD, any other ideas?
>>
>>51462212
>wants to cast without using casts
>>
>>51462276
>Stolman
>Supporting open sores
>ever
>>
>>51462276
They wont let you develop HURD if you use the acronym FOSS kek
>>
>>51462261
more context?
>>
>>51462279
Do it the enterprise way.
int toInteger(char c)
{
return c;
}
>>
>>51462297
Fine "FREE" software
>>
File: 1439137772329.jpg (10 KB, 240x200) Image search: [Google]
1439137772329.jpg
10 KB, 240x200
>>51460893
>>
File: 1436448774147.png (60 KB, 470x698) Image search: [Google]
1436448774147.png
60 KB, 470x698
>Tfw i am a shit programmer

I guess i am too stupid for this
>>
Can someone tell me how to print a list out with each string on one line in python. For instance if the list were ["red", "green", "blue"] it would print as

red
green
blue
>>
    return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2019' in position
0: character maps to <undefined>

What is best alternative to run python in windows?
Command prompt is annoying.
>install linux
gtfo
>>
>>51462338
for x in ["red", "green", "blue"]:
print x
>>
>>51462338
x = ['red', 'green', 'blue']
[print(v) for v in x]
>>
File: 1380676804528.png (375 KB, 996x998) Image search: [Google]
1380676804528.png
375 KB, 996x998
> first job out of school
> primary job role is to work on infrastructure automation
> within a year 8+ other teams want to use it and it becomes a full-time job teaching them to maintain it
> no longer get to work on automation

On the one hand, it looks like I could probably get promoted soon. On the other hand, a kid fresh out of school shouldn't be able to fix shit this quickly in a multi-billion dollar company. It's a fucking embarrassment.

Don't let the tech-debt boogeyman get you too.
>>
>>51462304
i'm
>>51461185
i tried rephrasing the part i think is the issue. BestIncreasingSublists are list cells
>>
>>51462336

If you suck at programming, you can always try web development!
>>
     while (sorted)              // 1
if (values[first] > pivot) // 2
sorted = false;
else
{
first++;
sorted = (first <= last); // 3
}


So how many compares is this? Does java run a compare on the while call? I've seen better implementations of this but this is from my text book. For example, there's ways to not nest an if inside the while loop.
>>
Do I really need to learn java to make an android application?
I'm half way though python and started some C++...
>>
File: 65258007.jpg (82 KB, 461x403) Image search: [Google]
65258007.jpg
82 KB, 461x403
>>51462399
>>
>>51462486
You can use C++ for Android development, but it isn't recommended unless you really need the performance. The installation, compilation, and support is all messed up if you don't use Java.
>>
>>51462457
    while(sorted) { // 1
if(values[first] > pivot) { // 2
sorted = false;
}
else {
++first;
sorted = first <= last; // 3
}
}
>>
>>51462486
it's strongly recommended to learn java for android dev but it's not even that hard. hard compared to python but easy compared to C++
>>
>>51462486

Yes. Even if you push most of the business logic into some other language through the JNI, you still need some Java for the interface. All of the libraries on Android for handling the UI are in Java.

This is the only thing wrong with Android.
>>
>>51462600
>This is the only thing wrong with Android.
This is bait.
>>
>>51462537
I wasn't concerned with formatting to be honest. It looks much like that in the code I had just fucked up the post while deleting my personal comments.
>>
>>51462600
>wrong

I detest the accusation.
>>
>>51462682

Java's all fine and dandy, but why not make a C library for UI shit, and let other languages make bindings for it, like everything else does?
>>
>>51462616

You're right, there's one more thing wrong with it - it doesn't have a root account by default, and companies are allowed to use the Android trademark while providing locked down bootloaders.
>>
>>51462308
kek, I exhaled sharply through my nostrils.
>>
>>51462439
But it is programming too
>>
>>51462336
no worries, you can still get a high paying job.
>>
>>51462798
How? I can't even do fizzbuzz... Fuck
>>
File: erlang.jpg (10 KB, 254x406) Image search: [Google]
erlang.jpg
10 KB, 254x406
We've just started functional programming at uni with Erlang. The task was to make a program that solves Towers of Hanoi for n disks.

Did that, but there's an optional bonus task I want to sink my teeth into but have spent the past five hours making no progress with: write function(s) that will solve the problem from any arbitrary (but valid) starting configuration.

Without straight-up telling me the answers, if anyone could push me in the right direction that'd be lovely.
>>
>>51462861
I get that I'm probably meant to try and rearrange the disks to the ideal start position, then just call my original
solve()
on that state, but I can't figure out how to recursively bring everything to that point.
>>
>>51462819
really? :(

You really should try web dev then
>>
>>51462861
differential evolution is always the answer, so what is the question
>>
Am I allowed to copyright a repo I upload to github?
Would the words "All Rights Reserved" suffice?
>>
>>51463129
https://help.github.com/articles/open-source-licensing/
>>
>>51463129
You can, but if you do you're probably being an asshole. Why not just avoid publishing it to github in the first place?
>>
>>51457707

Currently learning c++ from Stroustrup book.

Compiling on ubuntu/gnome with g++ command.

Get tons of errors first one is I need to use -std=c++11 or -std=gnu++11 experimental compiler options.

Does this mean my current version sees C++11 as experimental? Will it even work if I get around to trying something even newer like something added in 2014? Is this common for c++? Am I misinterpreting everything this is a pretty up to date version of the distro.
>>
>>51463129
You are a retard.
>>
>>51463189

It does compile if I use the option. How do I run the file it creates?
>>
>>51462957
w-wha
>>
>>51463145
http://choosealicense.com/
>>
>>51463224
it can solve literally anything
>>
>>51463206

I gave the compiled file a name with the -o command. Should I have included a file extension? Might be my problem with linux not wanting to run it.
>>
Anyone here familiar with Go?
I need some help parsing some weird xml shit.
I'm trying to parse it by creating structs that it can be unmarshaled in to.
The issue is that the tags aren't unique
<dict>
<key>frame</key>
<string>{{1125,225},{224,224}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{224,224}}</string>
<key>sourceSize</key>
<string>{224,224}</string>
</dict>


Can this shit be unmarshaled like this, or do I need to go about it in another way?
>>
>>51463257
Obviously that is some shitty hashmap.
>>
>>51463206
./a.out
>>
>>51463272
well, shit, so it would seem, thanks
>>
>>51463257
import lxml
>>
>>51463189
C++11 is the newest version of C++, it's not experimental; it works very well. I always use the -std=c++11 flag for my C++ code because I love so many of the C++11 features, don't worry about compatibility because all of the popular C++ compilers support it
>>
>>51462347
python on os x
>>
>>51463257
Just map it into a slice

Look at the example
https://golang.org/pkg/encoding/xml/#Unmarshal
>>
>>51463237
Can you elaborate at all? I'm reading everything I can find and it's not clicking.
>>
>>51463320
>C++11 is the newest version of C++
>>
>>51463129
>proprietary license - please don't steal :^)
>>
>>51462347
a UTF-8 (see: not cp437) terminal
>>
I'm transferring to a college and they're telling me none of my CS credits are transferring because they weren't "math-based." Was my advisor an idiot or am I really that fucked?
>>
How do I declare a 1-byte integer in C++?
>>
>>51463542
char name;
>>
>>51463542
int8_t dicks;
>>
>>51463146
I need something in my portfolio.
>>
>>51463382
>>51463320

So why does this ubuntu/gnome distro I downloaded 2 months ago need a special option to use code from anything 2011 or newer? Can I just expect linux compilers to be behind as fuck?
>>
>>51463542
signed or unsigned?
>>
>>51463575
What if you have code from >4 years ago that you want to compile?
>>
>>51463590
Then use today's compiler because it will work?
>>
Work is frustrating. I'm rewriting some software for my job and there is a field that has three different names throughout the program and database.

I'm also frustrated with our clients (governments). We ask them to send CSV files and many of them fuck it up so bad that we have to write a custom parser just for them. One would think that CSV files aren't that complicated, but it's apparently too complicated for a lot of government programmers.

Our build system and dependency management is a mess. We have half a dozen repositories and it's not that uncommon that projects have to pull from several of them because two dependencies in the same repository will have a version conflict with each other. We use Ant/Ivy. Years ago they tried to standardize it. It was a complete and total failure. So now we have a dozen "standard" Ant/Ivy configurations depending on the type of project, but they are still so fucking terrible that the reality is that people have to write their own anyway because out of the dozen different ones they have, they still aren't likely to do what you need or even work at all.

Security is a fucking joke. A lot of big companies have gotten hacked or had leaks so our top priority lately has been security. If you ever want to see a classical case of "security theater", this is it. Everything they've done has just made getting real work done more difficult. When I asked the lead architect about actually encrypting our sensitive data, the one they they really should be doing, the answer was that it was too difficult. Keeping libraries up to date which may have security vulnerabilities was also "too difficult".

My title is "software engineer", but it sure doesn't feel like a lot of engineering is going on. I'm just thankful our software isn't safety critical. A lot of people would die.
>>
>>51463590

Then use a command to use the old stuff? All the tutorials I am seeing dont use that command to do current stuff and it makes me think I am fucking up somewhere.

Also this >>51463605 wouldnt a current compiler be ready for old code?
>>
MICROSOFT VISUAL STUDIO
COMMUNITY VERSION FREE
ITS 2015 EDITION
seriously stop using your shitty ides
>>
>>51463575
Depends on the compiler version. Compilers support different standars and also use different ones as their default. Newer versions of compilers will default to C++11 or C++14, with older compilers you will need to explicitly tell it to use the newer standard with -std option (nothing bothersome also given that the compiler supports it).
>>
>>51463625

But I want to work on my linux laptop. And I am used to vim I kinda like doing everything in the terminal window.
>>
>>51463617
Code finds a way, anon.
>>
>>51463637
I think it plainly stated that you have a parameter name in your prototype without it's type.
>>
>>51463637
You need to specify what kind of type num is.
>>
>>51463637
the prototype should have either just the TYPES of the parameters or types AND var names
>>
>>51463641
>kinda like doing everything in the terminal window.

Doing things in a terminal window for the sake of doing them in a terminal window is second to none in terms of faggotry.

I swear if I hear the word 'productivity' one more time...
>>
>>51463617

This is just life anon. People literally do only what they have to in ever field and profession. A giant pile of shit barely holding together seems sadly inevitable.

I like this optimism though. >>51463651
>>
>>51463625
not free, fuck off
>still no good C support
>needs windows
>needs a nasa-tier machine to run on
>>
>>51463687

Its not productivity Im muddling through learning here. I just like not have to switch between shit.

Someone how I suspect vs wont work on linux anyways and I dont want to vm on my laptop though its probably not that difficult.
>>
>>51459200
Speaking of which, where is benchmark guy?
>>
>>51463703
>>still no good C support
Because it primarily focuses on the superior upgrade that C++ is.

>>needs windows
Unfortunately, I wish I could run MSVS on Linux.

>>needs a nasa-tier machine to run on
False. I have a Windows development machine with a chip from 2007 and barely 4 GB of RAM and it works just fine.
>>
>>51463703
Visual Studio 2015 Community is free

>Nasa tier
>16 bit
>4kb RAM
>70kb ROM
>>
>>51463687
A lot of people on /g/ use vim and do things in a terminal window not because it's more productive but because they are ignorant elitists. They read about computing legends like Dennis Ritchie and how they worked in the 70s and want to emulate them. They dismiss modern IDEs because they think they are for "code monkeys". They have a typical "everything was better in the past" type of mentality that you often hear from baby boomers when they talk about The Beatles. I also think they want to impress strangers. I suspect that half the people in this thread are the kind of people who open a bunch of terminal windows on their laptop at school or at Starbucks and are just hoping that someone notices it and thinks they're some uber hacker straight from The Matrix.
>>
>>51463720

It doesn't need a video card or anything right? With a modern processor you could run a vm with some kinda of invisible option you wouldn't even know its windows. You would take a minimal performance hit but not much worse thing would be the windows image for the vm taking up hard drive space.

Hell I might try this I was learning how to do hardware pass through weeks ago and just a vm withotu hardware is easy enough.

Well fuck compiling would be fucked though.
>>
>>>51463657
>>51463661
>>51463670
Holy shit I am retarded. Sleep deprivation, I'll blame sleep deprivation.
>>
>>51463740

What if I just want to do all my code in the same text editor with some mods on it? That is the biggest thing for me. Also the terminal windows means no mouse just commands to get out compile go back in whatever.
Thread replies: 255
Thread images: 31

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.