3 ms·
As someone who has (mostly) enjoyed working with Python and JS (CoffeeScript in the past, and ES6+ and TypeScript more recently), and also dabbled in Ruby/Rails
by ralmidani 6y ago
As someone who has (mostly) enjoyed working with Python and JS (CoffeeScript in the past, and ES6+ and TypeScript more recently), and also dabbled in Ruby/Rails, I've been intrigued by Rust for a while. Its promise of being close in speed to C/C++, but safer and more ergonomic, sounds great. I have not attempted to build anything with it yet, but I've looked at what (I think) is enough examples to be familiar with its constructs, and have seen some benchmarks.
For systems software or libraries that are meant to be hooked into from, say, a JS/TypeScript environment (see https://deno.land https://deno.land, a promising alternative to Node), it seems like Rust has a lot of potential.
But for building applications (which is what I'm focused on currently) it seems Rust has a "No OOP for you!" attitude that gets in the way of modeling your application domain quickly. Yes, you can use impl and trait as an alternative to classes. But it seems like you have to jump through a lot of hoops; define your structs, define a trait for default behavior and remember that &self is provided as an implicit first argument to the methods (this is similarly cumbersome in Python), then define an impl for each corresponding struct (don't forget about &self!). As opposed to just declaring a base class and overriding when you need to in the subclasses. I am definitely not saying classes are the only way to do OOP, but at least give developers the option of using them.
I have found Swift attractive for application development because it gives you structs for one-off (value-based) data types, classes when you need an easy way to do inheritance and polymorphism (and/or need reference-based data types), and extensions as a more abstract way to enhance structs and/or classes (and/or enums). It doesn't force you to use classes (and the community appears to think protocols are a better construct), but the language remains approachable, and you can always start with classes then refactor to protocols when the need arises.
- deltron3030 6y agoIs Vapor the rails-like go to web framework for Swift? Is it viable for indie hackers, or is it more like Java geared towards the enterprise? I find Swift interesting as a language because it seems that it's well balanced, usable for low level systems programming and higher level applications. But protocol first kinda indicates big design up front, something more geared towards enterprise usecases..
- ralmidani 6y agoI don't have any statistics, but based on the amount of learning articles, books, etc. out there it seems like Vapor is the dominant Swift Web framework. Kitura looked promising, but IBM has stopped supporting it, so its future is not clear (the last commit to the main branch was in November 2019). Also, the two main Vapor devs are members of the Swift Server Work Group (with the other two being from Apple): https://swift.org/server/ https://swift.org/server/ I'm not sure how to answer your question regarding whether Vapor is viable for indie hackers, because I've only been skimming the docs and looking at small examples. But it seems to draw a lot of inspiration from Express.js and/or Ruby's Sinatra library. It doesn't seem to have the up-front complexity of something like Java's Spring Framework, although I understand you can use services and dependency injection if needed. So my first impression is it's easy to get started, but it enables you to refactor to something more complex if your application demands it.
- deltron3030 6y agoThanks for your answer. So Vapor for building APIs, not web monoliths, good to know. It kinda makes sense considering that most of the users will use mobile apps on the client side. Personally I also find Elixir and the Phoenix framework very interesting.
- ralmidani 6y agoNo problem! Vapor does have its own template system if you don't want to build "just" an API: https://github.com/vapor/leaf https://github.com/vapor/leaf I have also looked at Elixir and Phoenix, but have not written any code in them. I have yet to really dive into anything outside the C-like languages (Python, JS, Java, Swift, Ruby, C, C++), and Elixir seems like a good reason to venture outside my comfort zone. By the way, no pressure, but if you ever want to discuss Swift, maybe do some paired programming/studying, let me know. I'm still fairly new but I have experimented with building a Swift-to-CSS DSL that I would like to eventually spend more time on. If you want to email me, ragheed.almidani is the name, and protonmail.com is the domain.