Need advice about which tool to choose?Ask the StackShare community!
C vs Erlang vs Swift: What are the differences?
<Write Introduction here>
Memory Management: In C, memory management is done manually by the programmer, which gives more control but also increases the risk of memory leaks and errors. Erlang, on the other hand, has built-in garbage collection, making memory management automatic and reducing the risk of memory-related bugs. Swift uses Automatic Reference Counting (ARC) to manage memory, automatically deallocating objects when they are no longer needed.
Concurrency: Erlang was designed for building concurrent and distributed systems, making it easier to handle parallel processing and communication between processes. C lacks built-in support for concurrency, making it more challenging to create efficient parallel programs. Swift has features like Grand Central Dispatch and async/await for writing concurrent code, but it is not as inherently concurrent as Erlang.
Type System: C is a statically typed language where variable types must be declared at compile time, allowing for more control but potentially leading to more verbose code. Erlang is dynamically typed, allowing for more flexibility but potentially leading to runtime errors related to type mismatches. Swift combines elements of both, with a strong type system that also supports type inference for cleaner code.
Community and Ecosystem: The C programming language has a long history and a vast amount of libraries and tools available, making it a popular choice for system programming and embedded development. Erlang is mainly used for telecom applications and has a smaller but dedicated community. Swift, being developed by Apple, has a strong ecosystem and community support, especially for iOS and macOS development.
Error Handling: C relies heavily on return codes and manual error-checking mechanisms for handling errors, which can lead to verbose and error-prone code. Erlang uses a "let it crash" philosophy, where errors are isolated to individual processes, improving fault tolerance and simplifying error handling. Swift introduces the concept of optionals and try-catch blocks for better error handling compared to C.
Pattern Matching: Erlang excels in pattern matching, allowing developers to easily destructure data and match complex patterns, making code more concise and readable. C lacks built-in support for pattern matching, making it more challenging to work with complex data structures. Swift also supports pattern matching, making it easier to write expressive code for handling different cases.
In Summary, C, Erlang, and Swift differ in memory management, concurrency support, type systems, community size, error handling mechanisms, and pattern matching capabilities.
include include int main(){ char name[10], pasword[10]; printf("enter you user name :"); gets(name); printf("enter your pasword : "); gets(pasword); printf("your name : %s \n your password : %s \n", name, pasword); if ( name != "youcef") { printf("name undefined\n"); } else { printf("finde name"); }
}
his not working
You will want to do a few things here. First, replace gets
with fgets
. Then, you're going to want to use strcmp
from string.h to compare the input with the desired result. The code listed below has been updated with a working example with the previously mentioned recommendations. This isn't perfect and there are other ways to accomplish the same task. Explore other options that are available when you have a chance and see if you can improve on this example.
#include <stdio.h>
#include <string.h>
int main()
{
char name[10],
pasword[10];
printf("enter you user name :");
// Use fgets as gets is insecure and can easily lead to buffer overflow exploits
fgets(name, sizeof(char) * sizeof(name), stdin);
// Remove \n from fgets stdin read with null character so as to not have to include
// in strcmp later.
name[strlen(name) - 1] = '\0';
printf("enter your pasword : ");
fgets(pasword, sizeof(char) * sizeof(pasword), stdin);
printf("your name : %s \n your password : %s \n", name, pasword);
// If strcmp result > 0 || < 0 it's not a match
if (strcmp(name, "youcef") != 0)
{
printf("name undefined\n");
}
else
{
printf("finde name");
}
}
Dear, Yusuf You can't use if statement to compare two strings, but you can use strcmp() function which means string compare The behavior of strcmp function is: If (string1 < string2)? Then: return a negative value. If (string1 > string2)? Then: return a positive value.
If(string1 == string2)? Then: return (0).So, you can modify this statment to: if(strcmp(name,"Yousef") != 0) printf("name undefined\n");
else printf("find name");But, In this case there is one logic problem that (strcmp) function don't ignore the letter case. For example: If you input name : yousef
The first letter here (y) is small, but in the comparing statement above is capital, So the result will be "name undefined", but in fact "yousef" = "Yousef".To solve this problem you should use stracasecmp() function. This function ignore the letter case while comparing. The code will be: if(strcasecmp(name,"Yousef") != 0) printf("name undefined\n");
else printf("find name");Attention: Include string libreary after using these functions to skip any problem may be found.
includemay Allah bless you ^_^
Hey guys, I learned the basics (OOP, data structures & some algorithms) with Python, but now I want to learn iOS development. I am considering to learn Swift, but I am afraid how the native mobile development will die out because of the cross-platform frameworks and reviews. My idea is to learn web development first and then learn React Native, and after all of that, finally Swift. What do you think about this roadmap? Should I just learn Swift first due to the pros of the native apps?
Native apps are not going to die. Especially not Swift because now Swift can be used to develop cross platform macOS and iOS apps due to the new macs having M1 chips.
I would suggest to bet more on Swift! I have developed act in React and Javascript in the past and played around with Swift a little... the performances of native code vs Javascript are way too slow compared to swift native app!
Now even more than ever M1 chip will give a boost, but if it gives a boost to JS it will give a boost also to native apps. I would seriously consider Swift more than Javascript, React or even Electron!
If asking about employment opportunities, native will never die out. There will always be opportunity for work in native mobile applications. There are also many advantages of using native over cross platform such as always having access to the latest APIs and developer libraries that may not be available to cross-platform without some native development involved or can wait until someone develops a bridge for you.
If you are asking about what you should develop with first? It really depends. React-Native is great for building proto-types or basic MVP application that doesn't require any of the latest and greatest features Apple has to offer at the moment. But if you're asking what to learn? I would say native will always give you a larger advantage as it will give you a good foundation in mobile development and provide you access to the latest native libraries. It is also a useful skill that can give you an edge in cross-platform mobile like react-native because you will most definitely encounter a situation where you will have to go down to the to native side to extend functionality or utilize APIs that are not yet out of the box.
"Should I just learn Swift first due to the pros of the native apps?".
React Native builds Native Apps. Technologies like ionic
does NOT build native apps, but React Native does it.
Learning Swift seems to be a really bad idea from my point of view. Learning JavaScript is all what you need. Why? Because then Frontend, Backend, and Mobile Dev, is simple, because it's all JavaScript.
The decision comes down to your goals and needs.
If you want to be able to create any kind of iOS app, simple or complex, learn Swift. It's indispensable if you're building specialised apps like video editing, augmented reality, machine learning or anything that uses iOS-specific APIs such as App Clips.
But if you just want to create apps that make HTTP requests and display static content such as text or basic video and music, React Native would do just fine, and you can publish the same code to Android. This is a no-brainer choice if you're on a low budget.
And if you know both, you can use both in the same app. You can add React Native screens or components inside a Swift app.
Mobile Native Development Apps will never die. Cross Plataform like React Native only exists to save time and costs for startups mainly, which is extraordinary, and indispensable often of course. But when the App get popular enough, it will probably will move to Native Development. Several improvements.
Less than 20% of the market is IOS, the rest is Android. Any developer must produce for Android and maybe support IOS. If you prototype on IOS you have to restart again for Android. React and JavaScript will run on IOS.
We chose React Native over native Android and iOS development because of React Native's cross-platform capabilities. React Native has really matured over the years, developing a native feel, with simple and intuitive APIs. The community is also huge, filling in any gaps in the default APIs. These are also the reasons why we didn't choose other hybrid mobile tools. Largely, other hybrid mobile tools don't have the same mobile feel and close connection to the underlying mobile APIs.
At a larger scale, the control that native development offers beats React Native's simplicity. However, at this early stage, it's worth the trade-off. Maintaining two mobile teams and two mobile apps, as we iterate the product rapidly would not be practical. Plus, there is always the escape hatch of native modules if more control is needed.
As a startup, we need the maximum flexibility and the ability to reach our customers in a more suitable way. So a hybrid application approach is the best because it allows you to develop a cross-platform application in a unique codebase. The choice behind Ionic is Angular, I think that angular is the best framework to develop a complex application that needs a lot of service interaction, its modularity forces you (the developer) to write the code in the correct way, so it can be maintainable and reusable.
Expo was a tool Macombey really wanted to utilize from the beginning. I have been working with React Native since 2016 and originally I had to use simulators in Xcode, install pods on top of node packages, configure certificates, and more abundant objectives that take time away from actual development. As a development studio, we have to move quick and get projects to our clients and partners in a matter of months.
Expo made this easy for us. We now have a mobile app for clients to download and test their project on, there is no need to install pods or configure Xcode, and development is super fast and reliable now.
Python has become the most popular language for machine learning right now since almost all machine learning tools provide service for this language, and it is really to use since it has many build-in objects like Hashtable. In C, you need to implement everything by yourself.
C++ is one of the most popular programming languages in graphics. It has many fancy libraries like eigen to help us process matrix. I have many previous projects about graphics based on C++ and this time, we also need to deal with graphics since we need to analyze movements of the human body. C++ has much more advantages than Java. C++ uses only compiler, whereas Java uses compiler and interpreter in both. C++ supports both operator overloading and method overloading whereas Java only supports method overloading. C++ supports manual object management with the help of new and delete keywords whereas Java has built-in automatic garbage collection.
1 code deploys for both: Android and iOS. There is a huge community behind React Native. And one of the best things is Expo. Expo uses React Native to make everything even more and more simple. Awesome technologies. Some other important thing is that while using React Native, you are reusing all JavaScript knowledge you have in your team. You can move easily a frontend dev to develop mobile applications.
A huge PRO of Expo, is that it includes a full building process. You run 1 line in the terminal, and 10 minutes after you have 2 builds done. Double check EAS Expo.
As a personal research project I wanted to add post-quantum crypto KEM (key encapsulation) algorithms and new symmetric crypto session algorithms to openssh. I found the openssh code and its channel/context management extremely complex.
Concurrently, I was learning Go. It occurred to me that Go's excellent standard library, including crypto libraries, plus its much safer memory model and string/buffer handling would be better suited to a secure remote shell solution. So I started from scratch, writing a clean-room Go-based solution, without regard for ssh compatibility. Interactive and token-based login, secure copy and tunnels.
Of course, it needs a proper security audit for side channel attacks, protocol vulnerabilities and so on -- but I was impressed by how much simpler a client-server application with crypto and complex terminal handling was in Go.
$ sloc openssh-portable Languages Files Code Comment Blank Total CodeLns Total 502 112982 14327 15705 143014 100.0% C 389 105938 13349 14416 133703 93.5% Shell 92 6118 937 1129 8184 5.7% Make 16 468 37 131 636 0.4% AWK 1 363 0 7 370 0.3% C++ 3 79 4 18 101 0.1% Conf 1 16 0 4 20 0.0% $ sloc xs Languages Files Code Comment Blank Total CodeLns Total 34 3658 1231 655 5544 100.0% Go 19 3230 1199 507 4936 89.0% Markdown 2 181 0 76 257 4.6% Make 7 148 4 50 202 3.6% YAML 1 39 0 5 44 0.8% Text 1 30 0 7 37 0.7% Modula 1 16 0 2 18 0.3% Shell 3 14 28 8 50 0.9%
Pros of C lang
- Performance68
- Low-level49
- Portability36
- Hardware level29
- Embedded apps19
- Pure13
- Performance of assembler9
- Ubiquity8
- Great for embedded6
- Compiles quickly4
- Old4
- No garbage collection to slow it down3
- Gnu/linux interoperable2
- OpenMP2
Pros of Erlang
- Real time, distributed applications62
- Concurrency Support62
- Fault tolerance58
- Soft real-time36
- Open source32
- Message passing22
- Functional programming22
- Immutable data16
- Works as expected14
- Facebook chat uses it at backend6
- Practical5
- Knowledgeable community5
- Bullets included4
- WhatsApp uses it at backend1
Pros of Swift
- Ios259
- Elegant180
- Not Objective-C126
- Backed by apple107
- Type inference93
- Generics61
- Playgrounds54
- Semicolon free49
- OSX38
- Tuples offer compound variables36
- Clean Syntax24
- Easy to learn24
- Open Source22
- Beautiful Code21
- Functional20
- Dynamic12
- Linux12
- Protocol-oriented programming11
- Promotes safe, readable code10
- No S-l-o-w JVM9
- Explicit optionals8
- Storyboard designer7
- Optionals6
- Type safety6
- Super addicting language, great people, open, elegant5
- Best UI concept5
- Its friendly4
- Highly Readable codes4
- Fail-safe4
- Powerful4
- Faster and looks better4
- Swift is faster than Objective-C4
- Feels like a better C++4
- Easy to learn and work3
- Much more fun3
- Protocol extensions3
- Native3
- Its fun and damn fast3
- Strong Type safety3
- Easy to Maintain3
- Protocol as type2
- All Cons C# and Java Swift Already has2
- Esay2
- MacOS2
- Type Safe2
- Protocol oriented programming2
- Can interface with C easily1
- Actually don't have to own a mac1
- Free from Memory Leak1
- Swift is easier to understand for non-iOS developers.1
- Numbers with underbar1
- Optional chain1
- Great for Multi-Threaded Programming1
- Runs Python 8 times faster1
- Objec1
Sign up to add or upvote prosMake informed product decisions
Cons of C lang
- Low-level5
- No built in support for parallelism (e.g. map-reduce)3
- Lack of type safety3
- No built in support for concurrency3
Cons of Erlang
- Languange is not popular demand1
Cons of Swift
- Must own a mac6
- Memory leaks are not uncommon2
- Very irritatingly picky about things that’s1
- Complicated process for exporting modules1
- Its classes compile to roughly 300 lines of assembly1
- Is a lot more effort than lua to make simple functions1
- Overly complex options makes it easy to create bad code0